04-October-2015 - 5.4.0
Note: PMD 5.4.0 requires JDK 1.7 or above.
- 9 new rules
- 4 features requests
- 18 pull requests
Feature Request and Improvements:
- #1344: AbstractNaming should check reverse
- #1361: ShortVariable and ShortMethodName configuration
- #1414: Command line parameter to disable “failOnViolation” behavior PMD and CPD Command Line Interfaces have a new optional parameter: failOnViolation. Executing PMD with the option -failOnViolation false will perform the PMD checks but won’t fail the build and still exit with status 0. This is useful if you only want to generate the report with violations but don’t want to fail your build.
- #1420: UnusedPrivateField: Ignore fields if using lombok
Ruleset snippet to activate the new rules:
- Basic: CheckResultSet (rulesets/java/basic.xml/CheckResultSet)
Do not require to check the result of a navigation method, if it is returned.
- JUnit: UseAssertTrueInsteadOfAssertEquals (rulesets/java/junit.xml/UseAssertTrueInsteadOfAssertEquals)
This rule also flags assertEquals, that use Boolean.TRUE/FALSE constants.
- Naming: AbstractNaming (rulesets/java/naming.xml/AbstractNaming)
By default, this rule flags now classes, that are named “Abstract” but are not abstract. This behavior can be disabled by setting the new property strict to false.
- Naming: ShortMethodName (rulesets/java/naming.xml/ShortMethodName)
Additional property minimum to configure the minimum required length of a method name.
- Naming: ShortVariable (rulesets/java/naming.xml/ShortVariable)
Additional property minimum to configure the minimum required length of a variable name.
- UnusedCode: UnusedPrivateField (rulesets/java/unusedcode.xml/UnusedPrivateField)
This rule won’t trigger anymore if Lombok is in use. See #1420.
UseSingleton - UseUtilityClass (rulesets/java/design.xml/UseUtilityClass)
The rule “UseSingleton” has been renamed to “UseUtilityClass”. See also bugs #1059 and #1339.
- Basic: The following rules of ruleset “Basic” were marked as deprecated and are removed with this release now:
EmptyCatchBlock, EmptyIfStatement, EmptyWhileStmt, EmptyTryBlock, EmptyFinallyBlock, EmptySwitchStatements, EmptySynchronizedBlock, EmptyStatementNotInLoop, EmptyInitializer, EmptyStatementBlock, EmptyStaticInitializer
UnnecessaryConversionTemporary, UnnecessaryReturn, UnnecessaryFinalModifier, UselessOverridingMethod, UselessOperationOnImmutable, UnusedNullCheckInEquals, UselessParentheses
These rules are still available in the rulesets “Empty” (rulesets/java/empty.xml) and “Unnecessary” (rulesets/java/unnecessary.xml) respectively.
- Design: The rule “UncommentedEmptyMethod” has been renamed last release to “UncommentedEmptyMethodBody”. The old rule name reference has been removed with this release now.
- Controversial: The rule “BooleanInversion” has been deprecated last release and has been removed with this release completely.
- #21: Added PMD Rules for Singleton pattern violations.
- #23: Extended Objective-C grammar to accept Unicode characters in identifiers
- #54: Add a new rulesets for Maven’s POM rules
- #55: Fix run.sh for paths with spaces
- #56: Adding support for WSDL rules
- #57: Add default access modifier as comment rule
- #58: Add rule for unnecessary literal boolean in ternary operators
- #59: Add check to Boxed booleans in UseAssertTrueInsteadOfAssertEquals rule
- #60: Add UselessQualifiedThisRule
- #61: Add CloneMethodReturnTypeMustMatchClassName rule
- #62: Add CloneMethodMustBePublic rule
- #63: Change CheckResultSet to allow for the result of the navigation methods to be returned
- #65: Fix ClassCastException in UselessOverridingMethodRule.
- #66: #1370 ConsecutiveAppendsShouldReuse not detected properly on StringBuffer
- #67: Use Path instead of string to check file exclusions to fix windows-only bug
- #68: #1370 ConsecutiveAppendsShouldReuse not detected properly on StringBuffer
- #69: #1371 InsufficientStringBufferDeclaration not detected properly on StringBuffer
- #70: Fix code example
- #1412: UnusedPrivateMethod false positive: Issue #1403 not completely solved
pmd requires now JDK 1.7 or above.
The method addNameOccurrence returns now a Set of NameDeclarations to which the given occurrence has been added. This is useful in case there are ambiguous declarations of methods.
The method findVariableHere returns now a Set of NameDeclarations which match the given occurrence. This is useful in case there are ambiguous declarations of methods.