-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #6068: migrate to picocli command line parser from Commons CLI #6126
Conversation
I may need some help with the failing CI. The IDEA Inspections Pull Request (Checkstyle) — TeamCity build failed with the below. I don't know
ci/circleci: pitest2 — tests failed on CircleCI: (at first glance this seems a problem in PowerMockJUnit44RunnerDelegateImpl)
|
You have to view the report at https://teamcity.jetbrains.com/viewLog.html?buildId=1628574&tab=Inspection&buildTypeId=Checkstyle_IdeaInspectionsPullRequest .
I am not sure if that exception is related. Usually the CI will tell you what is missing, but it looks like it failed to do that for some reason.
You may have to run pitest locally and look at the report to see what is missing. |
c378899
to
cfda81c
Compare
@rnveach, @romani, Please consider this PR. Sorry for the delay. I found it quite difficult to get the CI checks to pass (I’m relieved they pass now; I was close to giving up a few times). :-) This PR migrates the Note that I used picocli’s mixinStandardHelpOptions function to provide @rnveach, I considered moving the annotated fields into an inner class but I found the current code to be cleaner: we would end up either moving a significant portion of the logic into the inner class, or alternatively referencing the option fields indirectly like this: if (options.printAst || options.printAstWithComments
|| options.printJavadocTree || options.printTreeWithJavadoc) {
if (options.suppressionLineColumnNumber != null
|| options.configurationFile != null
|| options.propertiesFile != null
|| options.outputPath != null
... The current code (without the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@remkop It is alot to review and scanned some of it.
I question the use of so many no-inspections but that would require looking into this more.
cfda81c
to
a32179e
Compare
@rnveach Fixed some of the things you pointed out. I amended the commit with force-push to keep history clean. Is that the preferred way or do you prefer additional commits in response to feedback? |
412faaf
to
29c05ef
Compare
@romani Thanks for the detailed review. All items you mentioned have been addressed. CI build is green. Please take another look. Out of interest, what time zone are you in? I’m in Tokyo (JST). |
I am in PST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now code is really good and modular, far better than our previous cli version.
the very last items:
@rnveach , please start code review. Here is how it works:
nuances:
vs
@remkop , please share best practices, you probably saw a lot of CLI helps, your proposals are valuable. |
ea98b56
to
a714eec
Compare
|
866d096
to
14b6a1e
Compare
Please remove, our cli is not used that much, this parameter is new, feature behind him is not done up to the end. Thanks a lot for your help.
Can library be configured now to not print whole help ? If yes, please do. If not - please create an issue on picocli and issue on us, to not forget to fix it. It is annoying but not a showstopper.
Please create separate issue on us for this (to not forget ). Not a show stopper. As you modify code, please do me a favour and move listFiles right after getFilesToProcess, please see https://methods-distance.herokuapp.com/dsm?source_url=https://raw.githubusercontent.com/checkstyle/checkstyle/14b6a1e1796b8e9902f20137506dbc2f7a75de4e/src/main/java/com/puppycrawl/tools/checkstyle/Main.java , in ideal case red cells should be very close to diagonal. |
14b6a1e
to
35f630b
Compare
All done:
|
88f80ca
to
1670edd
Compare
I had to resubmit a few times to get past transient CI build failures, but all checks passed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I will see much else.
src/xdocs/cmdline.xml.vm
Outdated
@@ -40,8 +40,8 @@ java -D<property>=<value> \ | |||
-c <configurationFile> \ | |||
[-f <format>] [-p <propertiesFile>] [-o <file>] \ | |||
[-s <line:column>] [-gxs | --generate-xpath-suppression] [-tabWidth <length>] \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gxs
needs to be removed here and down below.
Please verify all commands are correct and no others have been changed/added/removed.
Please tell us when both are done individually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find. Both done:
-gxs
replaced by-g
in synopsis as well as the option description below- verified other options and made two updates to the documentation:
-tabWidth
became--tabWidth
as agreed-executeIgnoredModules
became--executeIgnoredModules
as agreed
config/pmd-main.xml
Outdated
</rule> | ||
<!-- Some fields with picocli annotations will be only used by | ||
the picocli and not by the application. | ||
They may appear unused by static code analysis tools. --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this comment to right above the <property
tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I updated the PR. Waiting for the CI pipeline to pass now.
private static final String USAGE = String.format(Locale.ROOT, | ||
"usage: java com.puppycrawl.tools.checkstyle.Main [options] -c <config.xml>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@romani Do we need to create a section documenting how some arguments changed between the versions?
See my next comment on why I am asking.
@remkop Some other utilities I have created use the CLI as an api to execute checkstyle.
I know some arguments changed, but I don't know the extent. If any of these are affected, please let me know.
https://github.com/checkstyle/contribution/blob/master/checkstyle-web-tester/checkstyle.php#L136
https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/launch_diff.sh#L208
https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/launch_diff_antlr.sh#L180
https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/sevntu_launch_diff.sh#L208
They are mostly -J
, -c
, -f
, -o
and return code -2
/-1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to create a section documenting how some arguments changed between the versions?
we can make comment in issue, to reference to it if somebody ask a questions. As far as know we change only "-gxs" (renamed to "-g") and "-V" for version, all other stay the same. Minor changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this comment that summarizes the option name changes: #6068 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rnveach I checked the 4 links above and I believe none of them should be impacted by the changes in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@remkop Thanks.
@remkop ,
This is still an issue on our side, we are not going to use such convenience methods, they are against our design ideas. I do believe we will not be alone to about extra "extends" and do more compositions. |
@romani I think there is a misunderstanding: in my last update for the PR I already implemented your request: Checkstyle now prints the error message followed by a short usage message and a hint to use Please see lines 126 and 127 in Main. I believe this is exactly what you asked for. Did I misunderstand? Please disregard my earlier comment on my plans for supporting this in future versions of picocli. Since Checkstyle does not use the convenience methods, it will not be impacted by such future changes. |
1670edd
to
7c5a1c6
Compare
my bad, I did not noticed this change. Here is how it works in comparison with "grep":
looks good. |
I’m hoping that other people will follow CheckStyle’s example and adopt picocli in their project. If you like what you’ve seen so far, please say some nice things about picocli in a few public places. It really helps! |
I will twit about it, ones we merge your PR. Travis was restarted, it was failed for unrelated issues. Teamcity is complaining due to time out (30 min is limit). Here is history of builds:
Average 22m. in PRs, average is 27
We are running to close to limits. Master build limit is set to 35 min. |
Issue #6068: migrate to picocli command line parser from Commons CLI
This PR replaces #6082.
Sorry it took so long. It was harder than I thought to get all the tests and checks to pass. :-)