Affects PMD Version: 6.0.0
Rule: ExcessiveClassLengthRule
and ExcessiveMethodLengthRule
Description: I was checking a class with a 200-line constructor in our codebase and ExcessiveMethodLength
didn't pick it up. I fired up the debugger and found out that the constructor DataPoint
s are not added to the StatisticalRuleHelper
.
Resolution: ExcessiveLengthRule
ctor needs to be vararg and
ExcessiveMethodLengthRule
call super(ASTMethodDeclaration, ASTConstructorDeclaration, ASTAnnotationMethodDeclaration)
ExcessiveClassLengthRule
call super(ASTClassOrInterfaceDeclaration, ASTEnumDeclaration, ASTAnnotationTypeDeclaration)
From a user perspective (everyday developer), all of those are methods and all of those are classes.
Alternatively the AST needs to change and let Constructor/AnnotMethod extend Method, and Enum/AnnotType extend ClassOrIface. Maybe it was in the past?
Code Sample demonstrating the issue:
class ExcessiveConstructor {
ExcessiveConstructor() {
// 300 lines of garbage
}
}
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other] CLI:
pmd -d ExcessiveConstructor.java -f text -R category/java/design.xml/ExcessiveMethodLength <no output>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4