[core] Use PicoCli and unify PMD usage under a single main#4059
Conversation
There was a problem hiding this comment.
@oowekyala I'm considering removing this from the configuration and PmdAnalysis, as it's exclusively intended for CLI usage… however, since instantiating the listener requires to know the final number of files to analyze, this requires some additional changes in PmdAnalysis. Therefore, I'll refrain from doing it in this PR and leave it for a follow up. WDTY?
There was a problem hiding this comment.
You're right that this should be refactored. Maybe we should have an own "ProgressListener" interface in pmd-core which the cli module could implement?
There was a problem hiding this comment.
I'll look into that after this PR is closed.
There was a problem hiding this comment.
Maybe we need a pmd-cli-integration-tests module to test with actual language modules? I would prefer pmd-cli not to depend on language modules, even if it's only a test-scoped dependency. Otherwise pmd-dist could contain those tests I guess
There was a problem hiding this comment.
If we were to do this, I'd do it in pmd-dist (as the same would apply to Ant).
However, I don't think this is particularly pressing… the way both CLI and Ant are being setup with separate modules, they are simply interfaces into PMDConfiguration / PmdAnalysis. These modules can be sufficiently tested on their own with the Dummy Languages. They could even be put into independent repositories without issue (like we do for the Eclipse Plugin as another "interface into PMDConfiguration / PmdAnalysis").
The only real integration point for language modules is ensuring the LanguageRegistry is properly being able to detect it (that is, that the service definitions are properly setup), and that can be tested from the language modules themselves, as it only requires accessing pmd-core (and this is something we should start doing…).
The current usages for this BaseCLITest as it stands are:
- issues with pmd-core itself, irrespective of CLI / Ant, or even the specific language (ie: these tests from pmd-java are actually testing an issue with pmd-core's
RuleSetFactorynot emitting errors. - testing behavior of the
LanguageVersionDiscovererirrespective of the language in use (ie: these tests in pmd-xml). - integration tests with very little value add that limit themselves to checking the run didn't blow up.
There was a problem hiding this comment.
We actually have some basic tests for all languages in pmd-dist already, even for Ant (see AntIT and AllRulesIT).
For the JUnit5 migration (#3797), I skipped for now this BaseCLITest class. But maybe, we can change/move the tests, that we don't actually need separate CLI tests in each module, like @jsotuyod proposes. And we can delete this base test class... I'll keep that in mind, when I continue on JUnit5 migration.
|
I'm also considering allowing positional parameters to be equivalent to using to be equivalent to: I'd do this in addition to the current usage of I'd also like to change the usage of |
adangel
left a comment
There was a problem hiding this comment.
Hi @jsotuyod ,
I've tested the batch script, I ran it partly under Windows.
My reference is https://ss64.com/nt/ - and you always learn some new weird behavior, e.g. variable expansion in if blocks... 😄
|
@adangel thanks for the love with that bat script! I did learn quite a few things, and I'm happy we get to offer Windows users the same experience we do for MacOS and Linux. |
|
I think this is finally ready for review 😄 |
Generated by 🚫 Danger |
| * @deprecated Use {@link #setInputPathList(List)} | ||
| */ | ||
| @Deprecated |
There was a problem hiding this comment.
Ideally, if we merge #4161 first into master(pmd6), then master->pmd/7.0.x and update this PR, these changes should disappear.
And then we can think about, removing the deprecated methods already (if we ourselves don't use them in pmd7 anymore).
|
I covered everything now, hopefully pmdtester will run as expected and this should be ready. We may want to wait until we merge #4161 and I'll merge back master into PMD 7 / remove deprecated methods from PMDConfiguration. |
Thanks! Yes, pmdtester seems to be working now: #4059 (comment) I hope to release a new pmdtester version this Thursday. And yes, I think it's better we wait until #4161 is merged into master. |
- This includes a PR I submitted to support suggestions of multi-word entries
|
Hi! Our tool BreakBot found that this pull request introduces 15 breaking changes and deprecations and they appear to impact 7 of your clients. You can find the full BreakBot report in our fork repository: report for PR#4059. We hope this information is valuable to you, and apologize otherwise. If you're willing to help, we would kindly ask for your help to fill in a 5-minutes survey about the report. Your feedback will help us improve the tool and provide a better experience for users in the future! |
|
Hi @jsotuyod, did you see @oowekyala's merge at jsotuyod#4 ? Is it ok, if he goes ahead and merges this PR or do you think there is anything missing? |
Merge latest pmd 7
|
@adangel sorry, I've been out for the last week. It's been merged now! |
|
Merged, thanks @jsotuyod! |
Remove some deprecated things left over by pmd#4059
Describe the PR
Migrating away from JCommander. Use PicoCli to provide a unified PMD CLI usage a-la-git. Make the most of PicoCli by shipping bash / zsh autocompletion support with the PMD distribution.
Take this chance to homogenize usage across all utilities. These changes need to be reflected on PMD 6 through a separate PR deprecating options /adding the new aliases to allow people to accommodate.
--filelistin favor of--file-list(as PMD already did)--failOnViolationnor-failOnViolationin favor of--fail-on-violation(as PMD already did)--filesin favor of--dir/-d(as PMD already did)-eas equivalent to--encoding(as PMD and ast-dump already did)--fail-on-violationis now negatable. The user no longer has to provide a boolean value, but can directly state--fail-on-violation/--no-fail-on-violationto set the intended behavior. The default keeps being--fail-on-violation.--no-progressis now negatable, so the user can set either--progress/--no-progressto set the desired behavior. The default keeps being--progress.--verbose,-v,--debugor-D. The usage of-Vis shifted to be an equivalent of--version(which is consistent with most Linux commands).--no-fail-on-violationis not set). Only applicable for PMD / CPD tasks.Additionally:
TODOs
-language,-version,-minoptions #3426) ( [core] Backport to PMD6 changes to accomodate PicoCli in PMD7 #4161)Related issues
-language,-version,-minoptions #3426Ready?
./mvnw clean verifypasses (checked automatically by github actions)