-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
1877: Add checkstyle to project #2042
1877: Add checkstyle to project #2042
Conversation
Add checkstyle plugin to common.gradle Add a checkstyle.xml based on google checkstyle xml with ammendments. Checkstyle errors do not fail the build, everything is marked as a warning, can be refined over time as per comments in jMonkeyEngine#1877. Checkstyle can be run with `./gradlew checkstyleMain` - it runs for all projects.
Andy, thank you for your contribution to the JMonkeyEngine project. |
Now that continuous tests have run, I see some changes will be required. Andy, would you be willing to do some rework on this PR?
|
Wound back checkstyle version to 9.3 Last good version to work out of the box with java 8 Re-copied the google checkstyle config from that version too Updated the links in the checkstyle config to the right docs url. Rebuilt with Java 8 & 17 to test.
Ah hey, just saw your comments - already did the fix for 9.3 and pushed a new checkstyle.xml to go with it. |
* Ignore some modules that produce a lot of warnings. * Increase line length to 150 so we only get the worst offenders * Reduces output by ~70% (counting main.html sizes, about 4M)
* Don't run checkstyle on jme3-networking and jme3-vr * These two make up about 1M of reporting * Fixed ref to checkstyle-suppressions and added a template file * Removed suppressionXPathFilter * Disabled a couple more checks. * Output is down to ~ 2.2M
So I've got it down to about 2.2M, ignore some modules and skipping the jme3-vr and jme3-networking projects. At this point, taking out modules is about the only way to get it down. jme3-examples and jm3-core are the next two biggest culprits at 632K and 912K respectively. |
Progress! |
* Only process /com/jme3/renderer sources * Rolled back jme3-network/vr exclusion (still not processed though) * Added modules back into checkstyle config * Now gives 38 errors from 11 files within com/jme3/renderer package * BeforeExecutionExclusionFileFilter wasn't playing nicely
|
* Realised I made a mistake on the package filter * was only pulling java classes directly under com/jme/renderer/ * Ammded to include all java classes in that package * Opened up to 200Kb of errors over 4 projects
Its always just after you push you spot the obvious mistakes ;-) I put the |
The portion of the codebase that was cleaned up in #1653 was specifically just the files directly under com/jme3/renderer in the jme3-core sub-project, so expanding it to packages below that in 4 sub-projects seems to me like a step backward. But since the scope of checking is supposed to evolve over time, it's not crucial to perfect it right now. The key things are:
That's good progress! Looking at the GitHub Actions logs, I see some CheckStyle diagnostics for code I believe conforms to our preferred coding style. For instance:
Regarding Section 3.4.2 of the Google style guide, our guidelines say "Logical ordering of class contents is encouraged but not required." So I suggest removing the Also:
Section 5.2.7 of the Google style guide says only that "local variable names are written in lowerCamelCase". I don't see any reason the second character can't be uppercase. I suggest modifying the pattern to Also
Regarding Section 4.8.6.1 of the Google style guide, our guidelines say "Commented-out code need not be indented at the same level as surrounding code." I suggest removing the Also
The letter "Z" is not an abbreviation or acronym, so I think |
* Made style changes suggested in the PR comments
I hadn't really looked too much at the actual content, just took the google config at face value with a few changes as per the project style guide. The details and scope of projects its checking can be changed over time. Could consider in future changing the max |
Sure. But unlike the I foresee a need for further tweaking of the Checkstyle configuration. For instance, the Thank you @andygibson for getting the ball rolling, so to speak. Unless there's further substantive discussion of this pull request, I plan to integrate it in about 96 hours. |
Add checkstyle plugin to common.gradle
Add a checkstyle.xml based on google checkstyle xml with ammendments.
Checkstyle errors do not fail the build since everything is marked as a warning.
modules can be refined over time as per comments in #1877.
Checkstyle can be run with
./gradlew checkstyleMain
- it runs for all projects.