PMD Changelog

What's new in PMD 7.0.0

Apr 1, 2024
  • Has a new logo
  • Analyzes Java 21 and Java 22 projects with even better type resolution and symbol table support
  • Analyzes Kotlin and Swift
  • Analyzes Apex with a new parser
  • Finds duplicated code in Coco, Julia, TypeScript
  • Ships 11 new rules and tons of improvements for existing rules
  • Provides a new CLI interface with progress bar
  • Supports Antlr based languages
  • And many more enhancements

New in PMD 7.0.0 RC 4 (Oct 1, 2023)

  • New and Noteworthy:
  • Migration Guide for PMD 7:
  • A detailed documentation of required changes are available in the
  • Migration Guide for PMD 7.
  • Apex Jorje Updated
  • With the new version of Apex Jorje, the new language constructs like User Mode Database Operations
  • can be parsed now. PMD should now be able to parse Apex code up to version 59.0 (Winter '23).
  • Java 21 Support
  • This release of PMD brings support for Java 21. There are the following new standard language features,
  • that are supported now:
  • JEP 440: Record Patterns
  • JEP 441: Pattern Matching for switch
  • PMD also supports the following preview language features:
  • JEP 430: String Templates (Preview)
  • JEP 443: Unnamed Patterns and Variables (Preview)
  • JEP 445: Unnamed Classes and Instance Main Methods (Preview)
  • In order to analyze a project with PMD that uses these language features,
  • you'll need to enable it via the environment variable PMD_JAVA_OPTS and select the new language
  • version 21-preview:
  • export PMD_JAVA_OPTS=--enable-preview
  • pmd check --use-version java-21-preview ...
  • Note: Support for Java 19 preview language features have been removed. The version "19-preview" is no longer available.
  • Fixed issues:
  • miscellaneous:
  • 4582: [dist] Download link broken
  • 4691: [CVEs] Critical and High CEVs reported on PMD and PMD dependencies
  • core:
  • 1204: [core] Allow numeric properties in XML to be within an unbounded range
  • 3919: [core] Merge CPD and PMD language
  • 4204: [core] Provide a CpdAnalysis class as a programmatic entry point into CPD
  • 4301: [core] Remove deprecated property concrete classes
  • 4302: [core] Migrate Property Framework API to Java 8
  • 4323: [core] Refactor CPD integration
  • 4397: [core] Refactor CPD
  • 4611: [core] Fix loading language properties from env vars
  • 4621: [core] Make ClasspathClassLoader::getResource child first
  • cli:
  • 4423: [cli] Fix NPE when only --file-list is specified
  • doc:
  • 4294: [doc] Migration Guide for upgrading PMD 6 ?? 7
  • 4303: [doc] Document new property framework
  • 4521: [doc] Website is not mobile friendly
  • apex:
  • 3973: [apex] Update parser to support new 'as user' keywords (User Mode for Database Operations)
  • 4453: [apex] [7.0-rc1] Exception while initializing Apexlink (Index 34812 out of bounds for length 34812)
  • apex-design:
  • 4596: [apex] ExcessivePublicCount ignores properties
  • apex-security:
  • 4646: [apex] ApexSOQLInjection does not recognise SObjectType or SObjectField as safe variable types
  • java:
  • 4401: [java] PMD 7 fails to build under Java 19
  • 4583: [java] Support JDK 21 (LTS)
  • java-bestpractices:
  • 4634: [java] JUnit4TestShouldUseTestAnnotation false positive with TestNG
  • API Changes:
  • pmd-java:
  • Support for Java 19 preview language features have been removed. The version "19-preview" is no longer available.
  • Rule properties:
  • The old deprecated classes like IntProperty and StringProperty have been removed. Please use
  • PropertyFactory to create properties.
  • All properties which accept multiple values now use a comma (,) as a delimiter. The previous default was a
  • pipe character (|). The delimiter is not configurable anymore. If needed, the comma can be escaped
  • with a backslash.
  • The min and max attributes in property definitions in the XML are now optional and can appear separately
  • or be omitted.
  • New Programmatic API for CPD:
  • See Detailed Release Notes for PMD 7
  • and PR #4397 for details.
  • Removed classes and methods
  • The following previously deprecated classes have been removed:
  • pmd-core
  • net.sourceforge.pmd.cpd.AbstractTokenizer ?? use AnyTokenizer instead
  • net.sourceforge.pmd.cpd.CPD ?? use PmdCli from pmd-cli module for CLI support or use
  • CpdAnalysis for programmatic API
  • net.sourceforge.pmd.cpd.GridBagHelper (now package private)
  • net.sourceforge.pmd.cpd.TokenEntry.State

New in PMD 7.0.0 RC 3 (May 31, 2023)

  • Changes since 7.0.0-rc2:
  • New CPD report format cpdhtml-v2.xslt
  • Fixed issues
  • API Changes
  • External Contributions

New in PMD 7.0.0 RC 2 (May 1, 2023)

  • Changes since 7.0.0-rc1:
  • This section lists the most important changes from the last release candidate.
  • The remaining section describes the complete release notes for 7.0.0.
  • API Changes:
  • Moved the two classes AntlrTokenizer and JavaCCTokenizer from
  • internal package into package net.sourceforge.pmd.cpd.impl. These two classes are part of the API and
  • are base classes for CPD language implementations.
  • AntlrBaseRule is gone in favor of AbstractVisitorRule.
  • The classes KotlinInnerNode and SwiftInnerNode
  • are package-private now.
  • The parameter order of addSourceFile has been swapped
  • in order to have the same meaning as in 6.55.0. That will make it easier if you upgrade from 6.55.0 to 7.0.0.
  • However, that means, that you need to change these method calls if you have migrated to 7.0.0-rc1 already.
  • Updated PMD Designer:
  • This PMD release ships a new version of the pmd-designer.
  • For the changes, see PMD Designer Changelog.
  • Language Related Changes
  • New: CPD support for TypeScript
  • New: CPD support for Julia
  • Rule Changes:
  • ImmutableField: the property ignoredAnnotations has been removed. The property was
  • deprecated since PMD 6.52.0.
  • SwitchDensity: the type of the property minimum has been changed from decimal to integer
  • for consistency with other statistical rules.
  • Fixed Issues:
  • cli
  • 4482: [cli] pmd.bat can only be executed once
  • 4484: [cli] ast-dump with no properties produce an NPE
  • core
  • 2500: [core] Clarify API for ANTLR based languages
  • doc
  • 2501: [doc] Verify ANTLR Documentation
  • 4438: [doc] Documentation links in VS Code are outdated
  • java-codestyle
  • 4273: [java] CommentDefaultAccessModifier ignoredAnnotations should include "org.junit.jupiter.api.extension.RegisterExtension" by default
  • 4487: [java] UnnecessaryConstructor: false-positive with @Inject and @Autowired
  • java-design
  • 4254: [java] ImmutableField - false positive with Lombok @Setter
  • 4477: [java] SignatureDeclareThrowsException: false-positive with TestNG annotations
  • 4490: [java] ImmutableField - false negative with Lombok @Getter
  • java-errorprone
  • 4449: [java] AvoidAccessibilityAlteration: Possible false positive in AvoidAccessibilityAlteration rule when using Lambda expression
  • 4493: [java] MissingStaticMethodInNonInstantiatableClass: false-positive about @Inject
  • 4505: [java] ImplicitSwitchFallThrough NPE in PMD 7.0.0-rc1
  • java-multithreading
  • 4483: [java] NonThreadSafeSingleton false positive with double-checked locking
  • miscellaneous
  • 4462: Provide Software Bill of Materials (SBOM)
  • External contributions:
  • 4402: [javascript] CPD: add support for Typescript using antlr4 grammar - Paul Guyot (@pguyot)
  • 4403: [julia] CPD: Add support for Julia code duplication - Wener (@wener-tiobe)
  • 4444: [java] CommentDefaultAccessModifier - ignore org.junit.jupiter.api.extension.RegisterExtension by default - Nirvik Patel (@nirvikpatel)
  • 4450: [java] Fix #4449 AvoidAccessibilityAlteration: Correctly handle Lambda expressions in PrivilegedAction scenarios - Seren (@mohui1999)
  • 4452: [doc] Update PMD_APEX_ROOT_DIRECTORY documentation reference - nwcm (@nwcm)
  • 4474: [java] ImmutableField: False positive with lombok (fixes #4254) - Pim van der Loos (@PimvanderLoos)
  • 4488: [java] Fix #4477: A false-positive about SignatureDeclareThrowsException - AnnaDev (@LynnBroe)
  • 4494: [java] Fix #4487: A false-positive about UnnecessaryConstructor and @Inject and @Autowired - AnnaDev (@LynnBroe)
  • 4495: [java] Fix #4493: false-positive about MissingStaticMethodInNonInstantiatableClass and @Inject - AnnaDev (@LynnBroe)
  • 4520: [doc] Fix typo: missing closing quotation mark after CPD-END - João Dinis Ferreira (@joaodinissf)

New in PMD 7.0.0 RC 1 (Mar 27, 2023)

  • Major Features and Enhancements:
  • New PMD Logo:
  • Revamped Java module:
  • Java grammar substantially refactored - more correct regarding the Java Language Specification (JLS)
  • Built-in rules have been upgraded for the changed AST
  • Rewritten type resolution framework and symbol table correctly implements the JLS
  • AST exposes more semantic information (method calls, field accesses)
  • For more information, see the Detailed Release Notes for PMD 7.
  • Contributors: Clément Fournier (@oowekyala),
  • Andreas Dangel (@adangel),
  • Juan Martín Sotuyo Dodero (@jsotuyod)
  • Revamped Command Line Interface:
  • unified and consistent Command Line Interface for both Linux/Unix and Windows across our different utilities
  • single script pmd (pmd.bat for Windows) to launch the different utilities:
  • pmd check to run PMD rules and analyze a project
  • pmd cpd to run CPD (copy paste detector)
  • pmd designer to run the PMD Rule Designer
  • progress bar support for pmd check
  • shell completion
  • For more information, see the Detailed Release Notes for PMD 7.
  • Contributors: Juan Martín Sotuyo Dodero (@jsotuyod)
  • Full Antlr support
  • Antlr based grammars can now be used to build full-fledged PMD rules.
  • Previously, Antlr grammar could only be used for CPD
  • New supported languages: Swift and Kotlin
  • For more information, see the Detailed Release Notes for PMD 7.
  • Contributors: Lucas Soncini (@lsoncini),
  • Matías Fraga (@matifraga),
  • Tomás De Lucca (@tomidelucca)
  • Language Related Changes:
  • Note that this is just a concise listing of the highlight.
  • For more information on the languages, see the Detailed Release Notes for PMD 7.
  • New: Swift support:
  • use PMD to analyze Swift code with PMD rules
  • initially 4 built-in rules
  • Contributors: Lucas Soncini (@lsoncini),
  • Matías Fraga (@matifraga),
  • Tomás De Lucca (@tomidelucca)
  • New: Kotlin support (experimental)
  • use PMD to analyze Kotlin code with PMD rules
  • Support for Kotlin 1.8 grammar
  • initially 2 built-in rules
  • Changed: JavaScript support:
  • latest version supports ES6 and also some new constructs (see Rhino])
  • comments are retained
  • Changed: Language versions:
  • more predefined language versions for each supported language
  • can be used to limit rule execution for specific versions only with minimumLanguageVersion and
  • maximumLanguageVersion attributes.
  • New and changed rules:
  • New Rules:
  • Apex:
  • UnusedMethod finds unused methods in your code.
  • Java:
  • UnnecessaryBoxing reports boxing and unboxing conversions that may be made implicit.
  • Kotlin:
  • FunctionNameTooShort
  • OverrideBothEqualsAndHashcode
  • Swift:
  • ProhibitedInterfaceBuilder
  • UnavailableFunction
  • ForceCast
  • ForceTry
  • Changed Rules:
  • Java:
  • UnnecessaryFullyQualifiedName: the rule has two new properties,
  • to selectively disable reporting on static field and method qualifiersThe rule also has been improved
  • to be more precise.
  • UselessParentheses: the rule has two new properties which control how strict
  • the rule should be appliedWith ignoreClarifying (default: true) parentheses that are strictly speaking
  • not necessary are allowed, if they separate expressions of different precedence.
  • The other property ignoreBalancing (default: true) is similar, in that it allows parentheses that help
  • reading and understanding the expressions.
  • LooseCoupling: the rule has a new property to allow some types to be coupled
  • to (allowedTypes).
  • EmptyCatchBlock: CloneNotSupportedException and InterruptedException are not
  • special-cased anymoreRename the exception parameter to ignored to ignore them.
  • DontImportSun: sun.misc.Signal is not special-cased anymore.
  • UseDiamondOperator: the property java7Compatibility is removedThe rule now
  • handles Java 7 properly without a property.
  • SingularField: Properties checkInnerClasses and disallowNotAssignment are removed.
  • The rule is now more precise and will check these cases properly.
  • UseUtilityClass: The property ignoredAnnotations has been removed.
  • LawOfDemeter: the rule has a new property trustRadiusThis defines the maximum degree
  • of trusted dataThe default of 1 is the most restrictive.
  • CommentContent: The properties caseSensitive and disallowedTerms are removedThe
  • new property fobiddenRegex can be used now to define the disallowed terms with a single regular
  • expression.
  • Removed Rules:
  • Many rules, that were previously deprecated have been finally removed.
  • See Detailed Release Notes for PMD 7 for the complete list.
  • API:
  • The API of PMD has been growing over the years and needed some cleanupThe goal is, to
  • have a clear separation between a well-defined API and the implementation, which is internal.
  • This should help us in future development.
  • Also, there are some improvement and changes in different areasFor the detailed description
  • of the changes listed here, see Detailed Release Notes for PMD 7.
  • Miscellaneous smaller changes and cleanups
  • XPath 3.1 support for XPath-based rules
  • Node stream API for AST ...

New in PMD 6.55.0 (Feb 26, 2023)

  • T-SQL support:
  • Thanks to the contribution from Paul Guyot PMD now has CPD support
  • for T-SQL (Transact-SQL).
  • Being based on a proper Antlr grammar, CPD can:
  • ignore comments
  • honor comment-based suppressions
  • Fixed Issues:
  • core:
  • #4395: [core] Support environment variable CLASSPATH with pmd.bat under Windows
  • java:
  • #4333: [java] Support JDK 20
  • java-errorprone
  • #4393: [java] MissingStaticMethodInNonInstantiatableClass false-positive for Lombok's @UtilityClass for classes with non-private fields
  • API Changes:
  • Go:
  • The LanguageModule of Go, that only supports CPD execution, has been deprecated. This language
  • is not fully supported by PMD, so having a language module does not make sense. The functionality of CPD is
  • not affected by this change. The following class has been deprecated and will be removed with PMD 7.0.0:
  • GoLanguageModule
  • Java:
  • Support for Java 18 preview language features have been removed. The version "18-preview" is no longer available.
  • The experimental class net.sourceforge.pmd.lang.java.ast.ASTGuardedPattern has been removed.

New in PMD 6.54.0 (Feb 11, 2023)

  • New and noteworthy:
  • New report format html-report-v2.xslt:
  • Thanks to @mohan-chinnappan-n a new PMD report format has been added which features a data table with charting functions. It uses an XSLT stylesheet to convert PMD’s XML format into HTML.
  • See the example report.
  • Fixed Issues:
  • apex-bestpractices
  • 2669: [apex] UnusedLocalVariable false positive in dynamic SOQL
  • core
  • 4026: [cli] Filenames printed as absolute paths in the report despite parameter --short-names
  • 4279: [core] Can not set ruleset property value to empty
  • 4329: [core] Refactor usage of snakeyaml
  • 4340: [core] Allow to filter found matches in CPDReport
  • java
  • 4364: [java] Parsing error with textblock containing quote followed by two backslashes
  • testing
  • 4236: [test] kotest logs look broken
  • API Changes:
  • PMD CLI:
  • PMD now supports a new --relativize-paths-with flag (or short -z), which replaces --short-names. It serves the same purpose: Shortening the pathnames in the reports. However, with the new flag it’s possible to explicitly define one or more pathnames that should be used as the base when creating relative paths. The old flag --short-names is deprecated.
  • Deprecated APIs:
  • For removal:
  • ApexRootNode#getApexVersion has been deprecated for removal. The version returned is always Version.CURRENT, as the apex compiler integration doesn’t use additional information which Apex version actually is used. Therefore, this method can’t be used to determine the Apex version of the project that is being analyzed.
  • CPDConfiguration#setEncoding and CPDConfiguration#getEncoding. Use the methods getSourceEncoding and setSourceEncoding instead. Both are available for CPDConfiguration which extends AbstractConfiguration.
  • BaseCLITest and BaseCPDCLITest have been deprecated for removal without replacement. CLI tests should be done in pmd-core only (and in PMD7 in pmd-cli). Individual language modules shouldn’t need to test the CLI integration logic again. Instead, the individual language modules should test their functionality as unit tests.
  • CPDConfiguration.LanguageConverter
  • FileCollector#addZipFile has been deprecated. It is replaced by FileCollector#addZipFileWithContent which directly adds the content of the zip file for analysis.
  • PMDConfiguration#setReportShortNames and PMDConfiguration#isReportShortNames have been deprecated for removal. Use PMDConfiguration#addRelativizeRoot instead.
  • Internal APIs:
  • CSVWriter
  • Some fields in AbstractAntTestHelper
  • Experimental APIs:
  • CPDReport has a new method which limited mutation of a given report:
  • filterMatches creates a new CPD report with some matches removed with a given predicate based filter.
  • External Contributions:
  • 4110: [apex] Feature/unused variable bind false positive with dynamic SOQL - Thomas Prouvot (@tprouvot)
  • 4125: [core] New report format html-report-v2.xslt to provide html with datatable and chart features - Mohan Chinnappan - (@mohan-chinnappan-n)
  • 4280: [apex] Deprecate ApexRootNode.getApexVersion - Aaron Hurst (@aaronhurst-google)
  • 4285: [java] CommentDefaultAccessModifier - add co.elastic.clients.util.VisibleForTesting as default suppressed annotation - Matthew Luckam (@mluckam)
  • Stats:
  • 107 commits
  • 19 closed tickets & PRs
  • Days since last release: 27

New in PMD 6.37.0 (Jul 31, 2021)

  • New and noteworthy:
  • Java 17 Support
  • This release of PMD brings support for Java 17. PMD supports JEP 409: Sealed
  • Classes which has been promoted to be a standard language feature of Java 17.
  • PMD also supports JEP 406: Pattern Matching for switch (Preview) as a preview
  • Language feature. In order to analyze a project with PMD that uses these language features, you'll need to enable
  • It via the environment variable PMD_JAVA_OPTS and select the new language version 17-preview:
  • Export PMD_JAVA_OPTS=--enable-preview
  • ./run.sh pmd -language java -version 17-preview ...
  • Note: Support for Java 15 preview language features have been removed. The version "15-preview" is no longer available.
  • Updated PMD Designer
  • This PMD release ships a new version of the pmd-designer.
  • For the changes, see PMD Designer Changelog.
  • New rules
  • This release ships with 3 new Java rules.
  • PrimitiveWrapperInstantiation reports usages of primitive wrapper constructors. They are deprecated since Java 9 and should not be used.
  • <rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />
  • The rule is part of the quickstart.xml ruleset.
  • SimplifiableTestAssertion suggests rewriting some test assertions to be more readable.
  • <rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion" />
  • The rule is part of the quickstart.xml ruleset.
  • ReturnEmptyCollectionRatherThanNull suggests returning empty collections / arrays instead of null.
  • <rule ref="category/java/errorprone.xml/ReturnEmptyCollectionRatherThanNull" />
  • The rule is part of the quickstart.xml ruleset.
  • Renamed rules
  • The Java rule MissingBreakInSwitch has been renamed to
  • ImplicitSwitchFallThrough (category error prone) to better reflect the rule's purpose: The rule finds implicit fall-through cases in switch statements, which are most
  • Likely unexpected. The old rule name described only one way how to avoid a fall-through, namely using break but continue, throw and return avoid a fall-through as well. This enables us to improve this rule in the future.
  • Deprecated rules:
  • The following Java rules are deprecated and removed from the quickstart ruleset, as the new rule SimplifiableTestAssertion merges their functionality:
  • UseAssertEqualsInsteadOfAssertTrue
  • UseAssertNullInsteadOfAssertTrue
  • UseAssertSameInsteadOfAssertTrue
  • UseAssertTrueInsteadOfAssertEquals
  • SimplifyBooleanAssertion
  • The Java rule ReturnEmptyArrayRatherThanNull is deprecated and removed from the quickstart ruleset, as the new rule ReturnEmptyCollectionRatherThanNull supersedes it.
  • The following Java rules are deprecated and removed from the quickstart ruleset, as the new rule PrimitiveWrapperInstantiation merges their functionality:
  • BooleanInstantiation
  • ByteInstantiation
  • IntegerInstantiation
  • LongInstantiation
  • ShortInstantiation
  • The Java rule UnnecessaryWrapperObjectCreation is deprecated with no planned replacement before PMD 7. In it's current state, the rule is not useful as it finds only contrived cases of creating a primitive wrapper and unboxing it explicitly in the same expression. In PMD 7 this and more cases will be covered by a new rule UnnecessaryBoxing.
  • Fixed Issues:
  • Apex
  • #3201: [apex] ApexCRUDViolation doesn't report Database class DMLs, inline no-arg object instantiations and inline list initialization
  • #3329: [apex] ApexCRUDViolation doesn't report SOQL for loops core
  • #1603: [core] Language version comparison
  • #2133: [xml] Allow to check Salesforce XML Metadata using XPath rules
  • #3377: [core] NPE when specifying report file in current directory in PMD CLI
  • #3387: [core] CPD should avoid unnecessary copies when running with --skip-lexical-errors
  • Java-bestpractices
  • #2908: [java] Merge Junit assertion simplification rules
  • #3235: [java] UseTryWithResources false positive when closeable is provided as a method argument or class field
  • Java-errorprone
  • #3361: [java] Rename rule MissingBreakInSwitch to ImplicitSwitchFallThrough
  • #3382: [java] New rule ReturnEmptyCollectionRatherThanNull
  • Java-performance
  • #3420: [java] NPE in InefficientStringBuffering with Records
  • API Changes
  • PMD CLI
  • PMD has a new CLI option -force-language. With that a language can be forced to be used for all input files, irrespective of filenames. When using this option, the automatic language selection by extension is disabled and all files are tried to be parsed with the given language. Parsing errors are ignored and unparsable files are skipped.
  • This option allows to use the xml language for files, that don't use xml as extension.
  • See also the examples on PMD CLI reference.
  • Experimental APIs:
  • The AST types and APIs around Sealed Classes are not experimental anymore:
  • ASTClassOrInterfaceDeclaration#isSealed,
  • ASTClassOrInterfaceDeclaration#isNonSealed,
  • ASTClassOrInterfaceDeclaration#getPermittedSubclasses
  • ASTPermitsList
  • Internal API:
  • Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0.
  • You can identify them with the @InternalApi annotation. You'll also get a deprecation warning.
  • The inner class net.sourceforge.pmd.cpd.TokenEntry.State is considered to be internal API.
  • It will probably be moved away with PMD 7.

New in PMD 6.32.0 (Mar 9, 2021)

  • New and noteworthy:
  • Java 16 Support:
  • This release of PMD brings support for Java 16. PMD supports JEP 394: Pattern Matching for instanceof and JEP 395: Records. Both have been promoted to be a standard language feature of Java 16.
  • PMD also supports JEP 397: Sealed Classes (Second Preview) as a preview language feature. In order to analyze a project with PMD that uses these language features, you’ll need to enable it via the environment variable PMD_JAVA_OPTS and select the new language version 16-preview:
  • export PMD_JAVA_OPTS=--enable-preview
  • ./run.sh pmd -language java -version 16-preview ...
  • Note: Support for Java 14 preview language features have been removed. The version “14-preview” is no longer available.
  • Modified Rules:
  • The Apex rule ApexDoc has two new properties: reportPrivate and reportProtected. Previously the rule only considered public and global classes, methods, and properties. With these properties, you can verify the existence of ApexDoc comments for private and protected methods as well. By default, these properties are disabled to preserve backwards compatible behavior.
  • Fixed Issues:
  • apex-documentation
  • 3075: [apex] ApexDoc should support private access modifier
  • java
  • 3101: [java] NullPointerException when running PMD under JRE 11
  • java-bestpractices
  • 3132: [java] UnusedImports with static imports on subclasses
  • java-errorprone
  • 2716: [java] CompareObjectsWithEqualsRule: False positive with Enums
  • 3089: [java] CloseResource rule throws exception on spaces in property types
  • 3133: [java] InvalidLogMessageFormat FP with StringFormattedMessage and ParameterizedMessage
  • plsql
  • 3106: [plsql] ParseException while parsing EXECUTE IMMEDIATE ‘drop database link ‘ || linkname;
  • API Changes:
  • Experimental APIs:
  • The experimental class ASTTypeTestPattern has been renamed to ASTTypePattern in order to align the naming to the JLS.
  • The experimental class ASTRecordConstructorDeclaration has been renamed to ASTCompactConstructorDeclaration in order to align the naming to the JLS.
  • The AST types and APIs around Pattern Matching and Records are not experimental anymore:
  • ASTVariableDeclaratorId#isPatternBinding
  • ASTPattern
  • ASTTypePattern
  • ASTRecordDeclaration
  • ASTRecordComponentList
  • ASTRecordComponent
  • ASTRecordBody
  • ASTCompactConstructorDeclaration
  • Internal API:
  • Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the @InternalApi annotation. You’ll also get a deprecation warning.
  • The protected or public member of the Java rule AvoidUsingHardCodedIPRule are deprecated and considered to be internal API. They will be removed with PMD 7.

New in PMD 6.30.0 (Dec 12, 2020)

  • New and noteworthy:
  • CPD:
  • The C# module now supports the new option --ignore-literal-sequences, which can be used to avoid detection of some uninteresting clones. Support for other languages may be added in the future. See #2945
  • The Scala module now supports suppression through CPD-ON/CPD-OFF comment pairs. See #2929
  • Type information for VisualForce:
  • The Visualforce AST now can resolve the data type of Visualforce expressions that reference Apex Controller properties and Custom Object fields. This feature improves the precision of existing rules, like VfUnescapeEl.
  • This can be configured using two environment variables:
  • Comma separated list of directories for Apex classes. Absolute or relative to the Visualforce directory. Default is ../classes. Specifying an empty string will disable data type resolution for Apex Controller properties.
  • Comma separated list of directories for Custom Objects. Absolute or relative to the Visualforce directory. Default is ../objects. Specifying an empty string will disable data type resolution for Custom Object fields.
  • This feature is experimental, in particular, expect changes to the way the configuration is specified. We’ll probably extend the CLI instead of relying on environment variables in a future version.
  • Fixed Issues:
  • core:
  • #1939: [core] XPath expressions return handling
  • #1961: [core] Text renderer should include name of violated rule
  • #2874: [core] Fix XMLRenderer with UTF-16
  • cs:
  • #2938: [cs] CPD: ignoring using directives could not be disabled
  • java:
  • #2911: [java] ClassTypeResolver#searchNodeNameForClass leaks memory
  • #2934: [java] CompareObjectsWithEquals / UseEqualsToCompareStrings - False negatives with fields
  • #2940: [java] Catch additional TypeNotPresentExceptions / LinkageErrors
  • scala:
  • #2480: [scala] Support CPD suppressions
  • API Changes:
  • Deprecated API:
  • Around RuleSet parsing:
  • RuleSetFactory and RuleSetFactoryUtils have been deprecated in favor of RuleSetLoader. This is easier to configure, and more maintainable than the multiple overloads of RuleSetFactoryUtils.
  • Some static creation methods have been added to RuleSet for simple cases, eg forSingleRule. These replace some counterparts in RuleSetFactory
  • Since RuleSets is also deprecated, many APIs that require a RuleSets instance now are deprecated, and have a counterpart that expects a List<RuleSet>.
  • RuleSetReferenceId, RuleSetReference, RuleSetFactoryCompatibility are deprecated. They are most likely not relevant outside of the implementation of pmd-core.
  • Around the PMD class:
  • Many classes around PMD’s entry point (PMD) have been deprecated as internal, including:
  • The contents of the packages net.sourceforge.pmd.cli, net.sourceforge.pmd.processor
  • SourceCodeProcessor
  • The constructors of PMD (the class will be made a utility class)
  • Miscellaneous:
  • ASTPackageDeclaration#getPackageNameImage, ASTTypeParameter#getParameterName and the corresponding XPath attributes. In both cases they’re replaced with a new method getName, the attribute is @Name.
  • ASTClassOrInterfaceBody#isAnonymousInnerClass, and ASTClassOrInterfaceBody#isEnumChild, refs #905
  • Internal API:
  • Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the @InternalApi annotation. You’ll also get a deprecation warning.
  • net.sourceforge.pmd.lang.ecmascript.Ecmascript3Handler
  • net.sourceforge.pmd.lang.ecmascript.Ecmascript3Parser
  • EcmascriptParser#parserOptions
  • EcmascriptParser#getSuppressMap
  • net.sourceforge.pmd.lang.rule.ParametricRuleViolation
  • ParserOptions#suppressMarker
  • net.sourceforge.pmd.lang.modelica.rule.ModelicaRuleViolationFactory
  • External Contributions:
  • #2864: [vf] Provide expression type information to Visualforce rules to avoid false positives - Jeff Bartolotta
  • #2914: [core] Include rule name in text renderer - Gunther Schrijvers
  • #2925: Cleanup: Correct annotation array initializer indents from checkstyle #8083 - Abhishek Kumar
  • #2929: [scala] Add support for CPD-ON and CPD-OFF special comments - Andy Robinson
  • #2936: [java] (doc) Fix typo: “an accessor” not “a” - Igor Moreno
  • #2938: [cs] CPD: fix issue where ignoring using directives could not be disabled - Maikel Steneker
  • #2945: [cs] Add option to ignore sequences of literals - Maikel Steneker
  • #2962: [cpp] Add support for C++ 14 binary literals - Maikel Steneker
  • Stats:
  • 190 commits
  • 25 closed tickets & PRs
  • Days since last release: 49

New in PMD 6.29.0 (Oct 24, 2020)

  • New and noteworthy:
  • Updated Apex Support:
  • The Apex language support has been bumped to version 50 (Winter ‘21). All new language features are now properly parsed and processed. Especially the Safe Navigation Operator is now supported. See also Salesforce Winter ‘21 Release Notes
  • New Rules:
  • The new Apex rule OperationWithLimitsInLoop (apex-performance) finds operations in loops that may hit governor limits such as DML operations, SOQL queries and more. The rule replaces the three rules “AvoidDmlStatementsInLoops”, “AvoidSoqlInLoops”, and “AvoidSoslInLoops”.
  • Renamed Rules:
  • The Java rule DoNotCallSystemExit has been renamed to DoNotTerminateVM, since it checks for all the following calls: System.exit(int), Runtime.exit(int), Runtime.halt(int). All these calls terminate the Java VM, which is bad, if the VM runs an application server which many independent applications.
  • Deprecated Rules:
  • The Apex rules AvoidDmlStatementsInLoops, AvoidSoqlInLoops and AvoidSoslInLoops (apex-performance) are deprecated in favour of the new rule OperationWithLimitsInLoop. The deprecated rules will be removed with PMD 7.0.0.
  • Fixed Issues:
  • apex:
  • #2839: [apex] Apex classes with safe navigation operator from Winter 21 (50.0) are skipped
  • apex-performance
  • #1713: [apex] Mark Database DML statements in For Loop
  • core:
  • #2831: [core] Fix XMLRenderer newlines when running under IBM Java
  • java-errorprone
  • #2157: [java] Improve DoNotCallSystemExit: permit call in main(), flag System.halt:
  • #2764: [java] CloseResourceRule does not recognize multiple assignment done to resource
  • miscellaneous:
  • #2823: [doc] Renamed/Moved rules are missing in documentation
  • vf (Salesforce VisualForce)
  • #2765: [vf] Attributes with dot cause a VfParseException
  • External Contributions:
  • #2803: [java] Improve DoNotCallSystemExit (Fixes #2157) - Vitaly Polonetsky
  • #2809: [java] Move test config from file to test class - Stefan Birkner
  • #2810: [core] Move method “renderTempFile” to XMLRendererTest - Stefan Birkner
  • #2811: [java] CloseResource - Fix #2764: False-negative when re-assigning variable - Andi Pabst
  • #2813: [core] Use JUnit’s TemporaryFolder rule - Stefan Birkner
  • #2816: [apex] Detect ‘Database’ method invocations inside loops - Jeff Bartolotta
  • #2829: [doc] Small correction in pmd_report_formats.md - Gustavo Krieger
  • #2834: [vf] Allow attributes with dot in Visualforce - rmohan20
  • #2842: [core] Bump antlr4 from 4.7 to 4.7.2 - Adrien Lecharpentier
  • #2865: [java] (doc) Update ExcessiveImports example code for clarity - Gustavo Krieger
  • #2866: [java] (doc) Fix example for CouplingBetweenObjects - Gustavo Krieger
  • Stats:
  • 50 commits
  • 23 closed tickets & PRs
  • Days since last release: 27

New in PMD 6.27.0 (Sep 27, 2020)

  • New and noteworthy:
  • CPD’s AnyTokenizer has been improved
  • The AnyTokenizer is used for languages, that don’t have an own lexer/grammar based tokenizer. AnyTokenizer now handles string literals and end-of-line comments. Fortran, Perl and Ruby have been updated to use AnyTokenizer instead of their old custom tokenizer based on AbstractTokenizer. See #2758 for details.
  • AbstractTokenizer and the custom tokenizers of Fortran, Perl and Ruby are deprecated now.
  • Fixed Issues:
  • cpd:
  • 2758: [cpd] Improve AnyTokenizer
  • 2760: [cpd] AnyTokenizer doesn’t count columns correctly
  • apex-security
  • 2774: [apex] ApexSharingViolations does not correlate sharing settings with class that contains data access
  • java
  • 2738: [java] Custom rule with @ExhaustiveEnumSwitch throws NPE
  • 2755: [java] [6.27.0] Exception applying rule CloseResource on file … java.lang.NullPointerException
  • 2756: [java] TypeTestUtil fails with NPE for anonymous class
  • 2767: [java] IndexOutOfBoundsException when parsing an initializer BlockStatement
  • 2783: [java] Error while parsing with lambda of custom interface
  • java-bestpractices
  • 2759: [java] False positive in UnusedAssignment
  • java-design
  • 2708: [java] False positive FinalFieldCouldBeStatic when using lombok Builder.Default
  • API Changes:
  • Deprecated API:
  • For removal:
  • net.sourceforge.pmd.RuleViolationComparator. Use RuleViolation#DEFAULT_COMPARATOR instead.
  • net.sourceforge.pmd.cpd.AbstractTokenizer. Use net.sourceforge.pmd.cpd.AnyTokenizer instead.
  • net.sourceforge.pmd.cpd.FortranTokenizer. Was replaced by an AnyTokenizer. Use FortranLanguage#getTokenizer anyway.
  • net.sourceforge.pmd.cpd.PerlTokenizer. Was replaced by an AnyTokenizer. Use PerlLanguage#getTokenizer anyway.
  • net.sourceforge.pmd.cpd.RubyTokenizer. Was replaced by an AnyTokenizer. Use RubyLanguage#getTokenizer anyway.
  • RuleReference#getOverriddenLanguage and RuleReference#setLanguage
  • Antlr4 generated lexers:
  • net.sourceforge.pmd.lang.cs.antlr4.CSharpLexer will be moved to package net.sourceforge.pmd.lang.cs.ast with PMD 7.
  • net.sourceforge.pmd.lang.dart.antlr4.Dart2Lexer will be renamed to DartLexer and moved to package net.sourceforge.pmd.lang.dart.ast with PMD 7. All other classes in the old package will be removed.
  • net.sourceforge.pmd.lang.go.antlr4.GolangLexer will be moved to package net.sourceforge.pmd.lang.go.ast with PMD 7. All other classes in the old package will be removed.
  • net.sourceforge.pmd.lang.kotlin.antlr4.Kotlin will be renamed to KotlinLexer and moved to package net.sourceforge.pmd.lang.kotlin.ast with PMD 7.
  • net.sourceforge.pmd.lang.lua.antlr4.LuaLexer will be moved to package net.sourceforge.pmd.lang.lua.ast with PMD 7. All other classes in the old package will be removed.
  • External Contributions:
  • 2735: [ci] Add github actions for a fast view of pr succeed/not - XenoAmess
  • 2747: [java] Don’t trigger FinalFieldCouldBeStatic when field is annotated with lombok @Builder.Default - Ollie Abbey
  • 2773: [java] issue-2738: Adding null check to avoid npe when switch case is default - Nimit Patel
  • 2789: Add badge for reproducible build - Dan Rollo
  • 2791: [apex] Analyze inner classes for sharing violations - Jeff Bartolotta

New in PMD 6.27.0 (Sep 1, 2020)

  • New and noteworthy:
  • Java 15 Support:
  • This release of PMD brings support for Java 15. PMD can parse Text Blocks which have been promoted to be a standard language feature of Java.
  • PMD also supports Pattern Matching for instanceof, Records, and Sealed Classes.
  • Note: The Pattern Matching for instanceof, Records, and Sealed Classes are all preview language features of OpenJDK 15 and are not enabled by default. In order to analyze a project with PMD that uses these language features, you'll need to enable it via the environment variable PMD_JAVA_OPTS and select the new language version 15-preview:
  • export PMD_JAVA_OPTS=--enable-preview
  • ./run.sh pmd -language java -version 15-preview ...
  • Note: Support for Java 13 preview language features have been removed. The version "13-preview" is no longer available.
  • Changes in how tab characters are handled
  • In the past, tab characters in source files has been handled differently in different languages by PMD. For instance in Java, tab characters had a width of 8 columns, while C# used only 1 column. Visualforce instead used 4 columns.
  • This has been unified now so that tab characters are consistently now always 1 column wide.
  • This however might be a incompatible change, if you're using the properties "BeginColumn" or "EndColumn" additionally to "BeginLine" and "EndLine" of a Token/AST node in order to highlight where a rule violation occurred in the source file. If you have logic there that deals with tab characters, you most likely can remove this logic now, since tab characters are now just "normal" characters in terms of string processing.
  • See also [all] Ensure PMD/CPD uses tab width of 1 for tabs consistently #2656.
  • Updated PMD Designer:
  • This PMD release ships a new version of the pmd-designer. For the changes, see PMD Designer Changelog.
  • New Rules:
  • The new Java rule AvoidReassigningCatchVariables (java-bestpractices) finds cases where the variable of the caught exception is reassigned. This practice is surprising and prevents further evolution of the code like multi-catch.
  • Modified Rules:
  • The Java rule CloseResource (java-errorprone) has a new property closeNotInFinally. With this property set to true the rule will also find calls to close a resource, which are not in a finally-block of a try-statement. If a resource is not closed within a finally block, it might not be closed at all in case of exceptions.
  • As this new detection would yield many new violations, it is disabled by default. It might be enabled in a later version of PMD.
  • Deprecated Rules:
  • The Java rule DataflowAnomalyAnalysis (java-errorprone) is deprecated in favour of UnusedAssignment (java-bestpractices), which was introduced in PMD 6.26.0.
  • Fixed Issues:
  • core:
  • 724: [core] Avoid parsing rulesets multiple times
  • 1962: [core] Simplify Report API
  • 2653: [lang-test] Upgrade kotlintest to Kotest
  • 2656: [all] Ensure PMD/CPD uses tab width of 1 for tabs consistently
  • 2690: [core] Fix java7 compatibility
  • java:
  • 2646: [java] Support JDK 15
  • java-bestpractices:
  • 2471: [java] New Rule: AvoidReassigningCatchVariables
  • 2663: [java] NoClassDefFoundError on upgrade from 6.25.0 to 6.26.0
  • 2668: [java] UnusedAssignment false positives
  • 2673: [java] UnusedPrivateField and SingularField false positive with lombok annotation EqualsAndHashCode
  • 2684: [java] UnusedAssignment FP in try/catch
  • 2686: [java] UnusedAssignment must not flag abstract method parameters in interfaces and abstract classes
  • java-design:
  • 2108: [java] [doc] ImmutableField rule: Description should clarify shallow immutability
  • 2461: [java] ExcessiveParameterListRule must ignore a private constructor
  • java-errorprone:
  • 2264: [java] SuspiciousEqualsMethodName: Improve description about error-prone overloading of equals()
  • 2410: [java] ProperCloneImplementation not valid for final class
  • 2431: [java] InvalidLogMessageFormatRule throws IndexOutOfBoundsException when only logging exception message
  • 2439: [java] AvoidCatchingThrowable can not detect the case: catch (java.lang.Throwable t)
  • 2470: [java] CloseResource false positive when resource included in return value
  • 2531: [java] UnnecessaryCaseChange can not detect the case like: foo.equals(bar.toLowerCase())
  • 2647: [java] Deprecate rule DataFlowAnomalyAnalysis
  • java-performance:
  • 1868: [java] false-positive for SimplifyStartsWith if string is empty
  • 2441: [java] RedundantFieldInitializer can not detect a special case for char initialize: char foo = '';
  • 2530: [java] StringToString can not detect the case: getStringMethod().toString()
  • dart:
  • 2750: [dart] [cpd] Cpd Dart escaped dollar
  • API Changes:
  • XML rule definition in rulesets: In PMD 7, the language attribute will be required on all rule elements that declare a new rule. Some base rule classes set the language implicitly in their constructor, and so this is not required in all cases for the rule to work. But this behavior will be discontinued in PMD 7, so missing language attributes are now reported as a forward compatibility warning.
  • Deprecated API:
  • For removal:
  • href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/Rule.html#getParserOptions()">Rule#getParserOptions
  • href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/lang/Parser.html#getParserOptions()">Parser#getParserOptions
  • href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/lang/AbstractParser.html#">AbstractParser
  • href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/RuleContext.html#removeAttribute(java.lang.String)">RuleContext#removeAttribute
  • href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/RuleContext.html#getAttribute(java.lang.String)">RuleContext#getAttribute
  • href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/RuleContext.html#setAttribute(java.lang.String,java.lang.Object)">RuleContext#setAttribute
  • href="https://docs.pmd-code.org/apidocs/pmd-apex/6.27.0/net/sourceforge/pmd/lang/apex/ApexParserOptions.html#">ApexParserOptions
  • href="https://docs.pmd-code.org/apidocs/pmd-java/6.27.0/net/sourceforge/pmd/lang/java/ast/ASTThrowStatement.html#getFirstClassOrInterfaceTypeImage()">ASTThrowStatement#getFirstClassOrInterfaceTypeImage
  • href="https://docs.pmd-code.org/apidocs/pmd-javascript/6.27.0/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.html#">EcmascriptParserOptions
  • href="https://docs.pmd-code.org/apidocs/pmd-javascript/6.27.0/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptXPathRule.html#">EcmascriptXPathRule
  • href="https://docs.pmd-code.org/apidocs/pmd-xml/6.27.0/net/sourceforge/pmd/lang/xml/XmlParserOptions.html#">XmlParserOptions
  • href="https://docs.pmd-code.org/apidocs/pmd-xml/6.27.0/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.html#">XmlXPathRule
  • Properties of href="https://docs.pmd-code.org/apidocs/pmd-xml/6.27.0/net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.html#">AbstractXmlRule
  • href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/Report.ReadableDuration.html#">net.sourceforge.pmd.Report.ReadableDuration
  • Many methods of href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/Report.html#">net.sourceforge.pmd.Report. They are replaced by accessors that produce a List. For example, href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/Report.html#iterator()">iterator() (and implementing Iterable) and href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/Report.html#isEmpty()">isEmpty() are both replaced by href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/Report.html#getViolations()">getViolations().
  • The dataflow codebase is deprecated for removal in PMD 7. This includes all code in the following packages, and their subpackages:
  • href="https://docs.pmd-code.org/apidocs/pmd-plsql/6.27.0/net/sourceforge/pmd/lang/plsql/dfa/package-summary.html#">net.sourceforge.pmd.lang.plsql.dfa
  • href="https://docs.pmd-code.org/apidocs/pmd-java/6.27.0/net/sourceforge/pmd/lang/java/dfa/package-summary.html#">net.sourceforge.pmd.lang.java.dfa
  • href="https://docs.pmd-code.org/apidocs/pmd-core/6.27.0/net/sourceforge/pmd/lang/dfa/package-summary.html#">net.sourceforge.pmd.lang.dfa
  • and the class href="https://docs.pmd-code.org/apidocs/pmd-plsql/6.27.0/net/sourceforge/pmd/lang/plsql/PLSQLDataFlowHandler.html#">PLSQLDataFlowHandler
  • href="https://docs.pmd-code.org/apidocs/pmd-visualforce/6.27.0/net/sourceforge/pmd/lang/vf/VfSimpleCharStream.html#">VfSimpleCharStream
  • href="https://docs.pmd-code.org/apidocs/pmd-jsp/6.27.0/net/sourceforge/pmd/lang/jsp/ast/ASTJspDeclarations.html#">ASTJspDeclarations
  • href="https://docs.pmd-code.org/apidocs/pmd-jsp/6.27.0/net/sourceforge/pmd/lang/jsp/ast/ASTJspDocument.html#">ASTJspDocument
  • href="https://docs.pmd-code.org/apidocs/pmd-scala_2.13/6.27.0/net/sourceforge/pmd/lang/scala/ast/ScalaParserVisitorAdapter.html#zero()">ScalaParserVisitorAdapter#zero
  • href="https://docs.pmd-code.org/apidocs/pmd-scala_2.13/6.27.0/net/sourceforge/pmd/lang/scala/ast/ScalaParserVisitorAdapter.html#combine(Object,Object)">ScalaParserVisitorAdapter#combine
  • href="https://docs.pmd-code.org/apidocs/pmd-apex/6.27.0/net/sourceforge/pmd/lang/apex/ast/ApexParserVisitorReducedAdapter.html#">ApexParserVisitorReducedAdapter
  • href="https://docs.pmd-code.org/apidocs/pmd-java/6.27.0/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorReducedAdapter.html#">JavaParserVisitorReducedAdapter
  • href="https://docs.pmd-code.org/apidocs/pmd-java/6.27.0/net/sourceforge/pmd/lang/java/typeresolution/TypeHelper.html#">TypeHelper is deprecated in favor of href="https://docs.pmd-code.org/apidocs/pmd-java/6.27.0/net/sourceforge/pmd/lang/java/types/TypeTestUtil.html#">TypeTestUtil, which has the same functionality, but a slightly changed API.
  • Many of the classes in href="https://docs.pmd-code.org/apidocs/pmd-java/6.27.0/net/sourceforge/pmd/lang/java/symboltable/package-summary.html#">net.sourceforge.pmd.lang.java.symboltable are deprecated as internal API.
  • External Contributions:
  • 2656: [all] Ensure PMD/CPD uses tab width of 1 for tabs consistently - Maikel Steneker
  • 2659: [java] StringToString can not detect the case: getStringMethod().toString() - Mykhailo Palahuta
  • 2662: [java] UnnecessaryCaseChange can not detect the case like: foo.equals(bar.toLowerCase()) - Mykhailo Palahuta
  • 2671: [java] CloseResource false positive when resource included in return value - Mykhailo Palahuta
  • 2674: [java] add lombok.EqualsAndHashCode in AbstractLombokAwareRule - berkam
  • 2677: [java] RedundantFieldInitializer can not detect a special case for char initialize: char foo = ''; - Mykhailo Palahuta
  • 2678: [java] AvoidCatchingThrowable can not detect the case: catch (java.lang.Throwable t) - Mykhailo Palahuta
  • 2679: [java] InvalidLogMessageFormatRule throws IndexOutOfBoundsException when only logging exception message - Mykhailo Palahuta
  • 2682: [java] New Rule: AvoidReassigningCatchVariables - Mykhailo Palahuta
  • 2697: [java] ExcessiveParameterListRule must ignore a private constructor - Mykhailo Palahuta
  • 2699: [java] ProperCloneImplementation not valid for final class - Mykhailo Palahuta
  • 2700: [java] Fix OnlyOneReturn code example - Jan-Lukas Else
  • 2722: [doc] [java] ImmutableField: extend description, fixes #2108 - Mateusz Stefanski
  • 2723: [doc] [java] SimplifyStartsWith: update description and example, fixes #1868 - Mateusz Stefanski
  • 2724: [doc] [java] SuspiciousEqualsMethodName: update description, fixes #2264 - Mateusz Stefanski
  • 2725: Cleanup: change valueOf to parse when we need primitive return value. - XenoAmess
  • 2726: Cleanup: replace StringBuffer with StringBuilder - XenoAmess
  • 2727: Cleanup: replace indexOf() < 0 with contains - XenoAmess
  • 2728: Cleanup: javadoc issues - XenoAmess
  • 2729: Cleanup: use print instead of printf if no format exists - XenoAmess
  • 2730: Cleanup: StringBuilder issues - XenoAmess
  • 2731: Cleanup: avoid compiling Patterns repeatedly - XenoAmess
  • 2732: Cleanup: use StandardCharsets instead of Charset.forName - XenoAmess
  • 2733: Cleanup: Collection::addAll issues - XenoAmess
  • 2734: Cleanup: use try with resources - XenoAmess
  • 2744: Cleanup: fix typos - XenoAmess
  • 2745: [core] Fix a NPE in buildUsageText - XenoAmess
  • 2749: [dart] [cpd] Improvements for Dart interpolated strings - Maikel Steneker
  • 2750: [dart] [cpd] Cpd Dart escaped dollar - Maikel Steneker

New in PMD 6.19.0 (Nov 1, 2019)

  • New and noteworthy:
  • Updated PMD Designer:
  • This PMD release ships a new version of the pmd-designer. For the changes, see PMD Designer Changelog.
  • Java Metrics
  • The new metric “Class Fan Out Complexity” has been added. See Java Metrics Documentation for details.
  • Modified Rules:
  • The Java rules InvalidLogMessageFormat and MoreThanOneLogger (java-errorprone) now both support Log4j2. Note that the rule “InvalidSlf4jMessageFormat” has been renamed to “InvalidLogMessageFormat” to reflect the fact, that it now supports more than slf4j.
  • The Java rule LawOfDemeter (java-design) ignores now also Builders, that are not assigned to a local variable, but just directly used within a method call chain. The method, that creates the builder needs to end with “Builder”, e.g. newBuilder() or initBuilder() works. This change fixes a couple of false positives.
  • The Java rule DataflowAnomalyAnalysis (java-errorprone) doesn’t check for UR anomalies (undefined and then referenced) anymore. These checks were all false-positives, since actual UR occurrences would lead to compile errors.
  • The java rule DoNotUseThreads (java-multithreading) has been changed to not report usages of java.lang.Runnable anymore. Just using Runnable does not automatically create a new thread. While the check for Runnable has been removed, the rule now additionally checks for usages of Executors and ExecutorService. Both create new threads, which are not managed by a J2EE server.
  • Renamed Rules:
  • The Java rule InvalidSlf4jMessageFormat has been renamed to InvalidLogMessageFormat since it supports now both slf4j and log4j2 message formats.
  • Fixed Issues:
  • Core:
  • #1978: [core] PMD fails on excluding unknown rules
  • #2014: [core] Making add(SourceCode sourceCode) public for alternative file systems
  • #2020: [core] Wrong deprecation warnings for unused XPath attributes
  • #2036: [core] Wrong include/exclude patterns are silently ignored
  • #2048: [core] Enable type resolution by default for XPath rules
  • #2067: [core] Build issue on Windows
  • #2068: [core] Rule loader should use the same resources loader for the ruleset
  • #2071: [ci] Add travis build on windows
  • #2072: [test][core] Not enough info in “test setup error” when numbers of lines do not match
  • #2082: [core] Incorrect logging of deprecated/renamed rules
  • Java:
  • #2042: [java] PMD crashes with ClassFormatError: Absent Code attribute…
  • Java-bestpractices:
  • #1531: [java] UnusedPrivateMethod false-positive with method result
  • #2025: [java] UnusedImports when @see / @link pattern includes a FQCN
  • Java-codestyle:
  • #2017: [java] UnnecessaryFullyQualifiedName triggered for inner class
  • Java-design:
  • #1912: [java] Metrics not computed correctly with annotations
  • Java-errorprone:
  • #336: [java] InvalidSlf4jMessageFormat applies to log4j2
  • #1636: [java] Stop checking UR anomalies for DataflowAnomalyAnalysis
  • Java-multithreading:
  • #1627: [java] DoNotUseThreads should not warn on Runnable
  • Doc:
  • #2058: [doc] CLI reference for -norulesetcompatibility shows a boolean default value
  • API Changes:
  • Deprecated APIs:
  • For removal:
  • Pmd-core:
  • All the package net.sourceforge.pmd.dcd and its subpackages. See DCD.
  • In LanguageRegistry:
  • commaSeparatedTerseNamesForLanguageVersion
  • commaSeparatedTerseNamesForLanguage
  • findAllVersions
  • findLanguageVersionByTerseName
  • getInstance
  • RuleSet#getExcludePatterns. Use the new method getFileExclusions instead.
  • RuleSet#getIncludePatterns. Use the new method getFileInclusions instead.
  • Parser#canParse
  • Parser#getSuppressMap
  • RuleBuilder#RuleBuilder. Use the new constructor with the correct ResourceLoader instead.
  • RuleFactory#RuleFactory. Use the new constructor with the correct ResourceLoader instead.
  • Pmd-java:
  • CanSuppressWarnings and its implementations
  • isSuppressed
  • getDeclaringType.
  • isSupressed
  • ASTMethodDeclarator
  • getMethodName
  • getBlock
  • getParameterCount
  • Pmd-apex:
  • CanSuppressWarnings and its implementations
  • isSupressed
  • Internal APIs:
  • Pmd-core:
  • All the package net.sourceforge.pmd.util and its subpackages, except net.sourceforge.pmd.util.datasource and net.sourceforge.pmd.util.database.
  • GridBagHelper
  • ColumnDescriptor

New in PMD 6.18.0 (Sep 23, 2019)

  • New and noteworthy:
  • Java 13 Support:
  • This release of PMD brings support for Java 13. PMD can parse Switch Expressions with the new yield statement and resolve the type of such an expression.
  • PMD also parses Text Blocks as String literals.
  • Note: The Switch Expressions and Text Blocks are a preview language feature of OpenJDK 13 and are not enabled by default. In order to analyze a project with PMD that uses these language features, you’ll need to enable it via the environment variable PMD_JAVA_OPTS and select the new language version 13-preview
  • Full support for Scala:
  • Thanks to Chris Smith PMD now fully supports Scala. Now rules for analyzing Scala code can be developed in addition to the Copy-Paste-Detection (CPD) functionality. There are no rules yet, so contributions are welcome.
  • Additionally Scala support has been upgraded from 2.12.4 to 2.13.
  • New rule designer documentation:
  • The documentation for the rule designer is now available on the main PMD documentation page: Rule Designer Reference. Check it out to learn about the usage and features of the rule designer.
  • New rules:
  • The Java rule AvoidMessageDigestField (java-bestpractices) detects fields of the type java.security.MessageDigest. Using a message digest instance as a field would need to be synchronized, as it can easily be used by multiple threads. Without synchronization the calculated hash could be entirely wrong. Instead of declaring this as a field and synchronize access to use it from multiple threads, a new instance should be created when needed. This rule is also active when using java’s quickstart ruleset.
  • The Apex rule DebugsShouldUseLoggingLevel (apex-bestpractices) detects usages of System.debug() method calls that are used without specifying the log level. Having the log level specified provides a cleaner log, and improves readability of it.
  • Modified Rules:
  • The Java rule CloseResource (java-errorprone) now ignores by default instances of java.util.stream.Stream. These streams are AutoCloseable, but most streams are backed by collections, arrays, or generating functions, which require no special resource management. However, there are some exceptions: The stream returned by Files::lines(Path) is backed by a actual file and needs to be closed. These instances won’t be found by default by the rule anymore.
  • Fixed Issues:
  • all:
  • 1465: [core] Stylesheet pmd-report.xslt fails to display filepath if ‘java’ in path
  • 1923: [core] Incremental analysis does not work with shortnames
  • 1983: [core] Avoid crashes with analysis cache when classpath references non-existing directories:
  • 1990: [core] Incremental analysis mixes XPath rule violations
  • apex:
  • 1901: [apex] Expose super type name of UserClass
  • 1942: [apex] Add best practice rule for debug statements in Apex
  • java:
  • 1930: [java] Add Java 13 support
  • java-bestpractices:
  • 1227: [java] UnusedFormalParameter should explain checkAll better
  • 1862: [java] New rule for MessageDigest.getInstance
  • 1952: [java] UnusedPrivateField not triggering if @Value annotation present
  • java-codestyle:
  • 1951: [java] UnnecessaryFullyQualifiedName rule triggered when variable name clashes with package name
  • java-errorprone:
  • 1922: [java] CloseResource possible false positive with Streams
  • 1966: [java] CloseResource false positive if Stream is passed as method parameter:
  • 1967: [java] CloseResource false positive with late assignment of variable
  • plsql:
  • 1933: [plsql] ParseException with cursor declared in anonymous block
  • 1935: [plsql] ParseException with SELECT INTO record defined as global variable
  • 1936: [plslq] ParseException with cursor inside procedure declaration
  • 1946: [plsql] ParseException with using TRIM inside IF statements condition
  • 1947: [plsql] ParseError - SELECT with FOR UPDATE OF
  • 1948: [plsql] ParseException with INSERT INTO using package global variables
  • 1950: [plsql] ParseException with UPDATE and package record variable
  • 1953: [plsql] ParseException with WITH in CURSOR
  • API Changes:
  • Changes to Renderer:
  • Each renderer has now a new method Renderer#setUseShortNames which is used for implementing the “shortnames” CLI option. The method is automatically called by PMD, if this CLI option is in use. When rendering filenames to the report, the new helper method AbstractRenderer#determineFileName should be used. This will change the filename to a short name, if the CLI option “shortnames” is used.
  • Not adjusting custom renderers will make them render always the full file names and not honoring the CLI option “shortnames”.
  • Deprecated APIs:
  • For removal
  • The methods getImportedNameNode and getPackage have been deprecated and will be removed with PMD 7.0.0.
  • The method RuleContext#setSourceCodeFilename has been deprecated and will be removed. The already existing method RuleContext#setSourceCodeFile should be used instead. The method RuleContext#getSourceCodeFilename still exists and returns just the filename without the full path.
  • The method AbstractPMDProcessor#filenameFrom has been deprecated. It was used to determine a “short name” of the file being analyzed, so that the report can use short names. However, this logic has been moved to the renderers.
  • The method Report#metrics and Report have been deprecated. They were leftovers from a previous deprecation round targeting StatisticalRule.
  • Internal APIs
  • Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the @InternalApi annotation. You’ll also get a deprecation warning.
  • pmd-core
  • net.sourceforge.pmd.cache
  • pmd-java
  • net.sourceforge.pmd.lang.java.typeresolution: Everything, including subpackages, except TypeHelper and JavaTypeDefinition.
  • ASTCompilationUnit#getClassTypeResolver
  • External Contributions:
  • 1943: [apex] Adds “debug should use logging level” best practice rule for Apex - Renato Oliveira
  • 1965: [scala] Use Scalameta for parsing - Chris Smith
  • 1970: [java] DoubleBraceInitialization: Fix example - Tobias Weimer
  • 1971: [java] 1862 - Message Digest should not be used as class field - AnthonyKot
  • 1972: [plsql] ParseError - SELECT with FOR UPDATE OF - Piotr Szymanski
  • 1974: [plsql] Fixes for referencing record type variables - Piotr Szymanski
  • 1975: [plsql] TRIM function with record type variables - Piotr Szymanski
  • 1976: [plsql] Fix for mistaking / for MultiplicativeExpression - Piotr Szymanski
  • 1977: [plsql] fix for skipping sql starting with WITH - Piotr Szymanski
  • 1986: [plsql] Fix for cursors in anonymous blocks - Piotr Szymanski
  • 1994: [core] Resolve pmd-report failure when java folder in filepath - Amish Shah
  • 2015: [java] Update doc for unused formal parameter - Amish Shah

New in PMD 6.13.0 (Apr 1, 2019)

  • New and noteworthy:
  • Call For Logo:
  • We are still searching for a new logo for PMD for the next major release.
  • Learn more about how to participate on github issue 1663.
  • Java 12 Support:
  • This release of PMD brings support for Java 12. PMD can parse the new Switch Expressions and resolve the type of such an expression.
  • Note: The Switch Expressions are a preview language feature of OpenJDK 12 and are not enabled by default. In order to analyze a project with PMD that uses these language features, you’ll need to enable it via the new environment variable PMD_JAVA_OPTS:
  • export PMD_JAVA_OPTS=--enable-preview
  • ./run.sh pmd ...
  • Quickstart Ruleset for Apex
  • PMD provides now a quickstart ruleset for Salesforce.com Apex, which you can use as a base ruleset to get your custom ruleset started. You can reference it with rulesets/apex/quickstart.xml. You are strongly encouraged to create your own ruleset though.
  • The quickstart ruleset has the intention, to be useful out-of-the-box for many projects. Therefore it references only rules, that are most likely to apply everywhere.
  • Any feedback would be greatly appreciated.
  • PMD Designer:
  • The rule designer’s codebase has been moved out of the main repository and will be developed at pmd/pmd-designer from now on. The maven coordinates will stay the same for the time being. The designer will still be shipped with PMD’s binaries.
  • Improved Apex Support:
  • Many AST nodes now expose more information which makes it easier to write XPath-based rules for Apex. Here are some examples:
  • Annotation[@Resolved = false()] finds unsupported annotations.
  • AnnotationParameter[@Name='RestResource'][@Value='/myurl'] gives access to annotation parameters.
  • CatchBlockStatement[@ExceptionType='Exception'][@VariableName='e'] finds catch block for specific exception types.
  • Field[@Type='String'] find all String fields, Field[string-length(@Name) < 5] finds all fields with short names and Field[@Value='a'] find alls fields, that are initialized with a specific value.
  • LiteralExpression[@String = true()] finds all String literals. There are attributes for each type: @Boolean, @Integer, @Double, @Long, @Decimal, @Null.
  • Method[@Constructor = true()] selects all constructors. Method[@ReturnType = 'String'] selects all methods that return a String.
  • The ModifierNode node has a couple of attributes to check for the existence of specific modifiers: @Test, @TestOrTestSetup, @WithSharing, @WithoutSharing, @InheritedSharing, @WebService, @Global, @Override.
  • Many nodes now expose their type. E.g. with Parameter[@Type='Integer'] you can find all method parameters of type Integer. The same attribute Type exists as well for: NewObjectExpression, Property, VariableDeclaration.
  • VariableExpression[@Image='i'] finds all variable usages of the variable “i”.
  • New Rules:
  • The new Java rule AvoidUncheckedExceptionsInSignatures (java-design) finds methods or constructors that declare unchecked exceptions in their throws clause. This forces the caller to handle the exception, even though it is a runtime exception.
  • The new Java rule DetachedTestCase (java-errorprone) searches for public methods in test classes, which are not annotated with @Test. These methods might be test cases where the annotation has been forgotten. Because of that those test cases are never executed.
  • The new Java rule WhileLoopWithLiteralBoolean (java-bestpractices) finds Do-While-Loops and While-Loops that can be simplified since they use simply true or false as their loop condition.
  • The new Apex rule ApexAssertionsShouldIncludeMessage (apex-bestpractices) searches for assertions in unit tests and checks, whether they use a message argument.
  • The new Apex rule ApexUnitTestMethodShouldHaveIsTestAnnotation (apex-bestpractices) searches for methods in test classes, which are missing the @IsTest annotation.
  • The new PLSQL rule AvoidTabCharacter (plsql-codestyle) checks, that there are no tab characters (“t”) in the source file.
  • The new PLSQL rule LineLength (plsql-codestyle) helps to enforce a maximum line length.
  • Fixed Issues:
  • doc
  • #1721: [doc] Documentation provides an invalid property configuration example
  • java
  • #1537: [java] Java 12 support
  • java-bestpractices
  • #1701: [java] UseTryWithResources does not handle multiple argument close methods
  • java-codestyle
  • #1527: [java] UseUnderscoresInNumericLiterals false positive on floating point numbers
  • #1674: [java] documentation of CommentDefaultAccessModifier is wrong
  • java-errorprone
  • #1570: [java] AvoidDuplicateLiterals warning about deprecated separator property when not used
  • plsql
  • #1510: [plsql] Support XMLTABLE functions
  • #1716: [plsql] Support access to whole plsql code
  • #1731: [pslql] ParseException when parsing ELSIF
  • #1733: [plsql] % not supported in “TestSearch%notfound”
  • #1734: [plsql] TooManyMethods false-negative
  • #1735: [plsql] False-negatives for TO_DATE_TO_CHAR, TO_DATEWithoutDateFormat, TO_TIMESTAMPWithoutDateFormat
  • API Changes
  • Command Line Interface
  • The start scripts run.sh, pmd.bat and cpd.bat support the new environment variable PMD_JAVA_OPTS. This can be used to set arbitrary JVM options for running PMD, such as memory settings (e.g. PMD_JAVA_OPTS=-Xmx512m) or enable preview language features (e.g. PMD_JAVA_OPTS=--enable-preview).
  • The previously available variables such as OPTS or HEAPSIZE are deprecated and will be removed with PMD 7.0.0.
  • Deprecated API
  • CodeClimateRule is deprecated in 7.0.0 because it was unused for 2 years and created an unwanted dependency. Properties “cc_categories”, “cc_remediation_points_multiplier”, “cc_block_highlighting” will also be removed. See #1702 for more.
  • The Apex ruleset rulesets/apex/ruleset.xml has been deprecated and will be removed in 7.0.0. Please use the new quickstart ruleset rulesets/apex/quickstart.xml instead.

New in PMD 6.9.0 (Oct 30, 2018)

  • New and noteworthy:
  • Improved Golang CPD Support:
  • Thanks to the work of ITBA students Matías Fraga, Tomi De Lucca and Lucas Soncini, Golang is now backed by a proper Antlr Grammar. This means CPD is now better at detecting duplicates, as comments are recognized as such and ignored.
  • New Rules:
  • The new PLSQL rule CodeFormat (plsql-codestyle) verifies that PLSQL code is properly formatted. It checks e.g. for correct indentation in select statements and verifies that each parameter is defined on a separate line.
  • Fixed Issues:
  • all:
  • [core] Exclude specific files from command line
  • [core] Could not find or load main class when using symlinked run.sh
  • [core] LanguageRegistry uses default class loader when invoking ServiceLocator
  • [doc] How to configure “-cache "
  • [doc] Broken link to adding new cpd language documentation
  • apex
  • [apex] ClassCastException caused by Javadoc
  • java
  • [java] PMD crashes with java.lang.ClassFormatError Absent Code attribute in method that is not native or abstract in class file javax/xml/ws/Service
  • java-bestpractices
  • [java] GuardLogStatement “There is log block not surrounded by if” doesn’t sound right
  • [java] UnusedImports false positive for static import with package-private method usage
  • [java] Update CommentDefaultAccessModifierRule to extend AbstractIgnoredAnnotationRule
  • [java] JUnitTestsShouldIncludeAssert false positive
  • [java] UnusedImports false positive with static ondemand import with method call
  • java-codestyle
  • [java] UnnecessaryFullyQualifiedName doesn’t flag same package FQCNs
  • [java] UnnecessaryModifier wrong message public->static
  • java-design
  • [java] Processing error (ClassCastException) if a TYPE_USE annotation is used on a base class in the “extends” clause
  • jsp
  • [jsp] JspTokenManager has a problem about jsp scriptlet
  • documentation
  • [doc] Provide some explanation for WHY duplicate code is bad, like mutations
  • API Changes:
  • PMD has a new CLI option -ignorelist. With that, you can provide a file containing a comma-delimit list of files, that should be excluded during analysis. The ignorelist is applied after the files have been selected via -dir or -filelist, which means, if the file is in both lists, then it will be ignored. Note there is no corresponding option for the Ant task, since the feature is already available via Ant’s FileSet include/exclude filters.
  • External Contributions:
  • [core] [cpd] Generalize ANTLR tokens preparing support for ANTLR token filter - Matías Fraga and Tomi De Lucca
  • [doc] Update cpd.md with information about risks - David M. Karr
  • [java] Static Modifier on Internal Interface pmd #1356 - avishvat
  • [doc] Updated outdated note in the building documentation. - Maikel Steneker
  • [java] Simplify check for ‘Test’ annotation in JUnitTestsShouldIncludeAssertRule. - Will Winder
  • [java] Add missing null check AbstractJavaAnnotatableNode - Will Winder
  • [all] Upgrading Apache Commons IO from 2.4 to 2.6 - Thunderforge
  • [all] Upgrading Apache Commons Lang 3 from 3.7 to 3.8.1 - Thunderforge
  • [all] Replacing deprecated IO methods with ones that specify a charset - Thunderforge
  • [java] Improved message for GuardLogStatement rule - Felix Lampe
  • [go] [cpd] Add CPD support for Antlr based grammar on Golang - Matías Fraga
  • [all] Upgrading SLF4J from 1.7.12 to 1.7.25 - Thunderforge
  • [java] Fix Issue 1343 Update CommentDefaultAccessModifierRule - CrazyUnderdog
  • [all] Replacing IOUtils.closeQuietly(foo) with try-with-resources statements - Thunderforge
  • [jsp] Fix issue 1402 JspTokenManager has a problem about jsp scriptlet - JustPRV
  • [core] Add ignore file path functionality - Jon Moroney
  • [doc] Fix broken link. Fixes #1412 - Johan Hammar

New in PMD 6.6.0 (Jul 30, 2018)

  • New and noteworthy:
  • Java 11 Support
  • PMD is now able to parse the local-variable declaration syntax var xxx, that has been extended for lambda parameters with Java 11 via JEP 323: Local-Variable Syntax for Lambda Parameters.
  • New Rules:
  • The new Java rule LocalVariableNamingConventions (java-codestyle) detects local variable names that don’t comply to a given convention. It defaults to standard Java convention of using camelCase, but can be configured. Special cases can be configured for final variables and caught exceptions’ names.
  • The new Java rule FormalParameterNamingConventions (java-codestyle) detects formal parameter names that don’t comply to a given convention. It defaults to standard Java convention of using camelCase, but can be configured. Special cases can be configured for final parameters and lambda parameters (considering whether they are explicitly typed or not).
  • Modified Rules:
  • The Java rules AccessorClassGeneration and AccessorMethodGeneration] (both in category java-bestpractices) have been modified to be only valid up until Java 10. Java 11 adds support for JEP 181: Nest-Based Access Control which avoids the generation of accessor classes / methods altogether.
  • Fixed Issues:
  • core
  • #1178: [core] “Unsupported build listener” in gradle build
  • #1225: [core] Error in sed expression on line 82 of run.sh while detecting installed version of Java
  • doc
  • #1215: [doc] TOC links don’t work?
  • java-codestyle
  • #1211: [java] CommentDefaultAccessModifier false positive with nested interfaces (regression from 6.4.0)
  • #1216: [java] UnnecessaryFullyQualifiedName false positive for the same name method
  • java-design
  • #1217: [java] CyclomaticComplexityRule counts ?-operator twice
  • #1226: [java] NPath complexity false negative due to overflow
  • plsql
  • #980: [plsql] ParseException for CREATE TABLE
  • #981: [plsql] ParseException when parsing VIEW
  • #1047: [plsql] ParseException when parsing EXECUTE IMMEDIATE
  • #1233: [ui] XPath autocomplete arrows on first and last items
  • API Changes
  • The findDescendantsOfType methods in net.sourceforge.pmd.lang.ast.AbstractNode no longer search for exact type matches, but will match subclasses, too. That means, it’s now possible to look for abstract node types such as AbstractJavaTypeNode and not only for it’s concrete subtypes.
  • External Contributions
  • #1182: [ui] XPath AutoComplete - Akshat Bahety
  • #1231: [doc] Minor typo fix in installation.md - Ashish Rana
  • #1250: [ci] [GSoC] Upload baseline of pmdtester automatically - BBG

New in PMD 6.2.0 (Mar 28, 2018)

  • NEW AND NOTEWORTHY:
  • Ecmascript (JavaScript):
  • The Rhino Library has been upgraded from version 1.7.7 to version 1.7.7.2.
  • Disable Incremental Analysis:
  • Some time ago, we added support for Incremental Analysis. On PMD 6.0.0, we started to add warns when not using it, as we strongly believe it’s a great improvement to our user’s experience as analysis time is greatly reduced; and in the future we plan to have it enabled by default. However, we realize some scenarios don’t benefit from it (ie: CI jobs), and having the warning logged can be noisy and cause confusion. To this end, we have added a new flag to allow you to explicitly disable incremental analysis. On CLI, this is the new -no-cache flag. On Ant, there is a noCache attribute for the <pmd> task. On both scenarios, disabling the cache takes precedence over setting a cache location
  • New Rules:
  • The new Java rule MissingOverride (category bestpractices) detects overridden and implemented methods, which are not marked with the @Override annotation. Annotating overridden methods with @Override ensures at compile time that the method really overrides one, which helps refactoring and clarifies intent.
  • The new Java rule UnnecessaryAnnotationValueElement (category codestyle) detects annotations with a single element (value) that explicitely names it. That is, doing @SuppressWarnings(value = "unchecked") would be flagged in favor of @SuppressWarnings("unchecked").
  • The new Java rule ControlStatementBraces (category codestyle) enforces the presence of braces on control statements where they are optional. Properties allow to customize which statements are required to have braces. This rule replaces the now deprecated rules WhileLoopMustUseBraces, ForLoopMustUseBraces, IfStmtMustUseBraces, and IfElseStmtMustUseBraces. More than covering the use cases of those rules, this rule also supports do ... while statements and case labels of switch statements (disabled by default)
  • Modified Rules:
  • The Java rule CommentContentRule (java-documentation) previously had the property wordsAreRegex. But this property never had been implemented and is removed now.
  • The Java rule UnusedPrivateField (java-bestpractices) now has a new ignoredAnnotations property that allows to configure annotations that imply the field should be ignored. By default @java.lang.Deprecated and @javafx.fxml.FXML are ignored.
  • The Java rule UnusedPrivateMethod (java-bestpractices) now has a new ignoredAnnotations property that allows to configure annotations that imply the method should be ignored. By default @java.lang.Deprecated is ignored.
  • The Java rule ImmutableField (java-design) now has a new ignoredAnnotations property that allows to configure annotations that imply the method should be ignored. By default several lombok annotations are ignored
  • The Java rule SingularField (java-design) now has a new ignoredAnnotations property that allows to configure annotations that imply the method should be ignored. By default several lombok annotations are ignored
  • Deprecated Rules:
  • The Java rules WhileLoopMustUseBraces, ForLoopMustUseBraces, IfStmtMustUseBraces, and IfElseStmtMustUseBraces are deprecated. They will be replaced by the new rule ControlStatementBraces, in the category codestyle
  • FIXED ISSUES:
  • all:
  • #928: [core] PMD build failure on Windows
  • java-bestpracrtices:
  • #907: [java] UnusedPrivateField false-positive with @FXML
  • #963: [java] ArrayIsStoredDirectly not triggered from variadic functions
  • java-codestyle:
  • #974: [java] Merge *StmtMustUseBraces rules
  • #983: [java] Detect annotations with single value element
  • java-design:
  • #832: [java] AvoidThrowingNullPointerException documentation suggestion
  • #837: [java] CFGs of declared but not called lambdas are treated as parts of an enclosing method’s CFG
  • #839: [java] SignatureDeclareThrowsException’s IgnoreJUnitCompletely property not honored for constructors
  • #968: [java] UseUtilityClassRule reports false positive with lombok NoArgsConstructor
  • documentation:
  • #978: [core] Broken link in CONTRIBUTING.md
  • #992: [core] Include info about rule doc generation in “Writing Documentation” md page
  • API CHANGES:
  • A new CLI switch, -no-cache, disables incremental analysis and the related suggestion. This overrides the -cache option. The corresponding Ant task parameter is noCache.
  • The static method PMDParameters.transformParametersIntoConfiguration(PMDParameters) is now deprecated, for removal in 7.0.0. The new instance method PMDParameters.toConfiguration() replaces it.
  • The method ASTConstructorDeclaration.getParameters() has been deprecated in favor of the new method getFormalParameters(). This method is available for both ASTConstructorDeclaration and ASTMethodDeclaration
  • EXTERNAL CONTRIBUTIONS:
  • 941: [java] Use char notation to represent a character to improve performance - reudismam
  • 943: [java] UnusedPrivateField false-positive with @FXML - BBG
  • 951: [java] Add ignoredAnnotations property to unusedPrivateMethod rule - BBG
  • 952: [java] SignatureDeclareThrowsException’s IgnoreJUnitCompletely property not honored for constructors - BBG
  • 958: [java] Refactor how we ignore annotated elements in rules - BBG
  • 965: [java] Make Varargs trigger ArrayIsStoredDirectly - Stephen
  • 967: [doc] Issue 959: fixed broken link to XPath Rule Tutorial - Andrey Mochalov
  • 969: [java] Issue 968 Add logic to handle lombok private constructors with utility classes - Kirk Clemens
  • 970: [java] Fixed inefficient use of keySet iterator instead of entrySet iterator - Andrey Mochalov
  • 984: [java] issue983 Add new UnnecessaryAnnotationValueElement rule - Kirk Clemens
  • 989: [core] Update Contribute.md to close Issue #978 - Bolarinwa Saheed Olayemi
  • 990: [java] Updated Doc on AvoidThrowingNullPointerException to close Issue #832 - Bolarinwa Saheed Olayemi
  • 993: [core] Update writing_documentation.md to fix Issue #992 - Bolarinwa Saheed Olayemi

New in PMD 6.0.1 (Jan 22, 2018)

  • With the release of PMD 6.0.0, all rules have been sorted into one of the following eight categories:
  • Best Practices: These are rules which enforce generally accepted best practices.
  • Code Style: These rules enforce a specific coding style.
  • Design: Rules that help you discover design issues.
  • Documentation: These rules are related to code documentation.
  • Error Prone: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
  • Multithreading: These are rules that flag issues when dealing with multiple threads of execution.
  • Performance: Rules that flag suboptimal code.
  • Security: Rules that flag potential security flaws.
  • Please note, that not every category in every language may have a rule. There might be categories with no rules at all, such as category/java/security.xml, which has currently no rules. There are even languages, which only have rules of one category (e.g. category/xml/errorprone.xml).
  • In order to help migrate to the new category scheme, the new name for the old, deprecated rule names will be logged as a warning. See PR #865. Please note, that the deprecated rule names will keep working throughout PMD 6. You can upgrade to PMD 6 without the immediate need to migrate your current ruleset. That backwards compatibility will be maintained until PMD 7.0.0 is released.
  • Fixed Issues:
  • #842: [core] Use correct java bootclasspath for compiling apex-errorprone
  • #792: [apex] AvoidDirectAccessTriggerMap incorrectly detects array access in classes apex-security
  • #788: [apex] Method chaining breaks ApexCRUDViolation doc
  • #782: [doc] Wrong information in the Release Notes about the Security ruleset
  • #794: [doc] Broken documentation links for 6.0.0
  • java
  • #793: [java] Parser error with private method in nested classes in interfaces
  • #814: [java] UnsupportedClassVersionError is failure instead of a warning
  • #831: [java] StackOverflow in JavaTypeDefinitionSimple.toString java-bestpractices
  • #783: [java] GuardLogStatement regression
  • #800: [java] ForLoopCanBeForeach NPE when looping on this object java-codestyle
  • #817: [java] UnnecessaryModifierRule crashes on valid code java-design
  • #785: [java] NPE in DataClass rule
  • #812: [java] Exception applying rule DataClass
  • #827: [java] GodClass crashes with java.lang.NullPointerException java-performance
  • #841: [java] InsufficientStringBufferDeclaration NumberFormatException
  • java-typeresolution
  • #866: [java] rulesets/java/typeresolution.xml lists non-existent rules
  • API Changes:
  • The constant net.sourceforge.pmd.PMD.VERSION has been deprecated and will be removed with PMD 7.0.0. Please use net.sourceforge.pmd.PMDVersion.VERSION instead.
  • External Contributions:
  • #796: [apex] AvoidDirectAccessTriggerMap incorrectly detects array access in classes - Robert Sösemann
  • #799: [apex] Method chaining breaks ApexCRUDViolation - Robert Sösemann

New in PMD 6.0.0 (Dec 16, 2017)

  • New Rule Designer:
  • Thanks to Clément Fournier, we now have a new rule designer GUI, which is based on JavaFX. It replaces the old designer and can be started via
  • bin/run.sh designer (on Unix-like platform such as Linux and Mac OS X)
  • bindesigner.bat (on Windows)
  • Java 9 support:
  • The Java grammar has been updated to support analyzing Java 9 projects:
  • private methods in interfaces are possible
  • The underscore “_” is considered an invalid identifier
  • Diamond operator for anonymous classes
  • The module declarations in module-info.java can be parsed
  • Concise try-with-resources statements are supported
  • Java 9 support is enabled by default. You can switch back to an older java version via the command line, e.g. -language java -version 1.8.
  • Revamped Apex CPD:
  • We are now using the Apex Jorje Lexer to tokenize Apex code for CPD. This change means:
  • All comments are now ignored for CPD. This is consistent with how other languages such as Java and Groovy work.
  • Tokenization honors the language specification, which improves accuracy.
  • CPD will therefore have less false positives and false negatives.
  • Java Type Resolution:
  • As part of Google Summer of Code 2017, Bendegúz Nagy worked on type resolution for Java. For this release he has extended support for method calls for both instance and static methods.
  • Method shadowing and overloading are supported, as are varargs. However, the selection of the target method upon the presence of generics and type inference is still work in progress. Expect it in forecoming releases.
  • As for fields, the basic support was in place for release 5.8.0, but has now been expanded to support static fields.
  • Metrics Framework:
  • As part of Google Summer of Code 2017, Clément Fournier is worked on the new metrics framework for object-oriented metrics.
  • There are already a couple of metrics (e.g. ATFD, WMC, Cyclo, LoC) implemented. More metrics are planned. Based on those metrics, rules like “GodClass” detection could be implemented more easily. The following rules benefit from the metrics framework: NcssCount (java), NPathComplexity (java), CyclomaticComplexity (both java and apex).
  • The Metrics framework has been abstracted and is available in pmd-core for other languages. With this PMD release, the metrics framework is supported for both Java and Apex.
  • Error Reporting:
  • A number of improvements on error reporting have taken place, meaning changes to some of the report formats.
  • Also of note, the xml report now provides a XML Schema definition, allowing easier parsing and validation.
  • Processing Errors:
  • Processing errors can now provide not only the message previously included on some reports, but also a full stacktrace. This will allow better error reports when providing feedback to the PMD team and help in debugging issues.
  • The report formats providing full stacktrace of errors are:
  • html
  • summaryhtml
  • textcolor
  • vbhtml
  • xml
  • Configuration Errors:
  • For a long time reports have been notified of configuration errors on rules, but they have remained hidden. On a push to make these more evident to users, and help them get the best results out of PMD, we have started to include them on the reports.
  • So far, only reports that include processing errors are showing configuration errors. In other words, the report formats providing configuration error reporting are:
  • csv
  • html
  • summaryhtml
  • text
  • textcolor
  • vbhtml
  • xml
  • As we move forward we will be able to detect and report more configuration errors (ie: incomplete auxclasspath) and include them to such reports.
  • Apex Rule Suppression:
  • Apex violations can now be suppressed very similarly to how it’s done in Java, by making use of a @SuppressWarnings annotation.
  • Supported syntax includes:
  • @SupressWarnings('PMD') // to supress all Apex rules
  • @SupressWarnings('all') // to supress all Apex rules
  • @SupressWarnings('PMD.ARuleName') // to supress only the rule named ARuleName
  • @SupressWarnings('PMD.ARuleName, PMD.AnotherRuleName') // to supress only the rule named ARuleName or AnotherRuleName
  • Rule Categories:
  • All built-in rules have been sorted into one of eight categories:
  • Best Practices: These are rules which enforce generally accepted best practices.
  • Code Style: These rules enforce a specific coding style.
  • Design: Rules that help you discover design issues.
  • Documentation: These rules are related to code documentation.
  • Error Prone: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
  • Multithreading: These are rules that flag issues when dealing with multiple threads of execution.
  • Performance: Rules that flag suboptimal code.
  • Security: Rules that flag potential security flaws.
  • These categories help you to find rules and figure out the relevance and impact for your project.
  • All rules have been moved accordingly, e.g. the rule “JumbledIncrementer”, which was previously defined in the ruleset “java-basic” has now been moved to the “Error Prone” category. The new rule reference to be used is <rule ref="category/java/errorprone.xml/JumbledIncrementer"/>.
  • The old rulesets like “java-basic” are still kept for backwards-compatibility but will be removed eventually. The rule reference documentation has been updated to reflect these changes.
  • New Rules:
  • The new Java rule NcssCount (category design) replaces the three rules “NcssConstructorCount”, “NcssMethodCount”, and “NcssTypeCount”. The new rule uses the metrics framework to achieve the same. It has two properties, to define the report level for method and class sizes separately. Constructors and methods are considered the same.
  • The new Java rule DoNotExtendJavaLangThrowable (category errorprone) is a companion for the java-strictexception.xml/DoNotExtendJavaLangError, detecting direct extensions of java.lang.Throwable.
  • The new Java rule ForLoopCanBeForeach (category errorprone) helps to identify those for-loops that can be safely refactored into for-each-loops available since java 1.5.
  • The new Java rule AvoidFileStream (category performance) helps to identify code relying on FileInputStream / FileOutputStream which, by using a finalizer, produces extra / unnecessary overhead to garbage collection, and should be replaced with Files.newInputStream / Files.newOutputStream available since java 1.7.
  • The new Java rule DataClass (category design) detects simple data-holders without behaviour. This might indicate that the behaviour is scattered elsewhere and the data class exposes the internal data structure, which breaks encapsulation.
  • The new Apex rule AvoidDirectAccessTriggerMap (category errorprone) helps to identify direct array access to triggers, which can produce bugs by either accessing non-existing indexes, or leaving them out. You should use for-each-loops instead.
  • The new Apex rule AvoidHardcodingId (category errorprone) detects hardcoded strings that look like identifiers and flags them. Record IDs change between environments, meaning hardcoded ids are bound to fail under a different setup.
  • The new Apex rule CyclomaticComplexity (category design) detects overly complex classes and methods. The report threshold can be configured separately for classes and methods.
  • A whole bunch of new rules has been added to Apex. They all fit into the category errorprone. The 5 rules are migrated for Apex from the equivalent Java rules and include:
  • EmptyCatchBlock to detect catch blocks completely ignoring exceptions.
  • EmptyIfStmt for if blocks with no content, that can be safely removed.
  • EmptyTryOrFinallyBlock for empty try / finally blocks that can be safely removed.
  • EmptyWhileStmt for empty while loops that can be safely removed.
  • EmptyStatementBlock for empty code blocks that can be safely removed.
  • The new Apex rule AvoidSoslInLoops (category performance) is the companion of the old AvoidSoqlInLoops rule, flagging SOSL (Salesforce Object Search Language) queries when within loops, to avoid governor issues, and hitting the database too often.
  • Modified Rules:
  • The Java rule UnnecessaryFinalModifier (category codestyle, former ruleset java-unnecessarycode) has been merged into the rule UnnecessaryModifier. As part of this, the rule has been revamped to detect more cases. It will now flag anonymous class’ methods marked as final (can’t be overridden, so it’s pointless), along with final methods overridden / defined within enum instances. It will also flag final modifiers on try-with-resources.
  • The Java rule UnnecessaryParentheses (category codestyle, former ruleset java-controversial) has been merged into UselessParentheses (category codestyle, former ruleset java-unnecessary). The rule covers all scenarios previously covered by either rule.
  • The Java rule UncommentedEmptyConstructor (category documentation, former ruleset java-design) will now ignore empty constructors annotated with javax.inject.Inject.
  • The Java rule AbstractClassWithoutAnyMethod (category bestpractices, former ruleset java-design) will now ignore classes annotated with com.google.auto.value.AutoValue.
  • The Java rule GodClass (category design', former ruleset java-design`) has been revamped to use the new metrics framework.
  • The Java rule LooseCoupling (category bestpractices, former ruleset java-coupling) has been replaced by the typeresolution-based implementation.
  • The Java rule CloneMethodMustImplementCloneable (category errorprone, former ruleset java-clone) has been replaced by the typeresolution-based implementation and is now able to detect cases if a class implements or extends a Cloneable class/interface.
  • The Java rule UnusedImports (category bestpractices, former ruleset java-imports) has been replaced by the typeresolution-based implementation and is now able to detect unused on-demand imports.
  • The Java rule SignatureDeclareThrowsException (category design, former ruleset ‘java-strictexception’) has been replaced by the typeresolution-based implementation. It has a new property IgnoreJUnitCompletely, which allows all methods in a JUnit testcase to throw exceptions.
  • The Java rule NPathComplexity (category design, former ruleset java-codesize) has been revamped to use the new metrics framework. Its report threshold can be configured via the property reportLevel, which replaces the now deprecated property minimum.
  • The Java rule CyclomaticComplexity (category design, former ruleset java-codesize) has been revamped to use the new metrics framework. Its report threshold can be configured via the properties classReportLevel and methodReportLevel separately. The old property reportLevel, which configured the level for both total class and method complexity, is deprecated.
  • The Java rule CommentRequired (category documentation, former ruleset java-comments) has been revamped to include 2 new properties:
  • accessorCommentRequirement to specify documentation requirements for getters and setters (default to ignored)
  • methodWithOverrideCommentRequirement to specify documentation requirements for methods annotated with @Override (default to ignored)
  • The Java rule EmptyCatchBlock (category errorprone, former ruleset java-empty) has been changed to ignore exceptions named ignore or expected by default. You can still override this behaviour by setting the allowExceptionNameRegex property.
  • The Java rule OptimizableToArrayCall (category performance, former ruleset design) has been modified to fit for the current JVM implementations: It basically detects now the opposite and suggests to use Collection.toArray(new E[0]) with a zero-sized array. See Arrays of Wisdom of the Ancients.
  • Deprecated Rules:
  • The Java rules NcssConstructorCount, NcssMethodCount, and NcssTypeCount (ruleset java-codesize) have been deprecated. They will be replaced by the new rule NcssCount in the category design.
  • The Java rule LooseCoupling in ruleset java-typeresolution is deprecated. Use the rule with the same name from category bestpractices instead.
  • The Java rule CloneMethodMustImplementCloneable in ruleset java-typeresolution is deprecated. Use the rule with the same name from category errorprone instead.
  • The Java rule UnusedImports in ruleset java-typeresolution is deprecated. Use the rule with the same name from category bestpractices instead.
  • The Java rule SignatureDeclareThrowsException in ruleset java-typeresolution is deprecated. Use the rule with the same name from category design instead.
  • The Java rule EmptyStaticInitializer in ruleset java-empty is deprecated. Use the rule EmptyInitializer from the category errorprone, which covers both static and non-static empty initializers.`
  • The Java rules GuardDebugLogging (ruleset java-logging-jakarta-commons) and GuardLogStatementJavaUtil (ruleset java-logging-java) have been deprecated. Use the rule GuardLogStatement from the category bestpractices, which covers all cases regardless of the logging framework.
  • Removed Rules:
  • The deprecated Java rule UseSingleton has been removed from the ruleset java-design. The rule has been renamed long time ago to UseUtilityClass (category design).
  • Java Symbol Table:
  • A bug in symbol table prevented the symbol table analysis to properly match primitive arrays types. The issue affected the java-unsedcode/UnusedPrivateMethod rule, but other rules may now produce improved results as consequence of this fix.
  • Apex Parser Update:
  • The Apex parser version was bumped, from 1.0-sfdc-187 to 210-SNAPSHOT. This update let us take full advantage of the latest improvements from Salesforce, but introduces some breaking changes:
  • BlockStatements are now created for all control structures, even if no brace is used. We have therefore added a hasCurlyBrace method to differentiate between both scenarios.
  • New AST node types are available. In particular CastExpression, ConstructorPreamble, IllegalStoreExpression, MethodBlockStatement, Modifier, MultiStatement, NestedExpression, NestedStoreExpression, NewKeyValueObjectExpression and StatementExecuted
  • Some nodes have been removed. Such is the case of TestNode, DottedExpression and NewNameValueObjectExpression (replaced by NewKeyValueObjectExpression)
  • All existing rules have been updated to reflect these changes. If you have custom rules, be sure to update them.
  • For more info about the included Apex parser, see the new pmd module “pmd-apex-jorje”, which packages and provides the parser as a binary.
  • Incremental Analysis:
  • The incremental analysis feature first introduced in PMD 5.6.0 has been enhanced. A few minor issues have been fixed, and several improvements have been performed to make it more accurate.
  • The cache will now detect changes to the JARs referenced in the auxclasspath instead of simply looking at their paths and order. This means that if you are referencing a JAR you are overwriting in some way, the incremental analysis can now detect it and invalidate it’s cache to avoid false reports.
  • Similarly, any changes to the execution classpath of PMD will invalidate the cache. This means that if you have custom rules packaged in a jar, any changes to it will invalidate the cache automatically.
  • We have also improved logging on the analysis code, allowing better insight into how the cache is performing, under debug / verbose builds you can even see individual hits / misses to the cache (and the reason for any miss!)
  • Finally, as this feature keeps maturing, we are gently pushing this forward. If not using incremental analysis, a warning will now be produced suggesting users to adopt it for better performance.
  • Rule and Report Properties:
  • The implementation around the properties support for rule properties and report properties has been revamped to be fully typesafe. Along with that change, the support classes have been moved into an own package net.sourceforge.pmd.properties. While there is no change necessary in the ruleset XML files, when using/setting values for rules, there are adjustments necessary when declaring properties in Java-implemented rules.
  • Rule properties can be declared both for Java based rules and XPath rules. This is now very well documented in Working with properties.
  • With PMD 6.0.0, multivalued properties are now also possible with XPath rules.
  • Fixed Issues:
  • #394: [core] PMD exclude rules are failing with IllegalArgumentException with non-default minimumPriority
  • #532: [core] security concerns on URL-based rulesets
  • #538: [core] Provide an XML Schema for XML reports
  • #600: [core] Nullpointer while creating cache File
  • #604: [core] Incremental analysis should detect changes to jars in classpath
  • #608: [core] Add DEBUG log when applying incremental analysis
  • #618: [core] Incremental Analysis doesn’t close file correctly on Windows upon a cache hit
  • #643: [core] PMD Properties (dev-properties) breaks markup on CodeClimateRenderer
  • #680: [core] Isolate classloaders for runtime and auxclasspath
  • #762: [core] Remove method and file property from available property descriptors for XPath rules
  • #763: [core] Turn property descriptor util into an enum and enrich its interface
  • apex
  • #265: [apex] Make Rule suppression work
  • #488: [apex] Use Apex lexer for CPD
  • #489: [apex] Update Apex compiler
  • #500: [apex] Running through CLI shows jorje optimization messages
  • #605: [apex] java.lang.NoClassDefFoundError in the latest build
  • #637: [apex] Avoid SOSL in loops
  • #760: [apex] EmptyStatementBlock complains about missing rather than empty block
  • #766: [apex] Replace old Jorje parser with new one
  • #768: [apex] java.lang.NullPointerException from PMD
  • cpp
  • #448: [cpp] Write custom CharStream to handle continuation characters
  • java
  • #1454: [java] OptimizableToArrayCall is outdated and invalid in current JVMs
  • #1513: [java] Remove deprecated rule UseSingleton
  • #328: [java] java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/jsp/PageContext
  • #487: [java] Fix typeresolution for anonymous extending object
  • #496: [java] processing error on generics inherited from enclosing class
  • #510: [java] Typeresolution fails on a simple primary when the source is loaded from a class literal
  • #527: [java] Lombok getter annotation on enum is not recognized correctly
  • #534: [java] NPE in MethodTypeResolution for static methods
  • #603: [core] incremental analysis should invalidate upon Java rule plugin changes
  • #650: [java] ProcesingError analyzing code under 5.8.1
  • #732: [java] LinkageError with aux classpath
  • java-basic
  • #565: [java] False negative on DontCallThreadRun when extending Thread
  • java-comments
  • #396: [java] CommentRequired: add properties to ignore @Override method and getters / setters
  • #536: [java] CommentDefaultAccessModifierRule ignores constructors
  • java-controversial
  • #388: [java] controversial.AvoidLiteralsInIfCondition 0.0 false positive
  • #408: [java] DFA not analyzing asserts
  • #537: [java] UnnecessaryParentheses fails to detect obvious scenario
  • java-design
  • #357: [java] UncommentedEmptyConstructor consider annotations on Constructor
  • #438: [java] Relax AbstractClassWithoutAnyMethod when class is annotated by @AutoValue
  • #590: [java] False positive on MissingStaticMethodInNonInstantiatableClass
  • java-logging * #457: [java] Merge all log guarding rules * #721: [java] NPE in PMD 5.8.1 InvalidSlf4jMessageFormat
  • java-sunsecure
  • #468: [java] ArrayIsStoredDirectly false positive
  • java-unusedcode
  • #521: [java] UnusedPrivateMethod returns false positives with primitive data type in map argument
  • java-unnecessarycode
  • #412: [java] java-unnecessarycode/UnnecessaryFinalModifier missing cases
  • #676: [java] java-unnecessarycode/UnnecessaryFinalModifier on try-with-resources
  • API Changes:
  • The class net.sourceforge.pmd.lang.dfa.NodeType has been converted to an enum. All node types are enum members now instead of int constants. The names for node types are retained.
  • The Properties API (rule and report properties) has been revamped to be fully typesafe. This is everything around net.sourceforge.pmd.properties.PropertyDescriptor.
  • Note: All classes related to properties have been moved into the package net.sourceforge.pmd.properties.
  • The rule classes net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestClassShouldHaveAsserts and net.sourceforge.pmd.lang.apex.rule.apexunit.ApexUnitTestShouldNotUseSeeAllDataTrue have been renamed to ApexUnitTestClassShouldHaveAssertsRule and ApexUnitTestShouldNotUseSeeAllDataTrueRule, respectively. This is to comply with the naming convention, that each rule class should be suffixed with “Rule”.
  • This change has no impact on custom rulesets, since the rule names themselves didn’t change.
  • The never implemented method PMD.processFiles(PMDConfiguration, RuleSetFactory, Collection<File>, RuleContext, ProgressMonitor) along with the interface ProgressMonitor has been removed.
  • The method PMD.setupReport(RuleSets, RuleContext, String) is gone. It was used to report dysfunctional rules. But PMD does this now automatically before processing the files, so there is no need for this method anymore.
  • All APIs deprecated in older versions are now removed. This includes:
  • Renderer.getPropertyDefinitions
  • AbstractRenderer.defineProperty(String, String)
  • AbstractRenderer.propertyDefinitions
  • ReportListener
  • Report.addListener(ReportListener)
  • SynchronizedReportListener
  • CPDConfiguration.CPDConfiguration(int, Language, String)
  • CPDConfiguration.getRendererFromString(String)
  • StreamUtil
  • StringUtil.appendXmlEscaped(StringBuilder, String)
  • StringUtil.htmlEncode(String)
  • Several methods in net.sourceforge.pmd.util.CollectionUtil have been deprecated and will be removed in PMD 7.0.0. In particular:
  • CollectionUtil.addWithoutDuplicates(T[], T)
  • CollectionUtil.addWithoutDuplicates(T[], T[])
  • CollectionUtil.areSemanticEquals(T[], T[])
  • CollectionUtil.areEqual(Object, Object)
  • CollectionUtil.arraysAreEqual(Object, Object)
  • CollectionUtil.valuesAreTransitivelyEqual(Object[], Object[])
  • Several methods in net.sourceforge.pmd.util.StringUtil have been deprecated and will be removed in PMD 7.0.0. In particular:
  • StringUtil.startsWithAny(String, String[])
  • StringUtil.isNotEmpty(String)
  • StringUtil.isEmpty(String)
  • StringUtil.isMissing(String)
  • StringUtil.areSemanticEquals(String, String)
  • StringUtil.replaceString(String, String, String)
  • StringUtil.replaceString(String, char, String)
  • StringUtil.substringsOf(String, char)
  • StringUtil.substringsOf(String, String)
  • StringUtil.asStringOn(StringBuffer, Iterator, String)
  • StringUtil.asStringOn(StringBuilder, Object[], String)
  • StringUtil.lpad(String, int)
  • The class net.sourceforge.pmd.lang.java.typeresolution.typedefinition.JavaTypeDefinition is now abstract, and has been enhanced to provide several new methods.
  • The constructor of net.sourceforge.pmd.RuleSetFactory, which took a ClassLoader is deprecated. Please use the alternative constructor with the net.sourceforge.pmd.util.ResourceLoader instead.
  • The following GUI related classes have been deprecated and will be removed in PMD 7.0.0. The tool “bgastviewer”, that could be started via the script bgastviewer.bat or run.sh bgastviewer is deprecated, too, and will be removed in PMD 7.0.0. Both the “old designer” and “bgastviewer” are replaced by the New Rule Designer.
  • net.sourceforge.pmd.util.designer.CodeEditorTextPane
  • net.sourceforge.pmd.util.designer.CreateXMLRulePanel
  • net.sourceforge.pmd.util.designer.Designer
  • net.sourceforge.pmd.util.designer.DFAPanel
  • net.sourceforge.pmd.util.designer.LineGetter
  • net.sourceforge.pmd.util.viewer.Viewer
  • net.sourceforge.pmd.util.viewer.gui.ActionCommands
  • net.sourceforge.pmd.util.viewer.gui.ASTPanel
  • net.sourceforge.pmd.util.viewer.gui.EvaluationResultsPanel
  • net.sourceforge.pmd.util.viewer.gui.MainFrame
  • net.sourceforge.pmd.util.viewer.gui.ParseExceptionHandler
  • net.sourceforge.pmd.util.viewer.gui.SourceCodePanel
  • net.sourceforge.pmd.util.viewer.gui.XPathPanel
  • net.sourceforge.pmd.util.viewer.gui.menu.ASTNodePopupMenu
  • net.sourceforge.pmd.util.viewer.gui.menu.AttributesSubMenu
  • net.sourceforge.pmd.util.viewer.gui.menu.SimpleNodeSubMenu
  • net.sourceforge.pmd.util.viewer.gui.menu.XPathFragmentAddingItem
  • net.sourceforge.pmd.util.viewer.model.ASTModel
  • net.sourceforge.pmd.util.viewer.model.AttributeToolkit
  • net.sourceforge.pmd.util.viewer.model.SimpleNodeTreeNodeAdapter
  • net.sourceforge.pmd.util.viewer.model.ViewerModel
  • net.sourceforge.pmd.util.viewer.model.ViewerModelEvent
  • net.sourceforge.pmd.util.viewer.model.ViewerModelListener
  • net.sourceforge.pmd.util.viewer.util.NLS
  • The following methods in net.sourceforge.pmd.Rule have been deprecated and will be removed in PMD 7.0.0. All methods are replaced by their bean-like counterparts
  • void setUsesDFA(). Use void setDfa(boolean) instead.
  • boolean usesDFA(). Use boolean isDfa() instead.
  • void setUsesTypeResolution(). Use void setTypeResolution(boolean) instead.
  • boolean usesTypeResolution(). Use boolean isTypeResolution() instead.
  • void setUsesMultifile(). Use void setMultifile(boolean) instead.
  • boolean usesMultifile(). Use boolean isMultifile() instead.
  • boolean usesRuleChain(). Use boolean isRuleChain() instead.
  • External Contributions:
  • #287: [apex] Make Rule suppression work - Robert Sösemann
  • #420: [java] Fix UR anomaly in assert statements - Clément Fournier
  • #482: [java] Metrics testing framework + improved capabilities for metrics - Clément Fournier
  • #484: [core] Changed linux usage to a more unix like path - patriksevallius
  • #486: [java] Add basic method typeresolution - Bendegúz Nagy
  • #492: [java] Typeresolution for overloaded methods - Bendegúz Nagy
  • #495: [core] Custom rule reinitialization code - Clément Fournier
  • #479: [core] Typesafe and immutable properties - Clément Fournier
  • #499: [java] Metrics memoization tests - Clément Fournier
  • #501: [java] Add support for most specific vararg method type resolution - Bendegúz Nagy
  • #502: [java] Add support for static field type resolution - Bendegúz Nagy
  • #505: [java] Followup on metrics - Clément Fournier
  • #506: [java] Add reduction rules to type inference - Bendegúz Nagy
  • #511: [core] Prepare abstraction of the metrics framework - Clément Fournier
  • #512: [java] Add incorporation to type inference - Bendegúz Nagy
  • #513: [java] Fix for maximally specific method selection - Bendegúz Nagy
  • #514: [java] Add static method type resolution - Bendegúz Nagy
  • #517: [doc] Metrics documentation - Clément Fournier
  • #518: [core] Properties refactoring: factorized enumerated property - Clément Fournier
  • #523: [java] Npath complexity metric and rule - Clément Fournier
  • #524: [java] Add support for explicit type arguments with method invocation - Bendegúz Nagy
  • #525: [core] Fix line ending and not ignored files issues - Matias Comercio
  • #528: [core] Fix typo - Ayoub Kaanich
  • #529: [java] Abstracted the Java metrics framework - Clément Fournier
  • #530: [java] Fix issue #527: Lombok getter annotation on enum is not recognized correctly - Clément Fournier
  • #533: [core] improve error message - Dennis Kieselhorst
  • #535: [apex] Fix broken Apex visitor adapter - Clément Fournier
  • #542: [java] Metrics abstraction - Clément Fournier
  • #545: [apex] Apex metrics framework - Clément Fournier
  • #548: [java] Metrics documentation - Clément Fournier
  • #550: [java] Add basic resolution to type inference - Bendegúz Nagy
  • #553: [java] Refactored ParserTst into a static utility class + add getSourceFromClass - Clément Fournier
  • #554: [java] Fix #537: UnnecessaryParentheses fails to detect obvious scenario - Clément Fournier
  • #555: [java] Changed metrics/CyclomaticComplexityRule to use WMC when reporting classes - Clément Fournier
  • #556: [java] Fix #357: UncommentedEmptyConstructor consider annotations on Constructor - Clément Fournier
  • #557: [java] Fix NPath metric not counting ternaries correctly - Clément Fournier
  • #563: [java] Add support for basic method type inference for strict invocation - Bendegúz Nagy
  • #566: [java] New rule in migrating ruleset: ForLoopCanBeForeach - Clément Fournier
  • #567: [java] Last API change for metrics (metric options) - Clément Fournier
  • #570: [java] Model lower, upper and intersection types - Bendegúz Nagy
  • #573: [java] Data class rule - Clément Fournier
  • #576: [doc][java] Add hint for Guava users in InefficientEmptyStringCheck - mmoehring
  • #578: [java] Refactored god class rule - Clément Fournier
  • #579: [java] Update parsing to produce upper and lower bounds - Bendegúz Nagy
  • #580: [core] Add AbstractMetric to topple the class hierarchy of metrics - Clément Fournier
  • #581: [java] Relax AbstractClassWithoutAnyMethod when class is annotated by @AutoValue - Niklas Baudy
  • #583: [java] Documentation about writing metrics - Clément Fournier
  • #585: [java] Moved NcssCountRule to codesize.xml - Clément Fournier
  • #587: [core] Properties refactoring: Move static constants of ValueParser to class ValueParserConstants - Clément Fournier
  • #588: [java] XPath function to compute metrics - Clément Fournier
  • #598: [java] Fix #388: controversial.AvoidLiteralsInIfCondition 0.0 false positive - Clément Fournier
  • #602: [java] [apex] Separate multifile analysis from metrics - Clément Fournier
  • #620: [core] Moved properties to n.s.pmd.properties - Clément Fournier
  • #625: [apex] empty code ruleset for apex - Jan Aertgeerts
  • #632: [apex] Add AvoidDirectAccessTriggerMap rule to the style set - Jan Aertgeerts
  • #644: [core] Prevent internal dev-properties from being displayed on CodeClimate renderer - Filipe Esperandio
  • #660: [apex] avoid sosl in loops - Jan Aertgeerts
  • #661: [apex] avoid hardcoding id’s - Jan Aertgeerts
  • #666: [java] Add DoNotExtendJavaLangThrowable rule - Robert Painsi
  • #668: [core] Fix javadoc warnings on pmd-core - Clément Fournier
  • #669: [core] Builder pattern for properties - Clément Fournier
  • #675: [java] Fix in Java grammar: Try with final resource node error - Gonzalo Ibars Ingman
  • #679: [core] Token scheme generalization - Gonzalo Ibars Ingman
  • #694: [core] Add minor fixes to root pom - Matias Comercio
  • #696: [core] Add remove operation over nodes - Matias Comercio
  • #711: [ui] New rule designer - Clément Fournier
  • #722: [java] Move NPathComplexity from metrics to design - Clément Fournier
  • #723: [core] Rule factory refactoring - Clément Fournier
  • #726: [java] Fix issue #721 (NPE in InvalidSlf4jMessageFormat) - Clément Fournier
  • #727: [core] Fix #725: numeric property descriptors now check their default value - Clément Fournier
  • #733: [java] Some improvements to CommentRequired - Clément Fournier
  • #734: [java] Move CyclomaticComplexity from metrics to design - Clément Fournier
  • #736: [core] Make Saxon support multi valued XPath properties - Clément Fournier
  • #737: [doc] Fix NPathComplexity documentation bad rendering - Clément Fournier
  • #744: [doc] Added Apex to supported languages - Michał Kuliński
  • #746: [doc] Fix typo in incremental analysis log message - Clément Fournier
  • #749: [doc] Update the documentation for properties - Clément Fournier
  • #758: [core] Expose the full mapping from property type id to property extractor - Clément Fournier
  • #764: [core] Prevent method and file property use in XPath rules - Clément Fournier
  • #771: [apex] Fix Apex metrics framework failing on triggers, refs #768 - Clément Fournier
  • #774: [java] Avoid using FileInput/Output - see JDK-8080225 - Chas Honton

New in PMD 5.8.1 (Jul 3, 2017)

  • This is a bug fixing release.
  • Table Of Contents:
  • Fixed Issues
  • API Changes
  • External Contributions
  • Fixed Issues:
  • [java] Error while processing class when EnumMap is used in PMD 5.8.0
  • [core] NoClassDefFoundError under 5.8
  • [core] Processing issues dealing with anonymous classes
  • API Changes:
  • The getGenericArgs() method introduced to TypeNode in 5.8.0 was removed. You can access to generics’ info through the JavaTypeDefinition object.
  • The JavaTypeDefinitionBuilder class introduced in 5.8.0 is not more. You can use factory methods available on JavaTypeDefinition
  • External Contributions:
  • [java] fix error with raw types, bug #471

New in PMD 5.8.0 (Jun 26, 2017)

  • New and noteworthy:
  • Java Type Resolution:
  • As part of Google Summer of Code 2017, Bendegúz Nagy has been working on completing type resolution for Java. His progress so far has allowed to properly resolve, in addition to previously supported statements:
  • References to this and super, even when qualified
  • References to fields, even when chained (ie: this.myObject.aField), and properly handling inheritance / shadowing
  • Lambda parameter types where these are infered rather than explicit are still not supported. Expect future releases to do so.
  • Metrics Framework:
  • As part of Google Summer of Code 2017, Clément Fournier has been working on a new metrics framework for object-oriented metrics.
  • The basic groundwork has been done already and with this release, including a first rule based on the metrics framework as a proof-of-concept: The rule CyclomaticComplexity, currently in the temporary ruleset java-metrics, uses the Cyclomatic Complexity metric to find overly complex code. This rule will eventually replace the existing three CyclomaticComplexity rules that are currently defined in the java-codesize ruleset (see also issue #445).
  • Since this work is still in progress, the metrics API (package net.sourceforge.pmd.lang.java.oom) is not finalized yet and is expected to change.
  • Modified Rules:
  • The Java rule UnnecessaryFinalModifier (ruleset java-unnecessary) now also reports on private methods marked as final. Being private, such methods can’t be overriden, and therefore, the final keyword is redundant.
  • The Java rule PreserveStackTrace (ruleset java-design) has been relaxed to support the builder pattern on thrown exception. This change may introduce some false positives if using the exception in non-orthodox ways for things other than setting the root cause of the exception. Contact us if you find any such scenarios.
  • The ruleset java-junit now properly detects JUnit5, and rules are being adapted to the changes on it’s API. This support is, however, still incomplete. Let us know of any uses we are still missing on the issue tracker
  • The Java rule EmptyTryBlock (ruleset java-empty) now allows empty blocks when using try-with-resources.
  • The Java rule EmptyCatchBlock (ruleset java-empty) now exposes a new property called allowExceptionNameRegex. This allow to setup a regular expression for names of exceptions you wish to ignore for this rule. For instance, setting it to ^(ignored|expected)$ would ignore all empty catch blocks where the catched exception is named either ignored or expected. The default ignores no exceptions, being backwards compatible.
  • Deprecated Rules:
  • The three complexity rules CyclomaticComplexity, StdCyclomaticComplexity, ModifiedCyclomaticComplexity (ruleset java-codesize) have been deprecated. They will be eventually replaced by a new CyclomaticComplexity rule based on the metrics framework. See also issue #445.
  • Fixed Issues:
  • General:
  • [core] NPE in RuleSet.hashCode
  • [web] Release date is not properly formatted
  • [core] Error when running PMD from folder with space
  • apex
  • [apex] CPD error when parsing apex code from release 5.5.3
  • cpp
  • [cpp] CPD gives wrong duplication blocks for CPP code
  • java
  • [java] Java 8 parsing problem with annotations for wildcards
  • [java] Parsing Error when having an Annotated Inner class
  • [java] Parsing Problem with Annotation for Array Member Types
  • java-design
  • [java] ConstructorCallsOverridableMethodRule: false positive for method called from lambda expression
  • [java] ImmutableField: False positive with lombok
  • [java] PreserveStackTraceRule: false positive when using builder pattern
  • java-empty
  • [java] EmptyCatchBlock don’t fail when exception is named ignore / expected
  • [java] EmptyTryBlock: false positive for empty try-with-resource
  • java-imports:
  • [java] imports/UnusedImport rule not considering static inner classes of imports
  • java-junit
  • [java] PMD requires public modifier on JUnit 5 test
  • [java] NullPointerException in JUnitTestsShouldIncludeAssertRule
  • java-logging:
  • [java] InvalidSlf4jMessageFormat does not handle inline incrementation of arguments
  • java-strictexceptions
  • [java] Throwing Exception in method signature is fine if the method is overriding or implementing something
  • java-typeresolution
  • [java] Throwing Exception in method signature is fine if the method is overriding or implementing something
  • java-unnecessary
  • [java] UnnecessaryFinalModifier final in private method
  • jsp
  • [jsp] Parse error on HTML boolean attribute
  • External Contributions:
  • [java] False positive with lambda in java-design/ConstructorCallsOverridableMethod
  • [java] Groundwork for the upcoming metrics framework
  • [java] FIXED: Java 8 parsing problem with annotations for wildcards
  • [java] Type resolution: super and this keywords
  • [java] Add field access type resolution in non-generic cases
  • [java] False positive with builder pattern in java-design/PreserveStackTrace
  • [java] UnnecessaryFinalModifier final in private method
  • [java] Metrics framework tests and various improvements
  • [core] Created ruleset schema 3.0.0 (to use metrics)
  • [java] Optimize typeresolution, by skipping package and import declarations in visit(ASTName)
  • [java] [typeresolution]: add support for generic fields
  • [java] Metrics framework: first metrics + first rule

New in PMD 5.7.0 (May 22, 2017)

  • NEW AND NOTEWORTHY:
  • Modified Rules:
  • The rule “FieldDeclarationsShouldBeAtStartOfClass” of the java-design ruleset has a new property ignoreInterfaceDeclarations. Setting this property to true ignores interface declarations, that precede fields. Example usage:
  • <rule ref="rulesets/java/design.xml/FieldDeclarationsShouldBeAtStartOfClass">
  • <properties>
  • <property name="ignoreInterfaceDeclarations" value="true"/>
  • </properties>
  • </rule>
  • Renderers:
  • Added the ‘empty’ renderer which will write nothing. Does not affect other behaviors, for example the command line PMD exit status will still indicate whether violations were found.
  • FIXED ISSUES:
  • General:
  • #377: [core] Use maven wrapper and upgrade to maven 3.5.0
  • #376: [core] Improve build time on travis
  • java
  • #378: [java] Parser Error for empty statements
  • java-coupling
  • #1427: [java] Law of Demeter violations for the Builder pattern
  • java-design
  • #345: [java] FieldDeclarationsShouldBeAtStartOfClass: Add ability to ignore interfaces
  • #389: [java] RuleSetCompatibility - not taking rename of UnusedModifier into account
  • java-junit
  • #358: [java] Mockito verify method is not taken into account in JUnitTestsShouldIncludeAssert rule
  • java-strings
  • #334: [java] [doc] Add suggestion to use StringUtils#isBlank for InefficientEmptyStringCheck
  • jsp-basic
  • #369: [jsp] Wrong issue “JSP file should use UTF-8 encoding”
  • API Changes:
  • The method net.sourceforge.pmd.util.StringUtil#htmlEncode(String) is deprecated. org.apache.commons.lang3.StringEscapeUtils#escapeHtml4(String) should be used instead.
  • External Contributions:
  • #368: [vf] Adding proper AST support for negation expressions
  • #372: [core] Fix XSS in HTML renderer
  • #374: [java] Add property to ignore interfaces in FieldDeclarationsShouldBeAtStartOfClassRule
  • #381: [core] Fix broken link in the site’s doc
  • #382: [java] Added documentation details on InefficientEmptyStringCheck
  • #383: [jsp] Fixed JspEncoding false positive
  • #390: [java] Remove trailing whitespaces in design.xml
  • #391: [apex] Fix documentation typo
  • #392: [java] False positive for Law Of Demeter (Builder pattern)
  • #395: [java] Mockito verify method is not taken into account in JUnitTestsShouldIncludeAssert rule

New in PMD 5.4.6 (Apr 20, 2017)

  • FIXED ISSUES:
  • general:
  • #305: [core] PMD not executing under git bash
  • java:
  • #309: [java] Parse error on method reference
  • java-design:
  • #275: [java] FinalFieldCouldBeStatic: Constant in @interface incorrectly reported as “could be made static”
  • java-junit:
  • #285: [java] JUnitTestsShouldIncludeAssertRule should support @Rule as well as @Test(expected = …)
  • java-optimizations:
  • #222: [java] UseStringBufferForStringAppends: False Positive with ternary operator
  • java-strings:
  • #290: [java] InefficientEmptyStringCheck misses String.trim().isEmpty()
  • EXTERNAL CONTRIBUTIONS:
  • #303: [java] InefficientEmptyStringCheckRule now reports String.trim().isEmpty()
  • #307: [java] Fix false positive with UseStringBufferForStringAppendsRule
  • #308: [java] JUnitTestsShouldIncludeAssertRule supports @Rule annotated ExpectedExceptions

New in PMD 5.5.2 (Nov 5, 2016)

  • NEW SUPPORTED LANGUAGES:
  • CPD now supports Groovy.
  • FEATURE REQUESTS AND IMPROVEMENTS:
  • plsql:
  • [plsql] Create new rule for strict syntax checking: MisplacedPragma
  • NEW RULES:
  • New Rules for plsql:
  • plsql-strictsyntax: MisplacedPragma
  • PULL REQUESTS:
  • [java] CPD: Keep constructor names under ignoreIdentifiers
  • [groovy] Initial support for CPD Groovy
  • [java] Fix parser error (issue 1530)
  • [java] Fix BooleanInstantiationRule for Java 8
  • [java] Fix ClassCastException on CloneMethodMustImplementCloneable
  • [java] Fix ClassCastException on SignatureDeclareThrowsException
  • [core] Remove multihreading workaround for JRE5, as no PMD version supports running on JRE5 anymore
  • [java] Simplify lambda parsing
  • [core] [java] Improve collection usage
  • [java] Improve symboltable performance
  • [java] Simplify VariableDeclaratorId parsing
  • [plsql] Fix PMD issue 1531- endless loop followed by OOM while parsing (PL)SQL
  • BUG FIXES:
  • apex-apexunit
  • [apex] ApexUnitTestClassShouldHaveAsserts: Parsing error on APEX class: expected one element but was:
  • Java
  • [java] Parser exception on Java code
  • [java] PMD Error while processing - NullPointerException
  • java-basic/BooleanInstantiation
  • [java] BooleanInstantiation: ClassCastException with Annotation
  • java-comments
  • [java] CommentRequired: false positive
  • java-design/SingularField
  • [java] SingularField: lombok.Data false positive
  • java-imports/UnusedImports
  • [java] UnusedImports: The created rule violation has no class name
  • java-logging-java
  • [java] InvalidSlf4jMessageFormat: doesn't ignore exception param
  • [java] InvalidSlf4jMessageFormat: NPE
  • java-typeresolution/CloneMethodMustImplementCloneable
  • [java] CloneMethodMustImplementCloneable: Implemented Interface extends Cloneable
  • [java] CloneMethodMustImplementCloneable: ClassCastException with Annotation (java8)
  • java-typeresolution/SignatureDeclareThrowsException
  • [java] SignatureDeclareThrowsException: ClassCastException with Annotation
  • PLSQL
  • [plsql] Missing PL/SQL language constructs in parser: Is Of Type, Using
  • [plsql] PRAGMA AUTONOMOUS_TRANSACTION gives processing errors
  • [plsql] OOM/Endless loop while parsing (PL)SQL
  • General
  • [core] When runing any RuleTst, start/end methods not called
  • [java] CPD reports on Java constructors when using ignoreIdentifiers

New in PMD 5.5.1 (Jul 28, 2016)

  • Pull Requests:
  • [java] Improve multithreading performance: do not lock on classloader
  • [apex] Restrict AvoidLogicInTrigger rule to max. 1 violation per file
  • [java] [apex] Fix for 1501: CyclomaticComplexity rule causes OOM when class reporting is disabled
  • [core] [java] Close opened file handles
  • apex #43: [apex] Basic apex unit test rules
  • BUG FIXES:
  • Apex:
  • [java] [apex] CyclomaticComplexity rule causes OOM when class reporting is disabled
  • Java:
  • [java] [apex] CyclomaticComplexity rule causes OOM when class reporting is disabled
  • General:
  • [core] CPD test break PMD 5.5.1 build on Windows
  • [core] [java] PMD is leaking file handles

New in PMD 5.4.2 (May 30, 2016)

  • New Supported Languages:
  • CPD supports now Swift
  • Feature Request and Improvements:
  • A JSON-renderer for PMD which is compatible with CodeClimate. See PR#83.
  • Provide backwards compatibility for PMD configuration file
  • Modified Rules:
  • java-design/UseVargs: public static void main method is ignored now and so are methods, that are annotated with Override. See PR#79.
  • Pull Requests:
  • Added support for Raw String Literals (C++11).
  • Added support for files with UTF-8 BOM to JSP tokenizer.
  • Removed file filter for files that are explicitly specified on the CPD command line using the '--files' command line option.
  • Added file encoding detection to CPD.
  • Extended Objective-C grammar to accept UTF-8 escapes (uXXXX) in string literals.
  • Added support for Swift to CPD.
  • do not flag public static void main(String[]) as UseVarargs; ignore @Override for UseVarargs
  • Update mvn-plugin.md
  • Adds new Code Climate-compliant JSON renderer
  • UseStringBufferForStringAppends False Positive with Ternary Operator
  • Bugfixes:
  • java-basic/DoubleCheckedLocking:
  • False positives for DoubleCheckedLocking
  • java-basic/SimplifiedTernary:
  • False positive with ternary operator
  • java-codesize/TooManyMethods:
  • TooManyMethods counts inner class methods
  • java-controversial/AvoidUsingShortType:
  • false positive when casting a variable to short
  • java-design/AccessorClassGeneration:
  • ArrayIndexOutOfBoundsException with Annotations for AccessorClassGenerationRule
  • java-design/CloseResource
  • CloseResource false positive on Statement
  • java-design/UseUtilityClass:
  • UseUtilityClass can't correctly check functions with multiple annotations
  • java-imports/UnusedImports:
  • False Positve UnusedImports with javadoc @link
  • java-junit/TestClassWithoutTestCases:
  • Test Class Without Test Cases gives false positive
  • java-optimizations/UseStringBufferForStringAppends:
  • UseStringBufferForStringAppends False Positive with ternary operator
  • java-sunsecure/ArrayIsStoredDirectly:
  • False positive of MethodReturnsInternalArray
  • False positive of ArrayIsStoredDirectly
  • java-unnecessary/UnnecessaryFinalModifier:
  • UnnecessaryFinalModifier false positive on a @SafeVarargs method
  • java-unusedcode/UnusedFormalParameter:
  • UnusedFormalParameter should ignore overriding methods
  • java-unusedcode/UnusedLocalVariable
  • UnusedLocalVariable - false positive - parenthesis
  • java-unusedcode/UnusedModifier
  • false positive on public modifier used with inner interface in enum
  • General
  • PMD doesn't handle Java 8 explicit receiver parameters
  • Performance degradation scanning large XML files with XPath custom rules
  • Possible threading issue due to PR#75
  • Error with type-bound lambda
  • no problems found results in blank file instead of empty xml
  • CLI Changes:
  • CPD: If a complete filename is specified, the language dependent filename filter is not applied. This allows to scan files, that are not using the standard file extension. If a directory is specified, the filename filter is still applied and only those files with the correct file extension of the language are scanned.
  • CPD: If no problems found, an empty report will be output instead of nothing. See also #1481
  • New command line parameter for PMD: -norulesetcompatibility - this disables the ruleset factory compatibility filter and fails, if e.g. an old rule name is used in the ruleset. See also #1360. This option is also available for the ant task: true.

New in PMD 5.4.1 (Dec 4, 2015)

  • Feature Request and Improvements:
  • CPD: New command line parameter --ignore-usings: Ignore using directives in C# when comparing text.
  • Modified Rules:
  • java-comments/CommentRequired: New property serialVersionUIDCommentRequired which controls the comment requirements for serialVersionUID fields. By default, no comment is required for this field.
  • Pull Requests:
  • #25: Added option to exclude C# using directives from CPD analysis
  • #72: Added capability in Java and JSP parser for tracking tokens.
  • #74: Fix rendering CommentDefaultAccessModifier description as code
  • #75: RuleSetFactory Performance Enhancement
  • Bugfixes:
  • java-comments/CommentDefaultAccessModifier
  • #1430: CommentDefaultAccessModifier triggers on field annotated with @VisibleForTesting
  • java-comments/CommentRequired
  • #1434: CommentRequired raises violation on serialVersionUID field
  • java-design/UseNotifyAllInsteadOfNotify
  • #1438: UseNotifyAllInsteadOfNotify gives false positive
  • java-finalizers/AvoidCallingFinalize
  • #1440: NPE in AvoidCallingFinalize
  • java-imports/UnnecessaryFullyQualifiedName
  • #1436: UnnecessaryFullyQualifiedName false positive on clashing static imports with enums
  • java-junit/JUnitAssertionsShouldIncludeMessage
  • #1373: JUnitAssertionsShouldIncludeMessage is no longer compatible with TestNG
  • java-migrating/JUnit4TestShouldUseBeforeAnnotation
  • #1446: False positive with JUnit4TestShouldUseBeforeAnnotation when TestNG is used
  • java-naming/SuspiciousEqualsMethodName
  • #1431: SuspiciousEqualsMethodName false positive
  • java-optimizations/RedundantFieldInitializer
  • #1443: RedundantFieldInitializer: False positive for small floats
  • java-unnecessary/UselessQualifiedThis
  • #1422: UselessQualifiedThis: False positive with Java 8 Function
  • java-unusedcode/UnusedPrivateField
  • #1428: False positive in UnusedPrivateField when local variable hides member variable
  • General:
  • #1425: Invalid XML Characters in Output
  • #1429: Java - Parse Error: Cast in return expression
  • #1441: PMD: Update documentation how to compile after modularization

New in PMD 5.4.0 (Dec 4, 2015)

  • 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
  • NEW RULES:
  • Java:
  • Basic: SimplifiedTernary (rulesets/java/basic.xml/SimplifiedTernary) Ternary operator with a boolean literal can be simplified with a boolean expression.
  • Clone: CloneMethodMustBePublic (rulesets/java/clone.xml/CloneMethodMustBePublic) The java manual says "By convention, classes that implement the Cloneable interface should override Object.clone (which is protected) with a public method."
  • Clone: CloneMethodReturnTypeMustMatchClassName (rulesets/java/clone.xml/CloneMethodReturnTypeMustMatchClassName) If a class implements Cloneable the return type of the method clone() must be the class name.
  • Comments: CommentDefaultAccessModifier (rulesets/java/comments.xml/CommentDefaultAccessModifier) In order to avoid mistakes with forgotten access modifiers for methods, this rule ensures, that you explicitly mark the usage of the default access modifier by placing a comment.
  • Design: SingletonClassReturningNewInstance (rulesets/java/design.xml/SingletonClassReturningNewInstance) Verifies that the method called getInstance returns a cached instance and not always a fresh, new instance.
  • Design: SingleMethodRule (rulesets/java/design.xml/SingleMethodSingletonRule) Verifies that there is only one method called getInstance. If there are more methods that return the singleton, then it can easily happen, that these are not the same instances - and thus no singleton.
  • Unnecessary: UselessQualifiedThis (rulesets/java/unnecessary.xml/UselessQualifiedThis) Flags unnecessary qualified usages of this, when this alone would be unique. E.g. use just this instead of Foo.this.
  • Maven POM:
  • Basic: ProjectVersionAsDependencyVersion (rulesets/pom/basic.xml/ProjectVersionAsDependencyVersion) Checks the usage of ${project.version} in Maven POM files.
  • Basic: InvalidDependencyTypes (rulesets/pom/basic.xml/InvalidDependencyTypes) Verifies that only the default types (jar, war, ...) for dependencies are used.
  • MODIFIED RULES:
  • Java:
  • 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.
  • RENAMED RULES:
  • Java:
  • Design: UseSingleton - UseUtilityClass (rulesets/java/design.xml/UseUtilityClass) The rule "UseSingleton" has been renamed to "UseUtilityClass". See also bugs #1059 and #1339.
  • REMOVED RULES:
  • 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.
  • Java:
  • 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.
  • Pull Requests:
  • #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
  • Bugfixes:
  • java-unusedcode/UnusedPrivateMethod:
  • #1412: UnusedPrivateMethod false positive: Issue #1403 not completely solved
  • API Changes:
  • pmd requires now JDK 1.7 or above.
  • pmd-core: net.sourceforge.pmd.lang.symboltable.Scope:
  • 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.
  • pmd-core: net.sourceforge.pmd.lang.symboltable.AbstractScope:
  • 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.

New in PMD 5.3.4 (Sep 19, 2015)

  • Bug fixes:
  • #1370: ConsecutiveAppendsShouldReuse not detected properly on StringBuffer
  • #1371: InsufficientStringBufferDeclaration not detected properly on StringBuffer
  • #1380: InsufficientStringBufferDeclaration false positive when literal string passed to a lookup service
  • #1384: NullPointerException in ConsecutiveLiteralAppendsRule
  • #1388: ConstructorCallsOverridableMethodRule doesn't work with params?
  • #1392: SimplifyStartsWith false-negative
  • #1393: PMD hanging during DataflowAnomalyAnalysis
  • #1394: dogfood.xml - Unable to exclude rules [UncommentedEmptyMethod]
  • #1395: UnusedPrivateMethod false positive for array element method call
  • #1396: PrematureDeclaration lambda false positive
  • #1397: StringToString should ignore method references
  • #1398: False positive for GuardLogStatementJavaUtil with Log4j
  • #1399: False positive for VariableNamingConventions with annotation @interface
  • #1400: False positive with JUnit4TestShouldUseBeforeAnnotation
  • #1401: False positive for StringBuilder.append called with constructor
  • #1402: Windows-Only: File exclusions are not case insensitive
  • #1403: False positive UnusedPrivateMethod with JAVA8
  • #1404: Java8 'Unnecessary use of fully qualified name' in Streams Collector
  • #1405: UnusedPrivateMethod false positive?

New in PMD 5.3.3 (Aug 3, 2015)

  • Pull Requests:
  • #55: Fix run.sh for paths with spaces
  • Bugfixes:
  • #1364: FieldDeclarationsShouldBeAtStartOfClass false positive using multiple annotations
  • #1365: Aggregated javadoc report is missing
  • #1366: UselessParentheses false positive on multiple equality operators
  • #1369: ConsecutiveLiteralAppends not detected properly on StringBuffer
  • #1372: False Negative for CloseResource rule.
  • #1375: CloseResource not detected properly
  • #1376: CompareObjectsWithEquals fails for type annotated method parameter
  • #1379: PMD CLI: Cannot specify multiple properties
  • #1381: CPD Cannot use CSV/VS Renderers because they don't support encoding property

New in PMD 5.3.2 (May 23, 2015)

  • Bugfixes:
  • AvoidReassigningParameters does not work with varargs
  • GuardLogStatementJavaUtil should not apply to SLF4J Logger
  • UseConcurrentHashMap false positive (with documentation example)
  • MethodNamingConventions for overrided methods
  • UseCollectionIsEmpty throws NullPointerException
  • False positive “Only One Return” with lambda
  • Complex FieldDeclarationsShouldBeAtStartOfClass false positive with Spring annotations
  • NullPointerException in a java file having a single comment line

New in PMD 5.3.1 (Apr 21, 2015)

  • New/Modified/Deprecated Rules:
  • Language Java, ruleset design.xml: The rule “UseSingleton” has been renamed to “UseUtilityClass”.
  • Pull Requests:
  • Fix some NullPointerExceptions
  • Bugfixes:
  • False Positive: UnusedPrivateMethod
  • Error while processing Java file with Lambda expressions
  • False positive “Avoid throwing raw exception types” when exception is not thrown
  • The pmd-java8 POM bears the wrong parent module version

New in PMD 5.3.0 (Apr 2, 2015)

  • Feature Requests and Improvements:
  • XML: Line numbers for XML documents are more accurate. This is a further improvement of #1054.
  • CPD: New output format ‘csv_with_linecount_per_file’
  • 1320: Enhance SimplifyBooleanReturns checks
  • PMD exits with status 4 if any violations have been found. This behavior has been introduced to ease PMD integration into scripts or hooks, such as SVN hooks.
  • New/Modified/Deprecated Rules:
  • The following rules have been enhanced :
  • Language Java, ruleset design.xml: The rule “SimplifyBooleanReturns” now also marks methods where the else case is omitted and just a return. See also feature #1320.
  • The following rules are marked as deprecated and will be removed with the next release of PMD:
  • Language Java, ruleset basic.xml: The following rules have been moved into the empty.xml ruleset. You’ll need to enable the “empty” ruleset explicitly from now on, if you want to have these rules executed:
  • EmptyCatchBlock, EmptyIfStatement, EmptyWhileStmt, EmptyTryBlock, EmptyFinallyBlock, EmptySwitchStatements, EmptySynchronizedBlock, EmptyStatementNotInLoop, EmptyInitializer, EmptyStatementBlock, EmptyStaticInitializer.
  • Language Java, ruleset basic.xml: The following rules have been moved into the unnecessary.xml ruleset. You’ll need to enable the “unnecessary” ruleset explicitly from now on, if you want to have these rules executed:
  • UnnecessaryConversionTemporary, UnnecessaryReturn, UnnecessaryFinalModifier, UselessOverridingMethod, UselessOperationOnImmutable, UnusedNullCheckInEquals, UselessParentheses.
  • Language Java, ruleset design.xml: The rule “UncommentedEmptyMethod” has been renamed to “UncommentedEmptyMethodBody”. See also bug #1283.
  • Language Java, ruleset controversial.xml: The rule “BooleanInversion” is deprecated and will be removed with the next release. See #1277 for more details.
  • Pull Requests:
  • 11: Added support for Python to CPD.
  • 12: Added support for Matlab to CPD.
  • 13: Added support for Objective-C to CPD.
  • 14: Added support for Scala to CPD.
  • 15: (pmd-cs) Fixed incorrect line numbers after mutiline comments and verbatim strings.
  • 16: Fixed several C++ lexical / tokenize errors.
  • 17: Fixed ‘–files’ command line option of CPD, so it also works for files and not only for directories.
  • 18: Created extra CSV output format csv_with_linecount_per_file which outputs the correct line count per file.
  • 19: Fixed exit status of PMD when error occurs
  • 48: Handle NoClassDefFoundError along ClassNotFoundException
  • 49: Fix some false positives in UnusedPrivateField
  • 50: Add missing assertions in JUnitAssertionsShouldIncludeMessage test
  • 51: [JUnit] Check assertion message present in assertEquals with delta
  • 52: Improves JDK8 support for default methods and static methods in interfaces
  • Bugfixes:
  • 914: False +ve from UnusedImports with wildcard static imports
  • 1197: JUnit4TestShouldUseTestAnnotation for private method
  • 1277: Delete BooleanInversion as it makes no sense
  • 1283: Rename UncommentedEmptyMethod to UncommentedEmptyMethodBody
  • 1296: PMD UnusedPrivateMethod invalid detection of ‘private void method(int,boolean,Integer…)’
  • 1298: Member variable int type with value 0xff000000 causes processing error
  • 1299: MethodReturnsInternalArray false positive
  • 1302: False Positive: UnusedPrivateField when accessed by inner class
  • 1303: OverrideBothEqualsAndHashcodeRule does not work on class implements resolvable interfaces
  • 1304: UseCollectionIsEmpty false positive comparing to 1
  • 1305: variable declaration inside switch causes ClassCastException
  • 1306: False positive on duplicate when using static imports
  • 1307: False positive: SingularField and lambda-expression
  • 1308: PMD runs endlessly on some generated files
  • 1312: Rule reference must not override rule name of referenced rule
  • 1313: Missing assertion message in assertEquals with delta not detected
  • 1316: Multi Rule Properties with delimiter not possible
  • 1317: RuntimeException when parsing class with multiple lambdas
  • 1319: PMD stops with NoClassDefFoundError (typeresolution)
  • 1321: CPD format XML fails with NullPointer
  • 1322: MethodReturnsInternalArray on private methods
  • 1323: False positive case of UseAssertTrueInsteadOfAssertEquals
  • 1324: MethodReturnsInternalArray false positive with clone()
  • 1325: Inner class declared within a method fails to parse (ClassCastException)
  • 1326: PMD 5.3.0-SNAPSHOT doesn’t compile under Windows
  • API Changes:
  • net.sourceforge.pmd.cpd.Match.iterator() now returns an iterator of the new type net.sourceforge.pmd.cpd.Mark instead of TokenEntry. A Mark contains all the informations about each single duplication, including the TokenEntry via Mark.getToken(). This Mark is useful for reporting the correct line count for each duplication. Previously only one line count was available. As for some languages CPD can be instructed to ignore comments, the line count could be different in the different files for the same duplication.
  • pmd-test: The utility class StreamUtil is deprecated. Just use Apache Commons IO Utils instead.

New in PMD 5.2.3 (Dec 22, 2014)

  • Feature Requests and Improvements:
  • MethodNamingConventions for native should be deactivated
  • Disable VariableNamingConventions for native methods
  • Modified Rules:
  • Java / Design / UseVarargs: if byte[] is used as the last argument, it is ignored and no violation will be reported.
  • Java / Naming / MethodNamingConventions: New property checkNativeMethods
  • Java / Naming / VariableNamingConventions: New property checkNativeMethodParameters
  • Pull requests:
  • RuleSetReferenceId does not process HTTP(S) correctly.
  • Allow byte[] as no-vargars last argument
  • Allow byte[] data and byte data[] as no-varargs last argument
  • Bugfixes:
  • net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file xxx.cpp
  • CommentRequired not ignored if javadoc {@inheritDoc} anon inner classes
  • RuleSetReferenceId does not process HTTP(S) correctly.
  • False positive UnusedPrivateMethod with public inner enum from another class

New in PMD 5.2.2 (Dec 4, 2014)

  • New Parameters for CPD:
  • For the language cpp, the following new parameters are supported:
  • no-skip-blocks: Disables skipping of code blocks like a pre-processor. This is by default enabled.
  • skip-blocks-pattern: Pattern to find the blocks to skip. Start and End pattern separated by “|”. Default value is “#if 0|#endif”.
  • Bugfixes:
  • cpp parser exception with inline asm
  • CompareObjectsWithEquals False Positive comparing boolean (primitive) values
  • CPD run that worked in 5.1.2 fails in 5.1.3 with OOM
  • False positive in UnusedPrivateMethod with inner enum
  • False Positive in UnusedImports when import used in javadoc
  • UnusedPrivateMethod incorrectly flagged for methods nested private classes
  • False Positive with implicit String.valuesOf() (Java)
  • Prevent to modify the System environment
  • UnusedPrivateMethod returns false positives for varags and enums

New in PMD 5.2.1 (Nov 15, 2014)

  • Bugfixes:
  • False +: MissingBreakInSwitch
  • net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file xxx.cpp
  • Document default behaviour when CPD command line arguments "encoding" and "ignoreAnnotations" are not specified
  • UseUtilityClass false positive with Exceptions
  • PositionLiteralsFirstInComparisons false positive with Characters
  • Java 8 Lambda parse error on direct field access
  • CloseResource rule ignores conditionnals within finally blocks
  • False positive "Avoid unused private methods" with Generics
  • False positive for MissingBreakInSwitch
  • PMD reports CheckResultSet violation in completely unrelated source files.
  • varargs in methods are causing IndexOutOfBoundException when trying to process files
  • CheckResultSet false positive in try-with-resources nested in if
  • ant integration broken with pmd-5.2.0
  • False positive: UnusedModifier rule for static inner class in enum

New in PMD 5.2.0 (Nov 15, 2014)

  • New Languages:
  • CPD supports now Go.
  • Pull requests:
  • #9: New rule: NoUnsanitizedJSPExpressionRule
  • #44: Add GoLang support to CPD
  • New/Modified Rules:
  • JSP - Basic ruleset:
  • NoUnsanitizedJSPExpression: Using unsanitized JSP expression can lead to Cross Site Scripting (XSS) attacks

New in PMD 5.1.3 (Sep 9, 2014)

  • Bugfixes:
  • False failure with "Avoid unused private methods"
  • double variable with AvoidDecimalLiteralsInBigDecimalConstructor
  • UnusedPrivateMethod returns false positives
  • UseCollectionIsEmpty gets false positives
  • No Error Message on Missing Rule
  • UnusedPrivateMethod: False positive : method called on returned object.
  • Unused private methods still giving false positives in 5.1.3 snapshot
  • scope dependencies in POM file
  • StackOverflowError in AbstractTokenizer.parseString running CPD on >1MB JS file
  • False+ AvoidProtectedMethodInFinalClassNotExtending
  • Useless Parentheses False Positive
  • False Positive for Law of Demeter
  • False positive from MissingBreakInSwitch
  • Not able to recognize JDK 8 Static Method References
  • Regression: UnusedPrivateMethod from 5.0.5 to 5.1.2
  • Method attribute missing for some violations
  • UnusedPrivateMethod false positives for boxing & unboxing arguments
  • Feature Requests and Improvements:
  • Make ShortClassName configurable
  • FieldDeclarationsShouldBeAtStartOfClass and anonymous classes
  • New/Modified Rules:
  • FieldDeclarationsShouldBeAtStartOfClass (ruleset java-design) has a new property called ignoreAnonymousClassDeclarations: Ignore Field Declarations, that are initialized with anonymous class declarations. This property is enabled by default. See feature #1244.
  • ShortClassName (ruleset java-naming) has a new property called minimum: Number of characters that are required as a minimum for a class name. By default, 5 characters are required - if the class name is shorter, a violation will be reported. See feature #1232.

New in PMD 5.1.2 (Jul 28, 2014)

  • Bugfixes:
  • Fixed [bug #1181]: unused import false positive if used as parameter in javadoc only.
  • Fixed [bug #1192]: Ecmascript fails to parse this operator " ^= "
  • Fixed [bug #1198]: ConfusingTernary does not ignore else if blocks even when property is set
  • Fixed [bug #1200]: setRuleSets method javadoc mistype commands instead commas
  • Fixed [bug #1201]: Error "Can't find resource null" when ruleset contains spaces after comma
  • Fixed [bug #1202]: StackOverflowError in RuleSetReferenceId
  • Fixed [bug #1205]: Parse error on lambda with if
  • Fixed [bug #1206]: SummaryHTMLRenderer always shows suppressed warnings/violations
  • Fixed [bug #1208]: yahtml's outputDir property does not work
  • Fixed [bug #1209]: XPath 2.0 following-sibling incorrectly includes context node
  • Fixed [bug #1211]: PMD is failing with NPE for rule UseIndexOfChar while analyzing Jdk 8 Lambda expression
  • Fixed [bug #1214]: UseCollectionIsEmpty misses some usage
  • Fixed [bug #1215]: AvoidInstantiatingObjectsInLoops matches the right side of a list iteration loop
  • Fixed [bug #1216]: AtLeastOneConstructor ignores classes with any methods
  • Fixed [bug #1218]: TooFewBranchesForASwitchStatement misprioritized
  • Fixed [bug #1219]: PrimarySuffix/@Image does not work in some cases in xpath 2.0
  • Fixed [bug #1223]: UnusedPrivateMethod: Java 8 method reference causing false positives
  • Fixed [bug #1224]: GuardDebugLogging broken in 5.1.1 - missing additive statement check in log statement
  • Fixed [bug #1226]: False Positive: UnusedPrivateMethod overloading with varargs
  • Fixed [bug #1227]: GuardLogStatementJavaUtil doesn't catch log(Level.FINE, "msg" + " msg") calls
  • Feature Requests and Improvements:
  • [#1203]: Make GuardLogStatementJavaUtil configurable
  • [#1213]: AvoidLiteralsInIfCondition -- switch for integer comparison with 0
  • [#1217]: SystemPrintln always says "System.out.print is used"
  • [#1221]: OneDeclarationPerLine really checks for one declaration each statement
  • Pull requests:
  • #41: Update to use asm 5.0.2
  • #42: Add SLF4j Logger type to MoreThanOneLogger rule
  • #43: Standard and modified cyclomatic complexity
  • New Rules:
  • Java - codesize ruleset:
  • StdCyclomaticComplexity: Like CyclomaticComplexityRule, but not including boolean operators
  • ModifiedCyclomaticComplexity: Like StdCyclomaticComplexity, but switch statement plus all cases count as 1

New in PMD 5.1.1 (Apr 28, 2014)

  • Bugfixes
  • Fixed [bug 1165]: SimplifyConditional false positive
  • Fixed [bug 1166]: PLSQL XPath Rules Fail for XPath 1.0
  • Fixed [bug 1167]: Error while processing PLSQL file with BOM
  • Fixed [bug 1168]: Designer errors when trying to copy xml to clipboard
  • Fixed [bug 1170]: false positive with switch in loop
  • Fixed [bug 1171]: Specifying minimum priority from command line gives NPE
  • Fixed [bug 1173]: Java 8 support: method references
  • Fixed [bug 1175]: false positive for StringBuilder.append called 2 consecutive times
  • Fixed [bug 1176]: ShortVariable false positive with for-each loops
  • Fixed [bug 1177]: Incorrect StringBuffer warning when that class is not used
  • Fixed [bug 1178]: LexicalError while parsing Java code aborts CPD run
  • Fixed [bug 1180]: False Positive for ConsecutiveAppendsShouldReuse on different variable names
  • Fixed [bug 1185]: UnusedModifier throws NPE when parsing enum with a nested static interface
  • Fixed [bug 1188]: False positive in UnusedPrivateField
  • Fixed [bug 1191]: Ecmascript fails to parse "void(0)"
  • Document that PMD requires Java 1.6, see [discussion].
  • [Pull request 38]: Some fixes for AbstractCommentRule
  • [Pull request 39]: Fixed NPE in ConsecutiveAppendsShouldReuseRule.getVariableAppended()
  • [Pull request 40]: Added support for enums in CommentRequiredRule
  • CPD Changes:
  • Command Line:
  • Added option "--skip-lexical-errors" to skip files, which can't be tokenized due to invalid characters instead of aborting CPD. See also [bug 1178].
  • Ant:
  • New optional parameter "skipDuplicateFiles": Ignore multiple copies of files of the same name and length in comparison; defaults to "false". This was already a command line option, but now also available in in CPD's ant task.
  • New optional parameter "skipLexicalErros": Skip files which can't be tokenized due to invalid characters instead of aborting CPD; defaults to "false".

New in PMD 5.1.0 (Feb 12, 2014)

  • New/Updated Languages:
  • Java 1.8 support added.
  • PLSQL support added; thanks to Stuart Turton.
  • Apache Velocity support added; thanks to Andrey Utis.
  • New/Updated Rulesets and Rules:
  • EcmaScript:
  • Controversial ruleset, featuring AvoidWithStatement
  • UseBaseWithParseInt
  • Java:
  • GuardLogStatement - replace xpath implementation of GuardDebugLogging by GuardLogStatement (better perf)
  • CommentRequired - basic rule to check for existence for formal (javadoc) comments.
  • AvoidProtectedMethodInFinalClassNotExtending - rule to avoid protected methods in final classes that don't extend anything other than Object.
  • ConsecutiveAppendsShouldReuse - rule to encourage to reuse StringBuilder.append returned object for consecutive calls.
  • PositionLiteralsFirstInCaseInsensitiveComparisons - rule similar to PositionLiteralsFirstInComparisons, but for case insensitive comparisons (equalsIgnoreCase).
  • ConfusingTernary - new property "ignoreElseIf" to suppress this rule in case of if-else-if-else usage. See [feature 1161]: Confusing Ternary should skip else if statements (or have a property to do so)
  • FieldDeclarationsShouldBeAtStartOfClass - new property "ignoreEnumDeclarations" which is enabled by default. This relaxes the rule, so that enums can be declared before fields and the rule is not triggered.
  • Bugfixes:
  • Fixed [bug 881]: private final without setter is flagged
  • Fixed [bug 1059]: Change rule name "Use Singleton" should be "Use Utility class"
  • Fixed [bug 1106]: PMD 5.0.4 fails with NPE on parsing java enum with inner class instance creation
  • Fixed [bug 1045]: //NOPMD not working (or not implemented) with ECMAscript
  • Fixed [bug 1054]: XML Rules ever report a line -1 and not the line/column where the error occurs
  • Fixed [bug 1115]: commentRequiredRule in pmd 5.1 is not working properly
  • Fixed [bug 1120]: equalsnull false positive
  • Fixed [bug 1121]: NullPointerException when invoking XPathCLI * Fixed [bug 1123]: failure in help examples
  • Fixed [bug 1124]: PMD.run() multithreading issue
  • Fixed [bug 1125]: Missing Static Method In Non Instantiatable Class * Fixed [bug 1126]: False positive with FieldDeclarationsShouldBeAtStartOfClass for static enums
  • Fixed [bug 1130]: CloseResource doesn't recognize custom close method
  • Fixed [bug 1131]: CloseResource should complain if code betwen declaration of resource and try
  • Fixed [bug 1134]: UseStringBufferLength: false positives
  • Fixed [bug 1135]: CheckResultSet ignores results set declared outside of try/catch
  • Fixed [bug 1136]: ECMAScript: NullPointerException in getLeft() and getRight()
  • Fixed [bug 1140]: public EcmascriptNode getBody(int index)
  • Fixed [bug 1141]: ECMAScript: getFinallyBlock() is buggy.
  • Fixed [bug 1142]: ECMAScript: getCatchClause() is buggy.
  • Fixed [bug 1144]: CPD encoding argument has no effect
  • Fixed [bug 1146]: UseArrayListInsteadOfVector false positive when using own Vector class
  • Fixed [bug 1147]: EmptyMethodInAbstractClassShouldBeAbstract false positives
  • Fixed [bug 1150]: "EmptyExpression" for valid statements!
  • Fixed [bug 1154]: Call super onPause when there is no super
  • Fixed [bug 1155]: maven pmd plugin does not like empty rule sets
  • Fixed [bug 1159]: false positive UnusedFormalParameter readObject(ObjectInputStream) if not used
  • Fixed [bug 1164]: Violations are not suppressed with @java.lang.SuppressWarnings("all")
  • CPD Changes:
  • Command Line - Added non-recursive option "--non-recursive" to not scan sub-directories
  • Added option "--exclude" to exclude specific files from being scanned (thanks to Delmas for patch #272)
  • CPD is now thread-safe, so that multiple instances of CPD can run concurrently without stepping on each other (eg: multi-module Maven projects.). Thanks to David Golpira.
  • Miscellaneous:
  • Upgrade to javacc 5.0 (see patch #1109 Patch to build with Javacc 5.0)
  • DBURI as DataSource possible - directly scan plsql code stored within the database

New in PMD 5.0.5 (Sep 11, 2013)

  • Fixed bug 991: AvoidSynchronizedAtMethodLevel for static methods
  • Fixed bug 1084: NPE at UselessStringValueOfRule.java:36
  • Fixed bug 1091: file extension for fortran seems to be wrong in cpdgui tools
  • Fixed bug 1092: Wrong Attribute "excludemarker" in Ant Task Documentation
  • Fixed bug 1095: AvoidFinalLocalVariable false positive
  • Fixed bug 1099: UseArraysAsList false positives
  • Fixed bug 1102: False positive: shift operator parenthesis
  • Fixed bug 1104: IdempotentOperation false positive
  • Fixed bug 1107: PMD 5.0.4 couldn't parse call of parent outer java class method from inner class
  • Fixed bug 1069: Eclipse plugin does not accept project-local config
  • Fixed bug 1111: False positive: Useless parentheses
  • Fixed bug 1114: CPD - Tokenizer not initialized with requested properties
  • Fixed bug 1118: ClassCastException in pmd.lang.ecmascript.ast.ASTElementGet

New in PMD 5.0.4 (May 1, 2013)

  • Fixed bug 254: False+ : UnusedImport with Javadoc @throws
  • Fixed bug 794: False positive on PreserveStackTrace with anonymous inner
  • Fixed bug 1063: False+: ArrayIsStoredDirectly
  • Fixed bug 1080: net.sourceforge.pmd.cpd.CPDTest test failing
  • Fixed bug 1081: Regression: CPD skipping all files when using relative paths
  • Fixed bug 1082: CPD performance issue on larger projects
  • Fixed bug 1085: NullPointerException by at net.sourceforge.pmd.lang.java.rule.design.GodClassRule.visit(GodClassRule.java:313)
  • Fixed bug 1086: Unsupported Element and Attribute in Ant Task Example
  • Fixed bug 1087: PreserveStackTrace (still) ignores initCause()
  • Fixed bug 1089: When changing priority in a custom ruleset, violations reported twice

New in PMD 5.0.3 (Apr 6, 2013)

  • Fixed bug 938: False positive on LooseCoupling for overriding methods Fixed bug 940: False positive on UnsynchronizedStaticDateFormatter
  • Fixed bug 942: CheckResultSet False Positive and Negative
  • Fixed bug 943: PreserveStackTrace false positive if a StringBuffer exists Fixed bug 945: PMD generates RuleSets it cannot read.
  • Fixed bug 958: Intermittent NullPointerException while loading XPath node attributes
  • Fixed bug 968: Issues with JUnit4 @Test annotation with expected exception
  • Fixed bug 975: false positive in ClassCastExceptionWithToArray
  • Fixed bug 976: UselessStringValueOf wrong when appending character arrays
  • Fixed bug 977: MisplacedNullCheck makes false positives
  • Fixed bug 984: Cyclomatic complexity should treat constructors like methods Fixed bug 985: Suppressed methods shouldn't affect avg CyclomaticComplexity
  • Fixed bug 992: Class java.beans.Statement triggered in CloseResource rule
  • Fixed bug 997: Rule NonThreadSafeSingleton gives analysis problem
  • Fixed bug 999: Law of Demeter: False positives and negatives
  • Fixed bug 1002: False +: FinalFieldCouldBeStatic on inner class
  • Fixed bug 1005: False + for ConstructorCallsOverridableMethod - overloaded methods Fixed bug 1027: PMD Ant: java.lang.ClassCastException
  • Fixed bug 1032: ImmutableField Rule: Private field in inner class gives false positive
  • Fixed bug 1064: Exception running PrematureDeclaration
  • Fixed bug 1068: CPD fails on broken symbolic links
  • Fixed bug 1073: Hard coded violation messages CommentSize
  • Fixed bug 1074: rule priority doesn't work on group definitions Fixed bug 1076: Report.treeIterator() does not return all violations
  • Fixed bug 1077: Missing JavaDocs for Xref-Test Files
  • Fixed bug 1078: Package statement introduces false positive UnnecessaryFullyQualifiedName violation
  • Merged pull request #14: fix Nullpointer Exception when using -l jsp

New in PMD 5.0.2 (Feb 4, 2013)

  • Fixed bug 878: False positive: UnusedFormalParameter for abstract methods
  • Fixed bug 913: SignatureDeclareThrowsException is raised twice
  • Fixed bug 947: CloseResource rule fails if field is marked with annotation
  • Fixed bug 1004: targetjdk isn't attribute of PMD task
  • Fixed bug 1007: Parse Exception with annotation
  • Fixed bug 1011: CloseResource Rule ignores Constructors
  • Fixed bug 1012: False positive: Useless parentheses.
  • Fixed bug 1020: Parsing Error
  • Fixed bug 1026: PMD doesn't handle 'value =' in SuppressWarnings annotation
  • Fixed bug 1028: False-positive: Compare objects with equals for Enums
  • Fixed bug 1030: CPD Java.lang.IndexOutOfBoundsException: Index:
  • Fixed bug 1037: Facing a showstopper issue in PMD Report Class (report listeners)
  • Fixed bug 1039: pmd-nicerhtml.xsl is packaged in wrong location
  • Fixed bug 1043: node.getEndLine() always returns 0 (ECMAscript)
  • Fixed bug 1044: Unknown option: -excludemarker
  • Fixed bug 1046: ant task CPDTask doesn't accept ecmascript
  • Fixed bug 1047: False Positive in 'for' loops for LocalVariableCouldBeFinal in 5.0.1
  • Fixed bug 1048: CommentContent Rule, String Index out of range Exception Fixed bug 1049: Errors in "How to write a rule"
  • Fixed bug 1055: Please add a colon in the ant output after line,column for Oracle JDeveloper IDE usage
  • Fixed bug 1056: "Error while processing" while running on xml file with DOCTYPE reference
  • Fixed bug 1060: GodClassRule >>> wrong method

New in PMD 5.0.1 (Nov 30, 2012)

  • Fixed bug 820: False+ AvoidReassigningParameters
  • Fixed bug 1008: pmd-5.0.0: ImmutableField false positive on self-inc/dec Fixed bug 1009: pmd-5.0.0: False + UselessParentheses
  • Fixed bug 1003: newline characters stripped from CPD data in PMD 5.0.0
  • Fixed bug 1001: InsufficientStringBufferDeclaration fails to parse hex
  • Fixed bug 522: InefficientStringBuffering bug false +
  • Fixed bug 953: String.InefficientStringBuffering false +
  • Fixed bug 981: Unable to parse
  • Fixed bug 1010: pmd: parsing of generic method call with super fails
  • Fixed bug 996: pmd-4.2.6: MissingBreakInSwitch fails to report violation Fixed bug 993: Invalid NPath calculation in return statement.
  • Fixed bug 1023: c/c++ \ as a continuation character not supported Fixed bug 1033: False+ : SingularField
  • Fixed bug 1025: Regression of Crash in PMDTask due to multithreading (Eclipse and Java 1.5)
  • Fixed bug 1017: Type resolution very slow for big project.
  • Fixed bug 1036: Documentation: default threshold values removed from v5.0 Fixed bug 1035: UseObjectForClearerAPI has misspelled message Fixed bug 1031: false DontImportJavaLang
  • Fixed bug 1034: UseConcurrentHashMap flags calls to methods that return Map Fixed bug 1006: Problem with implementation of getPackageNameImage method
  • Fixed bug 1014: AvoidLiteralsInIfCondition must NOT consider null Fixed bug 1013: jnlp link for CPD is wrong PMD
  • Command Line Changes:
  • Improved command line interface (CLI) parsing using JCommander.
  • Note: this breaks compatibility, but should be easy to fix.
  • With "-d" you specify nowtThe source files / source directory to be scanned.
  • With "-f" you select the report format (like text, html, ...)
  • With "-R" you select the rulesets to be used. Example: pmd -d c:\data\pmd\pmd\test-data\Unused1.java -f xml -R rulesets/java/unusedcode.xml
  • Improved JSP parser to be less strict with not valid XML documents (like HTML).
  • Fixed bgastviewer not working.
  • Improved CPD: Support in CPD for IgnoreAnnotations and SuppressWarnings("CPD-START").
  • Fixed C# support for CPD
  • New Ecmascript rules: Basic ruleset: AvoidTrailingComma

New in PMD 5.0 (May 2, 2012)

  • Fixed bug 3470274: Using Label for lines in XMLRenderer
  • Fixed bug 3175710: NPE in InsufficientStringBufferDeclaration
  • CPD:
  • Exit with status code 4 when CPD detects code duplication (

New in PMD 5.0 Alpha (May 2, 2012)

  • This version of PMD breaks API compatibility with prior versions of PMD, as well as RuleSet XML compatibility. Also the maven coordinates (groupId) have been changed. The decision to break compatibility, allows PMD internals and code organization to be improved to better handle additional languages. This opportunity was used to remove depreciated APIs, and beat up any code which has thumbed its nose at the developers over the years. ;) The following is relatively complete list of the major changes (this may not be 100% accurate, see actual source code when in doubt): Fixed bug (no number) - Fixed UseStringBufferLengthRule only worked once per class All StringBuffer-related rules now also catch StringBuilder-related issues in the same way API Change - Unification of treatment of languages within PMD core: Added - net.sourceforge.pmd.lang.Language (now an 'enum') Added - net.sourceforge.pmd.lang.LanguageVersion Added - net.sourceforge.pmd.lang.LanguageVersionDiscoverer Added - net.sourceforge.pmd.lang.LanguageVersionHandler Added - net.sourceforge.pmd.lang.XPathHandler Added - net.sourceforge.pmd.lang.ast.xpath.AbstractASTXPathHandler Added - net.sourceforge.pmd.lang.xpath.Initializer Added - net.sourceforge.pmd.lang.ast.AbstractTokenManager Added - net.sourceforge.pmd.lang.ast.CharStream Added - net.sourceforge.pmd.lang.ast.JavaCharStream Added - net.sourceforge.pmd.lang.ast.SimpleCharStream Added - net.sourceforge.pmd.lang.ast.TokenMgrError Added - net.sourceforge.pmd.lang.rule.stat.StatisticalRule Added - net.sourceforge.pmd.lang.rule.stat.StatisticalRuleHelper Added - net.sourceforge.pmd.lang.java.rule.AbstractStatisticalJavaRule Added - net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory Added - net.sourceforge.pmd.lang.rule.RuleViolationFactory Added - net.sourceforge.pmd.lang.java.rule.JavaRuleViolationFactory Added - net.sourceforge.pmd.lang.jsp.rule.JspRuleViolationFactory Renamed - net.sourceforge.pmd.AbstractRule to net.sourceforge.pmd.lang.rule.AbstractRule Renamed - net.sourceforge.pmd.AbstractJavaRule to net.sourceforge.pmd.lang.java.rule.AbstractJavaRule Renamed - net.sourceforge.pmd.AbstractRuleChainVisitor to net.sourceforge.pmd.lang.rule.AbstractRuleChainVisitor Renamed - net.sourceforge.pmd.RuleChainVisitor to net.sourceforge.pmd.lang.rule.RuleChainVisitor Renamed - net.sourceforge.pmd.SourceFileSelector to net.sourceforge.pmd.lang.rule.LanguageFilenameFilter Renamed - net.sourceforge.pmd.rule.XPathRule to net.sourceforge.pmd.lang.rule.XPathRule Renamed - net.sourceforge.pmd.jsp.rule.AbstractJspRule to net.sourceforge.pmd.lang.jsp.rule.AbstractJspRule Renamed - net.sourceforge.pmd.ast.CompilationUnit to net.sourceforge.pmd.lang.ast.RootNode Renamed - net.sourceforge.pmd.ast.JavaRuleChainVisitor to net.sourceforge.pmd.lang.java.rule.JavaRuleChainVisitor Renamed - net.sourceforge.pmd.jsp.ast.JspRuleChainVisitor to net.sourceforge.pmd.lang.jsp.rule.JspRuleChainVisitor Renamed - net.sourceforge.pmd.parser.Parser to net.sourceforge.pmd.lang.Parser Renamed - net.sourceforge.pmd.parser.TokenManager to net.sourceforge.pmd.lang.TokenManager Renamed - net.sourceforge.pmd.parser.* into net.sourceforge.pmd.lang.{Language} Renamed - net.sourceforge.pmd.sourcetypehandlers.SourceTypeHandler to net.sourceforge.pmd.lang.LanguageVersionHandler Renamed - net.sourceforge.pmd.sourcetypehandlers.VisitorStarter to net.sourceforge.pmd.lang.VisitorStarter Renamed - net.sourceforge.pmd.sourcetypehandlers.* into net.sourceforge.pmd.lang.{Language} Renamed - net.sourceforge.pmd.stat.StatisticalRule to net.sourceforge.pmd.lang.rule.StatisticalRuleHelper Renamed - net.sourceforge.pmd.jaxen.TypeOfFunction to net.sourceforge.pmd.lang.java.xpath.TypeOfFunction Renamed - net.sourceforge.pmd.jaxen.MatchesFunction to net.sourceforge.pmd.lang.xpath.MatchesFunction Renamed - net.sourceforge.pmd.jaxen.Attribute to net.sourceforge.pmd.lang.ast.xpath.Attribute Renamed - net.sourceforge.pmd.jaxen.AttributeAxisIterator to net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator Renamed - net.sourceforge.pmd.jaxen.DocumentNavigator to net.sourceforge.pmd.lang.ast.xpath.DocumentNavigator Renamed - net.sourceforge.pmd.jaxen.NodeIterator to net.sourceforge.pmd.lang.ast.xpath.NodeIterator Renamed - net.sourceforge.pmd.ast.* into net.sourceforge.pmd.lang.java.ast.* Renamed - net.sourceforge.pmd.rules.* into net.sourceforge.pmd.lang.java.rule.* and updated to follow conventions Renamed - net.sourceforge.pmd.jsp.ast.* into net.sourceforge.pmd.lang.jsp.ast.* Renamed - net.sourceforge.pmd.jsp.rules.* into net.sourceforge.pmd.lang.jsp.ast.rule.* and updated to follow conventions Deleted - net.sourceforge.pmd.cpd.cppast.* into net.sourceforge.pmd.lang.cpp.ast.* Deleted - net.sourceforge.pmd.CommonAbstractRule Deleted - net.sourceforge.pmd.SourceFileConstants Deleted - net.sourceforge.pmd.SourceType Deleted - net.sourceforge.pmd.SourceTypeDiscoverer Deleted - net.sourceforge.pmd.SourceTypeToRuleLanguageMapper Deleted - net.sourceforge.pmd.TargetJDK1_3 Deleted - net.sourceforge.pmd.TargetJDK1_4 Deleted - net.sourceforge.pmd.TargetJDK1_5 Deleted - net.sourceforge.pmd.TargetJDK1_6 Deleted - net.sourceforge.pmd.TargetJDK1_7 Deleted - net.sourceforge.pmd.TargetJDKVersion Deleted - net.sourceforge.pmd.cpd.SourceFileOrDirectoryFilter Deleted - net.sourceforge.pmd.sourcetypehandlers.SourceTypeHandlerBroker Deleted - net.sourceforge.pmd.ast.JavaCharStream Deleted - net.sourceforge.pmd.ast.CharStream Deleted - net.sourceforge.pmd.ast.TokenMgrError Deleted - net.sourceforge.pmd.jsp.ast.JspCharStream Deleted - net.sourceforge.pmd.jsp.ast.TokenMgrError API Change - Generalize RuleViolation treatment Renamed - net.sourceforge.pmd.IRuleViolation to net.sourceforge.pmd.RuleViolation Renamed - net.sourceforge.pmd.RuleViolation to net.sourceforge.pmd.lang.rule.AbstractRuleViolation Added - net.sourceforge.pmd.RuleViolationComparator Added - net.sourceforge.pmd.lang.java.rule.JavaRuleViolation Added - net.sourceforge.pmd.lang.jsp.rule.JspRuleViolation API Change - Generalize DFA treatment Renamed - net.sourceforge.pmd.dfa.IDataFlowNode to net.sourceforge.pmd.lang.dfa.DataFlowNode Renamed - net.sourceforge.pmd.dfa.DataFlowNode to net.sourceforge.pmd.lang.dfa.AbstractDataFlowNode Renamed - net.sourceforge.pmd.dfa.Linker to net.sourceforge.pmd.lang.dfa.Linker Renamed - net.sourceforge.pmd.dfa.LinkerException to net.sourceforge.pmd.lang.dfa.LinkerException Renamed - net.sourceforge.pmd.dfa.NodeType to net.sourceforge.pmd.lang.dfa.NodeType Renamed - net.sourceforge.pmd.dfa.StackObject to net.sourceforge.pmd.lang.dfa.StackObject Renamed - net.sourceforge.pmd.dfa.SequenceChecker to net.sourceforge.pmd.lang.dfa.SequenceChecker Renamed - net.sourceforge.pmd.dfa.SequenceException to net.sourceforge.pmd.lang.dfa.SequenceException Renamed - net.sourceforge.pmd.dfa.StartOrEndDataFlowNode to net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode Renamed - net.sourceforge.pmd.dfa.Structure to net.sourceforge.pmd.lang.dfa.Structure Renamed - net.sourceforge.pmd.dfa.variableaccess.VariableAccess to net.sourceforge.pmd.lang.dfa.VariableAccess Renamed - net.sourceforge.pmd.dfa.variableaccess.VariableAccessException to net.sourceforge.pmd.lang.dfa.VariableAccessException Renamed - net.sourceforge.pmd.dfa.pathfinder.* to net.sourceforge.pmd.lang.dfa.pathfinder.* Renamed - net.sourceforge.pmd.dfa.report.* to net.sourceforge.pmd.lang.dfa.report.* Renamed - net.sourceforge.pmd.dfa.DaaRuleViolation to net.sourceforge.pmd.lang.java.dfa.DaaRuleViolation Renamed - net.sourceforge.pmd.dfa.DataFlowFacade to net.sourceforge.pmd.lang.java.dfa.DataFlowFacade Renamed - net.sourceforge.pmd.dfa.StatementAndBraceFinder to net.sourceforge.pmd.lang.java.dfa.StatementAndBraceFinder Renamed - net.sourceforge.pmd.dfa.variableaccess.VariableAccessVisitor to net.sourceforge.pmd.lang.java.dfa.VariableAccessVisitor Added - net.sourceforge.pmd.lang.java.dfa.JavaDataFlowNode Added - net.sourceforge.pmd.lang.DataFlowHandler API Change - Generalize Symbol Table treatement Deleted - net.sourceforge.pmd.symboltable.JspSymbolFacade Deleted - net.sourceforge.pmd.symboltable.JspScopeAndDeclarationFinder Renamed - net.sourceforge.pmd.symboltable.* to net.sourceforge.pmd.lang.java.symboltable.* API Change - Generalize Type Resolution treatment Renamed - net.sourceforge.pmd.typeresolution.* to net.sourceforge.pmd.lang.java.typeresolution.* API Change - Generalize Property Descriptor treatment Renamed - net.sourceforge.pmd.properties.* to net.sourceforge.pmd.lang.rule.properties.* Renamed - net.sourceforge.pmd.properties.AbstractPMDProperty to net.sourceforge.pmd.lang.rule.properties.AbstractProperty Changed - net.sourceforge.pmd.properties.PropertyDescriptor to use Generics, and other changes Added - net.sourceforge.pmd.lang.rule.properties.* new types and other API changes API Change - Generalize AST treatment Added - net.sourceforge.pmd.lang.ast.Node (interface extracted from old Node/SimpleNode) Added - net.sourceforge.pmd.lang.ast.AbstractNode Added - net.sourceforge.pmd.ast.DummyJavaNode Added - net.sourceforge.pmd.jsp.ast.AbstractJspNode Added - net.sourceforge.pmd.jsp.ast.JspNode Renamed - net.sourceforge.pmd.ast.SimpleJavaNode to net.sourceforge.pmd.ast.AbstractJavaNode Renamed - net.sourceforge.pmd.ast.SimpleJavaTypeNode to net.sourceforge.pmd.ast.AbstractJavaTypeNode Renamed - net.sourceforge.pmd.ast.SimpleJavaAccessNode to net.sourceforge.pmd.ast.AbstractJavaAccessNode Renamed - net.sourceforge.pmd.ast.SimpleJavaAccessTypeNode to net.sourceforge.pmd.ast.AbstractJavaAccessTypeNode Deleted - net.sourceforge.pmd.ast.Node Deleted - net.sourceforge.pmd.ast.SimpleNode Deleted - net.sourceforge.pmd.ast.AccessNodeInterface Deleted - net.sourceforge.pmd.jsp.ast.Node Deleted - net.sourceforge.pmd.jsp.ast.SimpleNode API Change - General code reorganization/cleanup Renamed - net.sourceforge.pmd.AbstractDelegateRule to net.sourceforge.pmd.lang.rule.AbstractDelegateRule Renamed - net.sourceforge.pmd.MockRule to net.sourceforge.pmd.lang.rule.MockRule Renamed - net.sourceforge.pmd.RuleReference to net.sourceforge.pmd.lang.rule.RuleReference Renamed - net.sourceforge.pmd.ScopedLogHandlersManager to net.sourceforge.pmd.util.log.ScopedLogHandlersManager Renamed - net.sourceforge.pmd.util.AntLogHandler to net.sourceforge.pmd.util.log.AntLogHandler Renamed - net.sourceforge.pmd.util.ConsoleLogHandler to net.sourceforge.pmd.util.log.ConsoleLogHandler Renamed - net.sourceforge.pmd.util.PmdLogFormatter to net.sourceforge.pmd.util.log.PmdLogFormatter API Change - Changes to Rule/RuleSet/RuleSets Removed - boolean Rule.include() Removed - void Rule.setInclude(boolean) Removed - String Rule.getRulePriorityName() Removed - String Rule.getExample() Removed - Rule.LOWEST_PRIORITY Removed - Rule.PRIORITIES Removed - Properties Rule.getProperties() Removed - Rule.addProperties(Properties) Removed - boolean Rule.hasProperty(String) Removed - RuleSet.applies(Language,Language) Removed - RuleSet.getLanguage() Removed - RuleSet.setLanguage(Language) Removed - RuleSets.applies(Language,Language) Changed - void Rule.setPriority(int) to void Rule.setPriority(RulePriority) Changed - int Rule.getPriority() to void RulePriority Rule.getPriority() Changed - XXX Rule.getXXXProperty(String) to Rule.getProperty(PropertyDescriptor) Changed - XXX Rule.getXXXProperty(PropertyDescriptor) to Rule.getProperty(PropertyDescriptor) Changed - Rule.addProperty(String, String) to Rule.setProperty(PropertyDescriptor, T) Changed - Rule.setProperty(PropertyDescriptor, Object) to Rule.setProperty(PropertyDescriptor, T) Changed - Rule.setProperty(PropertyDescriptor, Object[]) to Rule.setProperty(PropertyDescriptor, T) Changed - Rule.propertyValuesByDescriptor() to Rule.getPropertiesByPropertyDescriptor() Changed - PropertyDescriptor Rule.propertyDescriptorFor(String) to PropertyDescriptor Rule.getPropertyDescriptor(String) Changed - boolean RuleSet.usesDFA() to boolean RuleSet.usesDFA(Language) Changed - boolean RuleSet.usesTypeResolution() to boolean RuleSet.usesTypeResolution(Language) Added - Rule.setLanguage(Language) Added - Language Rule.getLanguage() Added - Rule.setMinimumLanguageVersion(LanguageVersion) Added - LanguageVersion Rule.getMinimumLanguageVersion() Added - Rule.setMaximumLanguageVersion(LanguageVersion) Added - LanguageVersion Rule.getMaximumLanguageVersion() Added - Rule.setDeprecated(boolean) Added - boolean Rule.isDeprecated() Added - String Rule.dysfunctionReason(); Added - Rule.definePropertyDescriptor(PropertyDescriptor) Added - List Rule.getPropertyDescriptors() Added - RuleSet.applies(Rule,LanguageVersion) API Change - Changes to PMD class Renamed - PMD.EXCLUDE_MARKER to PMD.SUPPRESS_MARKER Removed - PMD.processFile(InputStream, RuleSet, RuleContext) Removed - PMD.processFile(InputStream, String, RuleSet, RuleContext) Removed - PMD.processFile(Reader, RuleSet, RuleContext) Removed - PMD.processFile(Reader, RuleSets, RuleContext, LanguageVersion) Moved - PMD.getExcludeMarker() to Configuration.getSuppressMarker() Moved - PMD.setExcludeMarker(String) to Configuration.getSuppressMarker(String) Moved - PMD.getClassLoader() to Configuration.getClassLoader() Moved - PMD.setClassLoader(ClassLoader) to Configuration.getClassLoader(ClassLoader) Moved - PMD.setDefaultLanguageVersion(LanguageVersion) to Configuration.setDefaultLanguageVersion(LanguageVersion) Moved - PMD.setDefaultLanguageVersions(List) to Configuration.setDefaultLanguageVersions(List) Moved - PMD.createClasspathClassLoader(String) to Configuration.createClasspathClassLoader(String) API Change - Changes to Node interface Renamed - Node.findChildrenOfType(Class) as Node.findDescendantsOfType(Class) Renamed - Node.getFirstChildOfType(Class) as Node.getFirstDescendantOfType(Class) Renamed - Node.containsChildOfType(Class) as Node.hasDescendantOfType(Class) Renamed - Node.getAsXml() as Node.getAsDocument() Added - Node.findChildrenOfType(Class), non recursive version Added - Node.getFirstChildOfType(Class), non recursive version API Change - Remove deprecated APIs Removed - AccessNode.setXXX() methods, use AccessNode.setXXX(boolean) instead. Removed - PMDException.getReason() Removed - RuleSetFactory.createRuleSet(String,ClassLoader), use RuleSetFactory.setClassLoader(ClassLoader) and RuleSetFactory.createRuleSets(String) instead. Removed - net.sourceforge.pmd.cpd.FileFinder use net.sourceforge.pmd.util.FileFinder instead. API Change - RuleSetFactory Added - RuleSetFactory.setClassLoader(ClassLoader) Added - RuleSetFactory.createRuleSets(List) Added - RuleSetFactory.createRuleSet(RuleSetReferenceId) Added - RuleSetFactory.setClassLoader(ClassLoader) Added - RuleSetReferenceId class to handle parsing of RuleSet strings, see RuleSetReferenceId.parse(String) Renamed - RuleSetFactory.createSingleRuleSet(String) to RuleSetFactory.createRuleSet(String); Removed - RuleSetFactory.createRuleSets(String, ClassLoader), use RuleSetFactory.createRuleSets(String) instead. Removed - RuleSetFactory.createSingleRuleSet(String, ClassLoader), use RuleSetFactory.createSingleRuleSet(String) instead. Removed - RuleSetFactory.createRuleSet(InputStream, ClassLoader), use RuleSetFactory.createRuleSet(RuleSetReferenceId) instead. Removed - ExternalRuleID, use RuleSetReferenceId instead Removed - SimpleRuleSetNameMapper, use RuleSetReferenceId instead API Change - Changes to Renderer class, and Renderer implementations Added - Renderer.getName() Added - Renderer.setName(String) Added - Renderer.getDescription() Added - Renderer.setDescription(String) Added - Renderer.getPropertyDefinitions() Added - Renderer.isShowSuppressedViolations() Added - AbstractAccumulatingRenderer Removed - Renderer.render(Report) Removed - Renderer.render(Report, Writer) Renamed - Renderer.showSuppressedViolations(boolean) to Renderer.setShowSuppressedViolations(boolean) Renamed - PapariTextRenderer to TextColorRenderer Renamed - OntheFlyRenderer to AbstractIncrementingRenderer PMD command line changes: Removed -lineprefix use -property linePrefix {value} instead Removed -linkprefix use -property linkPrefix {value} instead Removed -xslt use -property xsltFilename {value} instead Removed -nojsp now obsolete Removed -targetjdk use -version {name} {version} instead Added -version {name} {version} to set language version to use for a given language Added -property {name} {value} as generic way to pass properties to Renderers Added -showsuppressed as a means to show suppressed rule violations (consistent with Ant task behavior) Renamed 'nicehtml' report to 'xslt' Renamed 'papari' report to 'textcolor' Renamed -excludemarker option to -suppressmarker Renamed -cpus option to -threads Ant changes: Removed - 'linkPrefix' attribute, use instead Removed - 'linePrefix' attribute, use instead Changed - is optional - if not specified, falls back to "text" and console output. Removed - 'targetJDK' attribute to lang version instead Added - as generic way to pass properties to Renderers on Renamed - 'excludeMarker' attribute to 'suppressMarker' Renamed - 'cpus' attribute to 'threads' Maven changes: The new maven coordinates are: net.sourceforge.pmd:pmd, e.g. net.sourceforge.pmd pmd 5.0 New features: New Language 'ecmascript' added, for writing XPathRule and Java Rules against ECMAScript/JavaScript documents (must be standalone, not embedded in HTML). Many thanks to Rhino! New Language 'xml' added, for writing XPathRules against XML documents New Language 'xsl' added, as a derivative from XML. Rules can now define a 'violationSuppressRegex' property to universally suppress violations with messages matching the given regular expression Rules can now define a 'violationSuppressXPath' property to universally suppress violations on nodes which match the given relative XPath expression Rules are now directly associated with a corresponding Language, and a can also be associated with a specific Language Version range if desired. Rules can now be flagged with deprecated='true' in the RuleSet XML to allow the PMD Project to indicate a Rule (1) is scheduled for removal, (2) has been removed, or (3) has been renamed/moved. XPathRules can now query using XPath 2.0 with 'version=2.0"', or XPath 2.0 in XPath 1.0 compatibility mode using 'version="1.0 compatibility"'. Many thanks to Saxon! Rules can now use property values in messages, for example ${propertyName} will expand to the value of the 'propertyName' property on the Rule. Rules can now use violation specific values in messages, specifically ${variableName}, ${methodName}, ${className}, ${packageName}. New XPath function 'getCommentOn' can be used to search for strings in comments - Thanks to Andy Throgmorton CPD: Add .hxx and .hpp as valid file extension for CPD - Thanks to Ryan Pavlik Add options to to the CPD command line task - Thanks to Cd-Man Add C# support for CPD - thanks to Florian Bauer Fix small bug in Rule Designer UI Performance enhacement when parsing Javadoc (Patch ID: 3217201), thanks to Cd-Man Rework the XMLRenderer to use proper XML API and strictly uses the system value for encoding (Fix bug: 1435751) Other changes: Rule property API upgrades: All numeric property descriptors can specify upper & lower limits Newly functional Method & Type descriptors allow rule developers to incorporate/watch for individual methods or types Better initialization error detection Deprecated old string-keyed property API, will leave some methods behind for XPath rules however '41' and '42' shortcuts for rulesets added The default Java version processed by PMD is now uniformly Java 1.5. RuleViolations in Reports now uses List internally, and RuleViolationComparator is no longer broken TokenManager errors now include a file name whenever possible for every AST in PMD Added file encoding option to CPD GUI, which already existed for the command line and Ant AssignmentInOperand enhanced to catch assignment in 'for' condition, as well as use of increment/decrement operators. Customization properties added to allow assignment in if/while/for, or use of increment/decrement. Fix false positive on CastExpressions for UselessParentheses Fix false positive where StringBuffer.setLength(0) was using default constructor size of 16, instead of actual constructor size. Fix false negative for non-primitive types for VariableNamingConventions, also expanded scope to local and method/constructors, and enhanced customization options to choose between members/locals/parameters (all checked by default) Fix false negative for UseArraysAsList when the array was passed as method parameter - thanks to Andy Throgmorton Improve TooManyMethods rule - thanks to a patch from Riku Nykanen Improve DoNotCallSystemExit - thanks to a patch from Steven Christou Correct -benchmark reporting of Rule visits via the RuleChain Creating an Empty Code Ruleset and moved the following rules from Basic ruleset: * Empty Code Rules * EmptyCatchBlock * EmptyIfStmt * EmptyWhileStmt * EmptyTryBlock * EmptyFinallyBlock * EmptySwitchStatements * EmptySynchronizedBlock * EmptyStatementNotInLoop * EmptyInitializer * EmptyStatementBlock * EmptyStaticInitializer Basic rulesets still includes a reference to those rules. Creating a unnecessary Code Ruleset and moved the following rules from Basic ruleset: * UnnecessaryConversionTemporary * UnnecessaryReturn * UnnecessaryFinalModifier * UselessOverridingMethod * UselessOperationOnImmutable * UnusedNullCheckInEquals * UselessParentheses Basic rulesets still includes a reference to those rules. Fixed bug 2920057 - Fixed False + on CloseResource Fixed bug 1808110 - Fixed performance issues on PreserveStackTrace Fixed bug 2832322 - cpd.xml file tag path attribute should be entity-encoded Fixed bug 2826119 - False +: DoubleCheckedLocking warning with volatile field Fixed bug 2835074 - False -: DoubleCheckedLocking with reversed null check Fixed bug 1932242 - EmptyMethodInAbstractClassShouldBeAbstract false + Fixed bug 1928009 - Error using migration ruleset in PMD 4.2 Fixed bug 1808110 - PreserveStackTrace Fixed bug 1988829 - Violation reported without source file name (actually a fix to ConsecutiveLiteralAppends) Fixed bug 1989814 - false +: ConsecutiveLiteralAppends Fixed bug 1977230 - false positive: UselessOverridingMethod Fixed bug 1998185 - BeanMembersShouldSerialize vs @SuppressWarnings("serial") Fixed bug 2002722 - false + in UseStringBufferForStringAppends Fixed bug 2056318 - False positive for AvoidInstantiatingObjectsInLoops Fixed bug 1977438 - False positive for UselessStringValueOf Fixed bug 2050064 - False + SuspiciousOctalEscape with backslash literal Fixed bug 1556594 - Wonky detection of NullAssignment Fixed bug 1481051 - false + UnusedNullCheckInEquals (and other false positives too) Fixed bug 1943204 - Ant task: path should be relative to Ant basedir Fixed patch 2075906 - Add toString() to the rule UnnecessaryWrapperObjectCreation Fixed bug 2315623 - @SuppressWarnings("PMD.UseSingleton") has no effect Fixed bug 2230809 - False +: ClassWithOnlyPrivateConstructorsShouldBeFinal Fixed bug 2338341 - ArrayIndexOutOfBoundsException in CPD (on Ruby) Fixed bug 2315599 - False +: UseSingleton with class containing constructor Fixed bug 1955852 - false positives for UnusedPrivateMethod & UnusedLocalVariable Fixed bug 2404700 - UseSingleton should not act on enums Fixed bug - JUnitTestsShouldIncludeAssert now detects Junit 4 Assert.assert... constructs Fixed bug 1609038 - Xslt report generators break if path contains "java" Fixed bug 2142986 - UselessOverridingMethod doesn't consider annotations Fixed bug 2027626 - False + : AvoidFinalLocalVariable Fixed bug 2606609 - False "UnusedImports" positive in package-info.java Fixed bug 2645268 - ClassCastException in UselessOperationOnImmutable.getDeclaration Fixed bug 2724653 - AvoidThreadGroup reports false positives Fixed bug 2904832 - Type resolution not working for ASTType when using an inner class Fixed bug 1435751 - XML format does not support UTF-8 Fixed bug 3303811 - Deadlink on "Similar projects" page Fixed bug 3017616 - Updated documentation regarding Netbeans plugin - thanks to Jesse Glick Fixed bug 3427563 - Deprecated class (android.util.config) - thanks to Lukas Reschke for the patch ruleset.dtd and ruleset_xml_schema.xsd added to jar file in rulesets directory bin and java14/bin scripts: retroweaver version was not correct in java14/bin scripts support for extra languages in cpd.sh standard unix scripts can be used with cygwin Upgrading UselessOperationOnImmutable to detect more use cases, especially on String and fix false positives AvoidDuplicateLiteralRule now has 'skipAnnotations' boolean property Fixed false positive in UnusedImports: javadoc comments are parsed to check @see and other tags Fixed parsing bug: constant fields in annotation classes Bug fix: NPE in MoreThanOneLogger UnnecessaryParentheses now checks all expressions, not just return statements UnusedFormalParameter now reports violations on the parameter node, not the method/constructor node Updates to RuleChain to honor RuleSet exclude-pattern Optimizations and false positive fixes in PreserveStackTrace @SuppressWarnings("all") disables all warnings SingularField now checks for multiple fields in the same declaration Java grammar enhanced to include AnnotationMethodDeclaration as parent node of method related children of AnnotationTypeMemberDeclaration JavaCC generated artifacts updated to JavaCC 4.1. Dependencies updates: asm updated to 3.2 Ant requirement is now 1.7.0 or higher for compilation JUnit testing jar is packaged on 1.7.0+ only in ant binary distributions Note that the ant task still works with 1.6.0 and higher All comment types are now stored in ASTCompilationUnit, not just formal ones Fixed false negative in UselessOverridingMethod Fixed handling of escape characters in UseIndexOfChar and AppendCharacterWithChar Fixed ClassCastException on generic method in BeanMembersShouldSerialize Fixed ClassCastException in symbol table code Support for Java 1.4 runtime dropped, PMD now requires Java 5 or higher. PMD can still process Java 1.4 source files. Support for Java 1.7 Text renderer is now silent if there's no violation instead of displaying "No problems found!" RuleSet short names now require a language prefix, 'basic' is now 'java-basic', and 'rulesets/basic.xml' is now 'rulesets/java/basic.xml' The JSP RuleSets are now in the 'jsp' language, and are 'jsp-basic', 'jsp-basic-jsf', 'rulesets/jsp/basic.xml' and 'rulesets/jsp/basic-jsp.xml' Enhanced logging in the ClassTypeResolver to provide more detailed messaging. AvoidUsingHardCodedIP modified to not use InetAddress.getByName(String), instead does better pattern analysis. The JSP/JSF parser can now parse Unicode input. The JSP/JSP parser can now handle ... tags. The AST HtmlScript node contains the content. Added Ecmascript as a supported language for CPD. The RuleSet XML Schema namespace is now: http://pmd.sourceforge.net/ruleset/2.0.0 The RuleSet XML Schema is located in the source at: etc/ruleset_2_0_0.xsd The RuleSet DTD is located in the source at: etc/ruleset_2_0_0.dtd Improved include/exclude pattern matching performance for ends-with type patterns. Modify (and hopefully fixed) CPD algorithm thanks to a patch from Juan Jesús García de Soria. Fixed character reference in xml report - thanks to Seko Enhanced SuspiciousEqualsMethodName rule - thanks to Andy Throgmorton Add a script to launch CPDGUI on Unix system - thanks to Tom Wheeler New Java rules: Basic ruleset: ExtendsObject,CheckSkipResult,AvoidBranchingStatementAsLastInLoop,DontCallThreadRun,DontUseFloatTypeForLoopIndices Controversial ruleset: AvoidLiteralsInIfCondition, AvoidPrefixingMethodParameters, OneDeclarationPerLine, UseConcurrentHashMap Coupling ruleset: LoosePackageCoupling,LawofDemeter Design ruleset: LogicInversion,UseVarargs,FieldDeclarationsShouldBeAtStartOfClass,GodClass Empty ruleset: EmptyInitializer,EmptyStatementBlock Import ruleset: UnnecessaryFullyQualifiedName Optimization ruleset: RedundantFieldInitializer Naming ruleset: ShortClassName, GenericsNaming StrictException ruleset: AvoidThrowingNewInstanceOfSameException, AvoidCatchingGenericException, AvoidLosingExceptionInformation Unnecessary ruleset: UselessParentheses JUnit ruleset: JUnitTestContainsTooManyAsserts, UseAssertTrueInsteadOfAssertEquals Logging with Jakarta Commons ruleset: GuardDebugLogging New Java ruleset: android.xml: new rules specific to the Android platform New JSP rules: Basic ruleset: NoInlineScript New ECMAScript rules: Basic ruleset: AssignmentInOperand,ConsistentReturn,InnaccurateNumericLiteral,ScopeForInVariable,UnreachableCode Braces ruleset: ForLoopsMustUseBraces,IfStmtsMustUseBraces,IfElseStmtsMustUseBraces,WhileLoopsMustUseBraces Unnecessary ruleset: UnnecessaryParentheses,UnnecessaryBlock New XML rules: Basic ruleset: MistypedCDATASection

New in PMD 4.2.5 (Mar 6, 2009)

  • Enhanced logging in the ClassTypeResolver to provide more detailed messaging.
  • Fixed bug 2315623 - @SuppressWarnings("PMD.UseSingleton") has no effect
  • Fixed bug 2230809 - False +: ClassWithOnlyPrivateConstructorsShouldBeFinal
  • Fixed bug 2338341 - ArrayIndexOutOfBoundsException in CPD (on Ruby)
  • Fixed bug 2315599 - False +: UseSingleton with class containing constructor
  • Fixed bug 1955852 - false positives for UnusedPrivateMethod & UnusedLocalVariable
  • Fixed bug 2404700 - UseSingleton should not act on enums
  • Fixed bug 2225474 - VariableNamingConventions does not work with nonprimitives
  • Fixed bug 1609038 - Xslt report generators break if path contains "java"
  • Fixed bug - JUnitTestsShouldIncludeAssert now detects Junit 4 Assert.assert... constructs
  • Fixed bug 2142986 - UselessOverridingMethod doesn't consider annotations
  • Fixed bug 2027626 - False + : AvoidFinalLocalVariable
  • New rule:
  • StrictExceptions : AvoidThrowingNewInstanceOfSameException
  • New ruleset:
  • android.xml: new rules specific to the Android platform