From c9cb88e55ccfa57febd757f1db87453c0d1ea4f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 13 Aug 2018 05:16:17 +0200 Subject: [PATCH 01/64] Deprecate old rules --- docs/pages/release_notes.md | 11 +++++++++++ .../rule/codestyle/VariableNamingConventionsRule.java | 1 + .../src/main/resources/category/java/codestyle.xml | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index b341ed6703..ad2ae7d665 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -51,6 +51,17 @@ This is a minor release. ### API Changes +#### Deprecated rules + +* The Java rules [`VariableNamingConventions`](pmd_rules_java_codestyle.html#variablenamingconventions), + [`MIsLeadingVariableName`](pmd_rules_java_codestyle.html#misleadingvariablename), + [`SuspiciousConstantFieldName`](pmd_rules_java_codestyle.html#suspiciousconstantfieldname), + and [`AvoidPrefixingMethodParameters`](pmd_rules_java_codestyle.html#avoidprefixingmethodparameters) are now deprecated, + and will be removed with version 7.0.0. They are replaced by the more general + [`FieldNamingConventions`](pmd_rules_java_codestyle.html#fieldnamingconventions), + [`FormalParameterNamingConventions`](pmd_rules_java_codestyle.html#formalparameternamingconventions), and + [`LocalVariableNamingConventions`](pmd_rules_java_codestyle.html#localvariablenamingconventions). + ### External Contributions * [#109](https://github.com/pmd/pmd/pull/109): \[java] Add two linguistics rules under naming - [Arda Aslan](https://github.com/ardaasln) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/VariableNamingConventionsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/VariableNamingConventionsRule.java index 093cff17f6..3e79516e91 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/VariableNamingConventionsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/VariableNamingConventionsRule.java @@ -23,6 +23,7 @@ import net.sourceforge.pmd.properties.BooleanProperty; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.StringMultiProperty; +@Deprecated public class VariableNamingConventionsRule extends AbstractJavaRule { private boolean checkMembers; diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml index a6e9b4c955..398ae674e0 100644 --- a/pmd-java/src/main/resources/category/java/codestyle.xml +++ b/pmd-java/src/main/resources/category/java/codestyle.xml @@ -126,6 +126,7 @@ public class MyClass { @@ -1257,6 +1258,7 @@ public class Foo { @@ -1579,6 +1581,7 @@ public class Something { @@ -1955,6 +1958,7 @@ public class Foo { From a9c8ad7d97e45174002315f558101d4f39398c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 13 Aug 2018 10:32:47 +0200 Subject: [PATCH 02/64] Add PrivateApi and ReservedSubclassing annotations --- docs/pages/release_notes.md | 58 +++++++++++++++++++ .../net/sourceforge/pmd/annotation/Beta.java | 18 ++++++ .../pmd/annotation/Experimental.java | 18 ++++++ .../pmd/annotation/InternalApi.java | 25 ++++++++ .../pmd/annotation/ReservedSubclassing.java | 37 ++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/annotation/Beta.java create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/annotation/Experimental.java create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/annotation/InternalApi.java create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/annotation/ReservedSubclassing.java diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index b341ed6703..d98e41dd4c 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -13,6 +13,7 @@ This is a minor release. ### Table Of Contents * [New and noteworthy](#new-and-noteworthy) + * [Drawing a line between private and public API](#drawing-a-line-between-private-and-public-api) * [New Rules](#new-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) @@ -20,6 +21,63 @@ This is a minor release. ### New and noteworthy +#### Drawing a line between private and public API + +Until now, all released public members and types were implicitly considered part +of PMD's public API, including inheritance-specific members (protected members, abstract methods). +We have maintained those APIs with the goal to preserve full binary compatibility between minor releases, +only breaking those APIs infrequently, for major releases. + + +In order to allow PMD to move forward at a faster pace, this implicit contract will +be invalidated with PMD 7.0.0. We now introduce more fine-grained distinctions between +the type of compatibility support we guarantee for our libraries, and ways to make +them explicit to clients of PMD. + +##### `.internal` packages and `@InternalApi` annotation + +*Internal API* is meant for use *only* by the main PMD codebase. Internal types and methods +may be modified in any way, or even removed, at any time. + +Any API in a package that contains an `.internal` segment is considered internal. +The `@InternalApi` annotation will be used for APIs that have to live outside of +these packages, e.g. methods of a public type that shouldn't be used outside of PMD (again, +these can be removed anytime). + +##### `@ReservedSubclassing` + +Types marked with the `@ReservedSubclassing` annotation are only meant to be subclassed +by classes within PMD. As such, we may add new abstract methods, or remove protected methods, +at any time. All published public members remain supported. The annotation is *not* inherited, which +means a reserved interface doesn't prevent its implementors to be subclassed. + +##### `@Beta` + +APIs marked with the `@Beta` annotation at the class or method level are subject to change. +They can be modified in any way, or even removed, at any time. If your code is a library +itself (i.e. it is used on the CLASSPATH of users outside your own control), you should not +use beta APIs, unless you repackage them (e.g. using ProGuard, shading, etc). + +##### `@Experimental` + + +APIs marked with the `@Experimental` annotation at the class or method level will almost certainly +change. They can be modified in any way, or even removed, at any time. You should not use or rely + on them in any production code. They are purely to allow broad testing and feedback. + +##### `@Deprecated` + +APIs marked with the `@Deprecated` annotation at the class or method level will remain supported +until the next major release but it is recommended to stop using them. + + +##### The transition + +*All currently supported APIs will remain so until 7.0.0*. All APIs that are to be moved to +`.internal` packages or hidden will be tagged `@InternalApi` before that major release, and +the breaking API changes will be performed in 7.0.0. + + #### New Rules * The new Java rule [`LinguisticNaming`](pmd_rules_java_codestyle.html#linguisticnaming) (`java-codestyle`) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Beta.java b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Beta.java new file mode 100644 index 0000000000..60db861ca4 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Beta.java @@ -0,0 +1,18 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.annotation; + +import java.lang.annotation.Documented; + + +/** + * Indicates the feature is in beta state: it will be most likely stay but + * the signature may change between versions without warning. + * + * @since 6.7.0 + */ +@Documented +public @interface Beta { +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Experimental.java b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Experimental.java new file mode 100644 index 0000000000..82a838e616 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Experimental.java @@ -0,0 +1,18 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.annotation; + +import java.lang.annotation.Documented; + + +/** + * Indicates the feature is in experimental state: its existence, signature or behavior + * might change without warning from one release to the next. + * + * @since 6.7.0 + */ +@Documented +public @interface Experimental { +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/annotation/InternalApi.java b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/InternalApi.java new file mode 100644 index 0000000000..fbcef90350 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/InternalApi.java @@ -0,0 +1,25 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.annotation; + +import java.lang.annotation.Documented; + + +/** + * Tags API members that are not publicly supported API. + * Such members may be removed, renamed, moved, or otherwise + * broken at any time and should not be relied upon outside + * of the main PMD codebase. + * + *

Members and types tagged with this annotation will remain + * supported until 7.0.0, after which some will be moved to internal + * packages, or will see their visibility reduced. + * + * @since 6.7.0 + */ +// NOTE: use @Deprecated with this annotation to raise a compiler warning until 7.0.0 +@Documented +public @interface InternalApi { +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/annotation/ReservedSubclassing.java b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/ReservedSubclassing.java new file mode 100644 index 0000000000..47f10de80c --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/ReservedSubclassing.java @@ -0,0 +1,37 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + + +/** + * Indicates that subclassing this type is not publicly + * supported API. Abstract methods may be added or removed + * at any time, which could break binary compatibility with + * existing implementors. Protected methods are also part of + * the private API of this type. + * + *

The API that is not inheritance-specific (unless {@linkplain InternalApi noted otherwise}, + * all public members), is still public API and will remain binary- + * compatible between major releases. + * + *

Types tagged with this annotation will remain supported + * until 7.0.0, at which point no guarantees will be maintained + * about the stability of the inheritance hierarchy for external + * clients. + * + *

This should be used for example for base rule classes that + * are meant to be used in PMD only, or for AST-related interfaces + * and abstract classes. + * + * @since 6.7.0 + */ +@Target(ElementType.TYPE) +@Documented +public @interface ReservedSubclassing { +} From 74ed544500e1a79a8b80ad28024402c044a2d975 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 13 Aug 2018 09:14:36 +0200 Subject: [PATCH 03/64] [java] InvalidSlf4jMessageFormat false positive: too many arguments with string concatenation operator Fixes #1291 If there are multiple Literals for the first parameter, we assume, they are concatenated together and sum up all placeholders. Such String literals are concatenated already by the java compiler, so splitting a String in that way has no negative impact. This change also makes use of the RuleChain. --- docs/pages/release_notes.md | 1 + .../InvalidSlf4jMessageFormatRule.java | 38 ++++++++++++------- .../xml/InvalidSlf4jMessageFormat.xml | 25 +++++++++++- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 65deb54c44..7e421bc5d0 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -45,6 +45,7 @@ This is a minor release. * java-errorprone * [#1078](https://github.com/pmd/pmd/issues/1078): \[java] MissingSerialVersionUID rule does not seem to catch inherited classes * java-performance + * [#1291](https://github.com/pmd/pmd/issues/1291): \[java] InvalidSlf4jMessageFormat false positive: too many arguments with string concatenation operator * [#1298](https://github.com/pmd/pmd/issues/1298): \[java] RedundantFieldInitializer - NumberFormatException with Long * jsp * [#1274](https://github.com/pmd/pmd/issues/1274): \[jsp] Support EL in tag attributes diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/InvalidSlf4jMessageFormatRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/InvalidSlf4jMessageFormatRule.java index 86ab80b76c..a3a56cf22e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/InvalidSlf4jMessageFormatRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/InvalidSlf4jMessageFormatRule.java @@ -42,18 +42,22 @@ public class InvalidSlf4jMessageFormatRule extends AbstractJavaRule { .unmodifiableSet(new HashSet(Arrays.asList("trace", "debug", "info", "warn", "error"))); } + public InvalidSlf4jMessageFormatRule() { + addRuleChainVisit(ASTName.class); + } + @Override public Object visit(final ASTName node, final Object data) { final NameDeclaration nameDeclaration = node.getNameDeclaration(); // ignore imports or methods if (!(nameDeclaration instanceof VariableNameDeclaration)) { - return super.visit(node, data); + return data; } // ignore non slf4j logger Class type = ((VariableNameDeclaration) nameDeclaration).getType(); if (type == null || !type.getName().equals(LOGGER_CLASS)) { - return super.visit(node, data); + return data; } // get the node that contains the logger @@ -65,7 +69,7 @@ public class InvalidSlf4jMessageFormatRule extends AbstractJavaRule { // ignore if not a log level if (!LOGGER_LEVELS.contains(method)) { - return super.visit(node, data); + return data; } // find the arguments @@ -73,13 +77,13 @@ public class InvalidSlf4jMessageFormatRule extends AbstractJavaRule { .getFirstDescendantOfType(ASTArgumentList.class).findChildrenOfType(ASTExpression.class); // remove the message parameter - final ASTPrimaryExpression messageParam = argumentList.remove(0).getFirstDescendantOfType(ASTPrimaryExpression.class); + final ASTExpression messageParam = argumentList.remove(0); final int expectedArguments = expectedArguments(messageParam); if (expectedArguments == 0) { // ignore if we are not expecting arguments to format the message // or if we couldn't analyze the message parameter - return super.visit(node, data); + return data; } // Remove throwable param, since it is shown separately. @@ -89,12 +93,14 @@ public class InvalidSlf4jMessageFormatRule extends AbstractJavaRule { } if (argumentList.size() < expectedArguments) { - addViolationWithMessage(data, node, "Missing arguments," + getExpectedMessage(argumentList, expectedArguments)); + addViolationWithMessage(data, node, + "Missing arguments," + getExpectedMessage(argumentList, expectedArguments)); } else if (argumentList.size() > expectedArguments) { - addViolationWithMessage(data, node, "Too many arguments," + getExpectedMessage(argumentList, expectedArguments)); + addViolationWithMessage(data, node, + "Too many arguments," + getExpectedMessage(argumentList, expectedArguments)); } - return super.visit(node, data); + return data; } private boolean isNewThrowable(ASTPrimaryExpression last) { @@ -145,7 +151,7 @@ public class InvalidSlf4jMessageFormatRule extends AbstractJavaRule { + params.size(); } - private int expectedArguments(final ASTPrimaryExpression node) { + private int expectedArguments(final ASTExpression node) { int count = 0; // look if the logger have a literal message if (node.getFirstDescendantOfType(ASTLiteral.class) != null) { @@ -153,7 +159,8 @@ public class InvalidSlf4jMessageFormatRule extends AbstractJavaRule { } else if (node.getFirstDescendantOfType(ASTName.class) != null) { final String variableName = node.getFirstDescendantOfType(ASTName.class).getImage(); // look if the message is defined locally - final List localVariables = node.getFirstParentOfType(ASTMethodOrConstructorDeclaration.class) + final List localVariables = node + .getFirstParentOfType(ASTMethodOrConstructorDeclaration.class) .findDescendantsOfType(ASTVariableDeclarator.class); count = getAmountOfExpectedArguments(variableName, localVariables); @@ -183,10 +190,13 @@ public class InvalidSlf4jMessageFormatRule extends AbstractJavaRule { } private int countPlaceholders(final AbstractJavaTypeNode node) { - int result = 0; // zero means, no placeholders, or we could not analyze the message parameter - ASTLiteral stringLiteral = node.getFirstDescendantOfType(ASTLiteral.class); - if (stringLiteral != null) { - result = StringUtils.countMatches(stringLiteral.getImage(), "{}"); + // zero means, no placeholders, or we could not analyze the message parameter + int result = 0; + List literals = node.findDescendantsOfType(ASTLiteral.class); + // if there are multiple literals, we just assume, they are concatenated + // together... + for (ASTLiteral stringLiteral : literals) { + result += StringUtils.countMatches(stringLiteral.getImage(), "{}"); } return result; } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/InvalidSlf4jMessageFormat.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/InvalidSlf4jMessageFormat.xml index 4163fdb66c..7dd73838b5 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/InvalidSlf4jMessageFormat.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/InvalidSlf4jMessageFormat.xml @@ -240,5 +240,28 @@ public class Foo ]]> - + + #1291 [java] InvalidSlf4jMessageFormat false positive: too many arguments with string concatenation operator + 0 + + \ No newline at end of file From 89f6ae5806f20980b893d106016c98f04895d79d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 14 Aug 2018 10:50:39 +0200 Subject: [PATCH 04/64] [java] InvalidSlf4jMessageFormat: Avoid using findDescendantsOfType to limit the scope of searched nodes --- .../InvalidSlf4jMessageFormatRule.java | 37 +++++++++++++++---- .../xml/InvalidSlf4jMessageFormat.xml | 5 +++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/InvalidSlf4jMessageFormatRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/InvalidSlf4jMessageFormatRule.java index a3a56cf22e..55d90ff474 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/InvalidSlf4jMessageFormatRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/InvalidSlf4jMessageFormatRule.java @@ -10,9 +10,13 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.commons.lang3.StringUtils; +import org.jaxen.JaxenException; +import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBody; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType; @@ -26,13 +30,14 @@ import net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix; import net.sourceforge.pmd.lang.java.ast.ASTPrimarySuffix; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclarator; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; -import net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode; +import net.sourceforge.pmd.lang.java.ast.ASTVariableInitializer; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; import net.sourceforge.pmd.lang.java.symboltable.VariableNameDeclaration; import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper; import net.sourceforge.pmd.lang.symboltable.NameDeclaration; public class InvalidSlf4jMessageFormatRule extends AbstractJavaRule { + private static final Logger LOG = Logger.getLogger(InvalidSlf4jMessageFormatRule.class.getName()); private static final Set LOGGER_LEVELS; private static final String LOGGER_CLASS = "org.slf4j.Logger"; @@ -183,20 +188,36 @@ public class InvalidSlf4jMessageFormatRule extends AbstractJavaRule { for (final ASTVariableDeclarator astVariableDeclarator : variables) { if (astVariableDeclarator.getFirstChildOfType(ASTVariableDeclaratorId.class).getImage() .equals(variableName)) { - return countPlaceholders(astVariableDeclarator); + ASTVariableInitializer variableInitializer = astVariableDeclarator + .getFirstDescendantOfType(ASTVariableInitializer.class); + ASTExpression expression = null; + if (variableInitializer != null) { + expression = variableInitializer.getFirstChildOfType(ASTExpression.class); + } + if (expression != null) { + return countPlaceholders(expression); + } } } return 0; } - private int countPlaceholders(final AbstractJavaTypeNode node) { + private int countPlaceholders(final ASTExpression node) { // zero means, no placeholders, or we could not analyze the message parameter int result = 0; - List literals = node.findDescendantsOfType(ASTLiteral.class); - // if there are multiple literals, we just assume, they are concatenated - // together... - for (ASTLiteral stringLiteral : literals) { - result += StringUtils.countMatches(stringLiteral.getImage(), "{}"); + + try { + List literals = node + .findChildNodesWithXPath( + "AdditiveExpression/PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true']" + + "|PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true']"); + // if there are multiple literals, we just assume, they are concatenated + // together... + for (Node stringLiteral : literals) { + result += StringUtils.countMatches(stringLiteral.getImage(), "{}"); + } + } catch (JaxenException e) { + LOG.log(Level.FINE, "Could not determine literals", e); } return result; } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/InvalidSlf4jMessageFormat.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/InvalidSlf4jMessageFormat.xml index 7dd73838b5..0cbc4296a5 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/InvalidSlf4jMessageFormat.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/InvalidSlf4jMessageFormat.xml @@ -260,6 +260,11 @@ public final class Main { + "second line {}", string0, string1); + String string2 = "c"; + LOGGER.debug("first line {} " + + "second line {} and " + + "the third line {}.", + string0, string1, string2); } } ]]> From 707781600f84a483b489aeaff659f8e8551921fb Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 29 Jul 2018 19:50:53 +0200 Subject: [PATCH 05/64] Use openjfx dependencies from maven central * Can use the release flag of maven-compiler-plugin again * Make the openjfx dependencies as provided, so that they don't end up in pmd-bin-*.zip --- pmd-dist/src/main/scripts/designer.bat | 14 +------ pmd-dist/src/main/scripts/run.sh | 30 +-------------- pmd-ui/pom.xml | 51 +++++++++++++++++++++----- 3 files changed, 43 insertions(+), 52 deletions(-) diff --git a/pmd-dist/src/main/scripts/designer.bat b/pmd-dist/src/main/scripts/designer.bat index c19b4532f1..f274809ac2 100644 --- a/pmd-dist/src/main/scripts/designer.bat +++ b/pmd-dist/src/main/scripts/designer.bat @@ -3,16 +3,4 @@ set TOPDIR=%~dp0.. set OPTS= set MAIN_CLASS=net.sourceforge.pmd.util.fxdesigner.DesignerStarter - -:: sets the jver variable to the java version, eg 901 for 9.0.1+x or 180 for 1.8.0_171-b11 -for /f tokens^=2-4^ delims^=.-_+^" %%j in ('java -fullversion 2^>^&1') do set /A jver="%%j%%k%%l" - -if "%jver%" GEQ "900" ( - :: enable reflection - Set jreopts=--add-opens javafx.controls/javafx.scene.control.skin=ALL-UNNAMED -) else ( - Set jreopts= -) - - -java %jreopts% -classpath "%TOPDIR%\lib\*" %OPTS% %MAIN_CLASS% %* +java -classpath "%TOPDIR%\lib\*" %OPTS% %MAIN_CLASS% %* diff --git a/pmd-dist/src/main/scripts/run.sh b/pmd-dist/src/main/scripts/run.sh index 5cd03fb76a..908f8f6c98 100755 --- a/pmd-dist/src/main/scripts/run.sh +++ b/pmd-dist/src/main/scripts/run.sh @@ -74,34 +74,6 @@ check_lib_dir() { fi } -jre_specific_vm_options() { - full_ver=$(java -version 2>&1) - # java_ver is eg "18" for java 1.8, "90" for java 9.0, "100" for java 10.0.x - java_ver=$(echo $full_ver | sed -n '{ - # replace early access versions, e.g. 11-ea with 11.0.0 - s/-ea/.0.0/ - # replace versions such as 10 with 10.0.0 - s/version "\([0-9]\{1,\}\)"/version "\1.0.0"/ - # extract the major and minor parts of the version - s/^.* version "\(.*\)\.\(.*\)\..*".*$/\1\2/p - }') - options="" - - if [ "$java_ver" -ge 90 ] && [ "${APPNAME}" = "designer" ] - then # open internal module of javafx to reflection (for our TreeViewWrapper) - options="--add-opens javafx.controls/javafx.scene.control.skin=ALL-UNNAMED" - # The rest here is for RichtextFX - options+=" --add-opens javafx.graphics/javafx.scene.text=ALL-UNNAMED" - options+=" --add-opens javafx.graphics/com.sun.javafx.scene.text=ALL-UNNAMED" - options+=" --add-opens javafx.graphics/com.sun.javafx.text=ALL-UNNAMED" - options+=" --add-opens javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED" - # Warn of remaining illegal accesses - options+=" --illegal-access=warn" - fi - - echo $options -} - readonly APPNAME="${1}" if [ -z "${APPNAME}" ]; then usage @@ -156,5 +128,5 @@ cygwin_paths java_heapsize_settings -java ${HEAPSIZE} $(jre_specific_vm_options) -cp "${classpath}" "${CLASSNAME}" "$@" +java ${HEAPSIZE} -cp "${classpath}" "${CLASSNAME}" "$@" diff --git a/pmd-ui/pom.xml b/pmd-ui/pom.xml index d572e7050e..1befc3a7e1 100644 --- a/pmd-ui/pom.xml +++ b/pmd-ui/pom.xml @@ -15,6 +15,8 @@ 1.${java.version} 1.${java.version} + + 11-ea+19 @@ -29,15 +31,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - - - @@ -76,13 +69,51 @@ net.sourceforge.pmd pmd-core - ${project.version} net.sourceforge.pmd pmd-java ${project.version} + + + + org.openjfx + javafx-base + ${openjfx.version} + provided + + + org.openjfx + javafx-controls + ${openjfx.version} + provided + + + org.openjfx + javafx-fxml + ${openjfx.version} + provided + + + org.openjfx + javafx-graphics + ${openjfx.version} + provided + + + org.openjfx + javafx-media + ${openjfx.version} + provided + + + org.openjfx + javafx-web + ${openjfx.version} + provided + + org.fxmisc.richtext richtextfx From c4857aaa20d89897f07f1ab8e23b24b1175d8756 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 29 Jul 2018 19:55:44 +0200 Subject: [PATCH 06/64] [ci] Use openjdk11 for building, add osx into the build matrix * Allow travis to cache jdk * cache $HOME/.rvm, install bundler with current rvm ruby (needed for osx) --- .travis.yml | 39 +++++++++++++++++++++++++++---------- .travis/build-deploy.sh | 7 ++++++- .travis/common-functions.sh | 9 +++++++++ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9337e5c414..7a6a99fe97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -dist: trusty -sudo: false addons: ssh_known_hosts: - web.sourceforge.net @@ -16,14 +14,33 @@ env: - secure: "geOU/7VR83KYTOCR5XkgFqnHJEnXeB6hNDE7UFcN4ZsL9uVLhxlDVWV3ujJ87nyBzggG1KfSnUx11UwOQrbBl0K6sEXo/B2q5ytOsWoSLi7+0qm/uhhw/DTBOq57p8TIDKFM7rDhO7uajSn7Y86LeZkh9wIs5265Fh1yhCkiPbczDUMsX4P0GGg2qgkIKSBw4DZf6sPDc4xjJq/4/cLnjXo/K0ZYAIoSLqDfe1gmkzMtQlad+1t8Lwv/gOJ4BNRF4a5aEvGF6kbFovFoeFWCQTKlkn6VJtY+BETGKW2RH9efGeMs7JbBbNm+nnpoNsbJ0gdmGlhSbWT8enIm72/P0ThTBJWVcLJ30tUd0UeYD9C49wbJ3RHSxsoUKP9YhHJ+XKNx+8irkJ8LPCkNMQEFE153gEVvU7tCgah9Uq6laYZv9cQE0dWzNt3//Ymls8BzY38Ha4PbrIIJqEuWwnAX6ZgTgzVtXx1AJjkDFG9KFKPhN7NfNMbh7rn5C84a1h5zrIydm+6RcIBC+xTLDEiN7djiquf3PcNtyGLcO8dNN4Uv8iU0Jw8ch3+w0PJO53v5py+IS1V8pwwYaYF2iVPOoziS0tP8MsgYVGwpTZhvz3v8x0ge8r6KJE4zdvoPtCRNr2Oo3sJGYqkt86Hu6agKFiljP5AgJNx7iQD5GQn6J3w=" - secure: "gqyPF3d75JuwZptnQQQKO6rGUILXGO09y9dZhShdX8qq5Mexa2ISk77Y/b0yyAdhJMgEglls5cWlbHkwCAB0i4yL25RE5CtQUe4er+CIKwBIs0M56ghbcOwWAFB/cXeyyWmXDHBVnVUeKm7IJ34txsEclnMzQSR/DInSzsCFMUQok8HEaWZNssMjyRgo6goKGdG5vNWGfLLY7mKGMe/6PpYJD0G8k+Na08aX06ZWph38He8O3imUAngoQrxiSp0UYmnHDkigbV7S2LdZOsj7kMxkiyigzK/P1eygHVbFAhohLroaqS9B4CBK7QeOyup2vxVKqJVzFwOCylD0786CImvaG2ZYMtvJkapvaEE0mdMlyYpHgdIkmHZu28aMW7hXEhxHyBAxKuPcj5eGCGziO+ztCvfYIA9CGs1uA4KLrED7SahvB0oXnt3KTFdRc857cWcpp2NmRKihLzVdgHlmT8zcYaec3zP1VdMoa2bmLHoaZtAwvMTcAG56FcET1p7f9v+uiU88ZeptEjTJfpAWlq34tpwZXNyIQi5IROocSHM+PKTgLAsAMP5klGascr8E0sEzREl7tg8hqEwXKym/sVKyT+HMptA3UZcrZZhm07/cmQ0pUVvbV9QDb0MzU3O2wF7vT3U7R7Fb1u0LxMjblPyEazTp8ldabVRJREwlsDc=" - secure: "JIhuqaI0i+zvuqqXiQBHpuKr7AQ8jfk6Gbr8Qgiq4yJtdEWXZGxnAT9BmlbjkgT7ABXvLgxf2CIdUOMo1yYfBlxQL/y5+e89jaVpYF3tvNAzYQ1e12VzQRsd/jDb7qvm7tw3rDHEn3dSEot7Q6KbPcL6WzWJINVMCCmOgvq9gKHgE6Y5q5EgZ5rxiXyuO27ndzcbxaor4PIaiSzHO9+AJQ7p2zDLP+kG4nKVTBX0l9VoKiYFhIpIhpbigi3jyLDMDRiWpwTWZC6P8/RXfZg/lc5ADOuM2DM8oXPpZuqOa/g31LWQOSCuEnQ1G16vbLgipSPpgAc7jYWD5cywhG9dLkiKaZDh5x0meLM2RoAgz6eAnQfTTqJ68OM9o9yXjubEedsNpNRAr9/DXMd+fbh10W2vbvL5HCNB3lic3anehhR9le7PLuEKxg654wXt3KM2PZGVWbotIyBK0CvGzqGkppvwT23QdDDqSdkWuGQIhGQ0xBOdYkwebycxP5wwPUmObG+mymQ1Be2BXvmghttsiJdKlt4CVSYOJUMus6kU32G95hdTgKblsX4J1Of2i1nYsjyMKh3k945tqXwQrIsxOOQug0oIkz24zlLaOaQcorWtJ6Y1HPaZKpVIFUEF0y8Uq/O4oB2bOYC6WDUQfpj7nRG6xbi+BeBS84m1ttCEk4g=" - matrix: - - BUILD=deploy - - BUILD=doc - - BUILD=sonar - - BUILD=coveralls matrix: fast_finish: true + include: + - name: "linux - mvn deploy" + os: linux + dist: trusty + sudo: false + env: BUILD=deploy + - name: "linux - build documentation" + os: linux + dist: trusty + sudo: false + env: BUILD=doc + - name: "linux - run sonar" + os: linux + dist: trusty + sudo: false + env: BUILD=sonar + - name: "linux - run coveralls" + os: linux + dist: trusty + sudo: false + env: BUILD=coveralls + - name: "macosx - mvn verify" + os: osx + env: BUILD=deploy before_install: - wget https://github.com/sormuras/bach/raw/master/install-jdk.sh @@ -31,9 +48,10 @@ before_install: - bash .travis/configure-maven.sh - rvm install 2.4.1 - rvm use 2.4.1 -# Install OracleJDK 10 - see https://sormuras.github.io/blog/2018-03-20-jdk-matrix.html +# Install OpenJDK 11 - see https://sormuras.github.io/blog/2018-03-20-jdk-matrix.html install: - - . ./install-jdk.sh -F 10 -L BCL + - . ./install-jdk.sh -F 11 -L GPL -W $HOME/jdk + - gem install bundler - bundle install before_script: true script: source .travis/build-$BUILD.sh @@ -71,7 +89,8 @@ notifications: cache: directories: - "$HOME/.m2" - + - "$HOME/jdk" + - "$HOME/.rvm/" # Secure Keys, that need to be set for snapshot builds # diff --git a/.travis/build-deploy.sh b/.travis/build-deploy.sh index bad3f4eb92..8618ff06d9 100755 --- a/.travis/build-deploy.sh +++ b/.travis/build-deploy.sh @@ -48,7 +48,12 @@ log_info "Building PMD ${VERSION} on branch ${TRAVIS_BRANCH}" MVN_BUILD_FLAGS="-B -V" -if travis_isPullRequest; then +if travis_isOSX; then + + log_info "The build is running on OSX" + ./mvnw verify $MVN_BUILD_FLAGS + +elif travis_isPullRequest; then log_info "This is a pull-request build" ./mvnw verify $MVN_BUILD_FLAGS diff --git a/.travis/common-functions.sh b/.travis/common-functions.sh index 7c4742b5bd..887d15b759 100755 --- a/.travis/common-functions.sh +++ b/.travis/common-functions.sh @@ -10,6 +10,7 @@ echo "TRAVIS_SECURE_ENV_VARS: ${TRAVIS_SECURE_ENV_VARS}" echo "TRAVIS_BRANCH: ${TRAVIS_BRANCH}" echo "TRAVIS_TAG: ${TRAVIS_TAG}" echo "TRAVIS_ALLOW_FAILURE: ${TRAVIS_ALLOW_FAILURE}" +echo "TRAVIS_OS_NAME: ${TRAVIS_OS_NAME}" function travis_isPullRequest() { if [ "${TRAVIS_REPO_SLUG}" != "pmd/pmd" ] || [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then @@ -27,6 +28,14 @@ function travis_isPush() { fi } +function travis_isOSX() { + if [[ $TRAVIS_OS_NAME == 'osx' ]]; then + return 0 + else + return 1 + fi +} + function has_docs_change() { if [[ $(git diff --name-only ${TRAVIS_COMMIT_RANGE}) = *"docs/"* ]]; then log_info "Checking for changes in docs/ (TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE}): changes found" From 53a763d9016eae41a88dd1714443013a328a875f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 15 Aug 2018 21:20:38 +0200 Subject: [PATCH 07/64] Make run.sh / designer.bat compatible with java/openjfx * Use JAVAFX_HOME to add extra classpath for openjfx * Add back the jre_specific_vm_options when needed --- pmd-dist/src/main/scripts/designer.bat | 47 +++++++++++- pmd-dist/src/main/scripts/run.sh | 102 ++++++++++++++++++++++--- 2 files changed, 137 insertions(+), 12 deletions(-) diff --git a/pmd-dist/src/main/scripts/designer.bat b/pmd-dist/src/main/scripts/designer.bat index f274809ac2..60a4fecc63 100644 --- a/pmd-dist/src/main/scripts/designer.bat +++ b/pmd-dist/src/main/scripts/designer.bat @@ -3,4 +3,49 @@ set TOPDIR=%~dp0.. set OPTS= set MAIN_CLASS=net.sourceforge.pmd.util.fxdesigner.DesignerStarter -java -classpath "%TOPDIR%\lib\*" %OPTS% %MAIN_CLASS% %* + +:: sets the jver variable to the java version, eg 901 for 9.0.1+x or 180 for 1.8.0_171-b11 +:: sets the jvendor variable to either java (oracle) or openjdk +for /f tokens^=1^,3^,4^,5^ delims^=.-_+^"^ %%j in ('java -version 2^>^&1 ^| find "version"') do ( + set jvendor=%%j + if %%l EQU ea ( + set /A "jver=%%k00" + ) else ( + set /A jver=%%k%%l%%m + ) +) + +Set "jreopts=" +:: oracle java 9 and 10 has javafx included as a module +if /I "%jvendor%" EQU "java" ( + if %jver% GEQ 900 ( + if %jver% LSS 1100 ( + :: enable reflection + Set jreopts=--add-opens javafx.controls/javafx.scene.control.skin=ALL-UNNAMED + ) + ) +) + +set "_needjfxlib=0" +if /I "%jvendor%" EQU "openjdk" set _needjfxlib=1 +if /I "%jvendor%" EQU "java" ( + if %jver% GEQ 1100 set _needjfxlib=1 +) +if %_needjfxlib% EQU 1 ( + if %jver% LSS 1000 ( + echo For openjfx at least java 10 is required. + pause + exit + ) + if [%JAVAFX_HOME%] EQU [] ( + echo The environment variable JAVAFX_HOME is missing. + pause + exit + ) + set "classpath=%TOPDIR%\lib\*;%JAVAFX_HOME%\lib\*" +) else ( + set "classpath=%TOPDIR%\lib\*" +) + + +java %jreopts% -classpath "%classpath%" %OPTS% %MAIN_CLASS% %* diff --git a/pmd-dist/src/main/scripts/run.sh b/pmd-dist/src/main/scripts/run.sh index 908f8f6c98..9a5ce0d3e0 100755 --- a/pmd-dist/src/main/scripts/run.sh +++ b/pmd-dist/src/main/scripts/run.sh @@ -29,6 +29,7 @@ cygwin_paths() { # For Cygwin, switch paths to Windows format before running java if ${cygwin} ; then [ -n "${JAVA_HOME}" ] && JAVA_HOME=$(cygpath --windows "${JAVA_HOME}") + [ -n "${JAVAFX_HOME}" ] && JAVAFX_HOME=$(cygpath --windows "${JAVAFX_HOME}") [ -n "${DIRECTORY}" ] && DIRECTORY=$(cygpath --windows "${DIRECTORY}") classpath=$(cygpath --path --windows "${classpath}") fi @@ -38,6 +39,7 @@ convert_cygwin_vars() { # If cygwin, convert to Unix form before manipulating if ${cygwin} ; then [ -n "${JAVA_HOME}" ] && JAVA_HOME=$(cygpath --unix "${JAVA_HOME}") + [ -n "${JAVAFX_HOME}" ] && JAVAFX_HOME=$(cygpath --unix "${JAVAFX_HOME}") [ -n "${CLASSPATH}" ] && CLASSPATH=$(cygpath --path --unix "${CLASSPATH}") fi } @@ -74,6 +76,91 @@ check_lib_dir() { fi } +function script_exit() { + echo $1 >&2 + exit 1 +} + +determine_java_version() { + local full_ver=$(java -version 2>&1) + # java_ver is eg "18" for java 1.8, "90" for java 9.0, "100" for java 10.0.x + readonly java_ver=$(echo $full_ver | sed -n '{ + # replace early access versions, e.g. 11-ea with 11.0.0 + s/-ea/.0.0/ + # replace versions such as 10 with 10.0.0 + s/version "\([0-9]\{1,\}\)"/version "\1.0.0"/ + # extract the major and minor parts of the version + s/^.* version "\(.*\)\.\(.*\)\..*".*$/\1\2/p + }') + # java_vendor is either java (oracle) or openjdk + readonly java_vendor=$(echo $full_ver | sed -n -e 's/^\(.*\) version .*$/\1/p') +} + +jre_specific_vm_options() { + if [ "${APPNAME}" = "designer" ] + then + options="" + + if [ "$java_ver" -ge 80 ] && [ "$java_ver" -lt 90 ] + then + # no options needed for java8. + options="" + elif [ "$java_ver" -ge 90 ] && [ "$java_ver" -lt 110 ] && [ "$java_vendor" = "java" ] + then + # java9 and java10 from oracle contain javafx as a module + # open internal module of javafx to reflection (for our TreeViewWrapper) + options="--add-opens javafx.controls/javafx.scene.control.skin=ALL-UNNAMED" + # The rest here is for RichtextFX + options+=" --add-opens javafx.graphics/javafx.scene.text=ALL-UNNAMED" + options+=" --add-opens javafx.graphics/com.sun.javafx.scene.text=ALL-UNNAMED" + options+=" --add-opens javafx.graphics/com.sun.javafx.text=ALL-UNNAMED" + options+=" --add-opens javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED" + # Warn of remaining illegal accesses + options+=" --illegal-access=warn" + elif [ "$java_vendor" = "openjdk" ] || ( [ "$java_vendor" = "java" ] && [ "$java_ver" -ge 110 ] ) + then + # openjdk and java11 from oracle onwards do not contain javafx directly + # there are no extra options either - javafx will be added to the classpath without modules + options="" + fi + + echo $options + else + echo "" + fi +} + +function add_pmd_classpath() { + if [ -n "$classpath" ]; then + classpath="$classpath:${LIB_DIR}/*" + else + classpath="${LIB_DIR}/*" + fi +} + +function add_openjfx_classpath() { + if [ "${APPNAME}" = "designer" ] + then + if [ "$java_vendor" = "openjdk" ] && [ "$java_ver" -lt 100 ] + then + script_exit "For openjfx at least java 10 is required" + elif [ "$java_vendor" = "openjdk" ] || ( [ "$java_vendor" = "java" ] && [ "$java_ver" -ge 110 ] ) + then + # openjfx is required for openjdk builds and oracle java 11 or later + if [ -z "${JAVAFX_HOME}" ] + then + script_exit "The environment variable JAVAFX_HOME is missing." + else + if [ -n "$classpath" ]; then + classpath="$classpath:${JAVAFX_HOME}/lib/*" + else + classpath="${JAVAFX_HOME}/lib/*" + fi + fi + fi + fi +} + readonly APPNAME="${1}" if [ -z "${APPNAME}" ]; then usage @@ -114,19 +201,12 @@ convert_cygwin_vars classpath=$CLASSPATH -cd "${CWD}" - -for jarfile in "${LIB_DIR}"/*.jar; do - if [ -n "$classpath" ]; then - classpath=$classpath:$jarfile - else - classpath=$jarfile - fi -done +add_pmd_classpath +determine_java_version +add_openjfx_classpath cygwin_paths java_heapsize_settings -java ${HEAPSIZE} -cp "${classpath}" "${CLASSNAME}" "$@" - +java ${HEAPSIZE} $(jre_specific_vm_options) -cp "${classpath}" "${CLASSNAME}" "$@" From 9529dd9ad7c22072edf0fefbcfe0d81e151fe4d4 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 15 Aug 2018 23:21:09 +0200 Subject: [PATCH 08/64] [doc] Minimum java version for building is now java10, mention JAVAFX_HOME --- BUILDING.md | 5 +++-- docs/pages/pmd/devdocs/building.md | 5 ++--- docs/pages/pmd/userdocs/installation.md | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 78865d329f..b148affeab 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,7 +1,8 @@ # How to build PMD -PMD uses [Maven](https://maven.apache.org/) and requires [Java 9](http://www.oracle.com/technetwork/java/javase/downloads/index.html) -for building. +PMD uses [Maven](https://maven.apache.org/) and requires at least Java 10 for building. +You can get Java 10 from [Oracle](http://www.oracle.com/technetwork/java/javase/downloads/index.html) +or from the [OpenJDK Project](http://jdk.java.net). PMD uses the [maven wrapper](https://github.com/takari/maven-wrapper), so you can simply build PMD as following: diff --git a/docs/pages/pmd/devdocs/building.md b/docs/pages/pmd/devdocs/building.md index 90ca2caf60..c76ed1db04 100644 --- a/docs/pages/pmd/devdocs/building.md +++ b/docs/pages/pmd/devdocs/building.md @@ -10,10 +10,9 @@ author: Tom Copeland, Xavier Le Vourch # Compiling PMD -* JDK 9 or higher -* [Apache Maven](http://maven.apache.org) 3 or later. +* JDK 10 or higher -{% include note.html content="While Java 9 is required for building, running PMD only requires Java 7 (or Java 8 for Apex)." %} +{% include note.html content="While Java 10 is required for building, running PMD only requires Java 7 (or Java 8 for Apex and the Designer)." %} You’ll need to either check out the source code or download the latest source release. Assuming you’ve got the latest source release, unzip it to a directory: diff --git a/docs/pages/pmd/userdocs/installation.md b/docs/pages/pmd/userdocs/installation.md index 11e01f02aa..fc9d31ab32 100644 --- a/docs/pages/pmd/userdocs/installation.md +++ b/docs/pages/pmd/userdocs/installation.md @@ -17,6 +17,9 @@ sidebar: pmd_sidebar * For Windows: [Winzip](http://winzip.com) or the free [7-zip](http://www.7-zip.org/) * For Linux / Unix: [InfoZip](http://www.info-zip.org/pub/infozip/) +{% include note.html content="For executing the Designer (./run.sh designer) using [OpenJDK](http://jdk.java.net) or Java 11, you need additionally [OpenJFX](http://jdk.java.net). Download it, extract it and set the environment variable JAVAFX_HOME." %} + + ### Installation PMD is distributed as a zip archive, which includes both [PMD](#running-pmd-via-command-line) and [CPD](/pmd_userdocs_cpd.html). From cb323a34962c25b381f9827d104e464d2e2ce059 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 15 Aug 2018 23:40:13 +0200 Subject: [PATCH 09/64] Enforce building with at least java10 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16c89019e2..91a3a263ab 100644 --- a/pom.xml +++ b/pom.xml @@ -519,7 +519,7 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code - [9,) + [10,) From 94dc4694f206d81237364b177bc7dc312a170285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Thu, 16 Aug 2018 22:21:28 +0200 Subject: [PATCH 10/64] Use rule tag introduced by #1306 --- docs/pages/release_notes.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index ad2ae7d665..24f0c24b55 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -53,14 +53,11 @@ This is a minor release. #### Deprecated rules -* The Java rules [`VariableNamingConventions`](pmd_rules_java_codestyle.html#variablenamingconventions), - [`MIsLeadingVariableName`](pmd_rules_java_codestyle.html#misleadingvariablename), - [`SuspiciousConstantFieldName`](pmd_rules_java_codestyle.html#suspiciousconstantfieldname), - and [`AvoidPrefixingMethodParameters`](pmd_rules_java_codestyle.html#avoidprefixingmethodparameters) are now deprecated, - and will be removed with version 7.0.0. They are replaced by the more general - [`FieldNamingConventions`](pmd_rules_java_codestyle.html#fieldnamingconventions), - [`FormalParameterNamingConventions`](pmd_rules_java_codestyle.html#formalparameternamingconventions), and - [`LocalVariableNamingConventions`](pmd_rules_java_codestyle.html#localvariablenamingconventions). +* The Java rules {% rule java/codestyle/VariableNamingConventions %}, {% rule java/codestyle/MIsLeadingVariableName %}, + {% rule java/codestyle/SuspiciousConstantFieldName %}, and {% rule java/codestyle/AvoidPrefixingMethodParameters %} are + now deprecated, and will be removed with version 7.0.0. They are replaced by the more general + {% rule java/codestyle/FieldNamingConventions %}, {% rule java/codestyle/FormalParameterNamingConventions %}, and + {% rule java/codestyle/LocalVariableNamingConventions %}. ### External Contributions From 53b2b288ac996f1f645b4eb3e2f13a6af91ace7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sat, 18 Aug 2018 16:44:45 +0200 Subject: [PATCH 11/64] Generate the release notes' toc --- .travis/render_release_notes.rb | 1 + docs/_plugins/tocmaker_block.rb | 51 +++++++++++++++++++++++++++++++++ docs/pages/release_notes.md | 10 ++----- 3 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 docs/_plugins/tocmaker_block.rb diff --git a/.travis/render_release_notes.rb b/.travis/render_release_notes.rb index d8acab0e74..dc0eb0877d 100755 --- a/.travis/render_release_notes.rb +++ b/.travis/render_release_notes.rb @@ -13,6 +13,7 @@ require "safe_yaml" # include some custom liquid extensions require_relative "../docs/_plugins/rule_tag" +require_relative "../docs/_plugins/tocmaker_block" require_relative "../docs/_plugins/custom_filters" # explicitly setting safe mode to get rid of the warning diff --git a/docs/_plugins/tocmaker_block.rb b/docs/_plugins/tocmaker_block.rb new file mode 100644 index 0000000000..e62ee49374 --- /dev/null +++ b/docs/_plugins/tocmaker_block.rb @@ -0,0 +1,51 @@ +# Generates a table of contents based on markdown headers in the body +# +# The block's arg may be an int describing the maximum depth at which +# headers are added to the toc + +class TocMakerBlock < Liquid::Block + # include Enumerable + + def initialize(tag_name, arg, tokens) + super + @max_depth = arg.to_s.empty? ? 100 : arg.to_i + @body = tokens + end + + def to_internal_link(header) + url = header.downcase.gsub(/\s+/, "-") + + "[#{header}](##{url})" + end + + def render(context) + + contents = @body.render(context) + + + headers = contents.lines.map {|l| + if /^(#+)\s+(\S.*)$/ =~ l + [$1.length, $2] + end + }.compact + + min_indent = headers.min_by {|t| t[0]}[0] + + headers = headers.map {|t| + actual_depth = t[0] - min_indent + if actual_depth < @max_depth then + + indent = " " * actual_depth + + "#{indent}* #{to_internal_link(t[1])}" + end + }.compact + + headers.unshift("### Table Of Contents\n") + + headers.join("\n") + contents + end +end + + +Liquid::Template.register_tag('tocmaker', TocMakerBlock) \ No newline at end of file diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a324c2ee28..efa8e49230 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -10,13 +10,7 @@ The PMD team is pleased to announce PMD {{ site.pmd.version }}. This is a {{ site.pmd.release_type }} release. -### Table Of Contents - -* [New and noteworthy](#new-and-noteworthy) - * [New Rules](#new-rules) -* [Fixed Issues](#fixed-issues) -* [API Changes](#api-changes) -* [External Contributions](#external-contributions) +{% tocmaker %} ### New and noteworthy @@ -77,3 +71,5 @@ This is a {{ site.pmd.release_type }} release. * [#1289](https://github.com/pmd/pmd/pull/1289): \[java] UselessParentheses: Fix false positive with assignments - [cobratbq](https://github.com/cobratbq) * [#1290](https://github.com/pmd/pmd/pull/1290): \[docs] \[GSoC] Create the documentation about pmdtester - [BBG](https://github.com/djydewang) * [#1256](https://github.com/pmd/pmd/pull/1256): \[java] #940 Avoid JUnit 4 false positives for JUnit 5 tests - [Alex Shesterov](https://github.com/vovkss) + +{% endtocmaker %} From 3cf456dbfa63d8809d9b728b4da43ec4589ba397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sat, 18 Aug 2018 17:39:29 +0200 Subject: [PATCH 12/64] Update release script and doc --- do-release.sh | 9 +++------ docs/_plugins/tocmaker_block.rb | 2 +- docs/pages/pmd/projectdocs/committers/releasing.md | 9 +++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/do-release.sh b/do-release.sh index 5417ffd455..d11a80298a 100755 --- a/do-release.sh +++ b/do-release.sh @@ -149,12 +149,7 @@ The PMD team is pleased to announce PMD {{ site.pmd.version }}. This is a {{ site.pmd.release_type }} release. -### Table Of Contents - -* [New and noteworthy](#new-and-noteworthy) -* [Fixed Issues](#fixed-issues) -* [API Changes](#api-changes) -* [External Contributions](#external-contributions) +{% tocmaker %} ### New and noteworthy @@ -164,6 +159,8 @@ This is a {{ site.pmd.release_type }} release. ### External Contributions +{% endtocmaker %} + EOF git commit -a -m "Prepare next development version" diff --git a/docs/_plugins/tocmaker_block.rb b/docs/_plugins/tocmaker_block.rb index e62ee49374..53b0eb28d9 100644 --- a/docs/_plugins/tocmaker_block.rb +++ b/docs/_plugins/tocmaker_block.rb @@ -48,4 +48,4 @@ class TocMakerBlock < Liquid::Block end -Liquid::Template.register_tag('tocmaker', TocMakerBlock) \ No newline at end of file +Liquid::Template.register_tag('tocmaker', TocMakerBlock) diff --git a/docs/pages/pmd/projectdocs/committers/releasing.md b/docs/pages/pmd/projectdocs/committers/releasing.md index 5800289cac..34b5ac29aa 100644 --- a/docs/pages/pmd/projectdocs/committers/releasing.md +++ b/docs/pages/pmd/projectdocs/committers/releasing.md @@ -151,12 +151,7 @@ The PMD team is pleased to announce PMD {{ site.pmd.version }}. This is a {{ site.pmd.release_type }} release. -### Table Of Contents - -* [New and noteworthy](#new-and-noteworthy) -* [Fixed Issues](#fixed-issues) -* [API Changes](#api-changes) -* [External Contributions](#external-contributions) +{% tocmaker %} ### New and noteworthy @@ -166,6 +161,8 @@ This is a {{ site.pmd.release_type }} release. ### External Contributions +{% endtocmaker %} + ``` {%endraw%} From c7455012d4edb9da6bb334b9f4ef0bf47cbc2d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sat, 18 Aug 2018 20:30:19 +0200 Subject: [PATCH 13/64] Generate toc conditionnally --- docs/_plugins/tocmaker_block.rb | 18 ++++++++++++++---- docs/pages/release_notes.md | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/_plugins/tocmaker_block.rb b/docs/_plugins/tocmaker_block.rb index 53b0eb28d9..5bcffe8095 100644 --- a/docs/_plugins/tocmaker_block.rb +++ b/docs/_plugins/tocmaker_block.rb @@ -1,14 +1,20 @@ # Generates a table of contents based on markdown headers in the body # -# The block's arg may be an int describing the maximum depth at which -# headers are added to the toc +# The block has 2 optional args: +# * A variable name. If provided, the toc will only be generated if the var is true +# * An integer, describing the maximum depth at which headers are added to the toc class TocMakerBlock < Liquid::Block # include Enumerable def initialize(tag_name, arg, tokens) super - @max_depth = arg.to_s.empty? ? 100 : arg.to_i + + condition, depth = arg.split + + @max_depth = depth.to_s.empty? ? 100 : depth.to_i + @condition_var = condition.strip + @body = tokens end @@ -22,6 +28,10 @@ class TocMakerBlock < Liquid::Block contents = @body.render(context) + if @condition_var && !context[@condition_var] + # If the condition is false, the toc is not generated + return contents + end headers = contents.lines.map {|l| if /^(#+)\s+(\S.*)$/ =~ l @@ -29,7 +39,7 @@ class TocMakerBlock < Liquid::Block end }.compact - min_indent = headers.min_by {|t| t[0]}[0] + min_indent = headers.map {|t| t[0]}.min headers = headers.map {|t| actual_depth = t[0] - min_indent diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index efa8e49230..4756d84652 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -10,7 +10,7 @@ The PMD team is pleased to announce PMD {{ site.pmd.version }}. This is a {{ site.pmd.release_type }} release. -{% tocmaker %} +{% tocmaker is_release_notes_processor %} ### New and noteworthy From d2cdcb726270d77afbb8b713bd9fe81acbae86f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sat, 18 Aug 2018 22:03:13 +0200 Subject: [PATCH 14/64] Bug --- docs/_plugins/tocmaker_block.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_plugins/tocmaker_block.rb b/docs/_plugins/tocmaker_block.rb index 5bcffe8095..612d95c850 100644 --- a/docs/_plugins/tocmaker_block.rb +++ b/docs/_plugins/tocmaker_block.rb @@ -13,7 +13,7 @@ class TocMakerBlock < Liquid::Block condition, depth = arg.split @max_depth = depth.to_s.empty? ? 100 : depth.to_i - @condition_var = condition.strip + @condition_var = condition.strip unless condition.to_s.empty? @body = tokens end From 4066ca9986fc81bb822865acac0129f966ab8046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sun, 19 Aug 2018 00:19:02 +0200 Subject: [PATCH 15/64] Update tocmaker_block.rb --- docs/_plugins/tocmaker_block.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/_plugins/tocmaker_block.rb b/docs/_plugins/tocmaker_block.rb index 612d95c850..990d02e7a8 100644 --- a/docs/_plugins/tocmaker_block.rb +++ b/docs/_plugins/tocmaker_block.rb @@ -5,7 +5,6 @@ # * An integer, describing the maximum depth at which headers are added to the toc class TocMakerBlock < Liquid::Block - # include Enumerable def initialize(tag_name, arg, tokens) super From bf8964f9a49687cff3b606ab7aff4e37362a0317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sun, 19 Aug 2018 16:28:12 +0200 Subject: [PATCH 16/64] Fix inconsistent versioning Since we don't use a SNAPSHOT version in _config.yml during development, the release note's version is not SNAPSHOT either. --- do-release.sh | 2 +- docs/pages/pmd/projectdocs/committers/releasing.md | 2 +- docs/pages/release_notes.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/do-release.sh b/do-release.sh index 5417ffd455..9ccdda3783 100755 --- a/do-release.sh +++ b/do-release.sh @@ -143,7 +143,7 @@ permalink: pmd_release_notes.html keywords: changelog, release notes --- -## {{ site.pmd.date }} - {{ site.pmd.version | append_unless: is_release_version, "-SNAPSHOT" }} +## {{ site.pmd.date }} - {{ site.pmd.version }} The PMD team is pleased to announce PMD {{ site.pmd.version }}. diff --git a/docs/pages/pmd/projectdocs/committers/releasing.md b/docs/pages/pmd/projectdocs/committers/releasing.md index 5800289cac..3a907ac467 100644 --- a/docs/pages/pmd/projectdocs/committers/releasing.md +++ b/docs/pages/pmd/projectdocs/committers/releasing.md @@ -145,7 +145,7 @@ permalink: pmd_release_notes.html keywords: changelog, release notes --- -## {{ site.pmd.date }} - {{ site.pmd.version | append_unless: is_release_version, "-SNAPSHOT" }} +## {{ site.pmd.date }} - {{ site.pmd.version }} The PMD team is pleased to announce PMD {{ site.pmd.version }}. diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a324c2ee28..f0b6dc6643 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -4,7 +4,7 @@ permalink: pmd_release_notes.html keywords: changelog, release notes --- -## {{ site.pmd.date }} - {{ site.pmd.version | append_unless: is_release_version, "-SNAPSHOT" }} +## {{ site.pmd.date }} - {{ site.pmd.version }} The PMD team is pleased to announce PMD {{ site.pmd.version }}. From 3269f3a6cacdae414882d9882d9161ec36446042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sun, 19 Aug 2018 17:23:02 +0200 Subject: [PATCH 17/64] Render release notes before pushing to sourceforge --- .travis/build-deploy.sh | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/.travis/build-deploy.sh b/.travis/build-deploy.sh index bad3f4eb92..1d425457d6 100755 --- a/.travis/build-deploy.sh +++ b/.travis/build-deploy.sh @@ -90,13 +90,33 @@ elif travis_isPush; then else log_success "Successfully uploaded pmd-*-${VERSION}.zip to sourceforge" fi - rsync -avh docs/pages/release_notes.md ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ReadMe.md - if [ $? -ne 0 ]; then + + ) + + ( # UPLOAD RELEASE NOTES TO SOURCEFORGE + + # This handler is called if any command fails + function release_notes_fail() { log_error "Error while uploading release_notes.md as ReadMe.md to sourceforge!" log_error "Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" - else - log_success "Successfully uploaded release_notes.md as ReadMe.md to sourceforge" - fi + } + + # exit subshell after trap + set -e + trap release_notes_fail ERR + + RELEASE_NOTES_TMP=$(mktemp -t) + + .travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6 > "$RELEASE_NOTES_TMP" + + rsync -avh "$RELEASE_NOTES_TMP" ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ReadMe.md + + log_success "Successfully uploaded release_notes.md as ReadMe.md to sourceforge" + + ) + + + ( upload_baseline From 40ce9313aef9adcbefb4769d9639751286c14a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 20 Aug 2018 18:04:27 +0200 Subject: [PATCH 18/64] Deprecate R[UN]SIGNEDSHIFT No usages to report --- pmd-java/etc/grammar/Java.jjt | 8 ++++---- .../sourceforge/pmd/lang/java/ast/ASTRSIGNEDSHIFT.java | 4 ++++ .../pmd/lang/java/ast/ASTRUNSIGNEDSHIFT.java | 4 ++++ .../pmd/lang/java/ast/ASTShiftExpression.java | 7 +------ .../pmd/lang/java/ast/JavaParserDecoratedVisitor.java | 8 ++++++++ .../pmd/lang/java/ast/JavaParserVisitorAdapter.java | 10 ++++++++++ .../pmd/lang/java/ast/JavaParserVisitorDecorator.java | 8 ++++++++ .../pmd/lang/java/rule/AbstractJavaRule.java | 10 ++++++++++ 8 files changed, 49 insertions(+), 10 deletions(-) diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index ed713afee8..991335622f 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -2097,8 +2097,8 @@ void ShiftExpression() #ShiftExpression(>1): AdditiveExpression() ( LOOKAHEAD(2) ( "<<" { jjtThis.setImage("<<");} - | RSIGNEDSHIFT() - | RUNSIGNEDSHIFT() + | RSIGNEDSHIFT() { jjtThis.setImage(">>"); } + | RUNSIGNEDSHIFT() { jjtThis.setImage(">>>"); } ) AdditiveExpression() )* } @@ -2585,7 +2585,7 @@ void AssertStatement() : * type declaration syntax with generics clean */ -void RUNSIGNEDSHIFT(): +void RUNSIGNEDSHIFT(): // TODO 7.0.0 make #void {} { ( LOOKAHEAD({ getToken(1).kind == GT && @@ -2594,7 +2594,7 @@ void RUNSIGNEDSHIFT(): ) } -void RSIGNEDSHIFT(): +void RSIGNEDSHIFT(): // TODO 7.0.0 make #void {} { ( LOOKAHEAD({ getToken(1).kind == GT && diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRSIGNEDSHIFT.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRSIGNEDSHIFT.java index a48e0ae171..4e287e8fad 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRSIGNEDSHIFT.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRSIGNEDSHIFT.java @@ -5,6 +5,10 @@ package net.sourceforge.pmd.lang.java.ast; +/** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ +@Deprecated public class ASTRSIGNEDSHIFT extends AbstractJavaNode { public ASTRSIGNEDSHIFT(int id) { super(id); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRUNSIGNEDSHIFT.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRUNSIGNEDSHIFT.java index 15753e797d..9e2568014d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRUNSIGNEDSHIFT.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTRUNSIGNEDSHIFT.java @@ -5,6 +5,10 @@ package net.sourceforge.pmd.lang.java.ast; +/** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ +@Deprecated public class ASTRUNSIGNEDSHIFT extends AbstractJavaNode { public ASTRUNSIGNEDSHIFT(int id) { super(id); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTShiftExpression.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTShiftExpression.java index 2e664764d9..bff4995393 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTShiftExpression.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTShiftExpression.java @@ -39,12 +39,7 @@ public class ASTShiftExpression extends AbstractJavaTypeNode { * Returns the image of the operator, i.e. "<<", ">>", or ">>>". */ public String getOperator() { - if (getImage() != null) { - return getImage(); // << - } - - ASTRSIGNEDSHIFT rsshift = (ASTRSIGNEDSHIFT) jjtGetChild(1); - return rsshift != null ? ">>" : ">>>"; + return getImage(); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserDecoratedVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserDecoratedVisitor.java index e6bd5306e2..0e55523479 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserDecoratedVisitor.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserDecoratedVisitor.java @@ -252,14 +252,22 @@ public class JavaParserDecoratedVisitor implements JavaParserVisitor { } + /** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ @Override + @Deprecated public Object visit(ASTRUNSIGNEDSHIFT node, Object data) { visitor.visit(node, data); return visit((JavaNode) node, data); } + /** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ @Override + @Deprecated public Object visit(ASTRSIGNEDSHIFT node, Object data) { visitor.visit(node, data); return visit((JavaNode) node, data); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorAdapter.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorAdapter.java index b62e67f9bb..210b09c0b4 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorAdapter.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorAdapter.java @@ -156,12 +156,22 @@ public class JavaParserVisitorAdapter implements JavaParserVisitor { return visit((JavaNode) node, data); } + + /** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ @Override + @Deprecated public Object visit(ASTRUNSIGNEDSHIFT node, Object data) { return visit((JavaNode) node, data); } + + /** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ @Override + @Deprecated public Object visit(ASTRSIGNEDSHIFT node, Object data) { return visit((JavaNode) node, data); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorDecorator.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorDecorator.java index 028c65e96d..7451c09a30 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorDecorator.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitorDecorator.java @@ -199,13 +199,21 @@ public class JavaParserVisitorDecorator implements JavaParserControllessVisitor } + /** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ @Override + @Deprecated public Object visit(ASTRUNSIGNEDSHIFT node, Object data) { return visitor.visit(node, data); } + /** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ @Override + @Deprecated public Object visit(ASTRSIGNEDSHIFT node, Object data) { return visitor.visit(node, data); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java index 73a65444ac..0e17201d7a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java @@ -230,12 +230,22 @@ public abstract class AbstractJavaRule extends AbstractRule implements JavaParse return visit((JavaNode) node, data); } + + /** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ @Override + @Deprecated public Object visit(ASTRUNSIGNEDSHIFT node, Object data) { return visit((JavaNode) node, data); } + + /** + * @deprecated Will be removed in 7.0.0. Use {@link ASTShiftExpression#getOperator()} + */ @Override + @Deprecated public Object visit(ASTRSIGNEDSHIFT node, Object data) { return visit((JavaNode) node, data); } From d528dcd5d45582229ab3410deb7c40b2143d015d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 20 Aug 2018 18:35:46 +0200 Subject: [PATCH 19/64] Update release notes, refs #1312 --- docs/pages/release_notes.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a324c2ee28..2db1ef9031 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -65,6 +65,11 @@ This is a {{ site.pmd.release_type }} release. that this class is very specific to Java and not suitable for other languages. It has only been used for `YAHTMLRenderer`, which has been rewritten to work without these classes. +* The nodes RUNSIGNEDSHIFT and RSIGNEDSHIFT are deprecated and will be removed from the AST with PMD 7.0.0. + These represented the operator of ShiftExpression in two cases out of three, but they're not needed and + make ShiftExpression inconsistent. The operator of a ShiftExpression is now accessible through + ShiftExpression#getOperator. + ### External Contributions * [#109](https://github.com/pmd/pmd/pull/109): \[java] Add two linguistics rules under naming - [Arda Aslan](https://github.com/ardaasln) From 241eda93b92c9ff0f1711016ee0ee15a153f2180 Mon Sep 17 00:00:00 2001 From: Jeff Hube Date: Tue, 21 Aug 2018 13:50:47 -0400 Subject: [PATCH 20/64] Add OneDeclarationPerStatement --- .../resources/category/apex/codestyle.xml | 26 +++++++++++ .../main/resources/rulesets/apex/ruleset.xml | 11 +++++ .../rule/codestyle/CodeStyleRulesTest.java | 1 + .../xml/OneDeclarationPerStatement.xml | 46 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerStatement.xml diff --git a/pmd-apex/src/main/resources/category/apex/codestyle.xml b/pmd-apex/src/main/resources/category/apex/codestyle.xml index 6254e17d13..1d30583fed 100644 --- a/pmd-apex/src/main/resources/category/apex/codestyle.xml +++ b/pmd-apex/src/main/resources/category/apex/codestyle.xml @@ -149,6 +149,32 @@ public class Foo { + + Foo + 1 + + + + + + + + + + + + + + + + 3 + + + + + + + diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/CodeStyleRulesTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/CodeStyleRulesTest.java index 5d484265d8..eddb55d599 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/CodeStyleRulesTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/CodeStyleRulesTest.java @@ -17,6 +17,7 @@ public class CodeStyleRulesTest extends SimpleAggregatorTst { addRule(RULESET, "IfElseStmtsMustUseBraces"); addRule(RULESET, "IfStmtsMustUseBraces"); addRule(RULESET, "MethodNamingConventions"); + addRule(RULESET, "OneDeclarationPerStatement"); addRule(RULESET, "VariableNamingConventions"); addRule(RULESET, "WhileLoopsMustUseBraces"); } diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerStatement.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerStatement.xml new file mode 100644 index 0000000000..b24f7a8284 --- /dev/null +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerStatement.xml @@ -0,0 +1,46 @@ + + + + + + one field declaration per statement + 1 + + + + + one variable declaration per statement + 1 + + + + + + all is well + 0 + + + + From a4176126cae40870f2ed2a001ef95a52451cb31a Mon Sep 17 00:00:00 2001 From: Jeff Hube Date: Tue, 21 Aug 2018 17:01:01 -0400 Subject: [PATCH 21/64] Fix rule description --- pmd-apex/src/main/resources/category/apex/codestyle.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pmd-apex/src/main/resources/category/apex/codestyle.xml b/pmd-apex/src/main/resources/category/apex/codestyle.xml index 1d30583fed..99ee95f0b3 100644 --- a/pmd-apex/src/main/resources/category/apex/codestyle.xml +++ b/pmd-apex/src/main/resources/category/apex/codestyle.xml @@ -154,7 +154,10 @@ public class Foo { message="Use one line for each declaration, it enhances code readability." class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_codestyle.html#onedeclarationperstatement"> - Foo + +Apex allows the use of several variables declaration of the same type on one line. However, it +can lead to quite messy code. This rule looks for several declarations on the same line. + 1 From 780a9e5dde213c75910918531bc5bf6177808237 Mon Sep 17 00:00:00 2001 From: Jeff Hube Date: Wed, 22 Aug 2018 11:20:45 -0400 Subject: [PATCH 22/64] Fix pr comments --- pmd-apex/src/main/resources/category/apex/codestyle.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pmd-apex/src/main/resources/category/apex/codestyle.xml b/pmd-apex/src/main/resources/category/apex/codestyle.xml index 99ee95f0b3..9530830459 100644 --- a/pmd-apex/src/main/resources/category/apex/codestyle.xml +++ b/pmd-apex/src/main/resources/category/apex/codestyle.xml @@ -151,7 +151,7 @@ public class Foo { @@ -163,7 +163,8 @@ can lead to quite messy code. This rule looks for several declarations on the sa 1] | +//FieldDeclarationStatements[count(FieldDeclaration) > 1] ]]> From 8a9e0b9effb7ee7efe293ec3fa6fd53093890a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 27 Aug 2018 02:40:41 +0200 Subject: [PATCH 23/64] Remove page title from the toc --- docs/pages/release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index cd85be741d..7c3898555d 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -4,7 +4,7 @@ permalink: pmd_release_notes.html keywords: changelog, release notes --- -## {{ site.pmd.date }} - {{ site.pmd.version }} +# {{ site.pmd.date }} - {{ site.pmd.version }} The PMD team is pleased to announce PMD {{ site.pmd.version }}. From 5cf23344139d0230ec97b47d426c9e9f727f0570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Mon, 27 Aug 2018 03:02:44 -0300 Subject: [PATCH 24/64] Allow both strict and lax checking mode --- .../resources/category/apex/codestyle.xml | 21 +++- .../rule/codestyle/CodeStyleRulesTest.java | 2 +- .../codestyle/xml/OneDeclarationPerLine.xml | 95 +++++++++++++++++++ .../xml/OneDeclarationPerStatement.xml | 46 --------- 4 files changed, 112 insertions(+), 52 deletions(-) create mode 100644 pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerLine.xml delete mode 100644 pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerStatement.xml diff --git a/pmd-apex/src/main/resources/category/apex/codestyle.xml b/pmd-apex/src/main/resources/category/apex/codestyle.xml index 9530830459..0387f32b61 100644 --- a/pmd-apex/src/main/resources/category/apex/codestyle.xml +++ b/pmd-apex/src/main/resources/category/apex/codestyle.xml @@ -149,11 +149,11 @@ public class Foo { - + externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_codestyle.html#onedeclarationperline"> Apex allows the use of several variables declaration of the same type on one line. However, it can lead to quite messy code. This rule looks for several declarations on the same line. @@ -163,16 +163,27 @@ can lead to quite messy code. This rule looks for several declarations on the sa 1] | -//FieldDeclarationStatements[count(FieldDeclaration) > 1] +//VariableDeclarationStatements + [count(VariableDeclaration) > 1] + [$strictMode or count(distinct-values(VariableDeclaration/@BeginLine)) != count(VariableDeclaration)] +| +//FieldDeclarationStatements + [count(FieldDeclaration) > 1] + [$strictMode or count(distinct-values(FieldDeclaration/VariableExpression/@BeginLine)) != count(FieldDeclaration/VariableExpression)] ]]> + + diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/CodeStyleRulesTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/CodeStyleRulesTest.java index eddb55d599..7393757536 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/CodeStyleRulesTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/codestyle/CodeStyleRulesTest.java @@ -17,7 +17,7 @@ public class CodeStyleRulesTest extends SimpleAggregatorTst { addRule(RULESET, "IfElseStmtsMustUseBraces"); addRule(RULESET, "IfStmtsMustUseBraces"); addRule(RULESET, "MethodNamingConventions"); - addRule(RULESET, "OneDeclarationPerStatement"); + addRule(RULESET, "OneDeclarationPerLine"); addRule(RULESET, "VariableNamingConventions"); addRule(RULESET, "WhileLoopsMustUseBraces"); } diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerLine.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerLine.xml new file mode 100644 index 0000000000..7a1a36a987 --- /dev/null +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerLine.xml @@ -0,0 +1,95 @@ + + + + + + one field declaration per statement + 1 + + + + + one variable declaration per statement + 1 + + + + + + all is well + 0 + + + + + one variable declaration per line, ok by default + 0 + + + + + one field declaration per line, ok by default + 0 + + + + + one variable declaration per line, not ok when strictMode + true + 1 + + + + + one field declaration per line, not ok when strictMode + true + 1 + + + diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerStatement.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerStatement.xml deleted file mode 100644 index b24f7a8284..0000000000 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/OneDeclarationPerStatement.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - one field declaration per statement - 1 - - - - - one variable declaration per statement - 1 - - - - - - all is well - 0 - - - - From 1f79968bbb0dc05ebd8f31655b14469a01635451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Mon, 27 Aug 2018 03:03:39 -0300 Subject: [PATCH 25/64] Update changelog, refs 1315 --- docs/pages/release_notes.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7c3898555d..34a7c88dfb 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -29,6 +29,10 @@ This is a {{ site.pmd.release_type }} release. detects field names that don't comply to a given convention. It defaults to standard Java convention of using camelCase, but can be configured with ease for e.g. constants or static fields. +* The new Apex rule {% rule apex/codestyle/OneDeclarationPerLine %} (`apex-codestyle`) enforces declaring a + single field / variable per line; or per statement if the `strictMode` property is set. + It's an Apex equivalent of the already existing Java rule of the same name. + ### Fixed Issues * core @@ -76,5 +80,6 @@ This is a {{ site.pmd.release_type }} release. * [#1289](https://github.com/pmd/pmd/pull/1289): \[java] UselessParentheses: Fix false positive with assignments - [cobratbq](https://github.com/cobratbq) * [#1290](https://github.com/pmd/pmd/pull/1290): \[docs] \[GSoC] Create the documentation about pmdtester - [BBG](https://github.com/djydewang) * [#1256](https://github.com/pmd/pmd/pull/1256): \[java] #940 Avoid JUnit 4 false positives for JUnit 5 tests - [Alex Shesterov](https://github.com/vovkss) +* [#1315](https://github.com/pmd/pmd/pull/1315): \[apex] Add OneDeclarationPerStatement rule - [Jeff Hube](https://github.com/jeffhube) {% endtocmaker %} From 1740d25cd7a16db183f2710cf69027a41756d8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Mon, 27 Aug 2018 04:06:08 -0300 Subject: [PATCH 26/64] Rule was moved --- pmd-apex/src/main/resources/rulesets/apex/ruleset.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-apex/src/main/resources/rulesets/apex/ruleset.xml b/pmd-apex/src/main/resources/rulesets/apex/ruleset.xml index 627f67f0f5..f414d496a0 100644 --- a/pmd-apex/src/main/resources/rulesets/apex/ruleset.xml +++ b/pmd-apex/src/main/resources/rulesets/apex/ruleset.xml @@ -421,7 +421,7 @@ - + 3 From 26f5a41c4742c34e9696d3e26166aa392b8b5185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Mon, 27 Aug 2018 04:12:39 -0300 Subject: [PATCH 27/64] [java] OneDeclarationPerLine should check fields too --- .../resources/category/java/bestpractices.xml | 4 ++++ .../xml/OneDeclarationPerLine.xml | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 4e7d4fa7eb..7279965502 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -817,6 +817,10 @@ can lead to quite messy code. This rule looks for several declarations on the sa //LocalVariableDeclaration [count(VariableDeclarator) > 1] [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)] +| +//FieldDeclaration + [count(VariableDeclarator) > 1] + [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)] ]]> diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/OneDeclarationPerLine.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/OneDeclarationPerLine.xml index 72b07d6c97..39768c6233 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/OneDeclarationPerLine.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/OneDeclarationPerLine.xml @@ -62,6 +62,30 @@ public class Foo { String name, lastname; } +} + ]]> + + + + Check for field declarations without strictMode + false + 0 + + + + + Check for field declarations with strictMode + true + 1 + From f13227176cde6c42b081a245507ab3747fc7e0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Mon, 27 Aug 2018 04:14:12 -0300 Subject: [PATCH 28/64] Update changelog --- docs/pages/release_notes.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 34a7c88dfb..cd77380236 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -14,6 +14,11 @@ This is a {{ site.pmd.release_type }} release. ### New and noteworthy +#### Modified Rules + +* The Java rule {% rule java/bestpractices/OneDeclarationPerLine %} (`java-bestpractices`) has been revamped to + consider not only local variable declarations, but field declarations too. + #### New Rules * The new Java rule {% rule java/codestyle/LinguisticNaming %} (`java-codestyle`) From d743303f2e06c922ed22daacc594b67820203fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Mon, 27 Aug 2018 04:17:43 -0300 Subject: [PATCH 29/64] Update release ruleset --- pmd-core/src/main/resources/rulesets/releases/670.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pmd-core/src/main/resources/rulesets/releases/670.xml b/pmd-core/src/main/resources/rulesets/releases/670.xml index b250a1cabf..0209a7c72b 100644 --- a/pmd-core/src/main/resources/rulesets/releases/670.xml +++ b/pmd-core/src/main/resources/rulesets/releases/670.xml @@ -11,6 +11,7 @@ This ruleset contains links to rules that are new in PMD v6.7.0 + From f3c54cf7ec476b6264b5f0abbc1e575ec2ec5b1b Mon Sep 17 00:00:00 2001 From: "Travis CI (pmd-bot)" Date: Mon, 27 Aug 2018 07:38:24 +0000 Subject: [PATCH 30/64] Update documentation TRAVIS_JOB_NUMBER=2768.1 TRAVIS_COMMIT_RANGE=d743303f2e06...982effe7440a --- docs/pages/pmd/rules/apex.md | 3 +- docs/pages/pmd/rules/apex/codestyle.md | 48 +++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/docs/pages/pmd/rules/apex.md b/docs/pages/pmd/rules/apex.md index 3026c4ae17..7d1e5a2bc0 100644 --- a/docs/pages/pmd/rules/apex.md +++ b/docs/pages/pmd/rules/apex.md @@ -24,6 +24,7 @@ folder: pmd/rules * [IfElseStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using surrounding braces. If the code formattingor indent... * [IfStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifstmtsmustusebraces): Avoid using if statements without using braces to surround the code block. If the codeformatting ... * [MethodNamingConventions](pmd_rules_apex_codestyle.html#methodnamingconventions): Method names should always begin with a lower case character, and should not contain underscores. +* [OneDeclarationPerLine](pmd_rules_apex_codestyle.html#onedeclarationperline): Apex allows the use of several variables declaration of the same type on one line. However, itcan... * [VariableNamingConventions](pmd_rules_apex_codestyle.html#variablenamingconventions): A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina... * [WhileLoopsMustUseBraces](pmd_rules_apex_codestyle.html#whileloopsmustusebraces): Avoid using 'while' statements without using braces to surround the code block. If the codeformat... @@ -112,7 +113,7 @@ folder: pmd/rules It contains the following rules: - [ApexBadCrypto](pmd_rules_apex_security.html#apexbadcrypto), [ApexCRUDViolation](pmd_rules_apex_security.html#apexcrudviolation), [ApexCSRF](pmd_rules_apex_security.html#apexcsrf), [ApexDangerousMethods](pmd_rules_apex_security.html#apexdangerousmethods), [ApexInsecureEndpoint](pmd_rules_apex_security.html#apexinsecureendpoint), [ApexOpenRedirect](pmd_rules_apex_security.html#apexopenredirect), [ApexSharingViolations](pmd_rules_apex_security.html#apexsharingviolations), [ApexSOQLInjection](pmd_rules_apex_security.html#apexsoqlinjection), [ApexSuggestUsingNamedCred](pmd_rules_apex_security.html#apexsuggestusingnamedcred), [ApexUnitTestClassShouldHaveAsserts](pmd_rules_apex_bestpractices.html#apexunittestclassshouldhaveasserts), [ApexUnitTestShouldNotUseSeeAllDataTrue](pmd_rules_apex_bestpractices.html#apexunittestshouldnotuseseealldatatrue), [ApexXSSFromEscapeFalse](pmd_rules_apex_security.html#apexxssfromescapefalse), [ApexXSSFromURLParam](pmd_rules_apex_security.html#apexxssfromurlparam), [AvoidDeeplyNestedIfStmts](pmd_rules_apex_design.html#avoiddeeplynestedifstmts), [AvoidDirectAccessTriggerMap](pmd_rules_apex_errorprone.html#avoiddirectaccesstriggermap), [AvoidDmlStatementsInLoops](pmd_rules_apex_performance.html#avoiddmlstatementsinloops), [AvoidGlobalModifier](pmd_rules_apex_bestpractices.html#avoidglobalmodifier), [AvoidHardcodingId](pmd_rules_apex_errorprone.html#avoidhardcodingid), [AvoidLogicInTrigger](pmd_rules_apex_bestpractices.html#avoidlogicintrigger), [AvoidNonExistentAnnotations](pmd_rules_apex_errorprone.html#avoidnonexistentannotations), [AvoidSoqlInLoops](pmd_rules_apex_performance.html#avoidsoqlinloops), [AvoidSoslInLoops](pmd_rules_apex_performance.html#avoidsoslinloops), [ClassNamingConventions](pmd_rules_apex_codestyle.html#classnamingconventions), [CyclomaticComplexity](pmd_rules_apex_design.html#cyclomaticcomplexity), [EmptyCatchBlock](pmd_rules_apex_errorprone.html#emptycatchblock), [EmptyIfStmt](pmd_rules_apex_errorprone.html#emptyifstmt), [EmptyStatementBlock](pmd_rules_apex_errorprone.html#emptystatementblock), [EmptyTryOrFinallyBlock](pmd_rules_apex_errorprone.html#emptytryorfinallyblock), [EmptyWhileStmt](pmd_rules_apex_errorprone.html#emptywhilestmt), [ExcessiveClassLength](pmd_rules_apex_design.html#excessiveclasslength), [ExcessiveParameterList](pmd_rules_apex_design.html#excessiveparameterlist), [ExcessivePublicCount](pmd_rules_apex_design.html#excessivepubliccount), [ForLoopsMustUseBraces](pmd_rules_apex_codestyle.html#forloopsmustusebraces), [IfElseStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces), [IfStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifstmtsmustusebraces), [MethodNamingConventions](pmd_rules_apex_codestyle.html#methodnamingconventions), [MethodWithSameNameAsEnclosingClass](pmd_rules_apex_errorprone.html#methodwithsamenameasenclosingclass), [NcssConstructorCount](pmd_rules_apex_design.html#ncssconstructorcount), [NcssMethodCount](pmd_rules_apex_design.html#ncssmethodcount), [NcssTypeCount](pmd_rules_apex_design.html#ncsstypecount), [StdCyclomaticComplexity](pmd_rules_apex_design.html#stdcyclomaticcomplexity), [TooManyFields](pmd_rules_apex_design.html#toomanyfields), [VariableNamingConventions](pmd_rules_apex_codestyle.html#variablenamingconventions), [WhileLoopsMustUseBraces](pmd_rules_apex_codestyle.html#whileloopsmustusebraces) + [ApexBadCrypto](pmd_rules_apex_security.html#apexbadcrypto), [ApexCRUDViolation](pmd_rules_apex_security.html#apexcrudviolation), [ApexCSRF](pmd_rules_apex_security.html#apexcsrf), [ApexDangerousMethods](pmd_rules_apex_security.html#apexdangerousmethods), [ApexInsecureEndpoint](pmd_rules_apex_security.html#apexinsecureendpoint), [ApexOpenRedirect](pmd_rules_apex_security.html#apexopenredirect), [ApexSharingViolations](pmd_rules_apex_security.html#apexsharingviolations), [ApexSOQLInjection](pmd_rules_apex_security.html#apexsoqlinjection), [ApexSuggestUsingNamedCred](pmd_rules_apex_security.html#apexsuggestusingnamedcred), [ApexUnitTestClassShouldHaveAsserts](pmd_rules_apex_bestpractices.html#apexunittestclassshouldhaveasserts), [ApexUnitTestShouldNotUseSeeAllDataTrue](pmd_rules_apex_bestpractices.html#apexunittestshouldnotuseseealldatatrue), [ApexXSSFromEscapeFalse](pmd_rules_apex_security.html#apexxssfromescapefalse), [ApexXSSFromURLParam](pmd_rules_apex_security.html#apexxssfromurlparam), [AvoidDeeplyNestedIfStmts](pmd_rules_apex_design.html#avoiddeeplynestedifstmts), [AvoidDirectAccessTriggerMap](pmd_rules_apex_errorprone.html#avoiddirectaccesstriggermap), [AvoidDmlStatementsInLoops](pmd_rules_apex_performance.html#avoiddmlstatementsinloops), [AvoidGlobalModifier](pmd_rules_apex_bestpractices.html#avoidglobalmodifier), [AvoidHardcodingId](pmd_rules_apex_errorprone.html#avoidhardcodingid), [AvoidLogicInTrigger](pmd_rules_apex_bestpractices.html#avoidlogicintrigger), [AvoidNonExistentAnnotations](pmd_rules_apex_errorprone.html#avoidnonexistentannotations), [AvoidSoqlInLoops](pmd_rules_apex_performance.html#avoidsoqlinloops), [AvoidSoslInLoops](pmd_rules_apex_performance.html#avoidsoslinloops), [ClassNamingConventions](pmd_rules_apex_codestyle.html#classnamingconventions), [CyclomaticComplexity](pmd_rules_apex_design.html#cyclomaticcomplexity), [EmptyCatchBlock](pmd_rules_apex_errorprone.html#emptycatchblock), [EmptyIfStmt](pmd_rules_apex_errorprone.html#emptyifstmt), [EmptyStatementBlock](pmd_rules_apex_errorprone.html#emptystatementblock), [EmptyTryOrFinallyBlock](pmd_rules_apex_errorprone.html#emptytryorfinallyblock), [EmptyWhileStmt](pmd_rules_apex_errorprone.html#emptywhilestmt), [ExcessiveClassLength](pmd_rules_apex_design.html#excessiveclasslength), [ExcessiveParameterList](pmd_rules_apex_design.html#excessiveparameterlist), [ExcessivePublicCount](pmd_rules_apex_design.html#excessivepubliccount), [ForLoopsMustUseBraces](pmd_rules_apex_codestyle.html#forloopsmustusebraces), [IfElseStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces), [IfStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifstmtsmustusebraces), [MethodNamingConventions](pmd_rules_apex_codestyle.html#methodnamingconventions), [MethodWithSameNameAsEnclosingClass](pmd_rules_apex_errorprone.html#methodwithsamenameasenclosingclass), [NcssConstructorCount](pmd_rules_apex_design.html#ncssconstructorcount), [NcssMethodCount](pmd_rules_apex_design.html#ncssmethodcount), [NcssTypeCount](pmd_rules_apex_design.html#ncsstypecount), [OneDeclarationPerLine](pmd_rules_apex_codestyle.html#onedeclarationperline), [StdCyclomaticComplexity](pmd_rules_apex_design.html#stdcyclomaticcomplexity), [TooManyFields](pmd_rules_apex_design.html#toomanyfields), [VariableNamingConventions](pmd_rules_apex_codestyle.html#variablenamingconventions), [WhileLoopsMustUseBraces](pmd_rules_apex_codestyle.html#whileloopsmustusebraces) * Empty Code (`rulesets/apex/empty.xml`): diff --git a/docs/pages/pmd/rules/apex/codestyle.md b/docs/pages/pmd/rules/apex/codestyle.md index 1612e82a5c..0e59a82e23 100644 --- a/docs/pages/pmd/rules/apex/codestyle.md +++ b/docs/pages/pmd/rules/apex/codestyle.md @@ -5,7 +5,7 @@ permalink: pmd_rules_apex_codestyle.html folder: pmd/rules/apex sidebaractiveurl: /pmd_rules_apex.html editmepath: ../pmd-apex/src/main/resources/category/apex/codestyle.xml -keywords: Code Style, ClassNamingConventions, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, ForLoopsMustUseBraces, MethodNamingConventions, VariableNamingConventions, WhileLoopsMustUseBraces +keywords: Code Style, ClassNamingConventions, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, ForLoopsMustUseBraces, MethodNamingConventions, OneDeclarationPerLine, VariableNamingConventions, WhileLoopsMustUseBraces language: Apex --- ## ClassNamingConventions @@ -192,6 +192,52 @@ public class Foo { ``` +## OneDeclarationPerLine + +**Since:** PMD 6.7.0 + +**Priority:** High (1) + +Apex allows the use of several variables declaration of the same type on one line. However, it +can lead to quite messy code. This rule looks for several declarations on the same line. + +**This rule is defined by the following XPath expression:** +``` xpath +//VariableDeclarationStatements + [count(VariableDeclaration) > 1] + [$strictMode or count(distinct-values(VariableDeclaration/@BeginLine)) != count(VariableDeclaration)] +| +//FieldDeclarationStatements + [count(FieldDeclaration) > 1] + [$strictMode or count(distinct-values(FieldDeclaration/VariableExpression/@BeginLine)) != count(FieldDeclaration/VariableExpression)] +``` + +**Example(s):** + +``` java +Integer a, b; // not recommended + +Integer a, + b; // ok by default, can be flagged setting the strictMode property + +Integer a; // preferred approach +Integer b; +``` + +**This rule has the following properties:** + +|Name|Default Value|Description|Multivalued| +|----|-------------|-----------|-----------| +|cc_categories|Style|Code Climate Categories|yes. Delimiter is '\|'.| +|cc_remediation_points_multiplier|1|Code Climate Remediation Points multiplier|no| +|cc_block_highlighting|false|Code Climate Block Highlighting|no| +|strictMode|false|If true, mark combined declaration even if the declarations are on separate lines.|no| + +**Use this rule by referencing it:** +``` xml + +``` + ## VariableNamingConventions **Since:** PMD 5.5.0 From 2cf941dd4ecde4098d93f4b4b5ad860e9992af7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Mon, 27 Aug 2018 12:24:33 -0300 Subject: [PATCH 31/64] [core] Upgrade PMD on self --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 16c89019e2..c49413f8be 100644 --- a/pom.xml +++ b/pom.xml @@ -445,12 +445,12 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code net.sourceforge.pmd pmd-core - 6.5.0 + 6.6.0 net.sourceforge.pmd pmd-java - 6.5.0 + 6.6.0 From f25a2e08aad8a544a46d2e1df255c79b602b982d Mon Sep 17 00:00:00 2001 From: "Travis CI (pmd-bot)" Date: Mon, 27 Aug 2018 16:37:28 +0000 Subject: [PATCH 32/64] Update documentation TRAVIS_JOB_NUMBER=2772.1 TRAVIS_COMMIT_RANGE=f3c54cf7ec47...348a11f11995 --- docs/pages/pmd/rules/java.md | 8 ++++---- docs/pages/pmd/rules/java/codestyle.md | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/pages/pmd/rules/java.md b/docs/pages/pmd/rules/java.md index 48387179af..e3dbda321f 100644 --- a/docs/pages/pmd/rules/java.md +++ b/docs/pages/pmd/rules/java.md @@ -63,7 +63,7 @@ folder: pmd/rules * [AtLeastOneConstructor](pmd_rules_java_codestyle.html#atleastoneconstructor): Each non-static class should declare at least one constructor.Classes with solely static members ... * [AvoidDollarSigns](pmd_rules_java_codestyle.html#avoiddollarsigns): Avoid using dollar signs in variable/method/class/interface names. * [AvoidFinalLocalVariable](pmd_rules_java_codestyle.html#avoidfinallocalvariable): Avoid using final local variables, turn them into fields. -* [AvoidPrefixingMethodParameters](pmd_rules_java_codestyle.html#avoidprefixingmethodparameters): Prefixing parameters by 'in' or 'out' pollutes the name of the parameters and reduces code readab... +* [AvoidPrefixingMethodParameters](pmd_rules_java_codestyle.html#avoidprefixingmethodparameters): Deprecated Prefixing parameters by 'in' or 'out' pollutes the name of the parameters and reduces code readab... * [AvoidProtectedFieldInFinalClass](pmd_rules_java_codestyle.html#avoidprotectedfieldinfinalclass): Do not use protected fields in final classes since they cannot be subclassed.Clarify your intent ... * [AvoidProtectedMethodInFinalClassNotExtending](pmd_rules_java_codestyle.html#avoidprotectedmethodinfinalclassnotextending): Do not use protected methods in most final classes since they cannot be subclassed. This shouldon... * [AvoidUsingNativeCode](pmd_rules_java_codestyle.html#avoidusingnativecode): Unnecessary reliance on Java Native Interface (JNI) calls directly reduces application portabilit... @@ -96,7 +96,7 @@ folder: pmd/rules * [MDBAndSessionBeanNamingConvention](pmd_rules_java_codestyle.html#mdbandsessionbeannamingconvention): The EJB Specification states that any MessageDrivenBean or SessionBean should be suffixed by 'Bean'. * [MethodArgumentCouldBeFinal](pmd_rules_java_codestyle.html#methodargumentcouldbefinal): A method argument that is never re-assigned within the method can be declared final. * [MethodNamingConventions](pmd_rules_java_codestyle.html#methodnamingconventions): Configurable naming conventions for method declarations. This rule reports method decl... -* [MIsLeadingVariableName](pmd_rules_java_codestyle.html#misleadingvariablename): Detects when a non-field has a name starting with 'm_'. This usually denotes a field and could b... +* [MIsLeadingVariableName](pmd_rules_java_codestyle.html#misleadingvariablename): Deprecated Detects when a non-field has a name starting with 'm_'. This usually denotes a field and could b... * [NoPackage](pmd_rules_java_codestyle.html#nopackage): Detects when a class or interface does not have a package definition. * [OnlyOneReturn](pmd_rules_java_codestyle.html#onlyonereturn): A method should have only one exit point, and that should be the last statement in the method. * [PackageCase](pmd_rules_java_codestyle.html#packagecase): Detects when a package definition contains uppercase characters. @@ -106,7 +106,7 @@ folder: pmd/rules * [ShortClassName](pmd_rules_java_codestyle.html#shortclassname): Short Classnames with fewer than e.g. five characters are not recommended. * [ShortMethodName](pmd_rules_java_codestyle.html#shortmethodname): Method names that are very short are not helpful to the reader. * [ShortVariable](pmd_rules_java_codestyle.html#shortvariable): Fields, local variables, or parameter names that are very short are not helpful to the reader. -* [SuspiciousConstantFieldName](pmd_rules_java_codestyle.html#suspiciousconstantfieldname): Field names using all uppercase characters - Sun's Java naming conventions indicating constants -... +* [SuspiciousConstantFieldName](pmd_rules_java_codestyle.html#suspiciousconstantfieldname): Deprecated Field names using all uppercase characters - Sun's Java naming conventions indicating constants -... * [TooManyStaticImports](pmd_rules_java_codestyle.html#toomanystaticimports): If you overuse the static import feature, it can make your program unreadable and unmaintainable,... * [UnnecessaryAnnotationValueElement](pmd_rules_java_codestyle.html#unnecessaryannotationvalueelement): Avoid the use of value in annotations when it's the only element. * [UnnecessaryConstructor](pmd_rules_java_codestyle.html#unnecessaryconstructor): This rule detects when a constructor is not necessary; i.e., when there is only one constructor a... @@ -116,7 +116,7 @@ folder: pmd/rules * [UnnecessaryReturn](pmd_rules_java_codestyle.html#unnecessaryreturn): Avoid the use of unnecessary return statements. * [UselessParentheses](pmd_rules_java_codestyle.html#uselessparentheses): Useless parentheses should be removed. * [UselessQualifiedThis](pmd_rules_java_codestyle.html#uselessqualifiedthis): Look for qualified this usages in the same class. -* [VariableNamingConventions](pmd_rules_java_codestyle.html#variablenamingconventions): A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina... +* [VariableNamingConventions](pmd_rules_java_codestyle.html#variablenamingconventions): Deprecated A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina... * [WhileLoopsMustUseBraces](pmd_rules_java_codestyle.html#whileloopsmustusebraces): Deprecated Avoid using 'while' statements without using braces to surround the code block. If the code forma... ## Design diff --git a/docs/pages/pmd/rules/java/codestyle.md b/docs/pages/pmd/rules/java/codestyle.md index b6f2a4db50..749073eb7c 100644 --- a/docs/pages/pmd/rules/java/codestyle.md +++ b/docs/pages/pmd/rules/java/codestyle.md @@ -141,6 +141,8 @@ public class MyClass { ## AvoidPrefixingMethodParameters +Deprecated + **Since:** PMD 5.0 **Priority:** Medium Low (4) @@ -1444,6 +1446,8 @@ public class Foo { ## MIsLeadingVariableName +Deprecated + **Since:** PMD 3.4 **Priority:** Medium (3) @@ -1781,6 +1785,8 @@ public class Something { ## SuspiciousConstantFieldName +Deprecated + **Since:** PMD 2.0 **Priority:** Medium (3) @@ -2194,6 +2200,8 @@ public class Foo { ## VariableNamingConventions +Deprecated + **Since:** PMD 1.2 **Priority:** High (1) From 0a026a8142d05004a3e9244c603c08620cc9d541 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 30 Aug 2018 10:38:41 +0200 Subject: [PATCH 33/64] [ci] pmd-regression-tester - disable exit immediately for uploading baseline See also pmd/pmd-regression-tester#40 It fails at the very last step (determining result code), so the baseline is created and can be uploaded. --- .travis/build-deploy.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis/build-deploy.sh b/.travis/build-deploy.sh index 1d425457d6..fb01e22865 100755 --- a/.travis/build-deploy.sh +++ b/.travis/build-deploy.sh @@ -117,6 +117,8 @@ elif travis_isPush; then ( + # disable fast fail, exit immediately, in this subshell + set +e upload_baseline From c6b529dde88c2e996b59b7652310aefb9b652f95 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 30 Aug 2018 10:50:22 +0200 Subject: [PATCH 34/64] [ci] update github oauth token --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a52bb4c806..28b8d1d714 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ env: - secure: "mmHRnK/8CHfgtwaTN3MgjFD1R8EVQhIb/a0Aag3gPaHWW52Ex6xWG7GsF4kRcdzHdIdrQxHZTiDa2oVMWbnQ16CAu4dZJadwTxhBW4JmE1tsi2C6i+uwMBPvnKBXHwt+QOAqNB0L/ByYwWLkucSLoyRs6qU0i7sJ3ZC/EPCuLI8VfBlFUVegSbp2WmclmFnxOi5MKr15Zwd8BGgyWUsvd1OHxhvO3Xr/ZPO4R+1kIgyojloTMu6oGM/shYgsrUXgmI/WvZRTq+25SRCjUmATJtuDXXgVeJtYabi/+Zju5Z7K06oaKvFYM+BgZWPmGQkVCxKVjSlug0rx6+qgRKIf/B/cPxmQDS0ZZVDmDcbxeibBL9JhRqIDwDb0XS9t1qBXvIJ5E4ZmdX/XuvLCnC4xJptu/vHyKl1wbRM3dcXEBk8J0knJc4JvY2yupF3LS32sfEHftLwzr63U3/0dOQvsCSJRBy5zgI8ieABUZAeZmmaQ6RCGOTEYrGO2G4CCF2uVq4YdrCOsfmrb0DzH8llNMkXKzXlITRvmkuBlTRRKxGnPzS3vf0iicdAkmTiU5u7lArFFc7IKcW4ypO+RKDTUpq74K+UZBI9eBjV7Po368EO8epJ5aIx32a2kyS/hYWkS/dZh7I0fNZa2qBUceZO/KZGRjH4dQFW9t0J9Q7LLXJY=" - secure: "geOU/7VR83KYTOCR5XkgFqnHJEnXeB6hNDE7UFcN4ZsL9uVLhxlDVWV3ujJ87nyBzggG1KfSnUx11UwOQrbBl0K6sEXo/B2q5ytOsWoSLi7+0qm/uhhw/DTBOq57p8TIDKFM7rDhO7uajSn7Y86LeZkh9wIs5265Fh1yhCkiPbczDUMsX4P0GGg2qgkIKSBw4DZf6sPDc4xjJq/4/cLnjXo/K0ZYAIoSLqDfe1gmkzMtQlad+1t8Lwv/gOJ4BNRF4a5aEvGF6kbFovFoeFWCQTKlkn6VJtY+BETGKW2RH9efGeMs7JbBbNm+nnpoNsbJ0gdmGlhSbWT8enIm72/P0ThTBJWVcLJ30tUd0UeYD9C49wbJ3RHSxsoUKP9YhHJ+XKNx+8irkJ8LPCkNMQEFE153gEVvU7tCgah9Uq6laYZv9cQE0dWzNt3//Ymls8BzY38Ha4PbrIIJqEuWwnAX6ZgTgzVtXx1AJjkDFG9KFKPhN7NfNMbh7rn5C84a1h5zrIydm+6RcIBC+xTLDEiN7djiquf3PcNtyGLcO8dNN4Uv8iU0Jw8ch3+w0PJO53v5py+IS1V8pwwYaYF2iVPOoziS0tP8MsgYVGwpTZhvz3v8x0ge8r6KJE4zdvoPtCRNr2Oo3sJGYqkt86Hu6agKFiljP5AgJNx7iQD5GQn6J3w=" - secure: "gqyPF3d75JuwZptnQQQKO6rGUILXGO09y9dZhShdX8qq5Mexa2ISk77Y/b0yyAdhJMgEglls5cWlbHkwCAB0i4yL25RE5CtQUe4er+CIKwBIs0M56ghbcOwWAFB/cXeyyWmXDHBVnVUeKm7IJ34txsEclnMzQSR/DInSzsCFMUQok8HEaWZNssMjyRgo6goKGdG5vNWGfLLY7mKGMe/6PpYJD0G8k+Na08aX06ZWph38He8O3imUAngoQrxiSp0UYmnHDkigbV7S2LdZOsj7kMxkiyigzK/P1eygHVbFAhohLroaqS9B4CBK7QeOyup2vxVKqJVzFwOCylD0786CImvaG2ZYMtvJkapvaEE0mdMlyYpHgdIkmHZu28aMW7hXEhxHyBAxKuPcj5eGCGziO+ztCvfYIA9CGs1uA4KLrED7SahvB0oXnt3KTFdRc857cWcpp2NmRKihLzVdgHlmT8zcYaec3zP1VdMoa2bmLHoaZtAwvMTcAG56FcET1p7f9v+uiU88ZeptEjTJfpAWlq34tpwZXNyIQi5IROocSHM+PKTgLAsAMP5klGascr8E0sEzREl7tg8hqEwXKym/sVKyT+HMptA3UZcrZZhm07/cmQ0pUVvbV9QDb0MzU3O2wF7vT3U7R7Fb1u0LxMjblPyEazTp8ldabVRJREwlsDc=" - - secure: "JIhuqaI0i+zvuqqXiQBHpuKr7AQ8jfk6Gbr8Qgiq4yJtdEWXZGxnAT9BmlbjkgT7ABXvLgxf2CIdUOMo1yYfBlxQL/y5+e89jaVpYF3tvNAzYQ1e12VzQRsd/jDb7qvm7tw3rDHEn3dSEot7Q6KbPcL6WzWJINVMCCmOgvq9gKHgE6Y5q5EgZ5rxiXyuO27ndzcbxaor4PIaiSzHO9+AJQ7p2zDLP+kG4nKVTBX0l9VoKiYFhIpIhpbigi3jyLDMDRiWpwTWZC6P8/RXfZg/lc5ADOuM2DM8oXPpZuqOa/g31LWQOSCuEnQ1G16vbLgipSPpgAc7jYWD5cywhG9dLkiKaZDh5x0meLM2RoAgz6eAnQfTTqJ68OM9o9yXjubEedsNpNRAr9/DXMd+fbh10W2vbvL5HCNB3lic3anehhR9le7PLuEKxg654wXt3KM2PZGVWbotIyBK0CvGzqGkppvwT23QdDDqSdkWuGQIhGQ0xBOdYkwebycxP5wwPUmObG+mymQ1Be2BXvmghttsiJdKlt4CVSYOJUMus6kU32G95hdTgKblsX4J1Of2i1nYsjyMKh3k945tqXwQrIsxOOQug0oIkz24zlLaOaQcorWtJ6Y1HPaZKpVIFUEF0y8Uq/O4oB2bOYC6WDUQfpj7nRG6xbi+BeBS84m1ttCEk4g=" + - secure: "VezxV+VdmbmtrQYT8AZIyg41WBROxuxpumerkcubADF7V4wV6lwx9Rd2G6yAr0VuHCNUUhS4m+gPFIsuiQbAhyupiEkwhzUYqk1tF+LITlLLPegLypjiLmhJMwGUNuDSSsih1Icmg9FzrP4VyzgGn9pBjoG9QYj1civBZeGwg++e/XDYlHMXrpd/UEfMKVB71JwB0tle4fKJZSvblIqP62yvbBaKHx6A4+ZWzJV5Vps0DoIeNtKCNmNNloKZVHfjbsvqSjnMYUJzkOzyPkM822q41N/D+3IAufO16+jH/W0vAZeN0e4GXiN5W+CVkr2Gbh0FwkVQcI3bekaOIn45XLUMLKdf+JsWDPKz9RraHelR9YxL5GoJ7ntwvmucxw0p8EVyJ/xLk/pBCP8iHq0Jb8//js25XHgxzzAWI37MErPAAGgTKZAVdAN0mGXbe63tWmwaBlEbK8h2A8di6abW5x6YHTkTo2BRlHUSTU8dE3VqTnpSkne5n1SlEa4g1Bci3J45M0/pLmHV6yCxCM5BrVXS5ByaB61py/umSbpmdIBFV6TM1MaKK3lAucQrR+8To/vCbm8XqPyujJdOR+ENIuuDgEU/Yh5Hv5SAODekUYaCp4pjfGzFADHQWVNDxIOXrwBN4OfSiAvRc1x6HXndOmNI4QtOxheuCRFFthq8VZI=" matrix: - BUILD=deploy - BUILD=doc From 6ef3b5a5834081382f255c754438a9dbf9b68286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Thu, 30 Aug 2018 13:54:59 -0300 Subject: [PATCH 35/64] [java] Remove no longer used property - Fixes #1323 --- pmd-java/src/main/resources/category/java/bestpractices.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 4e7d4fa7eb..5f7086a55c 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -226,9 +226,6 @@ Application with hard-coded IP addresses can become impossible to deploy in some Externalizing IP adresses is preferable. 3 - - - Date: Thu, 30 Aug 2018 14:11:10 -0300 Subject: [PATCH 36/64] Update changelog, refs #1323 --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 2ab9f00a27..2888e1c4b9 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -43,6 +43,7 @@ This is a {{ site.pmd.release_type }} release. * java-bestpractices * [#940](https://github.com/pmd/pmd/issues/940): \[java] JUnit 4 false positives for JUnit 5 tests * [#1267](https://github.com/pmd/pmd/pull/1267): \[java] MissingOverrideRule: Avoid NoClassDefFoundError with incomplete classpath + * [#1323](https://github.com/pmd/pmd/issues/1323): \[java] AvoidUsingHardCodedIP ignores match pattern * java-codestyle * [#1255](https://github.com/pmd/pmd/issues/1255): \[java] UnnecessaryFullyQualifiedName false positive: static method on shadowed implicitly imported class * [#1258](https://github.com/pmd/pmd/issues/1285): \[java] False positive "UselessParentheses" for parentheses that contain assignment From a30d23e5874571e643aabee1b6c80920fb3971c6 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 31 Aug 2018 11:29:55 +0200 Subject: [PATCH 37/64] [java] LinguisticNaming - make tranform method names configurable Follow-up for #1252 --- .../rule/codestyle/LinguisticNamingRule.java | 50 +++++++++++++------ .../rule/codestyle/xml/LinguisticNaming.xml | 50 +++++++++++++++++++ 2 files changed, 84 insertions(+), 16 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java index 7ab22598c0..a39dcbfc20 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java @@ -5,6 +5,9 @@ package net.sourceforge.pmd.lang.java.rule.codestyle; import java.util.List; +import java.util.Locale; + +import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTLocalVariableDeclaration; @@ -18,27 +21,33 @@ import net.sourceforge.pmd.properties.StringMultiProperty; public class LinguisticNamingRule extends AbstractJavaRule { private static final BooleanProperty CHECK_BOOLEAN_METHODS = BooleanProperty.named("checkBooleanMethod") - .defaultValue(true).desc("Check method names and types for inconsistent naming").uiOrder(1.0f).build(); + .defaultValue(true).desc("Check method names and types for inconsistent naming.").uiOrder(1.0f).build(); private static final BooleanProperty CHECK_GETTERS = BooleanProperty.named("checkGetters").defaultValue(true) - .desc("Check return type of getters").uiOrder(2.0f).build(); + .desc("Check return type of getters.").uiOrder(2.0f).build(); private static final BooleanProperty CHECK_SETTERS = BooleanProperty.named("checkSetters").defaultValue(true) - .desc("Check return type of setters").uiOrder(3.0f).build(); + .desc("Check return type of setters.").uiOrder(3.0f).build(); private static final BooleanProperty CHECK_PREFIXED_TRANSFORM_METHODS = BooleanProperty - .named("checkPrefixedTransformMethods") - .defaultValue(true).desc("Check return type of methods whose names start with 'to'").uiOrder(4.0f).build(); + .named("checkPrefixedTransformMethods").defaultValue(true) + .desc("Check return type of methods whose names start with the configured prefix (see transformMethodNames property).") + .uiOrder(4.0f).build(); private static final BooleanProperty CHECK_TRANSFORM_METHODS = BooleanProperty.named("checkTransformMethods") - .defaultValue(false).desc("Check return type of methods which contain 'To' in their name").uiOrder(4.0f).build(); + .defaultValue(false) + .desc("Check return type of methods which contain the configured infix in their name (see transformMethodNames property).") + .uiOrder(4.0f).build(); private static final StringMultiProperty BOOLEAN_METHOD_PREFIXES_PROPERTY = StringMultiProperty .named("booleanMethodPrefixes").defaultValues("is", "has", "can", "have", "will", "should") - .desc("the prefixes of methods that return boolean").uiOrder(5.0f).build(); + .desc("The prefixes of methods that return boolean.").uiOrder(5.0f).build(); + private static final StringMultiProperty TRANSFORM_METHOD_NAMES_PROPERTY = StringMultiProperty + .named("transformMethodNames").defaultValues("to") + .desc("The prefixes and infixes that indicate a transform method.").uiOrder(6.0f).build(); private static final BooleanProperty CHECK_FIELDS = BooleanProperty.named("checkFields").defaultValue(true) - .desc("Check field names and types for inconsistent naming").uiOrder(6.0f).build(); + .desc("Check field names and types for inconsistent naming.").uiOrder(7.0f).build(); private static final BooleanProperty CHECK_VARIABLES = BooleanProperty.named("checkVariables").defaultValue(true) - .desc("Check local variable names and types for inconsistent naming").uiOrder(7.0f).build(); + .desc("Check local variable names and types for inconsistent naming.").uiOrder(8.0f).build(); private static final StringMultiProperty BOOLEAN_FIELD_PREFIXES_PROPERTY = StringMultiProperty .named("booleanFieldPrefixes").defaultValues("is", "has", "can", "have", "will", "should") - .desc("the prefixes of fields and variables that indicate boolean").uiOrder(8.0f).build(); + .desc("The prefixes of fields and variables that indicate boolean.").uiOrder(9.0f).build(); public LinguisticNamingRule() { definePropertyDescriptor(CHECK_BOOLEAN_METHODS); @@ -47,6 +56,7 @@ public class LinguisticNamingRule extends AbstractJavaRule { definePropertyDescriptor(CHECK_PREFIXED_TRANSFORM_METHODS); definePropertyDescriptor(CHECK_TRANSFORM_METHODS); definePropertyDescriptor(BOOLEAN_METHOD_PREFIXES_PROPERTY); + definePropertyDescriptor(TRANSFORM_METHOD_NAMES_PROPERTY); definePropertyDescriptor(CHECK_FIELDS); definePropertyDescriptor(CHECK_VARIABLES); definePropertyDescriptor(BOOLEAN_FIELD_PREFIXES_PROPERTY); @@ -84,8 +94,11 @@ public class LinguisticNamingRule extends AbstractJavaRule { private void checkPrefixedTransformMethods(ASTMethodDeclaration node, Object data, String nameOfMethod) { ASTResultType resultType = node.getResultType(); - if (resultType.isVoid() && hasPrefix(nameOfMethod, "to")) { - // To as prefix + List prefixes = getProperty(TRANSFORM_METHOD_NAMES_PROPERTY); + String[] splitMethodName = StringUtils.splitByCharacterTypeCamelCase(nameOfMethod); + if (resultType.isVoid() && splitMethodName.length > 0 + && prefixes.contains(splitMethodName[0].toLowerCase(Locale.ROOT))) { + // "To" or any other configured prefix found addViolationWithMessage(data, node, "Linguistics Antipattern - The transform method ''{0}'' should not return void linguistically", new Object[] { nameOfMethod }); } @@ -93,10 +106,15 @@ public class LinguisticNamingRule extends AbstractJavaRule { private void checkTransformMethods(ASTMethodDeclaration node, Object data, String nameOfMethod) { ASTResultType resultType = node.getResultType(); - if (resultType.isVoid() && containsWord(nameOfMethod, "To")) { - // To in the middle somewhere - addViolationWithMessage(data, node, "Linguistics Antipattern - The transform method ''{0}'' should not return void linguistically", - new Object[] { nameOfMethod }); + List infixes = getProperty(TRANSFORM_METHOD_NAMES_PROPERTY); + for (String infix : infixes) { + if (resultType.isVoid() && containsWord(nameOfMethod, StringUtils.capitalize(infix))) { + // "To" or any other configured infix in the middle somewhere + addViolationWithMessage(data, node, "Linguistics Antipattern - The transform method ''{0}'' should not return void linguistically", + new Object[] { nameOfMethod }); + // the first violation is sufficient - it is still the same method we are analyzing here + break; + } } } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml index 68a35fabcf..aea6ff3d0b 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml @@ -221,6 +221,31 @@ public class MethodTypeAndNameIsInconsistentWithPrefixTo { ]]> + + Method Prefix as: Transform Method with property configuration + as + 1 + 6 + + Linguistics Antipattern - The transform method 'asDataType' should not return void linguistically + + + + Method Contains To: Transformation methods true @@ -245,6 +270,31 @@ public class MethodTypeAndNameIsInconsistentWithPrefixTo { ]]> + + Method Contains As: Transformation methods with configured infix + true + as + 1 + 2 + + Linguistics Antipattern - The transform method 'grapeAsWine' should not return void linguistically + + + + Field/Variable Prefix is 2 From ded5c1ca5154a36d1967bb9c831be0f7fd3fd0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Sat, 1 Sep 2018 16:07:13 -0300 Subject: [PATCH 38/64] Add 'as' a a valid transformation prefix --- .../pmd/lang/java/rule/codestyle/LinguisticNamingRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java index a39dcbfc20..e75aea1c36 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java @@ -38,7 +38,7 @@ public class LinguisticNamingRule extends AbstractJavaRule { .named("booleanMethodPrefixes").defaultValues("is", "has", "can", "have", "will", "should") .desc("The prefixes of methods that return boolean.").uiOrder(5.0f).build(); private static final StringMultiProperty TRANSFORM_METHOD_NAMES_PROPERTY = StringMultiProperty - .named("transformMethodNames").defaultValues("to") + .named("transformMethodNames").defaultValues("to", "as") .desc("The prefixes and infixes that indicate a transform method.").uiOrder(6.0f).build(); private static final BooleanProperty CHECK_FIELDS = BooleanProperty.named("checkFields").defaultValue(true) From 2fb3cd13cb5a0d0ecf7fbe225a6b199a94898dc3 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 1 Sep 2018 21:12:29 +0200 Subject: [PATCH 39/64] [java] AvoidUsingHardCodedIP false positive for ":bee" "::bee" (two colons) is a valid IPv6 address, while ":bee" is not. Refs #1323 --- .../rule/bestpractices/AvoidUsingHardCodedIPRule.java | 7 +++++-- .../rule/bestpractices/xml/AvoidUsingHardCodedIP.xml | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java index 9b5b134de4..da340ced2a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java @@ -11,6 +11,8 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; + import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.ASTLiteral; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; @@ -135,8 +137,9 @@ public class AvoidUsingHardCodedIPRule extends AbstractJavaRule { // Quick check before using Regular Expression // 1) At least 3 characters // 2) 1st must be a Hex number or a : (colon) - // 3) Must contain at least 1 : (colon) - if (s.length() < 3 || !(isHexCharacter(firstChar) || firstChar == ':') || s.indexOf(':') < 0) { + // 3) Must contain at least 2 colons (:) + if (s.length() < 3 || !(isHexCharacter(firstChar) || firstChar == ':') || s.indexOf(':') < 0 + || StringUtils.countMatches(s, ':') < 2) { return false; } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/AvoidUsingHardCodedIP.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/AvoidUsingHardCodedIP.xml index 703082a119..bd8457e1d0 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/AvoidUsingHardCodedIP.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/AvoidUsingHardCodedIP.xml @@ -23,6 +23,7 @@ public class Foo { "0", "0000000000000", "2001:0db8:0000:0000:0000:0000:1428:57ab:0000", + ":bee", // IPv4 "0.0.0.0", @@ -43,7 +44,8 @@ public class Foo { "::ffff:0c22:384e", "0:0:0:0:0:ffff:0c22:384e", "ff00::", - + "::bee", + // IPv4 mapped IPv6 "2001:0db8:0000:0000:0000:0000:12.34.56.78", "::ffff:12.34.56.78", @@ -120,7 +122,7 @@ public class Foo { - 20 + 21 @@ -144,7 +146,7 @@ Comprehensive, check for IPv4 Comprehensive, check for IPv6 ]]> IPv6 - 10 + 11 @@ -160,7 +162,7 @@ Comprehensive, check for IPv4 mapped IPv6 Comprehensive, check for IPv6 and IPv4 mapped IPv6 ]]> IPv6|IPv4 mapped IPv6 - 14 + 15 From 378bfe5948a36f0a496f49e5d236ca74edb1efc2 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 1 Sep 2018 21:21:03 +0200 Subject: [PATCH 40/64] Update release notes, refs #1327 --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 2ab9f00a27..78a6575f51 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -43,6 +43,7 @@ This is a {{ site.pmd.release_type }} release. * java-bestpractices * [#940](https://github.com/pmd/pmd/issues/940): \[java] JUnit 4 false positives for JUnit 5 tests * [#1267](https://github.com/pmd/pmd/pull/1267): \[java] MissingOverrideRule: Avoid NoClassDefFoundError with incomplete classpath + * [#1327](https://github.com/pmd/pmd/pull/1327): \[java] AvoidUsingHardCodedIP false positive for ":bee" * java-codestyle * [#1255](https://github.com/pmd/pmd/issues/1255): \[java] UnnecessaryFullyQualifiedName false positive: static method on shadowed implicitly imported class * [#1258](https://github.com/pmd/pmd/issues/1285): \[java] False positive "UselessParentheses" for parentheses that contain assignment From b9501e5c779131a0632e61be90080993dbdb54c9 Mon Sep 17 00:00:00 2001 From: "Travis CI (pmd-bot)" Date: Sat, 1 Sep 2018 19:29:55 +0000 Subject: [PATCH 41/64] Update documentation TRAVIS_JOB_NUMBER=2786.1 TRAVIS_COMMIT_RANGE=ff63c5681a73...bec314ef276d --- docs/pages/pmd/rules/java/codestyle.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/pages/pmd/rules/java/codestyle.md b/docs/pages/pmd/rules/java/codestyle.md index 749073eb7c..de38f3acba 100644 --- a/docs/pages/pmd/rules/java/codestyle.md +++ b/docs/pages/pmd/rules/java/codestyle.md @@ -1140,15 +1140,16 @@ public class LinguisticNaming { |Name|Default Value|Description|Multivalued| |----|-------------|-----------|-----------| -|booleanFieldPrefixes|is \| has \| can \| have \| will \| should|the prefixes of fields and variables that indicate boolean|yes. Delimiter is '\|'.| -|checkVariables|true|Check local variable names and types for inconsistent naming|no| -|checkFields|true|Check field names and types for inconsistent naming|no| -|booleanMethodPrefixes|is \| has \| can \| have \| will \| should|the prefixes of methods that return boolean|yes. Delimiter is '\|'.| -|checkPrefixedTransformMethods|true|Check return type of methods whose names start with 'to'|no| -|checkTransformMethods|false|Check return type of methods which contain 'To' in their name|no| -|checkSetters|true|Check return type of setters|no| -|checkGetters|true|Check return type of getters|no| -|checkBooleanMethod|true|Check method names and types for inconsistent naming|no| +|booleanFieldPrefixes|is \| has \| can \| have \| will \| should|The prefixes of fields and variables that indicate boolean.|yes. Delimiter is '\|'.| +|checkVariables|true|Check local variable names and types for inconsistent naming.|no| +|checkFields|true|Check field names and types for inconsistent naming.|no| +|transformMethodNames|to \| as|The prefixes and infixes that indicate a transform method.|yes. Delimiter is '\|'.| +|booleanMethodPrefixes|is \| has \| can \| have \| will \| should|The prefixes of methods that return boolean.|yes. Delimiter is '\|'.| +|checkPrefixedTransformMethods|true|Check return type of methods whose names start with the configured prefix (see transformMethodNames property).|no| +|checkTransformMethods|false|Check return type of methods which contain the configured infix in their name (see transformMethodNames property).|no| +|checkSetters|true|Check return type of setters.|no| +|checkGetters|true|Check return type of getters.|no| +|checkBooleanMethod|true|Check method names and types for inconsistent naming.|no| **Use this rule by referencing it:** ``` xml From 7ebcb30aaa34e1eb1b86533339f8baab98d27001 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 1 Sep 2018 21:41:05 +0200 Subject: [PATCH 42/64] No need to check for missing ':' --- .../lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java index da340ced2a..a70cf3ce0e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java @@ -138,7 +138,7 @@ public class AvoidUsingHardCodedIPRule extends AbstractJavaRule { // 1) At least 3 characters // 2) 1st must be a Hex number or a : (colon) // 3) Must contain at least 2 colons (:) - if (s.length() < 3 || !(isHexCharacter(firstChar) || firstChar == ':') || s.indexOf(':') < 0 + if (s.length() < 3 || !(isHexCharacter(firstChar) || firstChar == ':') || StringUtils.countMatches(s, ':') < 2) { return false; } From ff5e83b21d14bc652d5b7f692be6385e47731a08 Mon Sep 17 00:00:00 2001 From: "Travis CI (pmd-bot)" Date: Sat, 1 Sep 2018 20:11:10 +0000 Subject: [PATCH 43/64] Update documentation TRAVIS_JOB_NUMBER=2790.1 TRAVIS_COMMIT_RANGE=b9501e5c7791...d0efb3cad751 --- docs/pages/pmd/rules/java/bestpractices.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/pages/pmd/rules/java/bestpractices.md b/docs/pages/pmd/rules/java/bestpractices.md index 56759de176..4c46a7a429 100644 --- a/docs/pages/pmd/rules/java/bestpractices.md +++ b/docs/pages/pmd/rules/java/bestpractices.md @@ -250,7 +250,6 @@ public class Foo { |Name|Default Value|Description|Multivalued| |----|-------------|-----------|-----------| |checkAddressTypes|IPv4 \| IPv6 \| IPv4 mapped IPv6|Check for IP address types.|yes. Delimiter is '\|'.| -|pattern|^"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"$|Regular Expression|no| **Use this rule by referencing it:** ``` xml @@ -874,6 +873,10 @@ can lead to quite messy code. This rule looks for several declarations on the sa //LocalVariableDeclaration [count(VariableDeclarator) > 1] [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)] +| +//FieldDeclaration + [count(VariableDeclarator) > 1] + [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)] ``` **Example(s):** From 2264d3c9641136c9c911a9cf3bcbc682661fbbda Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 1 Sep 2018 23:11:12 +0200 Subject: [PATCH 44/64] [ci] Fix sonar / coveralls build after switching to jdk 11 Also update jacoco plugin to 0.8.2 --- .travis/build-coveralls.sh | 2 +- .travis/build-sonar.sh | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis/build-coveralls.sh b/.travis/build-coveralls.sh index 7af296cd85..939e9b3a91 100755 --- a/.travis/build-coveralls.sh +++ b/.travis/build-coveralls.sh @@ -15,7 +15,7 @@ fi # # for java9: enable all modules. # coveralls plugin seems to need java.xml.bind module -echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se.ee'" > ${HOME}/.mavenrc +echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se'" > ${HOME}/.mavenrc ( # disable fast fail, exit immediately, in this subshell diff --git a/.travis/build-sonar.sh b/.travis/build-sonar.sh index e880f11d4d..37b3fc0c12 100755 --- a/.travis/build-sonar.sh +++ b/.travis/build-sonar.sh @@ -15,7 +15,7 @@ fi # # for java9: enable all modules. # sonar plugin seems to need java.xml.bind module -echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se.ee'" > ${HOME}/.mavenrc +echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se'" > ${HOME}/.mavenrc ( # disable fast fail, exit immediately, in this subshell diff --git a/pom.xml b/pom.xml index c6aeb24fee..065ae199c0 100644 --- a/pom.xml +++ b/pom.xml @@ -473,7 +473,7 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code org.jacoco jacoco-maven-plugin - 0.8.1 + 0.8.2 From 921d4190d74964da0aad9bba2f430faa6dd90cef Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 1 Sep 2018 23:15:29 +0200 Subject: [PATCH 45/64] [ci] Coveralls hasn't built the project since June 25th Fixes #1317 --- .travis/build-coveralls.sh | 2 +- docs/pages/release_notes.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis/build-coveralls.sh b/.travis/build-coveralls.sh index 939e9b3a91..bdcac5911f 100755 --- a/.travis/build-coveralls.sh +++ b/.travis/build-coveralls.sh @@ -22,7 +22,7 @@ echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se'" > ${HOME}/.mavenrc set +e ./mvnw clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V - ./mvnw test jacoco:report coveralls:report -Pcoveralls -B -V + ./mvnw package jacoco:report coveralls:report -Pcoveralls -B -V if [ $? -ne 0 ]; then log_error "Error creating coveralls report" diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 85ec75b3c1..22e49e19dd 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -45,6 +45,7 @@ This is a {{ site.pmd.release_type }} release. * [#1283](https://github.com/pmd/pmd/issues/1283): \[core] Deprecate ReportTree * [#1288](https://github.com/pmd/pmd/issues/1288): \[core] No supported build listeners found with Gradle * [#1300](https://github.com/pmd/pmd/issues/1300): \[core] PMD stops processing file completely, if one rule in a rule chain fails + * [#1317](https://github.com/pmd/pmd/issues/1317): \[ci] Coveralls hasn't built the project since June 25th * java-bestpractices * [#940](https://github.com/pmd/pmd/issues/940): \[java] JUnit 4 false positives for JUnit 5 tests * [#1267](https://github.com/pmd/pmd/pull/1267): \[java] MissingOverrideRule: Avoid NoClassDefFoundError with incomplete classpath From c9f686903e0abcc6e65e8eb091de178d0384fd6e Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 10:52:36 +0200 Subject: [PATCH 46/64] [ci] Coveralls hasn't built the project since June 25th The previous fix was not enough. Coveralls maven plugin depends on javax.xml.bind, which has been removed with JDK11, since it is a EE feature. Workaround is now, to add the jaxb-api as a plugin dependency, so that the utility class javax.xml.bind.DatatypeConverter is available. Fixes #1317 --- .travis/build-coveralls.sh | 5 ----- pom.xml | 11 +++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.travis/build-coveralls.sh b/.travis/build-coveralls.sh index bdcac5911f..0b9a82ec3d 100755 --- a/.travis/build-coveralls.sh +++ b/.travis/build-coveralls.sh @@ -12,11 +12,6 @@ if ! travis_isPush; then exit 0 fi -# -# for java9: enable all modules. -# coveralls plugin seems to need java.xml.bind module -echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se'" > ${HOME}/.mavenrc - ( # disable fast fail, exit immediately, in this subshell set +e diff --git a/pom.xml b/pom.xml index 065ae199c0..8108460aea 100644 --- a/pom.xml +++ b/pom.xml @@ -965,6 +965,17 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code org.eluder.coveralls coveralls-maven-plugin 4.3.0 + + + + javax.xml.bind + jaxb-api + 2.3.0 + + From 7a8847bacb958f325326652f07bba85048273fac Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 12:15:45 +0200 Subject: [PATCH 47/64] [ci] Fix sonar configuration For now, we need to use java10 with sonar, until sonarjava 5.8.0 is released, which adds support for java11. Apparantly sonar also loads the classfiles and can't yet load java11 classes, leading to many errors "Unsupported class file major version 55" while analyzing the project. Also update SONAR_TOKEN See https://jira.sonarsource.com/browse/SONARJAVA-2877 --- .travis.yml | 2 +- .travis/build-sonar.sh | 8 +++----- .travis/travis-settings.xml | 4 +++- pom.xml | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a2950387a..b93ad42d2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ env: global: - secure: KBEuB6U1p5RQXSYe157AwydFr/zpXQPA0IChVCgZV+X1mMyy9ZtrjH1J1AXuviseDDXDbaT25sRnsvpl82rfRw2xOkMGXHy4N95/ylTSr8DjHxTao71BhXsvFycNobFva5y2EGNWqDvpS8I2oSZo7Qk4la3yep3rcJQvcy6RDbbhpDTbL1QMFyadunIBm0WtqbunrMqtjSqaoPsXz8TiQuxHvX4vEXzVbaxV1QQt79Vi+daa6wAV3mRQAugnx+UffsC8JqMxgm06usWeJgCJzxgm8E7clZCLmf53B2TL8dK6bIYbqyvOY3uFxitsTG0d8Z0GOJwXBgZNgbniTRO8ZJSty5eZP8LBybbjVLSL25DNTWtCjADUL/uySnXIEidlMt2N/3QmH7zrGAfAk/tIwKpdRca2GLLydeXf6PSkiahnPEkIY/QupcsOLELhdifpdOjb8QW1OenA+vUbNM9dccLwKnX6Fj9cu4VQG601AcYDr2eyhq8WYkr3wYdw/6KdUa3hmplowTBs+qguppP+eOSgGuEsy38KLtqnvm6WlHy6tcLmcVYKG3DmR1b7TWXsOXC6/VMH8BHBkvsF1QdRg9+Cgx07vX3Hw7roPiYzmaO9Ajs20ATsUfRskMuWCTeTSK5pN8X27veRCZlhFjeKQMDdmfVwzpAfRgKsl3TEn1I= - secure: U1DfAv6acUUWe+dao/ZSDUX64JRadNJY16rITsdrM4ZNAJSuXpEY3p/LWcYjN7D49YmyutbXH9+L3KKQUQGrGXj9QTarfYvd8ZsKt4FK8yv7AFy+RQNIbAjNEHBzHx15p+srMheTaetl7aLwY0qhF+D/RtGapxHKyY4dBHrb0lp8VGyiCiL7Aop8GGskosi1mtirPBp/BStPZ2bEyxG0QzU5SsVWkJWwV9aWLPVAR/n7Xgx/6Gjl6Fed2c/WSrWi4vchm3Ny8pfTweOax3PGYYjBVxIfuX0mqmwuJsY7gNfXCfN3dPiPKGJPFy1pC+LGyGkklO5ReKFLd4O1ME6fU0dlIGfD6n+Q4H6/w9FHXegcKTfWIJm/MFa6vA/tJM5R6zJQuiTQJboHm/UmS/iQj76z0p6sK15Xp5vFId+/dHKqa8xY+Bt6HiXy6z401HOc8QcYBAf7TqhqUt/ZE7HN4be46uR90KmzIrWz6wEoDW7HfwQ9ZMbs55zoOXrvekyE9/gXskypO0p2JT3Y0vlvO27KQvIrSwI480kOVOrlyrYA+LZqlcKaayOuCuZh4lITQUYinUoZZict5joYthH+Cyh2zovoBpxsntDJdMnaZNLtSC7hlhpbMBYaT2y1O6vZH5Yix0mxuDvs/x6ogP5CNBeUYlXhaL+g4GnwKyr0ZA0= - - secure: "ElWjttpoMwqezP2zyHkx7CiPON/mRLUW7SsSlEqdlTUYRIaSaL7sShUORJUzj58U/Nnfi/eY4Rweo0CtVu20sG16s9B4adnmPS44LAitztybPR/co93gN9qb8jiIl41nVcOJq+Rut2Z4nr8AGRhVCG9Drg4+DreCqQ4DE5ZD6J99GN0IFGrREt59HQUlBlT9jD0AndK/1GQ6kWAenuSREE2P5ih59rf6FrrfddQO5iqyFFoaHek3JiOmpaLK+z7i4EvMKsAJEooFNuGhHVuyaJJRRZHAncGiQ+uW/yL7G5rY51G6YSNJczzEtfrRg+YrIUbokUPmifSIbnXO/AIZRAq1dMhA8exRc5n+75RB1X164qm4a+yggdybFBh0L59xu606PJQJAuWy+x10nled7FAVXiotxbB0r2bhlVmWFEN+FWPqXg2rVkHvw6+5PM67rG5g1LCgjKzb9I6JWPiVI+EMn8Pw8gryL2Sdqtl08Da0Ypbl2ZK/afU4CEPEKnrDc9ecXKjacehTYwGS48V213XvArcmoEpsyZDRSMTrvK3/e29GEaxoK/ZzWJylpeOtsICEEFYEBEiDsiIW4C50MIUPT2xHV6MaPQzhkuwrbQ6QFYzHzihBaiQuMmXUQ4DMb3fOPkNZAQHQo8CgJ78IcbCABAoGv9mu/fo2KoLo11U=" + - secure: "gxI7W4V4fUPQLMCvecXXdet1/mCh6m0RIQMtErVVOnwxEEjeDmko/3rHSl+wk6IeFaaQKcmHJJSJEj+e5TgWRH1uuzCnbFHZhuH28ce/H0EqLJ3GTXeDEgFLzhh//T3ySOZChZELgJ67cKxZJNFMhBVOR2/QIGjZjdzvl36ugsu80Ak3XJb8HCm8D2P8Vuezz/OlCkSOGXaiqZXfflV/cuaLWuueGfQGW9x/UyDTNsuBdB7YnEcxOWt8RgB4JrcPGV7/etxLHXTw9IMEeUhQ/RsxLZHKNYt9cx/QOZkpXemhdT9L2pAIi77eO98x+yAfB1qV6T6IeDd/OiABUzfb7asNBwE+bYRuVkCiWLo3x3hs8FcgsPe4L10guxfRMJPxax9E7uYb9TFxtvc42dDWNyp1BVCtEtmjErO4CJeW97ukhgkUkPhzUZgQ2Gj5Tn4VRjQOQyzh/S/YsHyfxoAQrscc/3bq5PBmtdowyGQd5dsvShdpE6glf+HnBZ8TCw5BaxQuTjapQWjsGuJVCVsrNDtwOFy5UTfxK9OeTUsjwfO5JjkoIeqGyLHPnTMWyZ6EYa//nWPOU1KgVE6Hrzfr3zxEzL1nN/TYahzhKOxXE701W9YhTmhCVljMlSYioTUfTaXHgGLpojvSWlhsTbc3r0gj4NglqakIy7MKgQLgES8=" - secure: "otZkFNhApMofp2Jl2baZdpNEPcTa79Xc9wyOw1gl1+ubCLtOGr32FDUSr0HQWKrGXcYZR4bc0A80hx0/ykZ/twJaRAabcNYtjwRMDKKrp3plvp8RTZlB1QW85nsdmk3qmHACzc94wKnmcaDohM5FPxnWspZG5Y4ejYX4HEK6r1fwL4FjMPSLd5QW8yCaAc7dpBSm2UyIXuuDjkekXblJFe8ydbf9aF97WKJMCwqIs9Zo5oJa2pnWCw47ixwjVdkaH5x5727I+YmFqn5rjdEideUFEAlggqMaxuOtfYhuG/8k5W3Q/+WX+G7rEPTcemjmaosbbpoOUE0YUHV3Wi3R5D66NuWIpQwX6kw4rTwL0YIh//0aNb8jv4Z8KwkiTMrYuj0we5tXzARp3yYn56P0JBAm6BihNhfEBv06655Tg5LUsWqUTZCl3KJhwtO1N+OuOkE5qoZm59knq6DeZOsYWAVb3MpzklP06kXGYTjb44PVMUc6ynuuZjgPJDv/0906feA3REHBJVxd3PvJp1c8VvQSeW3ndghEz0akJHY/jxV1rJZAZC1ZeshYUpBNmh0sFDty/UE43IvIB4EInypQHyTtQvMc6LuLjTeu2E5ZMsA3udj66EMrYm4Y2eheJycSfttDqzhsKXIVJ4LmA/xtDR01cp1jsqbbZBhVI67rA40=" - secure: "mmHRnK/8CHfgtwaTN3MgjFD1R8EVQhIb/a0Aag3gPaHWW52Ex6xWG7GsF4kRcdzHdIdrQxHZTiDa2oVMWbnQ16CAu4dZJadwTxhBW4JmE1tsi2C6i+uwMBPvnKBXHwt+QOAqNB0L/ByYwWLkucSLoyRs6qU0i7sJ3ZC/EPCuLI8VfBlFUVegSbp2WmclmFnxOi5MKr15Zwd8BGgyWUsvd1OHxhvO3Xr/ZPO4R+1kIgyojloTMu6oGM/shYgsrUXgmI/WvZRTq+25SRCjUmATJtuDXXgVeJtYabi/+Zju5Z7K06oaKvFYM+BgZWPmGQkVCxKVjSlug0rx6+qgRKIf/B/cPxmQDS0ZZVDmDcbxeibBL9JhRqIDwDb0XS9t1qBXvIJ5E4ZmdX/XuvLCnC4xJptu/vHyKl1wbRM3dcXEBk8J0knJc4JvY2yupF3LS32sfEHftLwzr63U3/0dOQvsCSJRBy5zgI8ieABUZAeZmmaQ6RCGOTEYrGO2G4CCF2uVq4YdrCOsfmrb0DzH8llNMkXKzXlITRvmkuBlTRRKxGnPzS3vf0iicdAkmTiU5u7lArFFc7IKcW4ypO+RKDTUpq74K+UZBI9eBjV7Po368EO8epJ5aIx32a2kyS/hYWkS/dZh7I0fNZa2qBUceZO/KZGRjH4dQFW9t0J9Q7LLXJY=" - secure: "geOU/7VR83KYTOCR5XkgFqnHJEnXeB6hNDE7UFcN4ZsL9uVLhxlDVWV3ujJ87nyBzggG1KfSnUx11UwOQrbBl0K6sEXo/B2q5ytOsWoSLi7+0qm/uhhw/DTBOq57p8TIDKFM7rDhO7uajSn7Y86LeZkh9wIs5265Fh1yhCkiPbczDUMsX4P0GGg2qgkIKSBw4DZf6sPDc4xjJq/4/cLnjXo/K0ZYAIoSLqDfe1gmkzMtQlad+1t8Lwv/gOJ4BNRF4a5aEvGF6kbFovFoeFWCQTKlkn6VJtY+BETGKW2RH9efGeMs7JbBbNm+nnpoNsbJ0gdmGlhSbWT8enIm72/P0ThTBJWVcLJ30tUd0UeYD9C49wbJ3RHSxsoUKP9YhHJ+XKNx+8irkJ8LPCkNMQEFE153gEVvU7tCgah9Uq6laYZv9cQE0dWzNt3//Ymls8BzY38Ha4PbrIIJqEuWwnAX6ZgTgzVtXx1AJjkDFG9KFKPhN7NfNMbh7rn5C84a1h5zrIydm+6RcIBC+xTLDEiN7djiquf3PcNtyGLcO8dNN4Uv8iU0Jw8ch3+w0PJO53v5py+IS1V8pwwYaYF2iVPOoziS0tP8MsgYVGwpTZhvz3v8x0ge8r6KJE4zdvoPtCRNr2Oo3sJGYqkt86Hu6agKFiljP5AgJNx7iQD5GQn6J3w=" diff --git a/.travis/build-sonar.sh b/.travis/build-sonar.sh index 37b3fc0c12..ac507c1106 100755 --- a/.travis/build-sonar.sh +++ b/.travis/build-sonar.sh @@ -12,17 +12,15 @@ if ! travis_isPush; then exit 0 fi -# -# for java9: enable all modules. -# sonar plugin seems to need java.xml.bind module -echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se'" > ${HOME}/.mavenrc +# for sonar, we need to use java10, until sonarjava 5.8.0 is released (Sept. 2018) +source ./install-jdk.sh -F 10 -L GPL -W $HOME/jdk ( # disable fast fail, exit immediately, in this subshell set +e # Run the build - ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN} -B -V + ./mvnw clean package sonar:sonar -Dsonar.login=${SONAR_TOKEN} -Psonar -B -V if [ $? -ne 0 ]; then log_error "Error updating sonar..." diff --git a/.travis/travis-settings.xml b/.travis/travis-settings.xml index 20ca3d60c8..d3c3c6446c 100644 --- a/.travis/travis-settings.xml +++ b/.travis/travis-settings.xml @@ -6,7 +6,9 @@ - + + org.sonarsource.scanner.maven + ossrh diff --git a/pom.xml b/pom.xml index 8108460aea..5428ceb903 100644 --- a/pom.xml +++ b/pom.xml @@ -980,6 +980,38 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code + + + sonar + + https://sonarcloud.io + + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.4.1.1168 + + + + + + org.jacoco + jacoco-maven-plugin + + + default-prepare-agent + + prepare-agent + + + + + + + From acdab9df56c280240efb1222e67afa6840f6375d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 12:31:11 +0200 Subject: [PATCH 48/64] [ci] Fix java10 installation for sonar --- .travis/build-sonar.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis/build-sonar.sh b/.travis/build-sonar.sh index ac507c1106..de418876db 100755 --- a/.travis/build-sonar.sh +++ b/.travis/build-sonar.sh @@ -12,10 +12,12 @@ if ! travis_isPush; then exit 0 fi -# for sonar, we need to use java10, until sonarjava 5.8.0 is released (Sept. 2018) -source ./install-jdk.sh -F 10 -L GPL -W $HOME/jdk - ( + # for sonar, we need to use java10, until sonarjava 5.8.0 is released (Sept. 2018) + JAVA_HOME=$(bash ./install-jdk.sh -F 10 -L GPL -W $HOME/jdk --emit-java-home | tail --lines 1) + export JAVA_HOME + export PATH=${JAVA_HOME}/bin:$PATH + # disable fast fail, exit immediately, in this subshell set +e From d8c51db85e13f85db006a6ce4fde0e763ca572c0 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 14:19:37 +0200 Subject: [PATCH 49/64] Prepare pmd release 6.7.0 --- docs/_config.yml | 2 +- docs/pages/release_notes.md | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index 86838109bd..6a57fd47c6 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -2,7 +2,7 @@ repository: pmd/pmd pmd: version: 6.7.0 - date: 2018-??-?? + date: 02-September-2018 release_type: minor output: web diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 1208aa184c..6330f72bb2 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -38,6 +38,14 @@ This is a {{ site.pmd.release_type }} release. single field / variable per line; or per statement if the `strictMode` property is set. It's an Apex equivalent of the already existing Java rule of the same name. +#### Deprecated Rules + +* The Java rules {% rule java/codestyle/VariableNamingConventions %}, {% rule java/codestyle/MIsLeadingVariableName %}, + {% rule java/codestyle/SuspiciousConstantFieldName %}, and {% rule java/codestyle/AvoidPrefixingMethodParameters %} are + now deprecated, and will be removed with version 7.0.0. They are replaced by the more general + {% rule java/codestyle/FieldNamingConventions %}, {% rule java/codestyle/FormalParameterNamingConventions %}, and + {% rule java/codestyle/LocalVariableNamingConventions %}. + ### Fixed Issues * core @@ -77,14 +85,6 @@ This is a {{ site.pmd.release_type }} release. make ShiftExpression inconsistent. The operator of a ShiftExpression is now accessible through ShiftExpression#getOperator. -#### Deprecated rules - -* The Java rules {% rule java/codestyle/VariableNamingConventions %}, {% rule java/codestyle/MIsLeadingVariableName %}, - {% rule java/codestyle/SuspiciousConstantFieldName %}, and {% rule java/codestyle/AvoidPrefixingMethodParameters %} are - now deprecated, and will be removed with version 7.0.0. They are replaced by the more general - {% rule java/codestyle/FieldNamingConventions %}, {% rule java/codestyle/FormalParameterNamingConventions %}, and - {% rule java/codestyle/LocalVariableNamingConventions %}. - ### External Contributions * [#109](https://github.com/pmd/pmd/pull/109): \[java] Add two linguistics rules under naming - [Arda Aslan](https://github.com/ardaasln) From b98bd0bb961d9f82437acccfe64923d992970310 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 14:27:33 +0200 Subject: [PATCH 50/64] [maven-release-plugin] prepare release pmd_releases/6.7.0 --- pmd-apex-jorje/pom.xml | 2 +- pmd-apex/pom.xml | 2 +- pmd-core/pom.xml | 2 +- pmd-cpp/pom.xml | 2 +- pmd-cs/pom.xml | 2 +- pmd-dist/pom.xml | 2 +- pmd-doc/pom.xml | 2 +- pmd-fortran/pom.xml | 2 +- pmd-go/pom.xml | 2 +- pmd-groovy/pom.xml | 2 +- pmd-java/pom.xml | 2 +- pmd-java8/pom.xml | 2 +- pmd-javascript/pom.xml | 2 +- pmd-jsp/pom.xml | 2 +- pmd-matlab/pom.xml | 2 +- pmd-objectivec/pom.xml | 2 +- pmd-perl/pom.xml | 2 +- pmd-php/pom.xml | 2 +- pmd-plsql/pom.xml | 2 +- pmd-python/pom.xml | 2 +- pmd-ruby/pom.xml | 2 +- pmd-scala/pom.xml | 2 +- pmd-swift/pom.xml | 2 +- pmd-test/pom.xml | 2 +- pmd-ui/pom.xml | 2 +- pmd-visualforce/pom.xml | 2 +- pmd-vm/pom.xml | 2 +- pmd-xml/pom.xml | 2 +- pom.xml | 4 ++-- 29 files changed, 30 insertions(+), 30 deletions(-) diff --git a/pmd-apex-jorje/pom.xml b/pmd-apex-jorje/pom.xml index f53d989da7..2296de21e5 100644 --- a/pmd-apex-jorje/pom.xml +++ b/pmd-apex-jorje/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-apex/pom.xml b/pmd-apex/pom.xml index 1fc38e5979..6970ba2de9 100644 --- a/pmd-apex/pom.xml +++ b/pmd-apex/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index 1d7f9819c6..2d3778844f 100644 --- a/pmd-core/pom.xml +++ b/pmd-core/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-cpp/pom.xml b/pmd-cpp/pom.xml index 52db8345e4..e3e3da4058 100644 --- a/pmd-cpp/pom.xml +++ b/pmd-cpp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-cs/pom.xml b/pmd-cs/pom.xml index 72e8afcc7c..47a0717d35 100644 --- a/pmd-cs/pom.xml +++ b/pmd-cs/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-dist/pom.xml b/pmd-dist/pom.xml index c09618a706..16593ddb4e 100644 --- a/pmd-dist/pom.xml +++ b/pmd-dist/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-doc/pom.xml b/pmd-doc/pom.xml index 7c9ddc5239..9ee352dd6f 100644 --- a/pmd-doc/pom.xml +++ b/pmd-doc/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-fortran/pom.xml b/pmd-fortran/pom.xml index d62194c4f9..262e97baa6 100644 --- a/pmd-fortran/pom.xml +++ b/pmd-fortran/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-go/pom.xml b/pmd-go/pom.xml index 13635af528..fa3b5e4543 100644 --- a/pmd-go/pom.xml +++ b/pmd-go/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-groovy/pom.xml b/pmd-groovy/pom.xml index d7f804400a..90adb6274f 100644 --- a/pmd-groovy/pom.xml +++ b/pmd-groovy/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index d43dbd7a6a..d4eaeada88 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-java8/pom.xml b/pmd-java8/pom.xml index 2fa4054c77..7b949da8c3 100644 --- a/pmd-java8/pom.xml +++ b/pmd-java8/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-javascript/pom.xml b/pmd-javascript/pom.xml index e6c8d5a17a..88c1a964fe 100644 --- a/pmd-javascript/pom.xml +++ b/pmd-javascript/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-jsp/pom.xml b/pmd-jsp/pom.xml index 614119b8e5..fec08876aa 100644 --- a/pmd-jsp/pom.xml +++ b/pmd-jsp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-matlab/pom.xml b/pmd-matlab/pom.xml index c08b83faa1..0c9c9bb4e8 100644 --- a/pmd-matlab/pom.xml +++ b/pmd-matlab/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-objectivec/pom.xml b/pmd-objectivec/pom.xml index 049e8bc890..d7dba0996a 100644 --- a/pmd-objectivec/pom.xml +++ b/pmd-objectivec/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-perl/pom.xml b/pmd-perl/pom.xml index 70f6d334e7..aa06d16790 100644 --- a/pmd-perl/pom.xml +++ b/pmd-perl/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-php/pom.xml b/pmd-php/pom.xml index 83b4e422a5..24c1af5a2b 100644 --- a/pmd-php/pom.xml +++ b/pmd-php/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-plsql/pom.xml b/pmd-plsql/pom.xml index 1936e058cc..a3ac95e29e 100644 --- a/pmd-plsql/pom.xml +++ b/pmd-plsql/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-python/pom.xml b/pmd-python/pom.xml index a88254c11c..a7c2781c66 100644 --- a/pmd-python/pom.xml +++ b/pmd-python/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-ruby/pom.xml b/pmd-ruby/pom.xml index 99fb66a08e..0f32180a43 100644 --- a/pmd-ruby/pom.xml +++ b/pmd-ruby/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-scala/pom.xml b/pmd-scala/pom.xml index b8837419a4..50015cef68 100644 --- a/pmd-scala/pom.xml +++ b/pmd-scala/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-swift/pom.xml b/pmd-swift/pom.xml index e3dfbd9d6e..30b8a71499 100644 --- a/pmd-swift/pom.xml +++ b/pmd-swift/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-test/pom.xml b/pmd-test/pom.xml index f525c34b05..91170a570d 100644 --- a/pmd-test/pom.xml +++ b/pmd-test/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-ui/pom.xml b/pmd-ui/pom.xml index 1befc3a7e1..ad43b4e632 100644 --- a/pmd-ui/pom.xml +++ b/pmd-ui/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-visualforce/pom.xml b/pmd-visualforce/pom.xml index 402ba937cf..a131789b2a 100644 --- a/pmd-visualforce/pom.xml +++ b/pmd-visualforce/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-vm/pom.xml b/pmd-vm/pom.xml index 9b004b42ee..4661972349 100644 --- a/pmd-vm/pom.xml +++ b/pmd-vm/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pmd-xml/pom.xml b/pmd-xml/pom.xml index 5c879bb41b..616c38d5c8 100644 --- a/pmd-xml/pom.xml +++ b/pmd-xml/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 diff --git a/pom.xml b/pom.xml index 5428ceb903..c5e26ad484 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.sourceforge.pmd pmd - 6.7.0-SNAPSHOT + 6.7.0 pom PMD @@ -234,7 +234,7 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code scm:git:git://github.com/pmd/pmd.git scm:git:ssh://git@github.com/pmd/pmd.git https://github.com/pmd/pmd - pmd_releases/6.5.0 + pmd_releases/6.7.0 From 291d36d8419bfc19e496c376c0ca1e28cd1a50f9 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 14:27:42 +0200 Subject: [PATCH 51/64] [maven-release-plugin] prepare for next development iteration --- pmd-apex-jorje/pom.xml | 2 +- pmd-apex/pom.xml | 2 +- pmd-core/pom.xml | 2 +- pmd-cpp/pom.xml | 2 +- pmd-cs/pom.xml | 2 +- pmd-dist/pom.xml | 2 +- pmd-doc/pom.xml | 2 +- pmd-fortran/pom.xml | 2 +- pmd-go/pom.xml | 2 +- pmd-groovy/pom.xml | 2 +- pmd-java/pom.xml | 2 +- pmd-java8/pom.xml | 2 +- pmd-javascript/pom.xml | 2 +- pmd-jsp/pom.xml | 2 +- pmd-matlab/pom.xml | 2 +- pmd-objectivec/pom.xml | 2 +- pmd-perl/pom.xml | 2 +- pmd-php/pom.xml | 2 +- pmd-plsql/pom.xml | 2 +- pmd-python/pom.xml | 2 +- pmd-ruby/pom.xml | 2 +- pmd-scala/pom.xml | 2 +- pmd-swift/pom.xml | 2 +- pmd-test/pom.xml | 2 +- pmd-ui/pom.xml | 2 +- pmd-visualforce/pom.xml | 2 +- pmd-vm/pom.xml | 2 +- pmd-xml/pom.xml | 2 +- pom.xml | 4 ++-- 29 files changed, 30 insertions(+), 30 deletions(-) diff --git a/pmd-apex-jorje/pom.xml b/pmd-apex-jorje/pom.xml index 2296de21e5..a6897a5657 100644 --- a/pmd-apex-jorje/pom.xml +++ b/pmd-apex-jorje/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-apex/pom.xml b/pmd-apex/pom.xml index 6970ba2de9..b9154e5ad6 100644 --- a/pmd-apex/pom.xml +++ b/pmd-apex/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index 2d3778844f..19059bc88a 100644 --- a/pmd-core/pom.xml +++ b/pmd-core/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-cpp/pom.xml b/pmd-cpp/pom.xml index e3e3da4058..954141a087 100644 --- a/pmd-cpp/pom.xml +++ b/pmd-cpp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-cs/pom.xml b/pmd-cs/pom.xml index 47a0717d35..15e7b227bf 100644 --- a/pmd-cs/pom.xml +++ b/pmd-cs/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-dist/pom.xml b/pmd-dist/pom.xml index 16593ddb4e..4f93d6128e 100644 --- a/pmd-dist/pom.xml +++ b/pmd-dist/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-doc/pom.xml b/pmd-doc/pom.xml index 9ee352dd6f..08a9c356a8 100644 --- a/pmd-doc/pom.xml +++ b/pmd-doc/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-fortran/pom.xml b/pmd-fortran/pom.xml index 262e97baa6..c068abea1b 100644 --- a/pmd-fortran/pom.xml +++ b/pmd-fortran/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-go/pom.xml b/pmd-go/pom.xml index fa3b5e4543..79d409113d 100644 --- a/pmd-go/pom.xml +++ b/pmd-go/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-groovy/pom.xml b/pmd-groovy/pom.xml index 90adb6274f..30c9b97c70 100644 --- a/pmd-groovy/pom.xml +++ b/pmd-groovy/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index d4eaeada88..329c8036a7 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-java8/pom.xml b/pmd-java8/pom.xml index 7b949da8c3..b9fda3ebcc 100644 --- a/pmd-java8/pom.xml +++ b/pmd-java8/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-javascript/pom.xml b/pmd-javascript/pom.xml index 88c1a964fe..bacddc1155 100644 --- a/pmd-javascript/pom.xml +++ b/pmd-javascript/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-jsp/pom.xml b/pmd-jsp/pom.xml index fec08876aa..897bbcd3cc 100644 --- a/pmd-jsp/pom.xml +++ b/pmd-jsp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-matlab/pom.xml b/pmd-matlab/pom.xml index 0c9c9bb4e8..08d1f1abf8 100644 --- a/pmd-matlab/pom.xml +++ b/pmd-matlab/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-objectivec/pom.xml b/pmd-objectivec/pom.xml index d7dba0996a..868abfc638 100644 --- a/pmd-objectivec/pom.xml +++ b/pmd-objectivec/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-perl/pom.xml b/pmd-perl/pom.xml index aa06d16790..527f8ba177 100644 --- a/pmd-perl/pom.xml +++ b/pmd-perl/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-php/pom.xml b/pmd-php/pom.xml index 24c1af5a2b..843498aacd 100644 --- a/pmd-php/pom.xml +++ b/pmd-php/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-plsql/pom.xml b/pmd-plsql/pom.xml index a3ac95e29e..dbfdcef557 100644 --- a/pmd-plsql/pom.xml +++ b/pmd-plsql/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-python/pom.xml b/pmd-python/pom.xml index a7c2781c66..d9d74f909b 100644 --- a/pmd-python/pom.xml +++ b/pmd-python/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-ruby/pom.xml b/pmd-ruby/pom.xml index 0f32180a43..f67a53fcb3 100644 --- a/pmd-ruby/pom.xml +++ b/pmd-ruby/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-scala/pom.xml b/pmd-scala/pom.xml index 50015cef68..eceaa262b0 100644 --- a/pmd-scala/pom.xml +++ b/pmd-scala/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-swift/pom.xml b/pmd-swift/pom.xml index 30b8a71499..371576e5aa 100644 --- a/pmd-swift/pom.xml +++ b/pmd-swift/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-test/pom.xml b/pmd-test/pom.xml index 91170a570d..873e8a371b 100644 --- a/pmd-test/pom.xml +++ b/pmd-test/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-ui/pom.xml b/pmd-ui/pom.xml index ad43b4e632..4ff9460aa4 100644 --- a/pmd-ui/pom.xml +++ b/pmd-ui/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-visualforce/pom.xml b/pmd-visualforce/pom.xml index a131789b2a..6bd353e38c 100644 --- a/pmd-visualforce/pom.xml +++ b/pmd-visualforce/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-vm/pom.xml b/pmd-vm/pom.xml index 4661972349..04d669d5b9 100644 --- a/pmd-vm/pom.xml +++ b/pmd-vm/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pmd-xml/pom.xml b/pmd-xml/pom.xml index 616c38d5c8..e1cd6a0fb7 100644 --- a/pmd-xml/pom.xml +++ b/pmd-xml/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index c5e26ad484..57df22d03d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.sourceforge.pmd pmd - 6.7.0 + 6.8.0-SNAPSHOT pom PMD @@ -234,7 +234,7 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code scm:git:git://github.com/pmd/pmd.git scm:git:ssh://git@github.com/pmd/pmd.git https://github.com/pmd/pmd - pmd_releases/6.7.0 + pmd_releases/6.5.0 From 86c89040b45af136b254e5627c8d060c51101486 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 14:30:21 +0200 Subject: [PATCH 52/64] Prepare next development version --- docs/_config.yml | 4 +- docs/pages/release_notes.md | 84 ++------------------------------- docs/pages/release_notes_old.md | 2 + 3 files changed, 7 insertions(+), 83 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index 6a57fd47c6..aa5028435f 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,8 +1,8 @@ repository: pmd/pmd pmd: - version: 6.7.0 - date: 02-September-2018 + version: 6.8.0 + date: ??-??-2018 release_type: minor output: web diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 6330f72bb2..7abd6980aa 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -4,99 +4,21 @@ permalink: pmd_release_notes.html keywords: changelog, release notes --- -# {{ site.pmd.date }} - {{ site.pmd.version }} +## {{ site.pmd.date }} - {{ site.pmd.version }} The PMD team is pleased to announce PMD {{ site.pmd.version }}. This is a {{ site.pmd.release_type }} release. -{% tocmaker is_release_notes_processor %} +{% tocmaker %} ### New and noteworthy -#### Modified Rules - -* The Java rule {% rule java/bestpractices/OneDeclarationPerLine %} (`java-bestpractices`) has been revamped to - consider not only local variable declarations, but field declarations too. - -#### New Rules - -* The new Java rule {% rule java/codestyle/LinguisticNaming %} (`java-codestyle`) - detects cases, when a method name indicates it returns a boolean (such as `isSmall()`) but it doesn't. - Besides method names, the rule also checks field and variable names. It also checks, that getters return - something but setters won't. The rule has several properties with which it can be customized. - -* The new PL/SQL rule {% rule plsql/codestyle/ForLoopNaming %} (`plsql-codestyle`) - enforces a naming convention for "for loops". Both "cursor for loops" and "index for loops" are covered. - The rule can be customized via patterns. By default, short variable names are reported. - -* The new Java rule {% rule java/codestyle/FieldNamingConventions %} (`java-codestyle`) - detects field names that don't comply to a given convention. It defaults to standard Java convention of using camelCase, - but can be configured with ease for e.g. constants or static fields. - -* The new Apex rule {% rule apex/codestyle/OneDeclarationPerLine %} (`apex-codestyle`) enforces declaring a - single field / variable per line; or per statement if the `strictMode` property is set. - It's an Apex equivalent of the already existing Java rule of the same name. - -#### Deprecated Rules - -* The Java rules {% rule java/codestyle/VariableNamingConventions %}, {% rule java/codestyle/MIsLeadingVariableName %}, - {% rule java/codestyle/SuspiciousConstantFieldName %}, and {% rule java/codestyle/AvoidPrefixingMethodParameters %} are - now deprecated, and will be removed with version 7.0.0. They are replaced by the more general - {% rule java/codestyle/FieldNamingConventions %}, {% rule java/codestyle/FormalParameterNamingConventions %}, and - {% rule java/codestyle/LocalVariableNamingConventions %}. - ### Fixed Issues -* core - * [#1191](https://github.com/pmd/pmd/issues/1191): \[core] Test Framework: Sort violations by line/column - * [#1283](https://github.com/pmd/pmd/issues/1283): \[core] Deprecate ReportTree - * [#1288](https://github.com/pmd/pmd/issues/1288): \[core] No supported build listeners found with Gradle - * [#1300](https://github.com/pmd/pmd/issues/1300): \[core] PMD stops processing file completely, if one rule in a rule chain fails - * [#1317](https://github.com/pmd/pmd/issues/1317): \[ci] Coveralls hasn't built the project since June 25th -* java-bestpractices - * [#940](https://github.com/pmd/pmd/issues/940): \[java] JUnit 4 false positives for JUnit 5 tests - * [#1267](https://github.com/pmd/pmd/pull/1267): \[java] MissingOverrideRule: Avoid NoClassDefFoundError with incomplete classpath - * [#1323](https://github.com/pmd/pmd/issues/1323): \[java] AvoidUsingHardCodedIP ignores match pattern - * [#1327](https://github.com/pmd/pmd/pull/1327): \[java] AvoidUsingHardCodedIP false positive for ":bee" -* java-codestyle - * [#1255](https://github.com/pmd/pmd/issues/1255): \[java] UnnecessaryFullyQualifiedName false positive: static method on shadowed implicitly imported class - * [#1258](https://github.com/pmd/pmd/issues/1285): \[java] False positive "UselessParentheses" for parentheses that contain assignment -* java-errorprone - * [#1078](https://github.com/pmd/pmd/issues/1078): \[java] MissingSerialVersionUID rule does not seem to catch inherited classes -* java-performance - * [#1291](https://github.com/pmd/pmd/issues/1291): \[java] InvalidSlf4jMessageFormat false positive: too many arguments with string concatenation operator - * [#1298](https://github.com/pmd/pmd/issues/1298): \[java] RedundantFieldInitializer - NumberFormatException with Long -* jsp - * [#1274](https://github.com/pmd/pmd/issues/1274): \[jsp] Support EL in tag attributes - * [#1276](https://github.com/pmd/pmd/issues/1276): \[jsp] add support for jspf and tag extensions -* plsql - * [#681](https://github.com/pmd/pmd/issues/681): \[plsql] Parse error with Cursor For Loop - ### API Changes -* All classes in the package `net.sourceforge.pmd.lang.dfa.report` have been deprecated and will be removed - with PMD 7.0.0. This includes the class `net.sourceforge.pmd.lang.dfa.report.ReportTree`. The reason is, - that this class is very specific to Java and not suitable for other languages. It has only been used for - `YAHTMLRenderer`, which has been rewritten to work without these classes. - -* The nodes RUNSIGNEDSHIFT and RSIGNEDSHIFT are deprecated and will be removed from the AST with PMD 7.0.0. - These represented the operator of ShiftExpression in two cases out of three, but they're not needed and - make ShiftExpression inconsistent. The operator of a ShiftExpression is now accessible through - ShiftExpression#getOperator. - ### External Contributions -* [#109](https://github.com/pmd/pmd/pull/109): \[java] Add two linguistics rules under naming - [Arda Aslan](https://github.com/ardaasln) -* [#1254](https://github.com/pmd/pmd/pull/1254): \[ci] \[GSoC] Integrating the danger and pmdtester to travis CI - [BBG](https://github.com/djydewang) -* [#1258](https://github.com/pmd/pmd/pull/1258): \[java] Use typeof in MissingSerialVersionUID - [krichter722](https://github.com/krichter722) -* [#1264](https://github.com/pmd/pmd/pull/1264): \[cpp] Fix NullPointerException in CPPTokenizer:99 - [Rafael Cortês](https://github.com/mrfyda) -* [#1277](https://github.com/pmd/pmd/pull/1277): \[jsp] #1276 add support for jspf and tag extensions - [Jordi Llach](https://github.com/jordillachmrf) -* [#1275](https://github.com/pmd/pmd/pull/1275): \[jsp] Issue #1274 - Support EL in tag attributes - [Jordi Llach](https://github.com/jordillachmrf) -* [#1278](https://github.com/pmd/pmd/pull/1278): \[ci] \[GSoC] Use pmdtester 1.0.0.pre.beta3 - [BBG](https://github.com/djydewang) -* [#1289](https://github.com/pmd/pmd/pull/1289): \[java] UselessParentheses: Fix false positive with assignments - [cobratbq](https://github.com/cobratbq) -* [#1290](https://github.com/pmd/pmd/pull/1290): \[docs] \[GSoC] Create the documentation about pmdtester - [BBG](https://github.com/djydewang) -* [#1256](https://github.com/pmd/pmd/pull/1256): \[java] #940 Avoid JUnit 4 false positives for JUnit 5 tests - [Alex Shesterov](https://github.com/vovkss) -* [#1315](https://github.com/pmd/pmd/pull/1315): \[apex] Add OneDeclarationPerStatement rule - [Jeff Hube](https://github.com/jeffhube) - {% endtocmaker %} + diff --git a/docs/pages/release_notes_old.md b/docs/pages/release_notes_old.md index 3c3cd9e857..d971f252ff 100644 --- a/docs/pages/release_notes_old.md +++ b/docs/pages/release_notes_old.md @@ -6,6 +6,8 @@ permalink: pmd_release_notes_old.html Previous versions of PMD can be downloaded here: http://sourceforge.net/projects/pmd/files/pmd/ + + ## 29-July-2018 - 6.6.0 The PMD team is pleased to announce PMD 6.6.0. From 65a3e1a3f71772ca9f4525a9a7005230576fba2a Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 14:33:51 +0200 Subject: [PATCH 53/64] Fix old release notes --- docs/pages/release_notes_old.md | 102 ++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/docs/pages/release_notes_old.md b/docs/pages/release_notes_old.md index d971f252ff..de6639ce49 100644 --- a/docs/pages/release_notes_old.md +++ b/docs/pages/release_notes_old.md @@ -6,6 +6,108 @@ permalink: pmd_release_notes_old.html Previous versions of PMD can be downloaded here: http://sourceforge.net/projects/pmd/files/pmd/ +## 02-September-2018 - 6.7.0 + +The PMD team is pleased to announce PMD 6.7.0. + +This is a minor release. + +### Table Of Contents + +* [New and noteworthy](#new-and-noteworthy) + * [Modified Rules](#modified-rules) + * [New Rules](#new-rules) + * [Deprecated Rules](#deprecated-rules) +* [Fixed Issues](#fixed-issues) +* [API Changes](#api-changes) +* [External Contributions](#external-contributions) + +### New and noteworthy + +#### Modified Rules + +* The Java rule {% rule java/bestpractices/OneDeclarationPerLine %} (`java-bestpractices`) has been revamped to + consider not only local variable declarations, but field declarations too. + +#### New Rules + +* The new Java rule {% rule java/codestyle/LinguisticNaming %} (`java-codestyle`) + detects cases, when a method name indicates it returns a boolean (such as `isSmall()`) but it doesn't. + Besides method names, the rule also checks field and variable names. It also checks, that getters return + something but setters won't. The rule has several properties with which it can be customized. + +* The new PL/SQL rule {% rule plsql/codestyle/ForLoopNaming %} (`plsql-codestyle`) + enforces a naming convention for "for loops". Both "cursor for loops" and "index for loops" are covered. + The rule can be customized via patterns. By default, short variable names are reported. + +* The new Java rule {% rule java/codestyle/FieldNamingConventions %} (`java-codestyle`) + detects field names that don't comply to a given convention. It defaults to standard Java convention of using camelCase, + but can be configured with ease for e.g. constants or static fields. + +* The new Apex rule {% rule apex/codestyle/OneDeclarationPerLine %} (`apex-codestyle`) enforces declaring a + single field / variable per line; or per statement if the `strictMode` property is set. + It's an Apex equivalent of the already existing Java rule of the same name. + +#### Deprecated Rules + +* The Java rules {% rule java/codestyle/VariableNamingConventions %}, {% rule java/codestyle/MIsLeadingVariableName %}, + {% rule java/codestyle/SuspiciousConstantFieldName %}, and {% rule java/codestyle/AvoidPrefixingMethodParameters %} are + now deprecated, and will be removed with version 7.0.0. They are replaced by the more general + {% rule java/codestyle/FieldNamingConventions %}, {% rule java/codestyle/FormalParameterNamingConventions %}, and + {% rule java/codestyle/LocalVariableNamingConventions %}. + +### Fixed Issues + +* core + * [#1191](https://github.com/pmd/pmd/issues/1191): \[core] Test Framework: Sort violations by line/column + * [#1283](https://github.com/pmd/pmd/issues/1283): \[core] Deprecate ReportTree + * [#1288](https://github.com/pmd/pmd/issues/1288): \[core] No supported build listeners found with Gradle + * [#1300](https://github.com/pmd/pmd/issues/1300): \[core] PMD stops processing file completely, if one rule in a rule chain fails + * [#1317](https://github.com/pmd/pmd/issues/1317): \[ci] Coveralls hasn't built the project since June 25th +* java-bestpractices + * [#940](https://github.com/pmd/pmd/issues/940): \[java] JUnit 4 false positives for JUnit 5 tests + * [#1267](https://github.com/pmd/pmd/pull/1267): \[java] MissingOverrideRule: Avoid NoClassDefFoundError with incomplete classpath + * [#1323](https://github.com/pmd/pmd/issues/1323): \[java] AvoidUsingHardCodedIP ignores match pattern + * [#1327](https://github.com/pmd/pmd/pull/1327): \[java] AvoidUsingHardCodedIP false positive for ":bee" +* java-codestyle + * [#1255](https://github.com/pmd/pmd/issues/1255): \[java] UnnecessaryFullyQualifiedName false positive: static method on shadowed implicitly imported class + * [#1258](https://github.com/pmd/pmd/issues/1285): \[java] False positive "UselessParentheses" for parentheses that contain assignment +* java-errorprone + * [#1078](https://github.com/pmd/pmd/issues/1078): \[java] MissingSerialVersionUID rule does not seem to catch inherited classes +* java-performance + * [#1291](https://github.com/pmd/pmd/issues/1291): \[java] InvalidSlf4jMessageFormat false positive: too many arguments with string concatenation operator + * [#1298](https://github.com/pmd/pmd/issues/1298): \[java] RedundantFieldInitializer - NumberFormatException with Long +* jsp + * [#1274](https://github.com/pmd/pmd/issues/1274): \[jsp] Support EL in tag attributes + * [#1276](https://github.com/pmd/pmd/issues/1276): \[jsp] add support for jspf and tag extensions +* plsql + * [#681](https://github.com/pmd/pmd/issues/681): \[plsql] Parse error with Cursor For Loop + +### API Changes + +* All classes in the package `net.sourceforge.pmd.lang.dfa.report` have been deprecated and will be removed + with PMD 7.0.0. This includes the class `net.sourceforge.pmd.lang.dfa.report.ReportTree`. The reason is, + that this class is very specific to Java and not suitable for other languages. It has only been used for + `YAHTMLRenderer`, which has been rewritten to work without these classes. + +* The nodes RUNSIGNEDSHIFT and RSIGNEDSHIFT are deprecated and will be removed from the AST with PMD 7.0.0. + These represented the operator of ShiftExpression in two cases out of three, but they're not needed and + make ShiftExpression inconsistent. The operator of a ShiftExpression is now accessible through + ShiftExpression#getOperator. + +### External Contributions + +* [#109](https://github.com/pmd/pmd/pull/109): \[java] Add two linguistics rules under naming - [Arda Aslan](https://github.com/ardaasln) +* [#1254](https://github.com/pmd/pmd/pull/1254): \[ci] \[GSoC] Integrating the danger and pmdtester to travis CI - [BBG](https://github.com/djydewang) +* [#1258](https://github.com/pmd/pmd/pull/1258): \[java] Use typeof in MissingSerialVersionUID - [krichter722](https://github.com/krichter722) +* [#1264](https://github.com/pmd/pmd/pull/1264): \[cpp] Fix NullPointerException in CPPTokenizer:99 - [Rafael Cortês](https://github.com/mrfyda) +* [#1277](https://github.com/pmd/pmd/pull/1277): \[jsp] #1276 add support for jspf and tag extensions - [Jordi Llach](https://github.com/jordillachmrf) +* [#1275](https://github.com/pmd/pmd/pull/1275): \[jsp] Issue #1274 - Support EL in tag attributes - [Jordi Llach](https://github.com/jordillachmrf) +* [#1278](https://github.com/pmd/pmd/pull/1278): \[ci] \[GSoC] Use pmdtester 1.0.0.pre.beta3 - [BBG](https://github.com/djydewang) +* [#1289](https://github.com/pmd/pmd/pull/1289): \[java] UselessParentheses: Fix false positive with assignments - [cobratbq](https://github.com/cobratbq) +* [#1290](https://github.com/pmd/pmd/pull/1290): \[docs] \[GSoC] Create the documentation about pmdtester - [BBG](https://github.com/djydewang) +* [#1256](https://github.com/pmd/pmd/pull/1256): \[java] #940 Avoid JUnit 4 false positives for JUnit 5 tests - [Alex Shesterov](https://github.com/vovkss) +* [#1315](https://github.com/pmd/pmd/pull/1315): \[apex] Add OneDeclarationPerStatement rule - [Jeff Hube](https://github.com/jeffhube) ## 29-July-2018 - 6.6.0 From 849cb30054c1ad8a32bb10e0c38c7fcfbd4964f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sun, 2 Sep 2018 15:11:21 +0200 Subject: [PATCH 54/64] Remove Beta annotation --- docs/pages/release_notes.md | 11 ++--------- .../net/sourceforge/pmd/annotation/Beta.java | 18 ------------------ 2 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/annotation/Beta.java diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7374f048d7..cd56290283 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -44,18 +44,11 @@ by classes within PMD. As such, we may add new abstract methods, or remove prote at any time. All published public members remain supported. The annotation is *not* inherited, which means a reserved interface doesn't prevent its implementors to be subclassed. -##### `@Beta` - -APIs marked with the `@Beta` annotation at the class or method level are subject to change. -They can be modified in any way, or even removed, at any time. If your code is a library -itself (i.e. it is used on the CLASSPATH of users outside your own control), you should not -use beta APIs, unless you repackage them (e.g. using ProGuard, shading, etc). - ##### `@Experimental` -APIs marked with the `@Experimental` annotation at the class or method level will almost certainly -change. They can be modified in any way, or even removed, at any time. You should not use or rely +APIs marked with the `@Experimental` annotation at the class or method level are subject to change. +They can be modified in any way, or even removed, at any time. You should not use or rely on them in any production code. They are purely to allow broad testing and feedback. ##### `@Deprecated` diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Beta.java b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Beta.java deleted file mode 100644 index 60db861ca4..0000000000 --- a/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Beta.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.annotation; - -import java.lang.annotation.Documented; - - -/** - * Indicates the feature is in beta state: it will be most likely stay but - * the signature may change between versions without warning. - * - * @since 6.7.0 - */ -@Documented -public @interface Beta { -} From 848a0761fee84d850ecdbc87c46ed833a68bf135 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 14:51:23 +0200 Subject: [PATCH 55/64] Fix release scripts * fix language var LANG * fix bundle install command * automate creation of release notes post in pmd.github.io * add var "is_release_notes_processor" * Always install the gems for rendering release notes --- .travis.yml | 2 +- .travis/build-coveralls.sh | 2 +- .travis/build-doc.sh | 2 +- .travis/build-sonar.sh | 2 +- .travis/release.sh | 3 --- Gemfile | 4 +++- do-release.sh | 22 +++++++++++----------- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index b93ad42d2a..684b34f79b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ before_install: install: - . ./install-jdk.sh -F 11 -L GPL -W $HOME/jdk - gem install bundler - - bundle install --without=release_notes_preprocessing + - bundle install --with=release_notes_preprocessing before_script: true script: source .travis/build-$BUILD.sh after_success: true diff --git a/.travis/build-coveralls.sh b/.travis/build-coveralls.sh index 0b9a82ec3d..b58629a5fa 100755 --- a/.travis/build-coveralls.sh +++ b/.travis/build-coveralls.sh @@ -4,7 +4,7 @@ set -e source .travis/logger.sh source .travis/common-functions.sh -VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) +VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec) log_info "Building PMD Coveralls.io report ${VERSION} on branch ${TRAVIS_BRANCH}" if ! travis_isPush; then diff --git a/.travis/build-doc.sh b/.travis/build-doc.sh index f340a42c61..e4ec9c9a9b 100755 --- a/.travis/build-doc.sh +++ b/.travis/build-doc.sh @@ -4,7 +4,7 @@ set -e source .travis/logger.sh source .travis/common-functions.sh -VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) +VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec) log_info "Building PMD Documentation ${VERSION} on branch ${TRAVIS_BRANCH}" if ! travis_isPush; then diff --git a/.travis/build-sonar.sh b/.travis/build-sonar.sh index de418876db..7e51aaf46d 100755 --- a/.travis/build-sonar.sh +++ b/.travis/build-sonar.sh @@ -4,7 +4,7 @@ set -e source .travis/logger.sh source .travis/common-functions.sh -VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) +VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec) log_info "Building PMD Sonar ${VERSION} on branch ${TRAVIS_BRANCH}" if ! travis_isPush; then diff --git a/.travis/release.sh b/.travis/release.sh index 883f9721d4..2565125c88 100755 --- a/.travis/release.sh +++ b/.travis/release.sh @@ -28,9 +28,6 @@ if [ "${BUILD}" = "deploy" ]; then true ) -# install the gems required for rendering the release notes -bundle install --with=release_notes_preprocessing - # renders, and skips the first 6 lines - the Jekyll front-matter RENDERED_RELEASE_NOTES=$(bundle exec .travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6) diff --git a/Gemfile b/Gemfile index ed76d93bfe..4894455d47 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,9 @@ source 'https://rubygems.org/' gem 'pmdtester', '~> 1.0.0.pre.beta3' gem 'danger', '~> 5.6', '>= 5.6' -# This group is only needed during release (via .travis/release.sh and do-release.sh) +# This group is only needed for rendering release notes +# this happens during release (.travis/release.sh and do-release.sh) +# but also during regular builds (.travis/build-deploy.sh) group :release_notes_preprocessing do gem 'liquid', '>=4.0.0' gem 'safe_yaml', '>=1.0' diff --git a/do-release.sh b/do-release.sh index e98ab9ec92..38aab524e3 100755 --- a/do-release.sh +++ b/do-release.sh @@ -1,7 +1,7 @@ #!/bin/bash # Make sure, everything is English... -export LANG=C.UTF8 +export LANG=C.UTF-8 # verify the current directory if [ ! -f pom.xml -o ! -d ../pmd.github.io ]; then @@ -62,15 +62,19 @@ echo "Press enter to continue..." read -# install bundles needed for rendering release notes -bundle install with=release_notes_preprocessing --path vendor/bundle - - export RELEASE_VERSION export DEVELOPMENT_VERSION export CURRENT_BRANCH + +# install bundles needed for rendering release notes +bundle install --with=release_notes_preprocessing --path vendor/bundle + RELEASE_RULESET="pmd-core/src/main/resources/rulesets/releases/${RELEASE_VERSION//\./}.xml" +export RELEASE_NOTES_POST="_posts/$(date -u +%Y-%m-%d)-PMD-${RELEASE_VERSION}.md" +echo "Generating ../pmd.github.io/${RELEASE_NOTES_POST}..." +NEW_RELEASE_NOTES=$(bundle exec .travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6) +echo "${NEW_RELEASE_NOTES}" > ../pmd.github.io/${RELEASE_NOTES_POST} echo "* Update date info in **docs/_config.yml**." echo " date: $(date -u +%d-%B-%Y)" @@ -80,8 +84,6 @@ echo " ${RELEASE_RULESET}" echo echo "* Update **../pmd.github.io/_config.yml** to mention the new release" echo -echo "* Add **../pmd.github.io/_posts/$(date -u +%Y-%m-%d)-PMD-${RELEASE_VERSION}.md" -echo echo "Press enter to continue..." read echo "Committing current changes (pmd)" @@ -95,7 +97,7 @@ git commit -a -m "Prepare pmd release ${RELEASE_VERSION}" ( echo "Committing current changes (pmd.github.io)" cd ../pmd.github.io - git add _posts/$(date -u +%Y-%m-%d)-PMD-${RELEASE_VERSION}.md + git add ${RELEASE_NOTES_POST} git commit -a -m "Prepare pmd release ${RELEASE_VERSION}" git push ) @@ -117,7 +119,6 @@ echo echo "Check the milestone on github:" echo "" echo " --> move any open issues to the next milestone, close the current milestone" -echo " --> Maybe there are some milestones on sourceforge, too: ." echo echo echo "Prepare Next development version:" @@ -129,7 +130,6 @@ read # update release_notes_old OLD_RELEASE_NOTES=$(tail -n +8 docs/pages/release_notes_old.md) -NEW_RELEASE_NOTES=$(bundle exec .travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6) echo "$(head -n 7 docs/pages/release_notes_old.md)" > docs/pages/release_notes_old.md echo "$NEW_RELEASE_NOTES" >> docs/pages/release_notes_old.md echo >> docs/pages/release_notes_old.md @@ -149,7 +149,7 @@ The PMD team is pleased to announce PMD {{ site.pmd.version }}. This is a {{ site.pmd.release_type }} release. -{% tocmaker %} +{% tocmaker is_release_notes_processor %} ### New and noteworthy From e3018c3892bb34805efff9d9a2e4c6acde682887 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 2 Sep 2018 15:36:38 +0200 Subject: [PATCH 56/64] [doc] Update gems --- docs/Gemfile.lock | 55 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index a8204adfd9..8edebbb121 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -13,10 +13,11 @@ GEM execjs coffee-script-source (1.11.1) colorator (1.1.0) - commonmarker (0.17.9) + commonmarker (0.17.11) ruby-enum (~> 0.5) concurrent-ruby (1.0.5) - dnsruby (1.60.2) + dnsruby (1.61.2) + addressable (~> 2.5) em-websocket (0.5.1) eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) @@ -26,29 +27,29 @@ GEM execjs (2.7.0) faraday (0.15.2) multipart-post (>= 1.2, < 3) - ffi (1.9.23) + ffi (1.9.25) forwardable-extended (2.6.0) gemoji (3.0.0) - github-pages (186) + github-pages (191) activesupport (= 4.2.10) github-pages-health-check (= 1.8.1) jekyll (= 3.7.3) - jekyll-avatar (= 0.5.0) + jekyll-avatar (= 0.6.0) jekyll-coffeescript (= 1.1.1) jekyll-commonmark-ghpages (= 0.1.5) jekyll-default-layout (= 0.1.4) - jekyll-feed (= 0.9.3) + jekyll-feed (= 0.10.0) jekyll-gist (= 1.5.0) jekyll-github-metadata (= 2.9.4) - jekyll-mentions (= 1.3.0) + jekyll-mentions (= 1.4.1) jekyll-optional-front-matter (= 0.3.0) jekyll-paginate (= 1.1.0) jekyll-readme-index (= 0.2.0) - jekyll-redirect-from (= 0.13.0) + jekyll-redirect-from (= 0.14.0) jekyll-relative-links (= 0.5.3) jekyll-remote-theme (= 0.3.1) jekyll-sass-converter (= 1.5.2) - jekyll-seo-tag (= 2.4.0) + jekyll-seo-tag (= 2.5.0) jekyll-sitemap (= 1.2.0) jekyll-swiss (= 0.4.0) jekyll-theme-architect (= 0.1.1) @@ -65,12 +66,12 @@ GEM jekyll-theme-tactile (= 0.1.1) jekyll-theme-time-machine (= 0.1.1) jekyll-titles-from-headings (= 0.5.1) - jemoji (= 0.9.0) - kramdown (= 1.16.2) + jemoji (= 0.10.1) + kramdown (= 1.17.0) liquid (= 4.0.0) listen (= 3.1.5) mercenary (~> 0.3) - minima (= 2.4.1) + minima (= 2.5.0) nokogiri (>= 1.8.2, < 2.0) rouge (= 2.2.1) terminal-table (~> 1.4) @@ -80,7 +81,7 @@ GEM octokit (~> 4.0) public_suffix (~> 2.0) typhoeus (~> 1.3) - html-pipeline (2.8.0) + html-pipeline (2.8.4) activesupport (>= 2) nokogiri (>= 1.4) http_parser.rb (0.6.0) @@ -99,7 +100,7 @@ GEM pathutil (~> 0.9) rouge (>= 1.7, < 4) safe_yaml (~> 1.0) - jekyll-avatar (0.5.0) + jekyll-avatar (0.6.0) jekyll (~> 3.0) jekyll-coffeescript (1.1.1) coffee-script (~> 2.2) @@ -113,15 +114,14 @@ GEM rouge (~> 2) jekyll-default-layout (0.1.4) jekyll (~> 3.0) - jekyll-feed (0.9.3) + jekyll-feed (0.10.0) jekyll (~> 3.3) jekyll-gist (1.5.0) octokit (~> 4.2) jekyll-github-metadata (2.9.4) jekyll (~> 3.1) octokit (~> 4.0, != 4.4.0) - jekyll-mentions (1.3.0) - activesupport (~> 4.0) + jekyll-mentions (1.4.1) html-pipeline (~> 2.3) jekyll (~> 3.0) jekyll-optional-front-matter (0.3.0) @@ -129,7 +129,7 @@ GEM jekyll-paginate (1.1.0) jekyll-readme-index (0.2.0) jekyll (~> 3.0) - jekyll-redirect-from (0.13.0) + jekyll-redirect-from (0.14.0) jekyll (~> 3.3) jekyll-relative-links (0.5.3) jekyll (~> 3.3) @@ -138,7 +138,7 @@ GEM rubyzip (>= 1.2.1, < 3.0) jekyll-sass-converter (1.5.2) sass (~> 3.4) - jekyll-seo-tag (2.4.0) + jekyll-seo-tag (2.5.0) jekyll (~> 3.3) jekyll-sitemap (1.2.0) jekyll (~> 3.3) @@ -187,12 +187,11 @@ GEM jekyll (~> 3.3) jekyll-watch (2.0.0) listen (~> 3.0) - jemoji (0.9.0) - activesupport (~> 4.0, >= 4.2.9) + jemoji (0.10.1) gemoji (~> 3.0) html-pipeline (~> 2.2) jekyll (~> 3.0) - kramdown (1.16.2) + kramdown (1.17.0) liquid (4.0.0) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) @@ -200,15 +199,15 @@ GEM ruby_dep (~> 1.2) mercenary (0.3.6) mini_portile2 (2.3.0) - minima (2.4.1) + minima (2.5.0) jekyll (~> 3.5) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) minitest (5.11.3) multipart-post (2.0.0) - nokogiri (1.8.2) + nokogiri (1.8.4) mini_portile2 (~> 2.3.0) - octokit (4.9.0) + octokit (4.11.0) sawyer (~> 0.8.0, >= 0.5.3) pathutil (0.16.1) forwardable-extended (~> 2.6) @@ -220,9 +219,9 @@ GEM ruby-enum (0.7.2) i18n ruby_dep (1.5.0) - rubyzip (1.2.1) + rubyzip (1.2.2) safe_yaml (1.0.4) - sass (3.5.6) + sass (3.5.7) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -237,7 +236,7 @@ GEM ethon (>= 0.9.0) tzinfo (1.2.5) thread_safe (~> 0.1) - unicode-display_width (1.3.3) + unicode-display_width (1.4.0) PLATFORMS ruby From 16f0633193e8de3018cc144c93de7754283709b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Tue, 4 Sep 2018 11:34:34 +0200 Subject: [PATCH 57/64] Fix #1329 --- .../java/ast/ASTVariableDeclaratorId.java | 8 +++++++ .../codestyle/FieldNamingConventionsRule.java | 15 +++++++++++- .../codestyle/xml/FieldNamingConventions.xml | 24 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclaratorId.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclaratorId.java index 9e4cb65496..5a549e5977 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclaratorId.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclaratorId.java @@ -133,6 +133,14 @@ public class ASTVariableDeclaratorId extends AbstractJavaTypeNode implements Dim } + /** + * Returns the name of the variable. + */ + public String getVariableName() { + return getImage(); + } + + /** * Returns true if the variable declared by this node is declared final. * Doesn't account for the "effectively-final" nuance. Resource diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/FieldNamingConventionsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/FieldNamingConventionsRule.java index f68dcb2556..0cfc4f2e5a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/FieldNamingConventionsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/FieldNamingConventionsRule.java @@ -11,6 +11,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.RegexProperty; +import net.sourceforge.pmd.properties.StringMultiProperty; /** @@ -20,6 +21,14 @@ import net.sourceforge.pmd.properties.RegexProperty; * @since 6.7.0 */ public class FieldNamingConventionsRule extends AbstractNamingConventionRule { + // TODO we need a more powerful scheme to match some fields, e.g. include modifiers/type + // We could define a new property, but specifying property values as a single string doesn't scale + private static final StringMultiProperty EXCLUDED_NAMES = StringMultiProperty.named("exclusions") + .desc("Names of fields to whitelist.") + .defaultValues("serialVersionUID") + .build(); + + private final RegexProperty publicConstantFieldRegex = defaultProp("public constant").defaultValue("[A-Z][A-Z_0-9]*").build(); private final RegexProperty constantFieldRegex = defaultProp("constant").desc("Regex which applies to non-public static final field names").defaultValue("[A-Z][A-Z_0-9]*").build(); private final RegexProperty enumConstantRegex = defaultProp("enum constant").defaultValue("[A-Z][A-Z_0-9]*").build(); @@ -35,6 +44,7 @@ public class FieldNamingConventionsRule extends AbstractNamingConventionRule + + + + Exclude serialVersionUID by default + 0 + + + From 492f1798d832b10e8701902e57bbd2cbf9464ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Tue, 4 Sep 2018 11:44:16 +0200 Subject: [PATCH 58/64] Fix tests --- .../rule/codestyle/CodeStyleRulesTest.java | 1 + .../codestyle/xml/FieldNamingConventions.xml | 28 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/CodeStyleRulesTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/CodeStyleRulesTest.java index e2fb35e5ed..840fdefd5d 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/CodeStyleRulesTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/CodeStyleRulesTest.java @@ -35,6 +35,7 @@ public class CodeStyleRulesTest extends SimpleAggregatorTst { addRule(RULESET, "EmptyMethodInAbstractClassShouldBeAbstract"); addRule(RULESET, "ExtendsObject"); addRule(RULESET, "FieldDeclarationsShouldBeAtStartOfClass"); + addRule(RULESET, "FieldNamingConventions"); addRule(RULESET, "ForLoopsMustUseBraces"); addRule(RULESET, "ForLoopShouldBeWhileLoop"); addRule(RULESET, "FormalParameterNamingConventions"); diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/FieldNamingConventions.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/FieldNamingConventions.xml index 37497d169d..a6d343bcb6 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/FieldNamingConventions.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/FieldNamingConventions.xml @@ -128,10 +128,13 @@ Test public constant property cons_[A-Z][A-Z0-9]+ - 2 + 5 + The field name 'Foo' doesn't match '[a-z][a-zA-Z0-9]*' + The final field name 'Hoo' doesn't match '[a-z][a-zA-Z0-9]*' + The static field name 'Bar' doesn't match '[a-z][a-zA-Z0-9]*' + The constant name 'cons_BOLG_FIELD' doesn't match '[A-Z][A-Z_0-9]*' The public constant name 'DDD' doesn't match 'cons_[A-Z][A-Z0-9]+' - The constant name 'cons_BOLG_FIELD' doesn't match '[A-Z][A-Z0-9]+' - Interface fields should be treated like constants + Interface fields should be treated like public constants 3 - The constant name 'Foo' doesn't match '[A-Z][A-Z_0-9]*' - The constant name 'Hoo' doesn't match '[A-Z][A-Z_0-9]*' - The constant name 'Bar' doesn't match '[A-Z][A-Z_0-9]*' + The public constant name 'Foo' doesn't match '[A-Z][A-Z_0-9]*' + The public constant name 'Hoo' doesn't match '[A-Z][A-Z_0-9]*' + The public constant name 'Bar' doesn't match '[A-Z][A-Z_0-9]*' + + More exclusions can be configured + m$mangled + 0 + + + From b0336d36160494c5bc6d1423e476d0f1219fba1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 5 Sep 2018 01:16:04 -0300 Subject: [PATCH 59/64] Update changelog, refs #1331 --- docs/pages/release_notes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7abd6980aa..a3437c1dbc 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -16,6 +16,9 @@ This is a {{ site.pmd.release_type }} release. ### Fixed Issues +* java-codestyle + * [#1329](https://github.com/pmd/pmd/issues/1329): \[java] FieldNamingConventions: false positive in serializable class with serialVersionUID + ### API Changes ### External Contributions From 98807dae251cf0691dbad45c0c13e29948f0d894 Mon Sep 17 00:00:00 2001 From: "Travis CI (pmd-bot)" Date: Wed, 5 Sep 2018 04:34:34 +0000 Subject: [PATCH 60/64] Update documentation TRAVIS_JOB_NUMBER=2805.1 TRAVIS_COMMIT_RANGE=e3018c3892bb...4999c5f9ffdf --- docs/pages/pmd/rules/java/codestyle.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/pmd/rules/java/codestyle.md b/docs/pages/pmd/rules/java/codestyle.md index de38f3acba..091987c4e1 100644 --- a/docs/pages/pmd/rules/java/codestyle.md +++ b/docs/pages/pmd/rules/java/codestyle.md @@ -804,6 +804,7 @@ class Foo { |finalFieldPattern|[a-z][a-zA-Z0-9]*|Regex which applies to final field names|no| |staticFieldPattern|[a-z][a-zA-Z0-9]*|Regex which applies to static field names|no| |defaultFieldPattern|[a-z][a-zA-Z0-9]*|Regex which applies to field names|no| +|exclusions|serialVersionUID|Names of fields to whitelist.|yes. Delimiter is '\|'.| **Use this rule by referencing it:** ``` xml From 7d3f287f3810e9487683f69035e3a02fc960a6e6 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 7 Sep 2018 14:28:11 +0200 Subject: [PATCH 61/64] [java] False positive in ConsecutiveLiteralAppends Fixes #1325 --- docs/pages/release_notes.md | 2 + .../ConsecutiveLiteralAppendsRule.java | 56 +++++++++++-------- .../xml/ConsecutiveLiteralAppends.xml | 23 ++++++++ 3 files changed, 57 insertions(+), 24 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a3437c1dbc..11f6401b40 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -18,6 +18,8 @@ This is a {{ site.pmd.release_type }} release. * java-codestyle * [#1329](https://github.com/pmd/pmd/issues/1329): \[java] FieldNamingConventions: false positive in serializable class with serialVersionUID +* java-performance + * [#1325](https://github.com/pmd/pmd/issues/1325): \[java] False positive in ConsecutiveLiteralAppends ### API Changes diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsRule.java index fe05d8a9b7..d025940561 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsRule.java @@ -4,6 +4,7 @@ package net.sourceforge.pmd.lang.java.rule.performance; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -85,7 +86,7 @@ public class ConsecutiveLiteralAppendsRule extends AbstractJavaRule { @Override public Object visit(ASTVariableDeclaratorId node, Object data) { - if (!isStringBuffer(node)) { + if (!isStringBuilderOrBuffer(node)) { return data; } threshold = getProperty(THRESHOLD_DESCRIPTOR); @@ -96,33 +97,22 @@ public class ConsecutiveLiteralAppendsRule extends AbstractJavaRule { } Node lastBlock = getFirstParentBlock(node); Node currentBlock = lastBlock; - Map> decls = node.getScope() - .getDeclarations(VariableNameDeclaration.class); Node rootNode = null; // only want the constructor flagged if it's really containing strings if (concurrentCount >= 1) { rootNode = node; } - for (List decl : decls.values()) { - for (NameOccurrence no : decl) { - JavaNameOccurrence jno = (JavaNameOccurrence) no; - Node n = jno.getLocation(); - // skip the declarations/usages, that deal with a different - // variable - if (!node.getImage().equals(jno.getImage())) { - continue; - } + List usages = determineUsages(node); - currentBlock = getFirstParentBlock(n); + for (NameOccurrence no : usages) { + JavaNameOccurrence jno = (JavaNameOccurrence) no; + Node n = jno.getLocation(); - if (!InefficientStringBufferingRule.isInStringBufferOperation(n, 3, "append")) { - if (!jno.isPartOfQualifiedName()) { - checkForViolation(rootNode, data, concurrentCount); - concurrentCount = 0; - } - continue; - } + currentBlock = getFirstParentBlock(n); + + if (InefficientStringBufferingRule.isInStringBufferOperation(n, 3, "append")) { + // append method call detected ASTPrimaryExpression s = n.getFirstParentOfType(ASTPrimaryExpression.class); int numChildren = s.jjtGetNumChildren(); for (int jx = 0; jx < numChildren; jx++) { @@ -154,14 +144,34 @@ public class ConsecutiveLiteralAppendsRule extends AbstractJavaRule { } else { concurrentCount++; } - lastBlock = currentBlock; + } + } else { + if (!jno.isPartOfQualifiedName()) { + // usage of the stringbuilder variable e.g. as an argument + checkForViolation(rootNode, data, concurrentCount); + concurrentCount = 0; } } + // always update the last block, so that we consider scope changes + lastBlock = currentBlock; } checkForViolation(rootNode, data, concurrentCount); return data; } + private List determineUsages(ASTVariableDeclaratorId node) { + Map> decls = node.getScope() + .getDeclarations(VariableNameDeclaration.class); + for (Map.Entry> entry : decls.entrySet()) { + // find the first variable that matches + if (node.hasImageEqualTo(entry.getKey().getName())) { + return entry.getValue(); + } + } + + return Collections.emptyList(); + } + /** * Determine if the constructor contains (or ends with) a String Literal * @@ -376,10 +386,8 @@ public class ConsecutiveLiteralAppendsRule extends AbstractJavaRule { return n instanceof ASTLiteral; } - private static boolean isStringBuffer(ASTVariableDeclaratorId node) { - + private static boolean isStringBuilderOrBuffer(ASTVariableDeclaratorId node) { if (node.getType() != null) { - // return node.getType().equals(StringBuffer.class); return TypeHelper.isEither(node, StringBuffer.class, StringBuilder.class); } Node nn = node.getTypeNameNode(); diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/ConsecutiveLiteralAppends.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/ConsecutiveLiteralAppends.xml index c29969df76..8c13fb4a23 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/ConsecutiveLiteralAppends.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/ConsecutiveLiteralAppends.xml @@ -1344,6 +1344,29 @@ public class Foo { s.append('h'); s.append("ello"); } +} + ]]> + + + + #1325 [java] False positive in ConsecutiveLiteralAppends + 0 + builder + .append(k) + .append(" = ") + .append(valueToStringFunction.apply(v)) + .append(", ")); + int length = builder.length(); + if (length > 1) { + builder.delete(length - 2, length); + } + builder.append(']'); + return builder.toString(); + } } ]]> From 212bf46be8f01ce98f2818d872d0d2390953d2da Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 7 Sep 2018 15:21:01 +0200 Subject: [PATCH 62/64] [java] LinguisticNaming should support AtomicBooleans Fixes #1334 --- docs/pages/release_notes.md | 1 + .../rule/codestyle/LinguisticNamingRule.java | 10 +++-- .../rule/codestyle/xml/LinguisticNaming.xml | 44 +++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a3437c1dbc..bd0b266e58 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -18,6 +18,7 @@ This is a {{ site.pmd.release_type }} release. * java-codestyle * [#1329](https://github.com/pmd/pmd/issues/1329): \[java] FieldNamingConventions: false positive in serializable class with serialVersionUID + * [#1334](https://github.com/pmd/pmd/issues/1334): \[java] LinguisticNaming should support AtomicBooleans ### API Changes diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java index e75aea1c36..d804809278 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java @@ -134,12 +134,16 @@ public class LinguisticNamingRule extends AbstractJavaRule { } } + private boolean isBooleanType(String typeImage) { + return "boolean".equalsIgnoreCase(typeImage) || "AtomicBoolean".equals(typeImage); + } + private void checkBooleanMethods(ASTMethodDeclaration node, Object data, String nameOfMethod) { ASTResultType resultType = node.getResultType(); ASTType t = node.getResultType().getFirstChildOfType(ASTType.class); if (!resultType.isVoid() && t != null) { for (String prefix : getProperty(BOOLEAN_METHOD_PREFIXES_PROPERTY)) { - if (hasPrefix(nameOfMethod, prefix) && !"boolean".equalsIgnoreCase(t.getTypeImage())) { + if (hasPrefix(nameOfMethod, prefix) && !isBooleanType(t.getTypeImage())) { addViolationWithMessage(data, node, "Linguistics Antipattern - The method ''{0}'' indicates linguistically it returns a boolean, but it returns ''{1}''", new Object[] { nameOfMethod, t.getTypeImage() }); } @@ -149,7 +153,7 @@ public class LinguisticNamingRule extends AbstractJavaRule { private void checkField(String typeImage, ASTVariableDeclarator node, Object data) { for (String prefix : getProperty(BOOLEAN_FIELD_PREFIXES_PROPERTY)) { - if (hasPrefix(node.getName(), prefix) && !"boolean".equalsIgnoreCase(typeImage)) { + if (hasPrefix(node.getName(), prefix) && !isBooleanType(typeImage)) { addViolationWithMessage(data, node, "Linguistics Antipattern - The field ''{0}'' indicates linguistically it is a boolean, but it is ''{1}''", new Object[] { node.getName(), typeImage }); } @@ -158,7 +162,7 @@ public class LinguisticNamingRule extends AbstractJavaRule { private void checkVariable(String typeImage, ASTVariableDeclarator node, Object data) { for (String prefix : getProperty(BOOLEAN_FIELD_PREFIXES_PROPERTY)) { - if (hasPrefix(node.getName(), prefix) && !"boolean".equalsIgnoreCase(typeImage)) { + if (hasPrefix(node.getName(), prefix) && !isBooleanType(typeImage)) { addViolationWithMessage(data, node, "Linguistics Antipattern - The variable ''{0}'' indicates linguistically it is a boolean, but it is ''{1}''", new Object[] { node.getName(), typeImage }); } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml index aea6ff3d0b..a4a840f6d0 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml @@ -461,6 +461,50 @@ public class BooleanFieldsMethodFP { public void myMethod() { Boolean hasLegs; } +} + ]]> + + + + #1334 [java] LinguisticNaming should support AtomicBooleans + 0 + From 06be51070236697106a1ce5da8fca566867b74e2 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 7 Sep 2018 16:31:58 +0200 Subject: [PATCH 63/64] [java] ConsecutiveLiteralAppends: Fix further FPs/FNs --- .../ConsecutiveLiteralAppendsRule.java | 14 +++--- .../xml/ConsecutiveLiteralAppends.xml | 48 +++++++++++++++++++ 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsRule.java index d025940561..f4f328e616 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsRule.java @@ -144,16 +144,16 @@ public class ConsecutiveLiteralAppendsRule extends AbstractJavaRule { } else { concurrentCount++; } + lastBlock = currentBlock; } + } else if (n.getImage().endsWith(".toString") || n.getImage().endsWith(".length")) { + // ignore toString and length, they do not change affect the content of the sb } else { - if (!jno.isPartOfQualifiedName()) { - // usage of the stringbuilder variable e.g. as an argument - checkForViolation(rootNode, data, concurrentCount); - concurrentCount = 0; - } + // usage of the stringbuilder variable for any other purpose, including + // calling e.g. delete + checkForViolation(rootNode, data, concurrentCount); + concurrentCount = 0; } - // always update the last block, so that we consider scope changes - lastBlock = currentBlock; } checkForViolation(rootNode, data, concurrentCount); return data; diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/ConsecutiveLiteralAppends.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/ConsecutiveLiteralAppends.xml index 8c13fb4a23..9e3d41b59f 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/ConsecutiveLiteralAppends.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/ConsecutiveLiteralAppends.xml @@ -1367,6 +1367,54 @@ public class ConsecutiveLiteralAppendsFP { builder.append(']'); return builder.toString(); } +} + ]]> + + + + FN append inside if statement + 2 + 12,13 + + + + + FP with constructor, append in while + 0 + From d14c7a963685ccb23d516aea557e82040ef9c0f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Sat, 8 Sep 2018 22:04:11 -0300 Subject: [PATCH 64/64] Use typeres to detect proper AtomicBooleans --- .../rule/codestyle/LinguisticNamingRule.java | 23 +++++----- .../resources/category/java/codestyle.xml | 3 +- .../rule/codestyle/xml/LinguisticNaming.xml | 44 +++++++++++++++++++ 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java index d804809278..8af4d19a9c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LinguisticNamingRule.java @@ -16,6 +16,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTResultType; import net.sourceforge.pmd.lang.java.ast.ASTType; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclarator; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; +import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper; import net.sourceforge.pmd.properties.BooleanProperty; import net.sourceforge.pmd.properties.StringMultiProperty; @@ -134,8 +135,8 @@ public class LinguisticNamingRule extends AbstractJavaRule { } } - private boolean isBooleanType(String typeImage) { - return "boolean".equalsIgnoreCase(typeImage) || "AtomicBoolean".equals(typeImage); + private boolean isBooleanType(ASTType node) { + return "boolean".equalsIgnoreCase(node.getTypeImage()) || TypeHelper.isA(node, "java.util.concurrent.atomic.AtomicBoolean"); } private void checkBooleanMethods(ASTMethodDeclaration node, Object data, String nameOfMethod) { @@ -143,7 +144,7 @@ public class LinguisticNamingRule extends AbstractJavaRule { ASTType t = node.getResultType().getFirstChildOfType(ASTType.class); if (!resultType.isVoid() && t != null) { for (String prefix : getProperty(BOOLEAN_METHOD_PREFIXES_PROPERTY)) { - if (hasPrefix(nameOfMethod, prefix) && !isBooleanType(t.getTypeImage())) { + if (hasPrefix(nameOfMethod, prefix) && !isBooleanType(t)) { addViolationWithMessage(data, node, "Linguistics Antipattern - The method ''{0}'' indicates linguistically it returns a boolean, but it returns ''{1}''", new Object[] { nameOfMethod, t.getTypeImage() }); } @@ -151,20 +152,20 @@ public class LinguisticNamingRule extends AbstractJavaRule { } } - private void checkField(String typeImage, ASTVariableDeclarator node, Object data) { + private void checkField(ASTType typeNode, ASTVariableDeclarator node, Object data) { for (String prefix : getProperty(BOOLEAN_FIELD_PREFIXES_PROPERTY)) { - if (hasPrefix(node.getName(), prefix) && !isBooleanType(typeImage)) { + if (hasPrefix(node.getName(), prefix) && !isBooleanType(typeNode)) { addViolationWithMessage(data, node, "Linguistics Antipattern - The field ''{0}'' indicates linguistically it is a boolean, but it is ''{1}''", - new Object[] { node.getName(), typeImage }); + new Object[] { node.getName(), typeNode.getTypeImage() }); } } } - private void checkVariable(String typeImage, ASTVariableDeclarator node, Object data) { + private void checkVariable(ASTType typeNode, ASTVariableDeclarator node, Object data) { for (String prefix : getProperty(BOOLEAN_FIELD_PREFIXES_PROPERTY)) { - if (hasPrefix(node.getName(), prefix) && !isBooleanType(typeImage)) { + if (hasPrefix(node.getName(), prefix) && !isBooleanType(typeNode)) { addViolationWithMessage(data, node, "Linguistics Antipattern - The variable ''{0}'' indicates linguistically it is a boolean, but it is ''{1}''", - new Object[] { node.getName(), typeImage }); + new Object[] { node.getName(), typeNode.getTypeImage() }); } } } @@ -175,7 +176,7 @@ public class LinguisticNamingRule extends AbstractJavaRule { if (type != null && getProperty(CHECK_FIELDS)) { List fields = node.findChildrenOfType(ASTVariableDeclarator.class); for (ASTVariableDeclarator field : fields) { - checkField(type.getTypeImage(), field, data); + checkField(type, field, data); } } return data; @@ -187,7 +188,7 @@ public class LinguisticNamingRule extends AbstractJavaRule { if (type != null && getProperty(CHECK_VARIABLES)) { List variables = node.findChildrenOfType(ASTVariableDeclarator.class); for (ASTVariableDeclarator variable : variables) { - checkVariable(type.getTypeImage(), variable, data); + checkVariable(type, variable, data); } } return data; diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml index edee2dfdca..9a9138a4f0 100644 --- a/pmd-java/src/main/resources/category/java/codestyle.xml +++ b/pmd-java/src/main/resources/category/java/codestyle.xml @@ -981,7 +981,8 @@ if (foo) { // preferred approach since="6.7.0" message="Linguistics Antipattern - Method name and return type is inconsistent linguistically" class="net.sourceforge.pmd.lang.java.rule.codestyle.LinguisticNamingRule" - externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#linguisticnaming"> + externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#linguisticnaming" + typeResolution="true"> This rule finds Linguistic Naming Antipatterns. It checks for fields, that are named, as if they should be boolean but have a different type. It also checks for methods, that according to their name, should diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml index a4a840f6d0..006b005d35 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/LinguisticNaming.xml @@ -508,4 +508,48 @@ public class AtomicBooleanFP { } ]]> + + + #1334 [java] LinguisticNaming should support AtomicBooleans false negative + 18 + +