GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — [core] Support forcing a specific language from the command-line by aidan-harding · Pull Request #3417 · pmd/pmd Conversation
|
Generated by 🚫 Danger |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Neat small fix that enables a ton of new possibilities. Love it. Thank you!
Would approve it but I need the main-tainers @adangel and @oowekyala to answer wether they are ok with the modified standard behaviour (see comment) and if more tests are needed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks for the PR! Just to give a bit of background info, why and for what reasons this cli parameter was introduced in the first place: If a language supports more than one version (Java and Scala being the only languages with multiple versions) you could tell PMD, that - when it has discovered the language Java by extension - it should use a specific version instead of the default (latest) version (some rules are version dependent and would suggest constructs that are only possible in later versions of the language). It's also needed if you want to use java preview features. I have to think a bit more about this as the other idea that was introduced with PMD 5 was, that it should be possible to have one ruleset with multiple languages and PMD should automagically do "the right thing". I guess, providing the language in that way limits the PMD run to exactly this language. I'm not sure how important this feature is really (one PMD execution, single ruleset, multiple languages) and how often this is actually used. Different languages also need different extra parameters to work correctly (besides the specific language version): for Java, it's auxclasspath, for Visualforce it's via environment parameters |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@adangel thanks for providing this background. What if we instead introduce an extensions parameter per ruleset like this @aidan-harding I guess this would also perfectly cover your flow use case, right? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
To me this looks like a nice workaround until a fix for #461 is introduced. But I don't think we should aim for keeping this in in the long-term... If we consider all input files to be of the given language, then we can't safely ignore things like .gitignore or resource files that may be in the file tree. They will probably fail parsing, which is a minor inconvenience I guess, since the user can then correct it by excluding the files anyway. I guess, few users will be concerned.
I don't know either how much users actually rely on pmd's language discovery mechanism, but I personally think it's a nice feature. Its only problem is extensibility, like in many places in pmd... We can work on that as we go.
What if we instead introduce an extensions parameter per ruleset like this
Side note, I made a detailed proposal for this in #461 (comment), though its scope is broader. The idea is to allow each rule to match the set of files it wants instead of configuring necessarily per language/ruleset. Language and ruleset would then just provide defaults.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@oowekyala thanks for mentioning #461. That looks like a solution to all issues @aidan-harding and I try to cover. What is the status of this issue? Can it be worked on? based on your proposal? Any blockers? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Accidentally clicked "Request for Re-Review"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the feedback and context, everyone. I agree that the ideal behaviour for a user would be able to point PMD at a set of source files in mixed languages and have it discover the right thing to do. So, a full solution to #461 would be amazing. Hopefully, my changes will help in the interim, though. I've updated the PR as per @oowekyala's comments |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
1de6c61 to
1c2298d
Compare
|
@rsoesemann could you please run the validation workflow for this? I think I'm at the final version of the PR, so it would be good to have the workflow tests complete before @oowekyala looks at the code Using a local build, I tried this in the scenario you cared about and I was able to check an object file from an MDAPI Salesforce project (Account.object) using an XML XPath rule. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@aidan-harding So @adangel and I chatted on Tuesday and agreed that a CLI argument to force use of a language is useful and we should merge it. However we'd like it to be more explicit, for instance, Currently using So @aidan-harding I think this PR needs a slight rework before we merge it. Could you add a new option We maintainers can take care of adding some integration tests and updating the documentation.
For us:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
That sounds like a decent way forward. But I wonder if we can make I do understand that, in general, you want PMD to be as smart as possible. So that I can run PMD on a directory containing a mix of files from different languages and some that aren't supported languages at all, and then it would use the right languages and skip other files. That's definitely the ideal. Separating out |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Store the language version provided by a -force-language command-line argument and use that as the default language before falling back to the filename
1c2298d to
6b8c12b
Compare
|
@oowekyala I've updated my changes to use a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the PR!
I'm ok with your solution for scanning all files if a directory is given.
I'll let it run now. If the regression tester is back at "This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.", then we know, that this change at least doesn't introduce any problems.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks, @adangel, I started to respond to your specific comments, then it turned out that I needed to refresh my browser to see that you'd already fixed up and merged the PR. And I see it's already in a release 🎉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[xml] Allow to check Salesforce XML Metadata using XPath rules
There was an error while loading. Please reload this page.