Bug #11396
Consider integrating a Java static analyzer
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:
0%
billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:
Related issues
History
#1 Updated by Alexandru Lungu 3 months ago
- File fwd-style-check.py
added
Add tooling for code formatting - Java most importantly.
Current suggestions:
[al2]
Based on the discussion yesterday: when I asked about static analysis tool, I already had some in mind :)
Spotless (https://github.com/diffplug/spotless)
Gradle plugin (https://plugins.gradle.org/plugin/com.diffplug.gradle.spotless)
There are multiple configurations that can be used with it. It can either be google-java-format (opinionated formatting) or eclipse (custom formatting based on eclipse formatter).
Personally, I think it is valuable that we can plug in the existing eclipse formatter to spotless and have it run out of the box.
There are also other nice to haves: licenseHeader, importOrder, ident, trimTrailingWhitespace
has spotless apply task that can auto-fix or spotless check that can dry run.
Checkstyle (https://github.com/checkstyle/checkstyle)
Gradle plugin (https://docs.gradle.org/current/userguide/checkstyle_plugin.html)
can ensure file length, line length, javadoc, consistent naming (e.g. <module name="MethodName"><property name="format" value="^[a-z][a-zA-Z0-9]*$"/></module>), etc.
has pre-configured linters like: ModifierOrder, NeedBraces, EqualsHashCode, MissingOverride etc.
has some nice code clarity checks like: CyclomaticComplexity, ParameterNumber, MethodLength, NestedIfDepth etc.
IMHO:
use Spotless for static analysis and small things like respecting the line length, 3 spaces, no tabs, braces on new lines etc. In general, these are things that can be auto-fixed without changing semantics.
this is required to adhere to coding standards and skip AI coding standards checks.
use Checkstyle for code clarity and semantics that can't be auto-fixed (name formatting, cyclomatic complexity, parameter number, etc.)
having even cleared code can help integration with AI (e.g. reducing CyclomaticComplexity may help AI read less and understand better the code).
[hc]
I put together a simple review dashboard app to make the review process more streamlined. It doesn't replace the existing tools like Redmine or fwd-review.py, but rather builds on them. It keeps track of the issues to be reviewed, past reviews, and integrates the ai-assisted review process (fwd-review.py). I've been using it over a week and I must say it helps with the reviews especially if your review queue is long. See the attached screen shots.
The attached new version of fwd-style-check.py adds the ability to list, enable or disable the specific rules. The full list of rules: RULE ID SEV AST LANGUAGES style.annotation-own-line MINOR yes java,typescript style.binary-op-space MINOR no c,cpp,java,javascript,typescript style.blank-after-open-brace MINOR no c,cpp,java,javascript,typescript style.blank-before-close-brace MINOR no c,cpp,java,javascript,typescript style.blank-between-methods MINOR yes c,cpp,java,javascript,typescript style.block-delimiter-required MAJOR yes c,cpp,java,javascript,typescript style.brace-own-line MINOR yes c,cpp,java,javascript,typescript style.class-declaration-wrap MINOR yes cpp,java,javascript,typescript style.comma-space MINOR no c,cpp,java,javascript,typescript style.comment-attached MINOR no c,cpp,java,javascript,typescript style.copyright-year MAJOR no c,cpp,java,javascript,typescript style.cr-endings MAJOR no c,cpp,java,javascript,typescript style.file-history-sequence MAJOR no c,cpp,java,javascript,typescript style.funcname-paren MINOR no c,cpp,java,javascript,typescript style.hard-tab MAJOR no c,cpp,java,javascript,typescript style.import-wildcard-suggestion MINOR no java style.indent-multiple-of-3 MINOR no c,cpp,java,javascript,typescript style.keyword-paren MINOR no c,cpp,java,javascript,typescript style.label-own-line MINOR no c,cpp,java style.line-length MINOR no c,cpp,java,javascript,typescript style.paren-inner-space MINOR no c,cpp,java,javascript,typescript style.pointer-asterisk-with-name MINOR no c,cpp style.separate-var-decl MINOR no c,cpp,java style.unary-tight MINOR no c,cpp,java,javascript,typescript
#3 Updated by Alexandru Lungu 3 months ago
- Related to Feature #11318: Consider integrating a built-time checker for JS code added