09 December 2018
The PMD team is pleased to announce PMD 6.10.0.
This is a minor release.
Thanks to Maikel Steneker, CPD now supports Kotlin. This means, you can use CPD to find duplicated code in your Kotlin projects.
UseUnderscoresInNumericLiterals
(java-codestyle
)
verifies that numeric literals over a given length (4 chars by default, but configurable) are using
underscores every 3 digits for readability. The rule only applies to Java 7+ codebases.The Java rule JUnitTestsShouldIncludeAssert
(java-bestpractices
)
now also detects Soft Assertions.
The property exceptionfile
of the rule AvoidDuplicateLiterals
(java-errorprone
)
has been deprecated and will be removed with 7.0.0. Please use exceptionList
instead.
The properties framework is about to get a lifting, and for that reason, we need to deprecate a lot of APIs to remove them in 7.0.0. The proposed changes to the API are described on the wiki
Construction of property descriptors has been possible through builders since 6.0.0. The 7.0.0 API will only allow
construction through builders. The builder hierarchy, currently found in the package net.sourceforge.pmd.properties.builders
,
is being replaced by the simpler PropertyBuilder
. Their APIs enjoy a high degree of source compatibility.
Concrete property classes like IntegerProperty
and StringMultiProperty
will gradually
all be deprecated until 7.0.0. Their usages should be replaced by direct usage of the PropertyDescriptor
interface, e.g. PropertyDescriptor<Integer>
or PropertyDescriptor<List<String>>
.
Instead of spreading properties across countless classes, the utility class PropertyFactory
will become
from 7.0.0 on the only provider for property descriptor builders. Each current property type will be replaced
by a corresponding method on PropertyFactory
:
IntegerProperty
is replaced by PropertyFactory#intProperty
IntegerMultiProperty
is replaced by PropertyFactory#intListProperty
FloatProperty
and DoubleProperty
are both replaced by PropertyFactory#doubleProperty
.
Having a separate property for floats wasn’t that useful.
FloatMultiProperty
and DoubleMultiProperty
are replaced by PropertyFactory#doubleListProperty
.StringProperty
is replaced by PropertyFactory#stringProperty
StringMultiProperty
is replaced by PropertyFactory#stringListProperty
RegexProperty
is replaced by PropertyFactory#regexProperty
EnumeratedProperty
is replaced by PropertyFactory#enumProperty
EnumeratedProperty
is replaced by PropertyFactory#enumListProperty
BooleanProperty
is replaced by PropertyFactory#booleanProperty
BooleanMultiProperty
, is not replaced, because it doesn’t have a use case.CharacterProperty
is replaced by PropertyFactory#charProperty
CharacterMultiProperty
is replaced by PropertyFactory#charListProperty
LongProperty
is replaced by PropertyFactory#longIntProperty
LongMultiProperty
is replaced by PropertyFactory#longIntListProperty
MethodProperty
, FileProperty
, TypeProperty
and their multi-valued counterparts
are discontinued for lack of a use-case, and have no planned replacement in 7.0.0 for now.
Here’s an example:
// Before 7.0.0, these are equivalent:
IntegerProperty myProperty = new IntegerProperty("score", "Top score value", 1, 100, 40, 3.0f);
IntegerProperty myProperty = IntegerProperty.named("score").desc("Top score value").range(1, 100).defaultValue(40).uiOrder(3.0f);
// They both map to the following in 7.0.0
PropertyDescriptor<Integer> myProperty = PropertyFactory.intProperty("score").desc("Top score value").require(inRange(1, 100)).defaultValue(40);
You’re highly encouraged to migrate to using this new API as soon as possible, to ease your migration to 7.0.0.
EnumeratedPropertyDescriptor
, NumericPropertyDescriptor
, PackagedPropertyDescriptor
,
and the related builders (in net.sourceforge.pmd.properties.builders
) will be removed.
These specialized interfaces allowed additional constraints to be enforced on the
value of a property, but made the property class hierarchy very large and impractical
to maintain. Their functionality will be mapped uniformly to PropertyConstraint
s,
which will allow virtually any constraint to be defined, and improve documentation and error reporting. The
related methods PropertyTypeId#isPropertyNumeric
and
PropertyTypeId#isPropertyPackaged
are also deprecated.
MultiValuePropertyDescriptor
and SingleValuePropertyDescriptor
are deprecated. 7.0.0 will introduce a new XML syntax which will remove the need for such a divide
between single- and multi-valued properties. The method PropertyDescriptor#isMultiValue
will be removed
accordingly.
preferredRowCount
is deprecated with no intended replacement. It was never implemented, and does not belong
in this interface. The methods uiOrder
and compareTo(PropertyDescriptor)
are deprecated for the
same reason. These methods mix presentation logic with business logic and are not necessary for PropertyDescriptors to work.
PropertyDescriptor
will not extend Comparable<PropertyDescriptor>
anymore come 7.0.0.propertyErrorFor
is deprecated and will be removed with no intended
replacement. It’s really just a shortcut for prop.errorFor(rule.getProperty(prop))
.T
valueFrom(String)
and String
asDelimitedString
(T)
are deprecated and will be removed. These were
used to serialize and deserialize properties to/from a string, but 7.0.0 will introduce a more flexible
XML syntax which will make them obsolete.isMultiValue
and type
are deprecated and won’t be replaced. The new XML syntax will remove the need
for a divide between multi- and single-value properties, and will allow arbitrary types to be represented.
Since arbitrary types may be represented, type
will become obsolete as it can’t represent generic types,
which will nevertheless be representable with the XML syntax. It was only used for documentation, but a
new way to document these properties exhaustively will be added with 7.0.0.errorFor
is deprecated as its return type will be changed to Optional<String>
with the shift to Java 8.The implementation of the adapters for the XPath engines Saxon and Jaxen (package net.sourceforge.pmd.lang.ast.xpath
)
are now deprecated. They’ll be moved to an internal package come 7.0.0. Only Attribute
remains public API.
The classes PropertyDescriptorField
, PropertyDescriptorBuilderConversionWrapper
, and the methods
PropertyDescriptor#attributeValuesById
, PropertyDescriptor#isDefinedExternally
and PropertyTypeId#getFactory
.
These were used to read and write properties to and from XML, but were not intended as public API.
The class ValueParserConstants
and the interface ValueParser
.
All classes from net.sourceforge.pmd.lang.java.metrics.impl.visitors
are now considered internal API. They’re deprecated
and will be moved into an internal package with 7.0.0. To implement your own metrics visitors,
JavaParserVisitorAdapter
should be directly subclassed.
LanguageVersionHandler#getDataFlowHandler()
, LanguageVersionHandler#getDFAGraphRule()
All classes from net.sourceforge.pmd.properties.modules
will be removed.
The interface Dimensionable
has been deprecated.
It gets in the way of a grammar change for 7.0.0 and won’t be needed anymore (see #997).
Several methods from ASTLocalVariableDeclaration
and ASTFieldDeclaration
have
also been deprecated:
ASTFieldDeclaration
won’t be a TypeNode
come 7.0.0, so
getType
and
getTypeDefinition
are deprecated.
The method getVariableName
on those two nodes will be removed, too.
All these are deprecated because those nodes may declare several variables at once, possibly
with different types (and obviously with different names). They both implement Iterator<
ASTVariableDeclaratorId
>
though, so you should iterate on each declared variable. See #910.
Visitor decorators are now deprecated and will be removed in PMD 7.0.0. They were originally a way to write composable visitors, used in the metrics framework, but they didn’t prove cost-effective.
net.sourceforge.pmd.lang.java.ast
: JavaParserDecoratedVisitor
, JavaParserControllessVisitor
,
JavaParserControllessVisitorAdapter
, and JavaParserVisitorDecorator
are deprecated with no intended replacement.The LanguageModules of several languages, that only support CPD execution, have been deprecated. These languages are 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 classes have been deprecated and will be removed with PMD 7.0.0:
CppHandler
CppLanguageModule
CppParser
CsLanguageModule
FortranLanguageModule
GroovyLanguageModule
MatlabHandler
MatlabLanguageModule
MatlabParser
ObjectiveCHandler
ObjectiveCLanguageModule
ObjectiveCParser
PhpLanguageModule
PythonHandler
PythonLanguageModule
PythonParser
RubyLanguageModule
ScalaLanguageModule
SwiftLanguageModule
Optional AST processing stages like symbol table, type resolution or data-flow analysis will be reified in 7.0.0 to factorise common logic and make them extensible. Further explanations about this change can be found on #1426. Consequently, the following APIs are deprecated for removal:
Rule
: isDfa()
, isTypeResolution()
, isMultifile()
and their
respective setters.RuleSet
: usesDFA(Language)
, usesTypeResolution(Language)
, usesMultifile(Language)
RuleSets
: usesDFA(Language)
, usesTypeResolution(Language)
, usesMultifile(Language)
LanguageVersionHandler
: getDataFlowFacade()
, getSymbolFacade()
, getSymbolFacade(ClassLoader)
,
getTypeResolutionFacade(ClassLoader)
, getQualifiedNameResolutionFacade(ClassLoader)