From 1a7699035cfc379b6cc7d25b520d424c43cddfd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sat, 14 Jan 2023 17:18:01 +0100 Subject: [PATCH 01/28] Make ASTVariableDeclarator not be a TypeNode --- .../pmd/lang/java/ast/ASTVariableDeclarator.java | 4 ++-- .../pmd/lang/java/types/ast/LazyTypeResolver.java | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclarator.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclarator.java index d0c06b6ffa..f502ae6382 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclarator.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTVariableDeclarator.java @@ -18,11 +18,11 @@ import org.checkerframework.checker.nullness.qual.Nullable; * *
  *
- * VariableDeclarator ::= {@linkplain ASTVariableDeclaratorId VariableDeclaratorId} {@link ASTArrayDimensions ArrayDimensions}? ( "=" {@linkplain ASTExpression Expression} )?
+ * VariableDeclarator ::= {@linkplain ASTVariableDeclaratorId VariableDeclaratorId} ( "=" {@linkplain ASTExpression Expression} )?
  *
  * 
*/ -public class ASTVariableDeclarator extends AbstractJavaTypeNode implements InternalInterfaces.VariableIdOwner { +public class ASTVariableDeclarator extends AbstractJavaNode implements InternalInterfaces.VariableIdOwner { ASTVariableDeclarator(int id) { super(id); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/LazyTypeResolver.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/LazyTypeResolver.java index b907a3d181..10c23a1b11 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/LazyTypeResolver.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/LazyTypeResolver.java @@ -29,7 +29,6 @@ import net.sourceforge.pmd.lang.java.ast.ASTBooleanLiteral; import net.sourceforge.pmd.lang.java.ast.ASTCastExpression; import net.sourceforge.pmd.lang.java.ast.ASTCharLiteral; import net.sourceforge.pmd.lang.java.ast.ASTClassLiteral; -import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.ASTConditionalExpression; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTEnumConstant; @@ -148,18 +147,6 @@ public final class LazyTypeResolver extends JavaVisitorBase Date: Sat, 14 Jan 2023 22:33:40 +0100 Subject: [PATCH 02/28] Micro-opts --- .../src/main/java/net/sourceforge/pmd/RuleSet.java | 2 +- .../sourceforge/pmd/lang/ast/impl/AbstractNode.java | 12 +++++++----- .../pmd/lang/rule/xpath/internal/AstTreeInfo.java | 13 +++++++++++++ .../net/sourceforge/pmd/lang/ast/DummyNode.java | 10 ---------- .../pmd/lang/java/ast/ASTAnnotationMemberList.java | 5 ----- .../pmd/lang/java/ast/ASTIntersectionType.java | 6 ------ .../net/sourceforge/pmd/lang/java/ast/ASTList.java | 4 ---- .../pmd/lang/java/ast/ASTMemberValuePair.java | 6 ------ .../sourceforge/pmd/lang/java/ast/ASTUnionType.java | 4 ---- .../pmd/lang/java/ast/ASTWildcardType.java | 5 ----- .../pmd/lang/java/ast/InternalInterfaces.java | 11 ++++------- .../rule/design/UselessOverridingMethodRule.java | 3 ++- .../java/rule/documentation/CommentSizeRule.java | 7 +++---- .../AvoidInstantiatingObjectsInLoopsRule.java | 7 +------ .../sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt | 2 +- 15 files changed, 32 insertions(+), 65 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java index 3614388738..723f5216eb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java @@ -650,7 +650,7 @@ public class RuleSet implements ChecksumAware { public static boolean applies(Rule rule, LanguageVersion languageVersion) { final LanguageVersion min = rule.getMinimumLanguageVersion(); final LanguageVersion max = rule.getMaximumLanguageVersion(); - Objects.requireNonNull(rule.getLanguage(), "Rule has no language " + rule); + assert rule.getLanguage() != null : "Rule has no language " + rule; return rule.getLanguage().equals(languageVersion.getLanguage()) && (min == null || min.compareTo(languageVersion) <= 0) && (max == null || max.compareTo(languageVersion) >= 0); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/AbstractNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/AbstractNode.java index 9d3839d411..5481dc9f70 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/AbstractNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/AbstractNode.java @@ -24,7 +24,9 @@ import net.sourceforge.pmd.util.DataMap.DataKey; * @param Public interface for nodes of this language (eg JavaNode * in the java module). */ -public abstract class AbstractNode, N extends GenericNode> implements GenericNode { +public abstract class AbstractNode, + // node the Node as first bound here is to make casts from Node to N noops at runtime. + N extends Node & GenericNode> implements GenericNode { private static final Node[] EMPTY_ARRAY = new Node[0]; @@ -41,22 +43,22 @@ public abstract class AbstractNode, N extends Gener } @Override - public N getParent() { + public final N getParent() { return (N) parent; } @Override - public int getIndexInParent() { + public final int getIndexInParent() { return childIndex; } @Override - public N getChild(final int index) { + public final N getChild(final int index) { return (N) children[index]; } @Override - public int getNumChildren() { + public final int getNumChildren() { return children.length; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstTreeInfo.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstTreeInfo.java index 386fa630b0..9469f6b8e7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstTreeInfo.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstTreeInfo.java @@ -4,7 +4,10 @@ package net.sourceforge.pmd.lang.rule.xpath.internal; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import org.apache.commons.lang3.mutable.MutableInt; @@ -21,6 +24,12 @@ import net.sf.saxon.om.GenericTreeInfo; public final class AstTreeInfo extends GenericTreeInfo { private DeprecatedAttrLogger logger; + private final Map wrapperCache = new LinkedHashMap() { + @Override + protected boolean removeEldestEntry(Entry eldest) { + return size() > 128; + } + }; /** * Builds an AstDocument, with the given node as the root. @@ -37,6 +46,10 @@ public final class AstTreeInfo extends GenericTreeInfo { } public AstElementNode findWrapperFor(Node node) { + return wrapperCache.computeIfAbsent(node, this::findWrapperImpl); + } + + private AstElementNode findWrapperImpl(Node node) { // for the RootNode, this returns the document node List indices = node.ancestorsOrSelf().toList(Node::getIndexInParent); AstElementNode cur = getRootNode().getRootElement(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNode.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNode.java index 4b7a88fb87..9c5b3e0bb7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNode.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNode.java @@ -50,21 +50,11 @@ public class DummyNode extends AbstractNode { } } - @Override - public DummyNode getParent() { - return super.getParent(); - } - @Override public void addChild(DummyNode child, int index) { super.addChild(child, index); } - @Override - public DummyNode getChild(int index) { - return super.getChild(index); - } - @Override public void setParent(DummyNode node) { super.setParent(node); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAnnotationMemberList.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAnnotationMemberList.java index b9b6123601..d36eab477a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAnnotationMemberList.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAnnotationMemberList.java @@ -24,11 +24,6 @@ public final class ASTAnnotationMemberList extends ASTMaybeEmptyListOf R acceptVisitor(JavaVisitor visitor, P data) { return visitor.visit(this, data); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTList.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTList.java index 5af84841a2..ff06abdb17 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTList.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTList.java @@ -167,9 +167,5 @@ public abstract class ASTList extends AbstractJavaNode imple return children(); } - @Override - public T getChild(int index) { - return (T) super.getChild(index); - } } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTMemberValuePair.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTMemberValuePair.java index 784dfea68d..02d0fcb2fe 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTMemberValuePair.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTMemberValuePair.java @@ -53,12 +53,6 @@ public final class ASTMemberValuePair extends AbstractJavaNode { } - @Override - public ASTAnnotationMemberList getParent() { - return (ASTAnnotationMemberList) super.getParent(); - } - - @Override protected R acceptVisitor(JavaVisitor visitor, P data) { return visitor.visit(this, data); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnionType.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnionType.java index d25de5e9f0..409e60f3bd 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnionType.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTUnionType.java @@ -47,8 +47,4 @@ public final class ASTUnionType extends AbstractJavaTypeNode return children(ASTClassOrInterfaceType.class).iterator(); } - @Override - public ASTClassOrInterfaceType getChild(int index) { - return (ASTClassOrInterfaceType) super.getChild(index); - } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTWildcardType.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTWildcardType.java index dc97754a65..09fa07f8cc 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTWildcardType.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTWildcardType.java @@ -28,11 +28,6 @@ public final class ASTWildcardType extends AbstractJavaTypeNode implements ASTRe isLowerBound = lowerBound; } - @Override - public ASTTypeArguments getParent() { - return (ASTTypeArguments) super.getParent(); - } - /** * Return true if this is an upper type bound, e.g. * {@code }, or the unbounded diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java index d5660840b6..3b41ebb4e4 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java @@ -84,16 +84,13 @@ final class InternalInterfaces { interface AllChildrenAreOfType extends JavaNode { - @Override - T getChild(int index); - @Override @Nullable default T getFirstChild() { if (getNumChildren() == 0) { return null; } - return getChild(0); + return (T) getChild(0); } @@ -103,7 +100,7 @@ final class InternalInterfaces { if (getNumChildren() == 0) { return null; } - return getChild(getNumChildren() - 1); + return (T) getChild(getNumChildren() - 1); } } @@ -118,7 +115,7 @@ final class InternalInterfaces { @NonNull default T getFirstChild() { assert getNumChildren() > 0 : "No children for node implementing AtLeastOneChild " + this; - return getChild(0); + return (T) getChild(0); } @@ -127,7 +124,7 @@ final class InternalInterfaces { @NonNull default T getLastChild() { assert getNumChildren() > 0 : "No children for node implementing AtLeastOneChild " + this; - return getChild(getNumChildren() - 1); + return (T) getChild(getNumChildren() - 1); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/UselessOverridingMethodRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/UselessOverridingMethodRule.java index cd764b2d86..fde6edc99c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/UselessOverridingMethodRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/UselessOverridingMethodRule.java @@ -12,6 +12,7 @@ import static net.sourceforge.pmd.properties.PropertyFactory.booleanProperty; import java.lang.reflect.Modifier; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; +import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTExpressionStatement; import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; import net.sourceforge.pmd.lang.java.ast.ASTList; @@ -97,7 +98,7 @@ public class UselessOverridingMethodRule extends AbstractJavaRulechainRule { ASTArgumentList arg = methodCall.getArguments(); int i = 0; for (ASTFormalParameter formal : node.getFormalParameters()) { - if (!JavaAstUtils.isReferenceToVar(arg.getChild(i), formal.getVarId().getSymbol())) { + if (!JavaAstUtils.isReferenceToVar((ASTExpression) arg.getChild(i), formal.getVarId().getSymbol())) { return false; } i++; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java index 6a409f3c76..fa23667104 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java @@ -67,12 +67,11 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { int offset = comment.getBeginLine(); for (int lineNum : lineNumbers) { int lineNumWithOff = lineNum + offset; - addViolationWithMessage( - data, + asCtx(data).addViolationWithPosition( cUnit, - this.getMessage() + ": Line too long", lineNumWithOff, - lineNum + lineNumWithOff, + this.getMessage() + ": Line too long" ); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AvoidInstantiatingObjectsInLoopsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AvoidInstantiatingObjectsInLoopsRule.java index a491bb20f2..14ae136dc9 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AvoidInstantiatingObjectsInLoopsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AvoidInstantiatingObjectsInLoopsRule.java @@ -19,7 +19,6 @@ import net.sourceforge.pmd.lang.java.ast.ASTForeachStatement; import net.sourceforge.pmd.lang.java.ast.ASTLoopStatement; import net.sourceforge.pmd.lang.java.ast.ASTMethodCall; import net.sourceforge.pmd.lang.java.ast.ASTReturnStatement; -import net.sourceforge.pmd.lang.java.ast.ASTStatement; import net.sourceforge.pmd.lang.java.ast.ASTThrowStatement; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; @@ -80,11 +79,7 @@ public class AvoidInstantiatingObjectsInLoopsRule extends AbstractJavaRulechainR private boolean notBreakFollowing(JavaNode node) { JavaNode statement = node.ancestors().filter(n -> n.getParent() instanceof ASTBlock).first(); if (statement != null) { - ASTBlock block = (ASTBlock) statement.getParent(); - if (block.getNumChildren() > statement.getIndexInParent() + 1) { - ASTStatement next = block.getChild(statement.getIndexInParent() + 1); - return !(next instanceof ASTBreakStatement); - } + return !(statement.getNextSibling() instanceof ASTBreakStatement); } return true; } diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt index 4f1c72d546..b104247530 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt @@ -117,7 +117,7 @@ object StatementParsingCtx : NodeParsingCtx("statement") { override fun retrieveNode(acu: ASTCompilationUnit): ASTStatement = TypeBodyParsingCtx.retrieveNode(acu) .descendants(ASTBlock::class.java) - .firstOrThrow().getChild(0) + .firstOrThrow().firstChild as ASTStatement } object TypeBodyParsingCtx : NodeParsingCtx("body declaration") { From ea4c8271169b33e3e79f4b5003e2c8cb8bbff5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 23 Jan 2023 17:33:33 +0100 Subject: [PATCH 03/28] Convert AddEmptyString to java rule --- .../rule/performance/AddEmptyStringRule.java | 49 +++++++++++++++++++ .../resources/category/java/performance.xml | 17 +------ 2 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AddEmptyStringRule.java diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AddEmptyStringRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AddEmptyStringRule.java new file mode 100644 index 0000000000..5c4224fb2e --- /dev/null +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AddEmptyStringRule.java @@ -0,0 +1,49 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.rule.performance; + +import net.sourceforge.pmd.lang.java.ast.ASTAnnotation; +import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; +import net.sourceforge.pmd.lang.java.ast.ASTStringLiteral; +import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclarator; +import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; +import net.sourceforge.pmd.lang.java.ast.BinaryOp; +import net.sourceforge.pmd.lang.java.ast.JModifier; +import net.sourceforge.pmd.lang.java.ast.JavaNode; +import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; +import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; + + +public class AddEmptyStringRule extends AbstractJavaRulechainRule { + + public AddEmptyStringRule() { + super(ASTStringLiteral.class); + } + + @Override + public Object visit(ASTStringLiteral node, Object data) { + if (!node.isEmpty()) { + return null; + } + JavaNode parent = node.getParent(); + checkExpr(data, parent); + if (parent instanceof ASTVariableDeclarator) { + ASTVariableDeclaratorId varId = ((ASTVariableDeclarator) parent).getVarId(); + if (varId.hasModifiers(JModifier.FINAL)) { + for (ASTNamedReferenceExpr usage : varId.getLocalUsages()) { + checkExpr(data, usage.getParent()); + } + } + } + return null; + } + + private void checkExpr(Object data, JavaNode parent) { + if (JavaAstUtils.isInfixExprWithOperator(parent, BinaryOp.ADD) + && parent.ancestors(ASTAnnotation.class).isEmpty()) { + addViolation(data, parent); + } + } +} diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index d52a13006e..e586ada4cb 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -13,28 +13,13 @@ Rules that flag suboptimal code. language="java" since="4.0" message="Do not add empty strings" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.java.rule.performance.AddEmptyStringRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#addemptystring"> The conversion of literals to strings by concatenating them with empty strings is inefficient. It is much better to use one of the type-specific `toString()` methods instead or `String.valueOf()`. 3 - - - - - - - Date: Sat, 19 Mar 2022 14:13:33 +0100 Subject: [PATCH 04/28] [core] Move utility classes around --- .../net/sourceforge/pmd/ant/Formatter.java | 2 +- .../pmd/ant/internal/PMDTaskImpl.java | 4 +- .../sourceforge/pmd/ant/AbstractAntTest.java | 2 +- .../net/sourceforge/pmd/ant/PMDTaskTest.java | 2 +- .../net/sourceforge/pmd/cpd/ApexCpdTest.java | 2 +- .../pmd/lang/apex/ast/ApexParserTest.java | 4 +- .../multifile/ApexMultifileAnalysisTest.java | 2 +- .../pmd/cli/commands/internal/CpdCommand.java | 2 +- .../net/sourceforge/pmd/PMDConfiguration.java | 4 +- .../java/net/sourceforge/pmd/PmdAnalysis.java | 6 +- .../net/sourceforge/pmd/RuleSetWriter.java | 2 +- .../pmd/cache/AbstractAnalysisCache.java | 2 +- .../cache/internal/RawFileFingerprinter.java | 2 +- .../java/net/sourceforge/pmd/cpd/CPD.java | 6 +- .../sourceforge/pmd/cpd/CPDConfiguration.java | 4 +- .../net/sourceforge/pmd/cpd/SourceCode.java | 2 +- .../net/sourceforge/pmd/cpd/XMLRenderer.java | 2 +- .../cpd/token/internal/BaseTokenFilter.java | 2 +- .../util/ClasspathClassLoader.java | 18 +++--- .../pmd/internal/util/FileCollectionUtil.java | 2 - .../pmd/{ => internal}/util/FileFinder.java | 9 +-- .../pmd/{ => internal}/util/FileUtil.java | 10 +--- .../pmd/{ => internal}/util/IOUtil.java | 9 +-- .../pmd/internal/util/PredicateUtil.java | 6 +- .../pmd/lang/LanguageVersionDiscoverer.java | 2 +- .../net/sourceforge/pmd/lang/ast/AstInfo.java | 2 +- .../pmd/lang/ast/GenericToken.java | 2 +- .../ast/impl/javacc/EscapeTranslator.java | 2 +- .../pmd/lang/ast/internal/AxisStream.java | 4 +- .../pmd/lang/ast/internal/Filtermap.java | 2 +- .../pmd/lang/ast/internal/GreedyNStream.java | 4 +- .../ast/internal/IteratorBasedNStream.java | 4 +- .../ast/internal/SingletonNodeStream.java | 4 +- .../pmd/lang/ast/internal/StreamImpl.java | 2 +- .../sourceforge/pmd/lang/document/Chars.java | 2 +- .../pmd/lang/document/FileCollector.java | 4 +- .../pmd/lang/document/FileLocation.java | 2 +- .../pmd/lang/document/NioTextFile.java | 2 +- .../pmd/lang/document/ReaderTextFile.java | 2 +- .../lang/document/SourceCodePositioner.java | 2 +- .../pmd/lang/document/StringTextFile.java | 2 +- .../pmd/lang/document/TextFile.java | 2 +- .../pmd/lang/document/TextFileBuilder.java | 2 +- .../pmd/lang/document/TextFileContent.java | 2 +- .../sourceforge/pmd/lang/metrics/Metric.java | 2 +- .../lang/rule/ParametricRuleViolation.java | 2 +- .../lang/rule/internal/LatticeRelation.java | 8 +-- .../lang/rule/internal/RuleApplicator.java | 2 +- .../pmd/lang/rule/internal/TreeIndex.java | 2 +- .../pmd/renderers/AbstractRenderer.java | 2 +- .../pmd/renderers/RendererFactory.java | 2 +- .../pmd/renderers/SarifRenderer.java | 2 +- .../pmd/renderers/XMLRenderer.java | 2 +- .../pmd/reporting/FileAnalysisListener.java | 4 +- .../pmd/reporting/GlobalAnalysisListener.java | 4 +- .../pmd/reporting/ListenerInitializer.java | 4 +- .../{internal => }/util/AssertionUtil.java | 7 ++- .../util/BaseResultProducingCloseable.java | 8 +-- .../sourceforge/pmd/util/CollectionUtil.java | 52 +--------------- .../net/sourceforge/pmd/util/ConsList.java | 2 - .../util/ContextedAssertionError.java | 4 +- .../util/ContextedStackOverflowError.java | 4 +- .../GraphUtils.java => util/GraphUtil.java} | 6 +- .../pmd/{internal => }/util/IteratorUtil.java | 4 +- .../net/sourceforge/pmd/util/StringUtil.java | 60 +------------------ .../pmd/util/datasource/ReaderDataSource.java | 2 +- .../sourceforge/pmd/PmdConfigurationTest.java | 2 +- .../pmd/RuleSetReferenceIdTest.java | 2 +- .../java/net/sourceforge/pmd/RuleSetTest.java | 2 +- .../net/sourceforge/pmd/cli/CoreCliTest.java | 2 +- .../net/sourceforge/pmd/cpd/CpdXsltTest.java | 2 +- .../sourceforge/pmd/cpd/FileReporterTest.java | 2 +- .../pmd/lang/document/CharsTest.java | 2 +- .../pmd/lang/document/NioTextFileTest.java | 2 +- .../pmd/lang/document/TextDocumentTest.java | 2 +- .../pmd/lang/rule/xpath/NoAttributeTest.java | 2 +- .../pmd/processor/PmdRunnableTest.java | 2 +- .../pmd/renderers/AbstractRendererTest.java | 2 +- .../pmd/renderers/XMLRendererTest.java | 2 +- .../pmd/renderers/YAHTMLRendererTest.java | 2 +- .../net/sourceforge/pmd/util/IOUtilTest.java | 2 + .../{internal => }/util/IteratorUtilTest.java | 2 +- .../sourceforge/pmd/util/StringUtilTest.java | 25 -------- .../internal/PathDataSourceTest.java | 2 +- .../java/net/sourceforge/pmd/it/AntIT.java | 2 +- .../net/sourceforge/pmd/it/PMDExecutor.java | 2 +- .../sourceforge/pmd/it/ZipFileExtractor.java | 2 +- .../pmd/docs/DeadLinksChecker.java | 2 +- .../pmd/docs/GenerateRuleDocsCmd.java | 2 +- .../pmd/docs/RuleDocGenerator.java | 2 +- .../sourceforge/pmd/docs/RuleSetUtils.java | 2 +- .../pmd/docs/RuleDocGeneratorTest.java | 2 +- .../pmd/docs/RuleSetResolverTest.java | 2 +- .../pmd/docs/SidebarGeneratorTest.java | 2 +- .../java/ast/ASTClassOrInterfaceType.java | 2 +- .../lang/java/ast/AbstractJavaTypeNode.java | 2 +- .../pmd/lang/java/ast/ConstantFolder.java | 2 +- .../pmd/lang/java/ast/InternalApiBridge.java | 2 +- .../pmd/lang/java/ast/JavaComment.java | 2 +- .../ast/internal/LanguageLevelChecker.java | 2 +- .../java/ast/internal/PrettyPrintingUtil.java | 2 +- .../java/internal/JavaViolationDecorator.java | 2 +- .../UnnecessaryFullyQualifiedNameRule.java | 2 +- .../codestyle/UselessParenthesesRule.java | 2 +- .../lang/java/rule/design/NcssCountRule.java | 2 +- .../internal/asm/AsmSymbolResolver.java | 2 +- .../internal/asm/SignatureScanner.java | 2 +- .../coreimpl/MostlySingularMultimap.java | 2 +- .../coreimpl/ShadowChainIteratorImpl.java | 2 +- .../internal/AbruptCompletionAnalysis.java | 2 +- .../symbols/table/internal/JavaResolvers.java | 2 +- .../table/internal/PatternBindingsUtil.java | 2 +- .../table/internal/SuperTypesEnumerator.java | 4 +- .../table/internal/SymTableFactory.java | 2 +- .../lang/java/types/InvocationMatcher.java | 2 +- .../pmd/lang/java/types/JTypeMirror.java | 2 +- .../pmd/lang/java/types/Substitution.java | 2 +- .../pmd/lang/java/types/TypeOps.java | 2 +- .../pmd/lang/java/types/TypeSystem.java | 2 +- .../pmd/lang/java/types/TypeTestUtil.java | 2 +- .../pmd/lang/java/types/TypeVarImpl.java | 2 +- .../pmd/lang/java/types/TypingContext.java | 2 +- .../pmd/lang/java/types/ast/ExprContext.java | 2 +- .../lang/java/types/ast/PolyResolution.java | 4 +- .../lang/java/types/internal/infer/Graph.java | 6 +- .../types/internal/infer/VarWalkStrategy.java | 2 +- .../internal/infer/ast/BaseInvocMirror.java | 2 +- .../internal/infer/ast/CtorInvocMirror.java | 2 +- .../internal/infer/ast/JavaExprMirrors.java | 2 +- .../internal/infer/ast/LambdaMirrorImpl.java | 2 +- .../infer/ast/MethodRefMirrorImpl.java | 2 +- .../net/sourceforge/pmd/ant/PMDTaskTest.java | 2 +- .../pmd/coverage/PMDCoverageTest.java | 2 +- .../pmd/lang/java/ast/TestExtensions.kt | 2 +- .../pmd/lang/java/types/IteratorUtilCopy.java | 1 + .../pmd/lang/ast/test/BaseParsingHelper.kt | 7 ++- .../pmd/AbstractRuleSetFactoryTest.java | 2 +- .../net/sourceforge/pmd/cli/BaseCLITest.java | 2 +- .../lang/xml/ast/internal/XmlNodeWrapper.java | 2 +- 139 files changed, 189 insertions(+), 333 deletions(-) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => internal}/util/ClasspathClassLoader.java (90%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => internal}/util/FileFinder.java (92%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => internal}/util/FileUtil.java (96%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => internal}/util/IOUtil.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{internal => }/util/AssertionUtil.java (97%) rename pmd-core/src/main/java/net/sourceforge/pmd/{internal => }/util/ContextedAssertionError.java (92%) rename pmd-core/src/main/java/net/sourceforge/pmd/{internal => }/util/ContextedStackOverflowError.java (92%) rename pmd-core/src/main/java/net/sourceforge/pmd/{internal/GraphUtils.java => util/GraphUtil.java} (96%) rename pmd-core/src/main/java/net/sourceforge/pmd/{internal => }/util/IteratorUtil.java (99%) rename pmd-core/src/test/java/net/sourceforge/pmd/{internal => }/util/IteratorUtilTest.java (99%) diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java index 6099351996..6c14fd7356 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java @@ -27,12 +27,12 @@ import org.apache.tools.ant.types.Parameter; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.RendererFactory; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.util.IOUtil; @InternalApi public class Formatter { diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java index de1ec6b952..6a3e426771 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java @@ -28,6 +28,8 @@ import net.sourceforge.pmd.ant.Formatter; import net.sourceforge.pmd.ant.PMDTask; import net.sourceforge.pmd.ant.SourceLanguage; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; +import net.sourceforge.pmd.internal.util.ClasspathClassLoader; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; @@ -36,8 +38,6 @@ import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.reporting.ReportStats; import net.sourceforge.pmd.reporting.ReportStatsListener; -import net.sourceforge.pmd.util.ClasspathClassLoader; -import net.sourceforge.pmd.util.IOUtil; public class PMDTaskImpl { diff --git a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java index 7b8d822486..1a671f4fcd 100644 --- a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java +++ b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java @@ -19,7 +19,7 @@ import org.apache.tools.ant.ProjectHelper; import org.junit.jupiter.api.AfterAll; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class AbstractAntTest { protected Project project; diff --git a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java index 5623c23284..bfff895e17 100644 --- a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java +++ b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java @@ -19,7 +19,7 @@ import org.apache.tools.ant.BuildException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class PMDTaskTest extends AbstractAntTest { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java index 7ce83fcfcb..c966e5a330 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java @@ -14,8 +14,8 @@ import java.util.Iterator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.apex.ApexLanguageModule; -import net.sourceforge.pmd.util.IOUtil; class ApexCpdTest { private File testdir; diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java index 935f362cf3..965167dfd9 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java @@ -20,9 +20,9 @@ import java.util.List; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileLocation; -import net.sourceforge.pmd.util.IOUtil; class ApexParserTest extends ApexParserTestBase { @@ -182,7 +182,7 @@ class ApexParserTest extends ApexParserTestBase { @Test void stackOverflowDuringClassParsing() throws Exception { String source = IOUtil.readToString(ApexParserTest.class.getResourceAsStream("StackOverflowClass.cls"), - StandardCharsets.UTF_8); + StandardCharsets.UTF_8); ASTUserClassOrInterface rootNode = parse(source); assertNotNull(rootNode); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java index c88133f447..6ff741235b 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java @@ -19,7 +19,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java index 2b809050db..c07dd15e6a 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java @@ -24,7 +24,7 @@ import net.sourceforge.pmd.cpd.CPDReport; import net.sourceforge.pmd.cpd.Language; import net.sourceforge.pmd.cpd.Tokenizer; import net.sourceforge.pmd.internal.LogMessages; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import picocli.CommandLine.Command; import picocli.CommandLine.Option; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index 052c0c3a22..6d57d55a28 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -25,13 +25,13 @@ import net.sourceforge.pmd.cache.AnalysisCache; import net.sourceforge.pmd.cache.FileAnalysisCache; import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.cli.PmdParametersParseResult; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.internal.util.ClasspathClassLoader; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.RendererFactory; -import net.sourceforge.pmd.util.ClasspathClassLoader; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.log.MessageReporter; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java index 32a4025700..955654e37b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -25,8 +25,9 @@ import net.sourceforge.pmd.benchmark.TimedOperationCategory; import net.sourceforge.pmd.cache.AnalysisCacheListener; import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.internal.LogMessages; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.internal.util.ClasspathClassLoader; import net.sourceforge.pmd.internal.util.FileCollectionUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; @@ -38,8 +39,7 @@ import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.reporting.ListenerInitializer; import net.sourceforge.pmd.reporting.ReportStats; import net.sourceforge.pmd.reporting.ReportStatsListener; -import net.sourceforge.pmd.util.ClasspathClassLoader; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java index 2d0a2a08c7..fa7fe15814 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java @@ -29,6 +29,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.rule.RuleReference; @@ -36,7 +37,6 @@ import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyDescriptorField; import net.sourceforge.pmd.properties.PropertyTypeId; -import net.sourceforge.pmd.util.IOUtil; /** * This class represents a way to serialize a RuleSet to an XML configuration diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java index 74af13c400..c10effe5f3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java @@ -33,9 +33,9 @@ import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; import net.sourceforge.pmd.benchmark.TimedOperationCategory; import net.sourceforge.pmd.cache.internal.ClasspathFingerprinter; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.util.IOUtil; /** * Abstract implementation of the analysis cache. Handles all operations, except for persistence. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java index 29e6457efe..7b31dac6f0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java @@ -16,7 +16,7 @@ import java.util.zip.Checksum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Base fingerprinter for raw files. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java index 032dbbfba0..57becf76b5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java @@ -28,10 +28,10 @@ import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.cpd.renderer.CPDReportRenderer; import net.sourceforge.pmd.internal.LogMessages; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; +import net.sourceforge.pmd.internal.util.FileFinder; +import net.sourceforge.pmd.internal.util.FileUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.TokenMgrError; -import net.sourceforge.pmd.util.FileFinder; -import net.sourceforge.pmd.util.FileUtil; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.database.DBMSMetadata; import net.sourceforge.pmd.util.database.DBURI; import net.sourceforge.pmd.util.database.SourceObject; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java index bb0cf4f702..ee5cbff182 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java @@ -25,8 +25,8 @@ import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import net.sourceforge.pmd.cpd.renderer.CPDRendererAdapter; import net.sourceforge.pmd.cpd.renderer.CPDReportRenderer; -import net.sourceforge.pmd.util.FileFinder; -import net.sourceforge.pmd.util.FileUtil; +import net.sourceforge.pmd.internal.util.FileFinder; +import net.sourceforge.pmd.internal.util.FileUtil; import com.beust.jcommander.IStringConverter; import com.beust.jcommander.Parameter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java index 20529bdea6..bd93023de7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java @@ -14,7 +14,7 @@ import java.nio.file.Files; import java.util.ArrayList; import java.util.List; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; public class SourceCode { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java index 67cafe395e..5aa2880c7e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java @@ -27,7 +27,7 @@ import org.w3c.dom.Element; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import net.sourceforge.pmd.cpd.renderer.CPDReportRenderer; -import net.sourceforge.pmd.internal.util.IteratorUtil; +import net.sourceforge.pmd.util.IteratorUtil; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilter.java index 692fc2462d..6d980ea41e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilter.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.cpd.token.internal; -import static net.sourceforge.pmd.internal.util.IteratorUtil.AbstractIterator; +import static net.sourceforge.pmd.util.IteratorUtil.AbstractIterator; import java.util.ConcurrentModificationException; import java.util.Iterator; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java similarity index 90% rename from pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java rename to pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java index 0266574901..92056007f8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.util; +package net.sourceforge.pmd.internal.util; import java.io.BufferedReader; import java.io.File; @@ -19,8 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * Create a ClassLoader which loads classes using a CLASSPATH like String. If @@ -28,10 +27,7 @@ import net.sourceforge.pmd.internal.util.AssertionUtil; * the file will be read with each line representing an path on the classpath. * * @author Edwin Chan - * @deprecated Is internal API */ -@InternalApi -@Deprecated public class ClasspathClassLoader extends URLClassLoader { private static final Logger LOG = LoggerFactory.getLogger(ClasspathClassLoader.class); @@ -105,10 +101,10 @@ public class ClasspathClassLoader extends URLClassLoader { @Override public String toString() { - return new StringBuilder(getClass().getSimpleName()) - .append("[[") - .append(StringUtils.join(getURLs(), ":")) - .append("] parent: ").append(getParent()).append(']').toString(); + return getClass().getSimpleName() + + "[[" + + StringUtils.join(getURLs(), ":") + + "] parent: " + getParent() + ']'; } @Override diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java index dc3df472b0..586d7f0c5a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java @@ -18,8 +18,6 @@ import org.slf4j.LoggerFactory; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.lang.document.FileCollector; -import net.sourceforge.pmd.util.FileUtil; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.database.DBMSMetadata; import net.sourceforge.pmd.util.database.DBURI; import net.sourceforge.pmd.util.database.SourceObject; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileFinder.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java similarity index 92% rename from pmd-core/src/main/java/net/sourceforge/pmd/util/FileFinder.java rename to pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java index c632997409..36a8dec0d7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileFinder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.util; +package net.sourceforge.pmd.internal.util; import java.io.File; import java.io.FilenameFilter; @@ -11,14 +11,9 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; -import net.sourceforge.pmd.annotation.InternalApi; - /** * A utility class for finding files within a directory. - * @deprecated Is internal API */ -@Deprecated -@InternalApi public class FileFinder { private FilenameFilter filter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java similarity index 96% rename from pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java rename to pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java index a37740c32e..b7b3fe94fd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.util; +package net.sourceforge.pmd.internal.util; import java.io.File; import java.io.FileNotFoundException; @@ -21,15 +21,9 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.annotation.InternalApi; - /** * This is a utility class for working with Files. - * - * @deprecated Is internal API */ -@Deprecated -@InternalApi public final class FileUtil { private FileUtil() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java rename to pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java index b017770b80..1fce3ef4c4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.util; +package net.sourceforge.pmd.internal.util; import java.io.Closeable; import java.io.File; @@ -34,15 +34,10 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.annotation.InternalApi; - /** * * @author Brian Remedios - * @deprecated Is internal API */ -@InternalApi -@Deprecated public final class IOUtil { /** * Unicode BOM character. Replaces commons io ByteOrderMark. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java index cb002d3f34..92984b94e9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java @@ -5,8 +5,8 @@ package net.sourceforge.pmd.internal.util; -import static net.sourceforge.pmd.internal.util.AssertionUtil.requireOver1; -import static net.sourceforge.pmd.internal.util.AssertionUtil.requireParamNotNull; +import static net.sourceforge.pmd.util.AssertionUtil.requireOver1; +import static net.sourceforge.pmd.util.AssertionUtil.requireParamNotNull; import java.util.Collection; import java.util.function.Predicate; @@ -14,6 +14,8 @@ import java.util.regex.Pattern; import org.checkerframework.checker.nullness.qual.NonNull; +import net.sourceforge.pmd.util.AssertionUtil; + /** * Utility class for working with {@link Predicate}. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java index 927e6572d3..6e7b1f3f94 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java @@ -15,7 +15,7 @@ import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.DeprecatedUntil700; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * This class can discover the LanguageVersion of a source file. Further, every diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java index 1e70b8549d..4cfaeccdac 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java @@ -10,9 +10,9 @@ import java.util.Map; import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.annotation.Experimental; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.Parser.ParserTask; import net.sourceforge.pmd.lang.document.TextDocument; +import net.sourceforge.pmd.util.AssertionUtil; /** * The output of {@link Parser#parse(ParserTask)}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java index eded4cdb3c..bc9e09a608 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java @@ -9,10 +9,10 @@ import java.util.stream.Stream; import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.annotation.Experimental; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.document.TextRegion; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.util.IteratorUtil; /** * Represents a token, part of a token chain in a source file. Tokens diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/EscapeTranslator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/EscapeTranslator.java index 30431d995d..f2852d8c45 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/EscapeTranslator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/EscapeTranslator.java @@ -6,11 +6,11 @@ package net.sourceforge.pmd.lang.ast.impl.javacc; import static java.lang.Integer.min; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.FragmentedDocBuilder; import net.sourceforge.pmd.lang.document.TextDocument; +import net.sourceforge.pmd.util.AssertionUtil; /** * An object that can translate an input document into an output document, diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java index 31ef6efd37..fd1eecb465 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java @@ -18,10 +18,10 @@ import java.util.function.Predicate; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; +import net.sourceforge.pmd.util.AssertionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * Stream that iterates over one axis of the tree. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java index 0ab3923adc..68ca382e9b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java @@ -13,8 +13,8 @@ import java.util.function.Predicate; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.util.IteratorUtil; /** * Combined filter/map predicate. Cannot accept null values. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java index aa17ef5290..98f7eee936 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java @@ -13,11 +13,11 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * A greedy stream evaluates all axis operations, except for descendants, diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java index cd322ac924..0319e8e974 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java @@ -22,11 +22,11 @@ import java.util.stream.StreamSupport; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * Implementations are based on the iterator rather than the stream. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java index 269574254e..ff1f4acca8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java @@ -15,11 +15,11 @@ import java.util.stream.Stream; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.ast.NodeStream.DescendantNodeStream; +import net.sourceforge.pmd.util.AssertionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * Optimised node stream implementation for a single element. Streams diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java index ffaa189452..893413d435 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java @@ -16,7 +16,6 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.ast.NodeStream.DescendantNodeStream; @@ -28,6 +27,7 @@ import net.sourceforge.pmd.lang.ast.internal.AxisStream.FilteredAncestorOrSelfSt import net.sourceforge.pmd.lang.ast.internal.AxisStream.FilteredChildrenStream; import net.sourceforge.pmd.lang.ast.internal.AxisStream.FilteredDescendantStream; import net.sourceforge.pmd.lang.ast.internal.GreedyNStream.GreedyKnownNStream; +import net.sourceforge.pmd.util.IteratorUtil; public final class StreamImpl { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/Chars.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/Chars.java index f39978c265..f07f905fca 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/Chars.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/Chars.java @@ -21,7 +21,7 @@ import java.util.stream.StreamSupport; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.IteratorUtil.AbstractIterator; +import net.sourceforge.pmd.util.IteratorUtil.AbstractIterator; /** * View on a string which doesn't copy the array for subsequence operations. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java index dab049f24a..3cb69e2d03 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java @@ -33,11 +33,11 @@ import org.slf4j.LoggerFactory; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java index 6cdf18785c..57768ac833 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java @@ -10,10 +10,10 @@ import java.util.Objects; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.GenericToken; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.util.AssertionUtil; /** * Represents the coordinates of a text region, used for reporting. This provides access diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java index b6b74edaf3..fabeb69dcd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java @@ -16,9 +16,9 @@ import java.nio.file.Path; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.internal.util.BaseCloseable; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.AssertionUtil; /** * A {@link TextFile} backed by a file in some {@link FileSystem}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java index dcb36819db..d23ae6494e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java @@ -9,8 +9,8 @@ import java.io.Reader; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.AssertionUtil; /** * Read-only view on a string. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java index cf8caab34c..0e098aacb5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.document; import java.util.Arrays; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * Wraps a piece of text, and converts absolute offsets to line/column diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java index cfa7273a8e..7c288ff04b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java @@ -6,8 +6,8 @@ package net.sourceforge.pmd.lang.document; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java index 76a715cd66..4c646dbbb1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java @@ -21,11 +21,11 @@ import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.cpd.SourceCode; import net.sourceforge.pmd.internal.util.BaseCloseable; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.TextFileBuilder.ForCharSeq; import net.sourceforge.pmd.lang.document.TextFileBuilder.ForNio; import net.sourceforge.pmd.lang.document.TextFileBuilder.ForReader; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.datasource.DataSource; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java index e23f3264b5..b8e146a91a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java @@ -10,8 +10,8 @@ import java.nio.file.Path; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.AssertionUtil; /** * A builder for a new text file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileContent.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileContent.java index 0219448387..b973f91d89 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileContent.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileContent.java @@ -23,7 +23,7 @@ import java.util.zip.Checksum; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Contents of a text file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java index 92d4f1796d..f9576c38d8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java @@ -13,8 +13,8 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.DataMap.DataKey; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java index 9b5241a897..aeca48672b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java @@ -10,9 +10,9 @@ import java.util.Map; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.util.AssertionUtil; /** * @deprecated This is internal. Clients should exclusively use {@link RuleViolation}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java index 7c2398c8d8..91ac6c5a77 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java @@ -5,11 +5,11 @@ package net.sourceforge.pmd.lang.rule.internal; import static java.util.stream.Collectors.toSet; -import static net.sourceforge.pmd.internal.GraphUtils.DotColor; import static net.sourceforge.pmd.util.CollectionUtil.any; import static net.sourceforge.pmd.util.CollectionUtil.finish; import static net.sourceforge.pmd.util.CollectionUtil.map; import static net.sourceforge.pmd.util.CollectionUtil.toMutableList; +import static net.sourceforge.pmd.util.GraphUtil.DotColor; import java.util.ArrayDeque; import java.util.Collections; @@ -26,8 +26,8 @@ import java.util.stream.Collector; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.GraphUtils; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; +import net.sourceforge.pmd.util.GraphUtil; /** * Indexes data of type {@code } with keys of type {@code }, where @@ -218,7 +218,7 @@ class LatticeRelation { public String toString() { // generates a DOT representation of the lattice // Visualize eg at http://webgraphviz.com/ - return GraphUtils.toDot( + return GraphUtil.toDot( nodes.values(), n -> n.transitiveSuccs, n -> n.getClass() == QueryNode.class ? DotColor.GREEN : DotColor.BLACK, diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java index e867253eb7..501cd96a1b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java @@ -19,10 +19,10 @@ import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; import net.sourceforge.pmd.benchmark.TimedOperationCategory; import net.sourceforge.pmd.internal.SystemProps; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; /** Applies a set of rules to a set of ASTs. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java index 420b4afcf7..d7ba9652fc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java @@ -14,8 +14,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.util.IteratorUtil; /** * Index of an AST, for use by the {@link RuleApplicator}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java index dabd3a99ae..f1bd734934 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java @@ -10,8 +10,8 @@ import java.io.Writer; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.cli.PMDParameters; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.properties.AbstractPropertySource; -import net.sourceforge.pmd.util.IOUtil; /** * Abstract base class for {@link Renderer} implementations. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java index 5bf6c47ac8..66750cb5e5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java @@ -16,8 +16,8 @@ import java.util.TreeMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.util.AssertionUtil; /** * This class handles the creation of Renderers. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java index 135858d80b..f4052818d0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java @@ -10,9 +10,9 @@ import java.util.Iterator; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.renderers.internal.sarif.SarifLog; import net.sourceforge.pmd.renderers.internal.sarif.SarifLogBuilder; -import net.sourceforge.pmd.util.IOUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java index e75ae3a25b..6fa8f6ff9a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java @@ -27,9 +27,9 @@ import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.PMDVersion; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java index b59c401d07..f882ac7632 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java @@ -11,8 +11,8 @@ import java.util.List; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.Report.SuppressedViolation; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * A handler for events occuring during analysis of a single file. Instances diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java index 1abe5accac..55008fa997 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java @@ -15,13 +15,13 @@ import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.GlobalReportBuilderListener; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.renderers.Renderer; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.BaseResultProducingCloseable; import net.sourceforge.pmd.util.CollectionUtil; -import net.sourceforge.pmd.util.IOUtil; /** * Listens to an analysis. This object produces new {@link FileAnalysisListener} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java index bf1f740cf1..2ae8547c8e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java @@ -8,8 +8,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * An initializer for {@link GlobalAnalysisListener} that gets notified of diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/AssertionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java similarity index 97% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/util/AssertionUtil.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java index 9ac28a1e7c..303ec3c3e7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/AssertionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import java.util.Collection; @@ -24,7 +24,7 @@ public final class AssertionUtil { } - /** @throws NullPointerException if $name */ + /** @throws NullPointerException if any item is null */ public static void requireContainsNoNullValue(String name, Collection c) { int i = 0; for (Object o : c) { @@ -65,7 +65,7 @@ public final class AssertionUtil { } } - public static boolean isJavaBinaryName(CharSequence name) { + private static boolean isJavaBinaryName(CharSequence name) { return name.length() > 0 && BINARY_NAME_PATTERN.matcher(name).matches(); } @@ -78,6 +78,7 @@ public final class AssertionUtil { } + /** Throws {@link IllegalStateException} if the condition is false. */ public static void validateState(boolean condition, String failed) { if (!condition) { throw new IllegalStateException(failed); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java index ea978cc9bd..d28e7180df 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java @@ -18,9 +18,7 @@ public abstract class BaseResultProducingCloseable implements AutoCloseable { private boolean closed; protected final void ensureOpen() { - if (closed) { - throw new IllegalStateException("Listener closed"); - } + AssertionUtil.validateState(!closed, "Listener has been closed"); } /** @@ -29,9 +27,7 @@ public abstract class BaseResultProducingCloseable implements AutoCloseable { * @throws IllegalStateException If this instance has not been closed yet */ public final T getResult() { - if (!closed) { - throw new IllegalStateException("Cannot get result before listener is closed"); - } + AssertionUtil.validateState(closed, "Cannot get result before listener is closed"); return getResultImpl(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java index 2ad062ee21..d470b6c7eb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -40,68 +39,21 @@ import org.pcollections.PMap; import org.pcollections.PSequence; import org.pcollections.PSet; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.document.Chars; /** - * Generic collection and array-related utility functions for java.util types. - * See ClassUtil for comparable facilities for short name lookup. + * Generic collection-related utility functions for java.util types. * * @author Brian Remedios - * @version $Revision$ - * @deprecated Is internal API + * @author Clément Fournier */ -@Deprecated -@InternalApi public final class CollectionUtil { private static final int UNKNOWN_SIZE = -1; - @SuppressWarnings("PMD.UnnecessaryFullyQualifiedName") - public static final Set COLLECTION_INTERFACES_BY_NAMES = collectionTypes(List.class, Collection.class, Map.class, Set.class); - - @SuppressWarnings({"PMD.LooseCoupling", "PMD.UnnecessaryFullyQualifiedName"}) - public static final Set COLLECTION_CLASSES_BY_NAMES - = collectionTypes(ArrayList.class, java.util.LinkedList.class, java.util.Vector.class, HashMap.class, - java.util.LinkedHashMap.class, java.util.TreeMap.class, java.util.TreeSet.class, - HashSet.class, java.util.LinkedHashSet.class, java.util.Hashtable.class); - - private CollectionUtil() { } - private static Set collectionTypes(Class... types) { - Set set = new HashSet<>(); - - for (Class type : types) { - if (!set.add(type.getSimpleName()) || !set.add(type.getName())) { - throw new IllegalArgumentException("Duplicate or name collision for " + type); - } - } - - return set; - } - - /** - * Return whether we can identify the typeName as a java.util collection - * class or interface as specified. - * - * @param typeName - * String - * @param includeInterfaces - * boolean - * @return boolean - * - * @deprecated Will be replaced with type resolution - */ - @Deprecated - public static boolean isCollectionType(String typeName, boolean includeInterfaces) { - return COLLECTION_CLASSES_BY_NAMES.contains(typeName) - || includeInterfaces && COLLECTION_INTERFACES_BY_NAMES.contains(typeName); - } - /** * Creates and returns a map populated with the keyValuesSets where the * value held by the tuples are they key and value in that order. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java index 3c3a40f4e0..66fdfcfe73 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java @@ -10,8 +10,6 @@ import java.util.List; import org.apache.commons.lang3.Validate; -import net.sourceforge.pmd.internal.util.IteratorUtil; - final class ConsList extends AbstractList { private final List head; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedAssertionError.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java similarity index 92% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedAssertionError.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java index e4ab1a5bdf..a6cb0615eb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedAssertionError.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java @@ -2,10 +2,12 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import org.apache.commons.lang3.exception.DefaultExceptionContext; +import net.sourceforge.pmd.internal.util.ExceptionContextDefaultImpl; + /** * An {@link AssertionError} with nice messages. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedStackOverflowError.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java similarity index 92% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedStackOverflowError.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java index e2fa9b2fe0..854f3a6b8e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedStackOverflowError.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java @@ -2,10 +2,12 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import org.apache.commons.lang3.exception.DefaultExceptionContext; +import net.sourceforge.pmd.internal.util.ExceptionContextDefaultImpl; + /** * A {@link StackOverflowError} with nice messages. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/GraphUtils.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java similarity index 96% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/GraphUtils.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java index 1748dfff42..bdd43e6525 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/GraphUtils.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java @@ -3,7 +3,7 @@ */ -package net.sourceforge.pmd.internal; +package net.sourceforge.pmd.util; import java.util.ArrayList; import java.util.Collection; @@ -16,9 +16,9 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; -public final class GraphUtils { +public final class GraphUtil { - private GraphUtils() { + private GraphUtil() { } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IteratorUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IteratorUtil.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java index 25c27dbe5e..4e10d396bb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IteratorUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import java.util.ArrayList; import java.util.Arrays; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java index fc4ecca0a6..1913a713ff 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java @@ -15,22 +15,16 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.document.Chars; /** - * A number of String-specific utility methods for use by PMD or its IDE - * plugins. + * String-related utility functions. See also {@link StringUtils}. * * @author BrianRemedios - * @deprecated Is internal API + * @author Clément Fournier */ -@Deprecated -@InternalApi public final class StringUtil { - private static final String[] EMPTY_STRINGS = new String[0]; private static final Pattern XML_10_INVALID_CHARS = Pattern.compile( "\\x00|\\x01|\\x02|\\x03|\\x04|\\x05|\\x06|\\x07|\\x08|" @@ -225,47 +219,6 @@ public final class StringUtil { return text; } - - /** - * @param supportUTF8 override the default setting, whether special characters should be replaced with entities ( - * false) or should be included as is ( true). - * @deprecated for removal. Use Java's XML implementations, that do the escaping, - * use {@link #removedInvalidXml10Characters(String)} for fixing invalid characters in XML 1.0 - * documents or use {@code StringEscapeUtils#escapeXml10(String)} from apache commons-text instead. - */ - @Deprecated - public static void appendXmlEscaped(StringBuilder buf, String src, boolean supportUTF8) { - char c; - int i = 0; - while (i < src.length()) { - c = src.charAt(i++); - if (c > '~') { - // 126 - if (!supportUTF8) { - int codepoint = c; - // surrogate characters are not allowed in XML - if (Character.isHighSurrogate(c)) { - char low = src.charAt(i++); - codepoint = Character.toCodePoint(c, low); - } - buf.append("&#x").append(Integer.toHexString(codepoint)).append(';'); - } else { - buf.append(c); - } - } else if (c == '&') { - buf.append("&"); - } else if (c == '"') { - buf.append("""); - } else if (c == '<') { - buf.append("<"); - } else if (c == '>') { - buf.append(">"); - } else { - buf.append(c); - } - } - } - /** * Remove characters, that are not allowed in XML 1.0 documents. * @@ -489,15 +442,6 @@ public final class StringUtil { return truncated + ellipsis; } - /** - * Returns an empty array of string - * - * @return String - */ - public static String[] getEmptyStrings() { - return EMPTY_STRINGS; - } - /** * Replaces unprintable characters by their escaped (or unicode escaped) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java index 6edb9e6553..149382ea09 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.Reader; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.util.datasource.internal.AbstractDataSource; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java index 772e481c9c..95643b12a0 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java @@ -32,9 +32,9 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.cache.FileAnalysisCache; import net.sourceforge.pmd.cache.NoopAnalysisCache; +import net.sourceforge.pmd.internal.util.ClasspathClassLoader; import net.sourceforge.pmd.renderers.CSVRenderer; import net.sourceforge.pmd.renderers.Renderer; -import net.sourceforge.pmd.util.ClasspathClassLoader; class PmdConfigurationTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java index 1e75e37584..4e271dbbba 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java @@ -25,7 +25,7 @@ import java.util.List; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.util.ResourceLoader; import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java index 81396be626..8ecbdd6377 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java @@ -40,6 +40,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.RuleSet.RuleSetBuilder; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.Node; @@ -47,7 +48,6 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; -import net.sourceforge.pmd.util.IOUtil; class RuleSetTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cli/CoreCliTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cli/CoreCliTest.java index 6856e00f6b..a0a1c8237b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cli/CoreCliTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cli/CoreCliTest.java @@ -34,7 +34,7 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.PMD.StatusCode; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java index ea2cffa619..49f135e4d4 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java @@ -22,7 +22,7 @@ import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class CpdXsltTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/FileReporterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/FileReporterTest.java index 72a90390b7..35ca4746b0 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/FileReporterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/FileReporterTest.java @@ -15,7 +15,7 @@ import java.io.Reader; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * @author Philippe T'Seyen diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java index e0681d607e..a62bfba125 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java @@ -24,8 +24,8 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.util.CollectionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/NioTextFileTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/NioTextFileTest.java index 597d09f6d8..deeb878cd8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/NioTextFileTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/NioTextFileTest.java @@ -19,10 +19,10 @@ import java.util.zip.ZipOutputStream; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.util.IOUtil; class NioTextFileTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java index 08e3edab7a..1e4aa3ded1 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java @@ -15,9 +15,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.util.IOUtil; class TextDocumentTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java index d035f6f961..d06ad5e6f7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java @@ -12,10 +12,10 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.xpath.NoAttribute.NoAttrScope; +import net.sourceforge.pmd.util.IteratorUtil; /** * @author Clément Fournier diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java index 415a7f2845..334da77a7b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java @@ -34,7 +34,6 @@ import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSets; import net.sourceforge.pmd.internal.SystemProps; -import net.sourceforge.pmd.internal.util.ContextedAssertionError; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.DummyLanguageModule.Handler; import net.sourceforge.pmd.lang.Language; @@ -45,6 +44,7 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.processor.MonoThreadProcessor.MonothreadRunnable; +import net.sourceforge.pmd.util.ContextedAssertionError; import net.sourceforge.pmd.util.log.MessageReporter; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java index 84570db95d..78ba7dd755 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java @@ -27,6 +27,7 @@ import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.RuleWithProperties; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.FileLocation; @@ -35,7 +36,6 @@ import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.util.IOUtil; abstract class AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java index c2c13b7c83..00173d2f5d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java @@ -30,10 +30,10 @@ import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import net.sourceforge.pmd.util.IOUtil; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java index 88667ee62c..12d78fae60 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java @@ -26,10 +26,10 @@ import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.util.CollectionUtil; -import net.sourceforge.pmd.util.IOUtil; class YAHTMLRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/IOUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/IOUtilTest.java index 7d149e886a..9b558684b2 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/IOUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/IOUtilTest.java @@ -33,6 +33,8 @@ import java.nio.file.Path; import org.apache.commons.lang3.SystemUtils; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.internal.util.IOUtil; + class IOUtilTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/internal/util/IteratorUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/IteratorUtilTest.java similarity index 99% rename from pmd-core/src/test/java/net/sourceforge/pmd/internal/util/IteratorUtilTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/util/IteratorUtilTest.java index e306fcfc0c..c58f39afc0 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/internal/util/IteratorUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/IteratorUtilTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import static java.util.Collections.emptyIterator; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java index 052244bf84..189040c97b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java @@ -51,31 +51,6 @@ class StringUtilTest { assertEquals(-1, StringUtil.columnNumberAt("", 1)); } - @Test - void testUTF8NotSupported() { - StringBuilder sb = new StringBuilder(); - String test = "é"; - StringUtil.appendXmlEscaped(sb, test, false); - assertEquals("é", sb.toString()); - } - - @Test - void testUTF8NotSupportedSurrogates() { - // D8 34 DD 1E -> U+1D11E - StringBuilder sb = new StringBuilder(); - String test = new String(new char[] {0xd834, 0xdd1e}); - StringUtil.appendXmlEscaped(sb, test, false); - assertEquals("𝄞", sb.toString()); - } - - @Test - void testUTF8Supported() { - StringBuilder sb = new StringBuilder(); - String test = "é"; - StringUtil.appendXmlEscaped(sb, test, true); - assertEquals("é", sb.toString()); - } - @Test void testRemoveSurrounding() { assertThat(StringUtil.removeSurrounding("", 'q'), equalTo("")); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/datasource/internal/PathDataSourceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/datasource/internal/PathDataSourceTest.java index 0acbbbf255..195e78e1e0 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/datasource/internal/PathDataSourceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/datasource/internal/PathDataSourceTest.java @@ -19,7 +19,7 @@ import java.util.zip.ZipOutputStream; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class PathDataSourceTest { @TempDir diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java index 78114cb84e..f28e430273 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.OS; import net.sourceforge.pmd.PMDVersion; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * This test calls ant in a fake terminal to make sure we have a {@link java.io.Console} connected. diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/PMDExecutor.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/PMDExecutor.java index 7998ae0652..d4d601789b 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/PMDExecutor.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/PMDExecutor.java @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.SystemUtils; import net.sourceforge.pmd.PMDVersion; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Executes PMD from command line. Deals with the differences, when PMD is run on Windows or on Linux. diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java index 609dde0e44..053e84db70 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java @@ -18,7 +18,7 @@ import java.util.List; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipFile; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Extracts a zip file with preserving the unix file permissions. diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java index 499b7b67e3..9188ebef0d 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java @@ -39,7 +39,7 @@ import java.util.stream.Stream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Checks links to local pages for non-existing link-targets. diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java index 56cdad1a81..ebe55f4abd 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java @@ -19,7 +19,7 @@ import java.util.regex.Pattern; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoader; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; public final class GenerateRuleDocsCmd { diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index d6a82e1a06..0e4e886329 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -37,13 +37,13 @@ import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoadException; import net.sourceforge.pmd.RuleSetLoader; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.MultiValuePropertyDescriptor; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.util.IOUtil; public class RuleDocGenerator { private static final Logger LOG = LoggerFactory.getLogger(RuleDocGenerator.class); diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java index 0ab05a68bc..f581ae6776 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java @@ -12,8 +12,8 @@ import org.apache.commons.lang3.SystemUtils; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleSet; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.util.IOUtil; public final class RuleSetUtils { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java index d7d5f2162e..69665c54b5 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoader; import net.sourceforge.pmd.docs.MockedFileWriter.FileEntry; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class RuleDocGeneratorTest { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java index 8d476217a3..f5baf81b34 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java @@ -15,7 +15,7 @@ import java.util.List; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.RuleSetLoader; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class RuleSetResolverTest { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java index 004d4244de..18eca76d2f 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java @@ -24,9 +24,9 @@ import org.yaml.snakeyaml.DumperOptions.LineBreak; import org.yaml.snakeyaml.Yaml; import net.sourceforge.pmd.RuleSet; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.util.IOUtil; class SidebarGeneratorTest { private MockedFileWriter writer = new MockedFileWriter(); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceType.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceType.java index 155e865e0c..3c780af67d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceType.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceType.java @@ -6,10 +6,10 @@ package net.sourceforge.pmd.lang.java.ast; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; import net.sourceforge.pmd.lang.java.symbols.JTypeDeclSymbol; import net.sourceforge.pmd.lang.java.types.JClassType; +import net.sourceforge.pmd.util.AssertionUtil; // @formatter:off /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaTypeNode.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaTypeNode.java index 1954bb04bc..36208aef3a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaTypeNode.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaTypeNode.java @@ -6,10 +6,10 @@ package net.sourceforge.pmd.lang.java.ast; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.TypingContext; import net.sourceforge.pmd.lang.java.types.ast.LazyTypeResolver; +import net.sourceforge.pmd.util.AssertionUtil; /** * An extension of the SimpleJavaNode which implements the TypeNode interface. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ConstantFolder.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ConstantFolder.java index 663b31bb87..2e33a43d1c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ConstantFolder.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ConstantFolder.java @@ -9,13 +9,13 @@ import org.apache.commons.lang3.tuple.Pair; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; import net.sourceforge.pmd.lang.java.symbols.JFieldSymbol; import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol; import net.sourceforge.pmd.lang.java.types.JPrimitiveType; import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * Computes constant expression values. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalApiBridge.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalApiBridge.java index a5aa733418..d8f536eeaf 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalApiBridge.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalApiBridge.java @@ -8,7 +8,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; @@ -33,6 +32,7 @@ import net.sourceforge.pmd.lang.java.types.ast.ExprContext; import net.sourceforge.pmd.lang.java.types.ast.LazyTypeResolver; import net.sourceforge.pmd.lang.java.types.internal.infer.Infer; import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger; +import net.sourceforge.pmd.util.AssertionUtil; /** * Acts as a bridge between outer parts of PMD and the restricted access diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java index 8fe146edfc..74893e2eec 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.ast; import java.util.stream.Stream; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.GenericToken; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; import net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode; @@ -14,6 +13,7 @@ import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.util.IteratorUtil; /** * Wraps a comment token to provide some utilities. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java index 7a2a31fa06..e5caff888e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java @@ -11,7 +11,6 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAnnotation; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; @@ -53,6 +52,7 @@ import net.sourceforge.pmd.lang.java.ast.JModifier; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.JavaTokenKinds; import net.sourceforge.pmd.lang.java.ast.JavaVisitorBase; +import net.sourceforge.pmd.util.IteratorUtil; /** * Checks that an AST conforms to some language level. The reporting diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/PrettyPrintingUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/PrettyPrintingUtil.java index 0e1945919c..730a477e9d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/PrettyPrintingUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/PrettyPrintingUtil.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.java.ast.internal; -import static net.sourceforge.pmd.internal.util.AssertionUtil.shouldNotReachHere; +import static net.sourceforge.pmd.util.AssertionUtil.shouldNotReachHere; import org.checkerframework.checker.nullness.qual.NonNull; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java index d0691d7695..05900cd459 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java @@ -12,7 +12,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTBodyDeclaration; @@ -26,6 +25,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclarator; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.reporting.ViolationDecorator; +import net.sourceforge.pmd.util.IteratorUtil; final class JavaViolationDecorator implements ViolationDecorator { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryFullyQualifiedNameRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryFullyQualifiedNameRule.java index 95407f525e..79ca132157 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryFullyQualifiedNameRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryFullyQualifiedNameRule.java @@ -13,7 +13,6 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType; import net.sourceforge.pmd.lang.java.ast.ASTFieldAccess; import net.sourceforge.pmd.lang.java.ast.ASTMethodCall; @@ -31,6 +30,7 @@ import net.sourceforge.pmd.lang.java.symbols.table.coreimpl.ShadowChain; import net.sourceforge.pmd.lang.java.symbols.table.coreimpl.ShadowChainIterator; import net.sourceforge.pmd.lang.java.types.JMethodSig; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.util.AssertionUtil; public class UnnecessaryFullyQualifiedNameRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UselessParenthesesRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UselessParenthesesRule.java index aeca43decc..6efdd0ef2a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UselessParenthesesRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UselessParenthesesRule.java @@ -11,7 +11,6 @@ import static net.sourceforge.pmd.lang.java.rule.codestyle.UselessParenthesesRul import static net.sourceforge.pmd.lang.java.rule.codestyle.UselessParenthesesRule.Necessity.definitely; import static net.sourceforge.pmd.lang.java.rule.codestyle.UselessParenthesesRule.Necessity.necessaryIf; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTAssignmentExpression; import net.sourceforge.pmd.lang.java.ast.ASTCastExpression; import net.sourceforge.pmd.lang.java.ast.ASTConditionalExpression; @@ -26,6 +25,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.util.AssertionUtil; public final class UselessParenthesesRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java index 93d9c09b49..6bd257afa4 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java @@ -11,7 +11,6 @@ import java.util.List; import java.util.Map; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; @@ -24,6 +23,7 @@ import net.sourceforge.pmd.lang.metrics.MetricOptions; import net.sourceforge.pmd.lang.metrics.MetricsUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.util.AssertionUtil; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/AsmSymbolResolver.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/AsmSymbolResolver.java index 6e45e1dda0..31b06c9884 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/AsmSymbolResolver.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/AsmSymbolResolver.java @@ -13,12 +13,12 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.objectweb.asm.Opcodes; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.SymbolResolver; import net.sourceforge.pmd.lang.java.symbols.internal.asm.Loader.FailedLoader; import net.sourceforge.pmd.lang.java.symbols.internal.asm.Loader.UrlLoader; import net.sourceforge.pmd.lang.java.types.TypeSystem; +import net.sourceforge.pmd.util.AssertionUtil; /** * A {@link SymbolResolver} that reads class files to produce symbols. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/SignatureScanner.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/SignatureScanner.java index 029f2f6a9d..752e6b08d9 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/SignatureScanner.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/SignatureScanner.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.java.symbols.internal.asm; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * Base class to scan a type signature. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/MostlySingularMultimap.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/MostlySingularMultimap.java index 2a18b98237..d324eafa39 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/MostlySingularMultimap.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/MostlySingularMultimap.java @@ -17,7 +17,7 @@ import org.apache.commons.lang3.Validate; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * An unmodifiable multimap type, efficient if the single-value case is the diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/ShadowChainIteratorImpl.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/ShadowChainIteratorImpl.java index fc234944b6..5d6a55f43a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/ShadowChainIteratorImpl.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/ShadowChainIteratorImpl.java @@ -10,7 +10,7 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; +import net.sourceforge.pmd.util.IteratorUtil; import net.sourceforge.pmd.util.OptionalBool; class ShadowChainIteratorImpl diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/AbruptCompletionAnalysis.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/AbruptCompletionAnalysis.java index 6bd9eb3061..4b972c595c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/AbruptCompletionAnalysis.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/AbruptCompletionAnalysis.java @@ -12,7 +12,6 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.java.ast.ASTBlock; import net.sourceforge.pmd.lang.java.ast.ASTBreakStatement; @@ -41,6 +40,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.JavaVisitorBase; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.symbols.table.internal.AbruptCompletionAnalysis.ReachabilityVisitor.VisitResult; +import net.sourceforge.pmd.util.AssertionUtil; /** * Implementation of {@link #canCompleteNormally(ASTStatement)}, which diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/JavaResolvers.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/JavaResolvers.java index 00c5716d9f..ee8fb653b7 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/JavaResolvers.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/JavaResolvers.java @@ -25,7 +25,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.pcollections.HashTreePSet; import org.pcollections.PSet; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.symbols.JAccessibleElementSymbol; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JElementSymbol; @@ -43,6 +42,7 @@ import net.sourceforge.pmd.lang.java.types.JVariableSig; import net.sourceforge.pmd.lang.java.types.JVariableSig.FieldSig; import net.sourceforge.pmd.lang.java.types.TypeOps; import net.sourceforge.pmd.lang.java.types.internal.infer.OverloadSet; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; public final class JavaResolvers { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/PatternBindingsUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/PatternBindingsUtil.java index 4855b48ebb..311cb0d2e2 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/PatternBindingsUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/PatternBindingsUtil.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.java.symbols.table.internal; import org.pcollections.HashTreePSet; import org.pcollections.PSet; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTGuardedPattern; import net.sourceforge.pmd.lang.java.ast.ASTInfixExpression; @@ -19,6 +18,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTUnaryExpression; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.ast.BinaryOp; import net.sourceforge.pmd.lang.java.ast.UnaryOp; +import net.sourceforge.pmd.util.AssertionUtil; /** * Utilities to resolve scope of pattern binding variables. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SuperTypesEnumerator.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SuperTypesEnumerator.java index 3890162836..b05e5bda9c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SuperTypesEnumerator.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SuperTypesEnumerator.java @@ -18,9 +18,9 @@ import java.util.stream.StreamSupport; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil.AbstractIterator; import net.sourceforge.pmd.lang.java.types.JClassType; +import net.sourceforge.pmd.util.IteratorUtil; +import net.sourceforge.pmd.util.IteratorUtil.AbstractIterator; /** * Strategies to enumerate a type hierarchy. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SymTableFactory.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SymTableFactory.java index 46ffb2b987..fb93d4edb0 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SymTableFactory.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SymTableFactory.java @@ -5,9 +5,9 @@ package net.sourceforge.pmd.lang.java.symbols.table.internal; -import static net.sourceforge.pmd.internal.util.AssertionUtil.isValidJavaPackageName; import static net.sourceforge.pmd.lang.java.symbols.table.ScopeInfo.FORMAL_PARAM; import static net.sourceforge.pmd.lang.java.symbols.table.ScopeInfo.SAME_FILE; +import static net.sourceforge.pmd.util.AssertionUtil.isValidJavaPackageName; import java.lang.reflect.Modifier; import java.util.ArrayList; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/InvocationMatcher.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/InvocationMatcher.java index 09224b77d1..59558c999c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/InvocationMatcher.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/InvocationMatcher.java @@ -13,13 +13,13 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTList; import net.sourceforge.pmd.lang.java.ast.InvocationNode; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.QualifiableExpression; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.OptionalBool; import net.sourceforge.pmd.util.StringUtil; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/JTypeMirror.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/JTypeMirror.java index a6eb81adad..03aace3844 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/JTypeMirror.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/JTypeMirror.java @@ -16,7 +16,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.pcollections.PSet; import net.sourceforge.pmd.annotation.Experimental; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.TypeNode; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol; @@ -27,6 +26,7 @@ import net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymAnnot; import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind; import net.sourceforge.pmd.lang.java.types.TypeOps.Convertibility; import net.sourceforge.pmd.lang.java.types.internal.infer.InferenceVar; +import net.sourceforge.pmd.util.AssertionUtil; /** * Type mirrors represent Java types. They are created by a {@link TypeSystem} diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/Substitution.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/Substitution.java index 10892fd4eb..234833a1a2 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/Substitution.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/Substitution.java @@ -17,7 +17,7 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeOps.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeOps.java index e82adeb78f..5339bcb280 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeOps.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeOps.java @@ -29,7 +29,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JConstructorSymbol; import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol; @@ -43,6 +42,7 @@ import net.sourceforge.pmd.lang.java.types.internal.infer.InferenceVar; import net.sourceforge.pmd.lang.java.types.internal.infer.InferenceVar.BoundKind; import net.sourceforge.pmd.lang.java.types.internal.infer.OverloadSet; import net.sourceforge.pmd.util.CollectionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * Common operations on types. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeSystem.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeSystem.java index 06b044fdc7..788dc9ec94 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeSystem.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeSystem.java @@ -23,7 +23,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.pcollections.HashTreePSet; import org.pcollections.PSet; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol; @@ -40,6 +39,7 @@ import net.sourceforge.pmd.lang.java.symbols.internal.asm.Classpath; import net.sourceforge.pmd.lang.java.types.BasePrimitiveSymbol.RealPrimitiveSymbol; import net.sourceforge.pmd.lang.java.types.BasePrimitiveSymbol.VoidSymbol; import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeTestUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeTestUtil.java index 0eac183735..f9c5df63eb 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeTestUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeTestUtil.java @@ -11,13 +11,13 @@ import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.InternalApiBridge; import net.sourceforge.pmd.lang.java.ast.TypeNode; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JTypeDeclSymbol; import net.sourceforge.pmd.lang.java.symbols.JTypeParameterSymbol; import net.sourceforge.pmd.lang.java.symbols.internal.UnresolvedClassStore; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.OptionalBool; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeVarImpl.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeVarImpl.java index 491b2d4270..e682425b6c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeVarImpl.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeVarImpl.java @@ -11,9 +11,9 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.pcollections.PSet; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.symbols.JTypeParameterSymbol; import net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymAnnot; +import net.sourceforge.pmd.util.AssertionUtil; @SuppressWarnings("PMD.CompareObjectsWithEquals") abstract class TypeVarImpl implements JTypeVar { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypingContext.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypingContext.java index bcd6813748..fc55e155a6 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypingContext.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypingContext.java @@ -11,8 +11,8 @@ import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol; +import net.sourceforge.pmd.util.AssertionUtil; /** * A mapping of variables to types. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/ExprContext.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/ExprContext.java index 8f59b577cd..aa80538da1 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/ExprContext.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/ExprContext.java @@ -13,11 +13,11 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.Experimental; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.InvocationNode; import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.OverloadSelectionResult; import net.sourceforge.pmd.lang.java.types.TypeConversion; +import net.sourceforge.pmd.util.AssertionUtil; /** * Context of an expression. This determines the target type of poly diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/PolyResolution.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/PolyResolution.java index 0baf61a9c0..a8f731c0c8 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/PolyResolution.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/PolyResolution.java @@ -7,8 +7,8 @@ package net.sourceforge.pmd.lang.java.types.ast; import static java.util.Arrays.asList; -import static net.sourceforge.pmd.internal.util.AssertionUtil.shouldNotReachHere; import static net.sourceforge.pmd.lang.java.types.TypeConversion.isConvertibleUsingBoxing; +import static net.sourceforge.pmd.util.AssertionUtil.shouldNotReachHere; import static net.sourceforge.pmd.util.CollectionUtil.all; import static net.sourceforge.pmd.util.CollectionUtil.map; @@ -17,7 +17,6 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; @@ -71,6 +70,7 @@ import net.sourceforge.pmd.lang.java.types.internal.infer.Infer; import net.sourceforge.pmd.lang.java.types.internal.infer.MethodCallSite; import net.sourceforge.pmd.lang.java.types.internal.infer.PolySite; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors; +import net.sourceforge.pmd.util.AssertionUtil; /** * Routines to handle context around poly expressions. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/Graph.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/Graph.java index ceddc46062..77db849273 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/Graph.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/Graph.java @@ -18,8 +18,8 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import net.sourceforge.pmd.internal.GraphUtils; -import net.sourceforge.pmd.internal.GraphUtils.DotColor; +import net.sourceforge.pmd.util.GraphUtil; +import net.sourceforge.pmd.util.GraphUtil.DotColor; /** * A graph to walk over ivar dependencies in an efficient way. @@ -157,7 +157,7 @@ class Graph { @Override public String toString() { - return GraphUtils.toDot( + return GraphUtil.toDot( vertices, this::successorsOf, v -> DotColor.BLACK, diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/VarWalkStrategy.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/VarWalkStrategy.java index 4f3291f909..2177a1cf92 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/VarWalkStrategy.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/VarWalkStrategy.java @@ -8,10 +8,10 @@ import java.util.Collections; import java.util.Iterator; import java.util.Set; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.java.types.internal.infer.Graph.UniqueGraph; import net.sourceforge.pmd.lang.java.types.internal.infer.Graph.Vertex; import net.sourceforge.pmd.lang.java.types.internal.infer.InferenceVar.BoundKind; +import net.sourceforge.pmd.util.IteratorUtil; /** * Strategy to walk the set of remaining free variables. Interdependent diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/BaseInvocMirror.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/BaseInvocMirror.java index c3f3a338c4..575ffb6f8c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/BaseInvocMirror.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/BaseInvocMirror.java @@ -10,7 +10,6 @@ import java.util.stream.Collectors; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTList; @@ -25,6 +24,7 @@ import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.InvocationMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.MethodCallSite; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors.MirrorMaker; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; abstract class BaseInvocMirror extends BasePolyMirror implements InvocationMirror { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/CtorInvocMirror.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/CtorInvocMirror.java index 0b25ad842c..5aea093a0e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/CtorInvocMirror.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/CtorInvocMirror.java @@ -13,7 +13,6 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTEnumConstant; import net.sourceforge.pmd.lang.java.ast.ASTExplicitConstructorInvocation; @@ -26,6 +25,7 @@ import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.CtorInvocationMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors.MirrorMaker; +import net.sourceforge.pmd.util.IteratorUtil; class CtorInvocMirror extends BaseInvocMirror implements CtorInvocationMirror { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/JavaExprMirrors.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/JavaExprMirrors.java index 890415436e..fbd113f641 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/JavaExprMirrors.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/JavaExprMirrors.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.java.types.internal.infer.ast; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTConditionalExpression; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTEnumConstant; @@ -25,6 +24,7 @@ import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.FunctionalE import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.InvocationMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.Infer; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.CtorInvocMirror.EnumCtorInvocMirror; +import net.sourceforge.pmd.util.AssertionUtil; /** Façade that creates {@link ExprMirror} instances. */ public final class JavaExprMirrors { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/LambdaMirrorImpl.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/LambdaMirrorImpl.java index 51a4663079..69f6fa1da2 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/LambdaMirrorImpl.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/LambdaMirrorImpl.java @@ -9,7 +9,6 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTAssignmentExpression; import net.sourceforge.pmd.lang.java.ast.ASTBlock; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; @@ -29,6 +28,7 @@ import net.sourceforge.pmd.lang.java.types.TypingContext; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.LambdaExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors.MirrorMaker; +import net.sourceforge.pmd.util.AssertionUtil; class LambdaMirrorImpl extends BaseFunctionalMirror implements LambdaExprMirror { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/MethodRefMirrorImpl.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/MethodRefMirrorImpl.java index 40933a3092..af9cded3d3 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/MethodRefMirrorImpl.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/MethodRefMirrorImpl.java @@ -10,7 +10,6 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTList; import net.sourceforge.pmd.lang.java.ast.ASTMethodReference; @@ -22,6 +21,7 @@ import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.MethodRefMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors.MirrorMaker; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; final class MethodRefMirrorImpl extends BaseFunctionalMirror implements MethodRefMirror { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java index db07462b49..a9b9dbabaa 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java @@ -20,7 +20,7 @@ import org.junit.rules.ExternalResource; import org.junit.rules.TestRule; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; public class PMDTaskTest extends AbstractAntTestHelper { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java index a54b5989a9..f573e94f61 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java @@ -22,9 +22,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.PMD; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.java.JavaLanguageModule; -import net.sourceforge.pmd.util.IOUtil; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt index b8ea9745bf..6e310638bc 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt @@ -11,7 +11,6 @@ import io.kotest.matchers.collections.shouldBeEmpty import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import io.kotest.matchers.types.shouldBeInstanceOf -import net.sourceforge.pmd.internal.util.IteratorUtil import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken import net.sourceforge.pmd.lang.ast.test.NodeSpec @@ -19,6 +18,7 @@ import net.sourceforge.pmd.lang.ast.test.ValuedNodeSpec import net.sourceforge.pmd.lang.ast.test.shouldBe import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind.* +import net.sourceforge.pmd.util.IteratorUtil fun > C?.shouldContainAtMostOneOf(vararg expected: T) { this shouldNotBe null diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.java index 7c30ffa1a6..f9a49c17be 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.java @@ -22,6 +22,7 @@ import java.util.function.Predicate; import java.util.stream.Stream; import java.util.stream.StreamSupport; +import net.sourceforge.pmd.util.AssertionUtil; public final class IteratorUtilCopy { diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt index f3914a0e8b..6466448c66 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt @@ -4,18 +4,21 @@ package net.sourceforge.pmd.lang.ast.test import net.sourceforge.pmd.* +import net.sourceforge.pmd.internal.util.IOUtil import net.sourceforge.pmd.lang.Language import net.sourceforge.pmd.lang.LanguageRegistry import net.sourceforge.pmd.lang.LanguageVersion import net.sourceforge.pmd.lang.LanguageVersionHandler -import net.sourceforge.pmd.lang.ast.* +import net.sourceforge.pmd.lang.ast.Node +import net.sourceforge.pmd.lang.ast.Parser +import net.sourceforge.pmd.lang.ast.RootNode +import net.sourceforge.pmd.lang.ast.SemanticErrorReporter import net.sourceforge.pmd.lang.document.TextDocument import net.sourceforge.pmd.lang.document.TextFile import net.sourceforge.pmd.lang.rule.XPathRule import net.sourceforge.pmd.lang.rule.xpath.XPathVersion import net.sourceforge.pmd.processor.AbstractPMDProcessor import net.sourceforge.pmd.reporting.GlobalAnalysisListener -import net.sourceforge.pmd.util.IOUtil import java.io.InputStream import java.nio.charset.StandardCharsets import java.nio.file.Files diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java index 2825adbb4a..0012282d64 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java @@ -39,12 +39,12 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.util.IOUtil; /** * Base test class to verify the language's rulesets. This class should be diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/cli/BaseCLITest.java b/pmd-test/src/main/java/net/sourceforge/pmd/cli/BaseCLITest.java index b199a22742..4634849fbc 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/cli/BaseCLITest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/cli/BaseCLITest.java @@ -26,7 +26,7 @@ import org.junit.contrib.java.lang.system.SystemOutRule; import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.PMD.StatusCode; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * @author Romain Pelisse <belaran@gmail.com> diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlNodeWrapper.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlNodeWrapper.java index 306611f217..93817548fa 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlNodeWrapper.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlNodeWrapper.java @@ -18,7 +18,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.lang.document.TextRegion; import net.sourceforge.pmd.lang.rule.xpath.Attribute; @@ -26,6 +25,7 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.CoordinateXPathFunction; import net.sourceforge.pmd.lang.xml.ast.XmlNode; import net.sourceforge.pmd.util.DataMap; import net.sourceforge.pmd.util.DataMap.DataKey; +import net.sourceforge.pmd.util.IteratorUtil; /** From fe568a016151d8a8151e1daf311e1b4a4955c600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 25 Jan 2023 01:46:35 -0300 Subject: [PATCH 05/28] Add failing test using type inference --- .../java/rule/errorprone/xml/CloseResource.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/CloseResource.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/CloseResource.xml index faeb1f6d6a..9921cdbf96 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/CloseResource.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/CloseResource.xml @@ -2010,6 +2010,22 @@ public record MyRecord(boolean a) { private static Object test; } } +} + ]]> + + + + NullPointerException with type inference + 0 + (); // infers ArrayList + var stream = list.stream(); // infers Stream, is never closed + } } ]]> From 25afa04d7671d1d2c748946f621cc308df6fec56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 25 Jan 2023 01:47:02 -0300 Subject: [PATCH 06/28] Fix failing test - Type inference now leads to runtime types being used, even if it's on a MethodCall expression --- .../pmd/lang/java/rule/errorprone/CloseResourceRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java index 2f39b9ccb1..a56e86bb28 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java @@ -216,7 +216,7 @@ public class CloseResourceRule extends AbstractJavaRule { private TypeNode getRuntimeTypeOfVariable(ASTVariableDeclaratorId var) { ASTExpression initExpr = var.getInitializer(); - return isRuntimeType(initExpr) ? initExpr : null; + return var.isTypeInferred() || isRuntimeType(initExpr) ? initExpr : null; } private boolean isRuntimeType(ASTExpression expr) { From 4aceb42e9cfe34fbd15c397fcf06545315b74626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 25 Jan 2023 17:00:37 -0300 Subject: [PATCH 07/28] Fix rule benchmark counting - Recover the old behavior, where the number of rule applications is split from the number of tree transversals. - This means that rules that are applied, but didn't match any node where previously unlisted, but know show they were applied to all files, and evaluated 0 nodes. - We also count towards the rule's benchmark the cost of getting to the nodes it want's to evaluate, so poor xpath selectors actually show for the particular rule. --- .../pmd/lang/rule/internal/RuleApplicator.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java index e867253eb7..fa16d8dbdc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java @@ -56,8 +56,9 @@ public class RuleApplicator { for (Rule rule : rules) { RuleContext ctx = RuleContext.create(listener, rule); rule.start(ctx); - try { + try (TimedOperation rcto = TimeTracker.startOperation(TimedOperationCategory.RULE, rule.getName())) { + int nodeCounter = 0; Iterator targets = rule.getTargetSelector().getVisitedNodes(idx); while (targets.hasNext()) { Node node = targets.next(); @@ -65,9 +66,9 @@ public class RuleApplicator { continue; } - try (TimedOperation rcto = TimeTracker.startOperation(TimedOperationCategory.RULE, rule.getName())) { + try { + nodeCounter++; rule.apply(node, ctx); - rcto.close(1); } catch (RuntimeException e) { reportOrRethrow(listener, rule, node, AssertionUtil.contexted(e), true); } catch (StackOverflowError e) { @@ -76,6 +77,8 @@ public class RuleApplicator { reportOrRethrow(listener, rule, node, AssertionUtil.contexted(e), SystemProps.isErrorRecoveryMode()); } } + + rcto.close(nodeCounter); } finally { rule.end(ctx); } From c5d410367a91b6c628d17aa971b578796637ea9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 25 Jan 2023 17:06:24 -0300 Subject: [PATCH 08/28] Remove numbers from Java LPS names - The numbers relate to how they are executed, but don't necessarilly imply a required order (ie: Comment Assignment could be done at any point) - Since the benchmark report sorts by time spent on each one, the numbered labels are simply confusing --- .../pmd/lang/java/internal/JavaAstProcessor.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaAstProcessor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaAstProcessor.java index 486b4c78a3..17fc0e285e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaAstProcessor.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaAstProcessor.java @@ -165,7 +165,7 @@ public final class JavaAstProcessor { */ public void process(ASTCompilationUnit acu) { - SymbolResolver knownSyms = TimeTracker.bench("1. Symbol resolution", () -> SymbolResolutionPass.traverse(this, acu)); + SymbolResolver knownSyms = TimeTracker.bench("Symbol resolution", () -> SymbolResolutionPass.traverse(this, acu)); // Now symbols are on the relevant nodes this.symResolver = SymbolResolver.layer(knownSyms, this.symResolver); @@ -174,12 +174,12 @@ public final class JavaAstProcessor { // as scopes depend on type resolution in some cases. InternalApiBridge.initTypeResolver(acu, this, typeInferenceLogger); - TimeTracker.bench("2. Symbol table resolution", () -> SymbolTableResolver.traverse(this, acu)); - TimeTracker.bench("3. AST disambiguation", () -> InternalApiBridge.disambigWithCtx(NodeStream.of(acu), ReferenceCtx.root(this, acu))); - TimeTracker.bench("4. Force type resolution", () -> InternalApiBridge.forceTypeResolutionPhase(this, acu)); - TimeTracker.bench("5. Comment assignment", () -> InternalApiBridge.assignComments(acu)); - TimeTracker.bench("6. Usage resolution", () -> InternalApiBridge.usageResolution(this, acu)); - TimeTracker.bench("7. Override resolution", () -> InternalApiBridge.overrideResolution(this, acu)); + TimeTracker.bench("Symbol table resolution", () -> SymbolTableResolver.traverse(this, acu)); + TimeTracker.bench("AST disambiguation", () -> InternalApiBridge.disambigWithCtx(NodeStream.of(acu), ReferenceCtx.root(this, acu))); + TimeTracker.bench("Force type resolution", () -> InternalApiBridge.forceTypeResolutionPhase(this, acu)); + TimeTracker.bench("Comment assignment", () -> InternalApiBridge.assignComments(acu)); + TimeTracker.bench("Usage resolution", () -> InternalApiBridge.usageResolution(this, acu)); + TimeTracker.bench("Override resolution", () -> InternalApiBridge.overrideResolution(this, acu)); } public TypeSystem getTypeSystem() { From 521e0201002a26f372e4965adf4d5cd80c6ccaa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 25 Jan 2023 17:52:53 -0300 Subject: [PATCH 09/28] Prevent double counting time - First off, all LPS are benchmarked in the AstProcessor, having this here was inconsistent - Since these passes can be triggered by the symbol table LPS phase, we ended up double counting total time. - This however puts all disambiguation passes done for symbol table as symbol table cost, which although accurate, may not help to identify speed up opportunities as clearly, but the benchmark is not a profiling tool. --- .../sourceforge/pmd/lang/java/ast/AstDisambiguationPass.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstDisambiguationPass.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstDisambiguationPass.java index 5fabade9f3..5f3f2c009c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstDisambiguationPass.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstDisambiguationPass.java @@ -12,7 +12,6 @@ import java.util.Iterator; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; @@ -56,7 +55,7 @@ final class AstDisambiguationPass { */ public static void disambigWithCtx(NodeStream nodes, ReferenceCtx ctx) { assert ctx != null : "Null context"; - TimeTracker.bench("AST disambiguation", () -> nodes.forEach(it -> it.acceptVisitor(DisambigVisitor.INSTANCE, ctx))); + nodes.forEach(it -> it.acceptVisitor(DisambigVisitor.INSTANCE, ctx)); } From 0d71f605d1f2ce58413f940e93886e01999a0523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 25 Jan 2023 19:45:24 -0300 Subject: [PATCH 10/28] Ensure file processing time doesn't go unaccounted - Unnacounted time was significantly larger than it used to be, and in proportion tok about 10% of total execution time. Properly account attaining ruleset copies, TextDocuments, and overal parser and rule setup as processing time. --- .../java/net/sourceforge/pmd/processor/PmdRunnable.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java b/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java index 3ae36944bd..94e0e49043 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java @@ -64,10 +64,11 @@ abstract class PmdRunnable implements Runnable { public void run() throws FileAnalysisException { TimeTracker.initThread(); - RuleSets ruleSets = getRulesets(); - - try (FileAnalysisListener listener = globalListener.startFileAnalysis(textFile)) { + try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.FILE_PROCESSING); + FileAnalysisListener listener = globalListener.startFileAnalysis(textFile)) { + RuleSets ruleSets = getRulesets(); + // Coarse check to see if any RuleSet applies to file, will need to do a finer RuleSet specific check later if (ruleSets.applies(textFile)) { try (TextDocument textDocument = TextDocument.create(textFile); From 34c00c5b1ad94aa0328704e0a1cfd9a354577203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Thu, 26 Jan 2023 12:43:33 -0300 Subject: [PATCH 11/28] Fix PMD warning --- .../main/java/net/sourceforge/pmd/processor/PmdRunnable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java b/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java index 94e0e49043..f29259a085 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java @@ -64,7 +64,7 @@ abstract class PmdRunnable implements Runnable { public void run() throws FileAnalysisException { TimeTracker.initThread(); - try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.FILE_PROCESSING); + try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.FILE_PROCESSING); FileAnalysisListener listener = globalListener.startFileAnalysis(textFile)) { RuleSets ruleSets = getRulesets(); From ad198cbcf9105cad6fb27907538f5e90249735f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 27 Jan 2023 15:50:45 +0100 Subject: [PATCH 12/28] Dogfood --- .../performance/AvoidInstantiatingObjectsInLoopsRule.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AvoidInstantiatingObjectsInLoopsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AvoidInstantiatingObjectsInLoopsRule.java index 14ae136dc9..b43c5be2f0 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AvoidInstantiatingObjectsInLoopsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/AvoidInstantiatingObjectsInLoopsRule.java @@ -78,10 +78,7 @@ public class AvoidInstantiatingObjectsInLoopsRule extends AbstractJavaRulechainR private boolean notBreakFollowing(JavaNode node) { JavaNode statement = node.ancestors().filter(n -> n.getParent() instanceof ASTBlock).first(); - if (statement != null) { - return !(statement.getNextSibling() instanceof ASTBreakStatement); - } - return true; + return statement == null || !(statement.getNextSibling() instanceof ASTBreakStatement); } /** From 8834c6e981c9b1bcdee2a2cc39714a086181076b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 27 Jan 2023 16:09:46 +0100 Subject: [PATCH 13/28] Improve CommentSize --- .../pmd/lang/java/ast/JavaComment.java | 2 +- .../rule/documentation/CommentSizeRule.java | 46 +++++-------------- .../rule/documentation/xml/CommentSize.xml | 21 +++++++++ 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java index 8fe146edfc..3e19a5923c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java @@ -116,7 +116,7 @@ public class JavaComment implements Reportable { * Trim the start of the provided line to remove a comment * markup opener ({@code //, /*, /**, *}) or closer {@code * /}. */ - private static Chars removeCommentMarkup(Chars line) { + public static Chars removeCommentMarkup(Chars line) { line = line.trim().removeSuffix("*/"); int subseqFrom = 0; if (line.startsWith('/', 0)) { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java index fa23667104..7c999ea643 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java @@ -5,14 +5,8 @@ package net.sourceforge.pmd.lang.java.rule.documentation; import static net.sourceforge.pmd.properties.constraints.NumericConstraints.positive; -import static net.sourceforge.pmd.util.CollectionUtil.setOf; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.apache.commons.lang3.StringUtils; +import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaComment; @@ -37,12 +31,6 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { .desc("Maximum line length") .require(positive()).defaultValue(80).build(); - static final Set IGNORED_LINES = setOf(Chars.wrap("//"), - Chars.wrap("/*"), - Chars.wrap("/**"), - Chars.wrap("*"), - Chars.wrap("*/")); - public CommentSizeRule() { super(ASTCompilationUnit.class); definePropertyDescriptor(MAX_LINES); @@ -59,28 +47,14 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { + ": Too many lines", comment.getBeginLine(), comment.getEndLine()); } - List lineNumbers = overLengthLineIndicesIn(comment); - if (lineNumbers.isEmpty()) { - continue; - } - - int offset = comment.getBeginLine(); - for (int lineNum : lineNumbers) { - int lineNumWithOff = lineNum + offset; - asCtx(data).addViolationWithPosition( - cUnit, - lineNumWithOff, - lineNumWithOff, - this.getMessage() + ": Line too long" - ); - } + reportLinesTooLong(cUnit, asCtx(data), comment); } return null; } private static boolean hasRealText(Chars line) { - return !StringUtils.isBlank(line) && !IGNORED_LINES.contains(line.trim()); + return !JavaComment.removeCommentMarkup(line).isEmpty(); } private boolean hasTooManyLines(JavaComment comment) { @@ -90,8 +64,7 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { int i = 0; int maxLines = getProperty(MAX_LINES); for (Chars line : comment.getText().lines()) { - boolean real = hasRealText(line); - if (real) { + if (hasRealText(line)) { lastLineWithText = i; if (firstLineWithText == -1) { firstLineWithText = i; @@ -105,18 +78,21 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { return false; } - private List overLengthLineIndicesIn(JavaComment comment) { + private void reportLinesTooLong(ASTCompilationUnit acu, RuleContext ctx, JavaComment comment) { int maxLength = getProperty(MAX_LINE_LENGTH); - List indices = new ArrayList<>(); + int offset = comment.getReportLocation().getStartLine(); int i = 0; for (Chars line : comment.getFilteredLines(true)) { if (line.length() > maxLength) { - indices.add(i); + ctx.addViolationWithPosition(acu, + i + offset, + i + offset, + getMessage() + ": Line too long"); } + i++; } - return indices; } } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml index 0469bd08f2..2df48596fd 100755 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml @@ -22,6 +22,27 @@ public class Foo { public Foo() { } + public void doNothing() { + } +} + ]]> + + + Line too long + 5 + 1 + 5 + Date: Fri, 27 Jan 2023 16:12:55 +0100 Subject: [PATCH 14/28] Revert changes to CommentSize --- .../rule/documentation/CommentSizeRule.java | 47 ++++++++++++++----- .../rule/documentation/xml/CommentSize.xml | 21 --------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java index 7c999ea643..6a409f3c76 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java @@ -5,8 +5,14 @@ package net.sourceforge.pmd.lang.java.rule.documentation; import static net.sourceforge.pmd.properties.constraints.NumericConstraints.positive; +import static net.sourceforge.pmd.util.CollectionUtil.setOf; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaComment; @@ -31,6 +37,12 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { .desc("Maximum line length") .require(positive()).defaultValue(80).build(); + static final Set IGNORED_LINES = setOf(Chars.wrap("//"), + Chars.wrap("/*"), + Chars.wrap("/**"), + Chars.wrap("*"), + Chars.wrap("*/")); + public CommentSizeRule() { super(ASTCompilationUnit.class); definePropertyDescriptor(MAX_LINES); @@ -47,14 +59,29 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { + ": Too many lines", comment.getBeginLine(), comment.getEndLine()); } - reportLinesTooLong(cUnit, asCtx(data), comment); + List lineNumbers = overLengthLineIndicesIn(comment); + if (lineNumbers.isEmpty()) { + continue; + } + + int offset = comment.getBeginLine(); + for (int lineNum : lineNumbers) { + int lineNumWithOff = lineNum + offset; + addViolationWithMessage( + data, + cUnit, + this.getMessage() + ": Line too long", + lineNumWithOff, + lineNum + ); + } } return null; } private static boolean hasRealText(Chars line) { - return !JavaComment.removeCommentMarkup(line).isEmpty(); + return !StringUtils.isBlank(line) && !IGNORED_LINES.contains(line.trim()); } private boolean hasTooManyLines(JavaComment comment) { @@ -64,7 +91,8 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { int i = 0; int maxLines = getProperty(MAX_LINES); for (Chars line : comment.getText().lines()) { - if (hasRealText(line)) { + boolean real = hasRealText(line); + if (real) { lastLineWithText = i; if (firstLineWithText == -1) { firstLineWithText = i; @@ -78,21 +106,18 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { return false; } - private void reportLinesTooLong(ASTCompilationUnit acu, RuleContext ctx, JavaComment comment) { + private List overLengthLineIndicesIn(JavaComment comment) { int maxLength = getProperty(MAX_LINE_LENGTH); - int offset = comment.getReportLocation().getStartLine(); + List indices = new ArrayList<>(); int i = 0; for (Chars line : comment.getFilteredLines(true)) { if (line.length() > maxLength) { - ctx.addViolationWithPosition(acu, - i + offset, - i + offset, - getMessage() + ": Line too long"); + indices.add(i); } - i++; } + return indices; } } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml index 2df48596fd..0469bd08f2 100755 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml @@ -22,27 +22,6 @@ public class Foo { public Foo() { } - public void doNothing() { - } -} - ]]> - - - Line too long - 5 - 1 - 5 - Date: Wed, 31 Mar 2021 15:27:28 +0200 Subject: [PATCH 15/28] Move TypeResTest rule out of security.xml Fix #4367 --- .../TypeResTestRule.java | 10 ++++---- .../main/resources/category/java/security.xml | 14 ----------- .../rulesets/java/internal/diagnostics.xml | 24 +++++++++++++++++++ 3 files changed, 28 insertions(+), 20 deletions(-) rename pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/{security => internal}/TypeResTestRule.java (93%) create mode 100644 pmd-java/src/main/resources/rulesets/java/internal/diagnostics.xml diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/security/TypeResTestRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/TypeResTestRule.java similarity index 93% rename from pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/security/TypeResTestRule.java rename to pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/TypeResTestRule.java index a3f2537c81..63ac824684 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/security/TypeResTestRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/TypeResTestRule.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.lang.java.rule.security; +package net.sourceforge.pmd.lang.java.rule.internal; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; @@ -17,11 +17,9 @@ import net.sourceforge.pmd.lang.java.types.TypeSystem; import net.sourceforge.pmd.util.StringUtil; /** - * @deprecated This is just a toy rule that counts the proportion of resolved types in a codebase, - * not meant as a real rule + * This is just a toy rule that counts the proportion of resolved types + * in a codebase, not meant as a real rule. */ -// TODO Move this rule to a (internal) diagnostics category/ruleset -@Deprecated @SuppressWarnings("PMD") public class TypeResTestRule extends AbstractJavaRule { diff --git a/pmd-java/src/main/resources/category/java/security.xml b/pmd-java/src/main/resources/category/java/security.xml index d3a59092bf..e279d7b30f 100644 --- a/pmd-java/src/main/resources/category/java/security.xml +++ b/pmd-java/src/main/resources/category/java/security.xml @@ -63,18 +63,4 @@ public class Foo { ]]> - - - -This is just a toy rule that counts the proportion of resolved types in a codebase, not meant as a real rule. - -It is used to test the capability of PMD's own type resolution. - - 3 - diff --git a/pmd-java/src/main/resources/rulesets/java/internal/diagnostics.xml b/pmd-java/src/main/resources/rulesets/java/internal/diagnostics.xml new file mode 100644 index 0000000000..52a523fe02 --- /dev/null +++ b/pmd-java/src/main/resources/rulesets/java/internal/diagnostics.xml @@ -0,0 +1,24 @@ + + + + Contains rules for internal use. + + + + + This is just a toy rule that counts the proportion of resolved types in a codebase, not meant as a real rule. + + It is used to test the capability of PMD's own type resolution. + + 3 + + + From ba18f3b364b326c42ae2480ae6638ab4c215b59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 27 Jan 2023 16:11:05 +0100 Subject: [PATCH 16/28] Improve CommentSize --- .../pmd/lang/java/ast/JavaComment.java | 2 +- .../rule/documentation/CommentSizeRule.java | 47 +++++-------------- .../rule/documentation/xml/CommentSize.xml | 21 +++++++++ 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java index 8fe146edfc..3e19a5923c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java @@ -116,7 +116,7 @@ public class JavaComment implements Reportable { * Trim the start of the provided line to remove a comment * markup opener ({@code //, /*, /**, *}) or closer {@code * /}. */ - private static Chars removeCommentMarkup(Chars line) { + public static Chars removeCommentMarkup(Chars line) { line = line.trim().removeSuffix("*/"); int subseqFrom = 0; if (line.startsWith('/', 0)) { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java index 6a409f3c76..7c999ea643 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java @@ -5,14 +5,8 @@ package net.sourceforge.pmd.lang.java.rule.documentation; import static net.sourceforge.pmd.properties.constraints.NumericConstraints.positive; -import static net.sourceforge.pmd.util.CollectionUtil.setOf; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.apache.commons.lang3.StringUtils; +import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaComment; @@ -37,12 +31,6 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { .desc("Maximum line length") .require(positive()).defaultValue(80).build(); - static final Set IGNORED_LINES = setOf(Chars.wrap("//"), - Chars.wrap("/*"), - Chars.wrap("/**"), - Chars.wrap("*"), - Chars.wrap("*/")); - public CommentSizeRule() { super(ASTCompilationUnit.class); definePropertyDescriptor(MAX_LINES); @@ -59,29 +47,14 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { + ": Too many lines", comment.getBeginLine(), comment.getEndLine()); } - List lineNumbers = overLengthLineIndicesIn(comment); - if (lineNumbers.isEmpty()) { - continue; - } - - int offset = comment.getBeginLine(); - for (int lineNum : lineNumbers) { - int lineNumWithOff = lineNum + offset; - addViolationWithMessage( - data, - cUnit, - this.getMessage() + ": Line too long", - lineNumWithOff, - lineNum - ); - } + reportLinesTooLong(cUnit, asCtx(data), comment); } return null; } private static boolean hasRealText(Chars line) { - return !StringUtils.isBlank(line) && !IGNORED_LINES.contains(line.trim()); + return !JavaComment.removeCommentMarkup(line).isEmpty(); } private boolean hasTooManyLines(JavaComment comment) { @@ -91,8 +64,7 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { int i = 0; int maxLines = getProperty(MAX_LINES); for (Chars line : comment.getText().lines()) { - boolean real = hasRealText(line); - if (real) { + if (hasRealText(line)) { lastLineWithText = i; if (firstLineWithText == -1) { firstLineWithText = i; @@ -106,18 +78,21 @@ public class CommentSizeRule extends AbstractJavaRulechainRule { return false; } - private List overLengthLineIndicesIn(JavaComment comment) { + private void reportLinesTooLong(ASTCompilationUnit acu, RuleContext ctx, JavaComment comment) { int maxLength = getProperty(MAX_LINE_LENGTH); - List indices = new ArrayList<>(); + int offset = comment.getReportLocation().getStartLine(); int i = 0; for (Chars line : comment.getFilteredLines(true)) { if (line.length() > maxLength) { - indices.add(i); + ctx.addViolationWithPosition(acu, + i + offset, + i + offset, + getMessage() + ": Line too long"); } + i++; } - return indices; } } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml index 0469bd08f2..2df48596fd 100755 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/documentation/xml/CommentSize.xml @@ -22,6 +22,27 @@ public class Foo { public Foo() { } + public void doNothing() { + } +} + ]]> + + + Line too long + 5 + 1 + 5 + Date: Sat, 28 Jan 2023 10:18:27 +0100 Subject: [PATCH 17/28] Prepare pmd release 6.54.0 --- docs/_config.yml | 2 +- docs/pages/next_major_development.md | 47 ++++++++++++++++++++++++++++ docs/pages/release_notes.md | 5 +++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/docs/_config.yml b/docs/_config.yml index c4c18dae74..47f173009f 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,7 +1,7 @@ repository: pmd/pmd pmd: - version: 6.54.0-SNAPSHOT + version: 6.54.0 previous_version: 6.53.0 date: 28-January-2023 release_type: minor diff --git a/docs/pages/next_major_development.md b/docs/pages/next_major_development.md index 335516295b..35a7385fda 100644 --- a/docs/pages/next_major_development.md +++ b/docs/pages/next_major_development.md @@ -125,6 +125,53 @@ the breaking API changes will be performed in 7.0.0. an API is tagged as `@Deprecated` or not in the latest minor release. During the development of 7.0.0, we may decide to remove some APIs that were not tagged as deprecated, though we'll try to avoid it." %} +#### 6.54.0 + +##### PMD CLI + +* PMD now supports a new `--relativize-paths-with` flag (or short `-z`), which replaces `--short-names`. + It serves the same purpose: Shortening the pathnames in the reports. However, with the new flag it's possible + to explicitly define one or more pathnames that should be used as the base when creating relative paths. + The old flag `--short-names` is deprecated. + +##### Deprecated APIs + +###### For removal + +* {% jdoc !!apex::lang.apex.ast.ApexRootNode#getApexVersion() %} has been deprecated for removal. The version returned is + always `Version.CURRENT`, as the apex compiler integration doesn't use additional information which Apex version + actually is used. Therefore, this method can't be used to determine the Apex version of the project + that is being analyzed. +* {% jdoc !!core::cpd.CPDConfiguration#setEncoding(java.lang.String) %} and + {% jdoc !!core::cpd.CPDConfiguration#getEncoding() %}. Use the methods + {% jdoc core::AbstractConfiguration#getSourceEncoding() %} and + {% jdoc core::AbstractConfiguration#setSourceEncoding(java.lang.String) %} instead. Both are available + for `CPDConfiguration` which extends `AbstractConfiguration`. +* {% jdoc test::cli.BaseCLITest %} and {% jdoc test::cli.BaseCPDCLITest %} have been deprecated for removal without + replacement. CLI tests should be done in pmd-core only (and in PMD7 in pmd-cli). Individual language modules + shouldn't need to test the CLI integration logic again. Instead, the individual language modules should test their + functionality as unit tests. +* {% jdoc core::cpd.CPDConfiguration.LanguageConverter %} + +* {% jdoc !!core::lang.document.FileCollector#addZipFile(java.nio.file.Path) %} has been deprecated. It is replaced + by {% jdoc !!core::lang.document.FileCollector#addZipFileWithContent(java.nio.file.Path) %} which directly adds the + content of the zip file for analysis. + +* {% jdoc !!core::PMDConfiguration#setReportShortNames(boolean) %} and + {% jdoc !!core::PMDConfiguration#isReportShortNames() %} have been deprecated for removal. + Use {% jdoc !!core::PMDConfiguration#addRelativizeRoot(java.nio.file.Path) %} instead. + +###### Internal APIs + +* {% jdoc core::renderers.CSVWriter %} +* Some fields in {% jdoc test::ant.AbstractAntTestHelper %} + +###### Experimental APIs + +* CPDReport has a new method which limited mutation of a given report: + * {%jdoc core::cpd.CPDReport#filterMatches(net.sourceforge.pmd.util.Predicate) %} creates a new CPD report + with some matches removed with a given predicate based filter. + #### 6.53.0 ##### Deprecated APIs diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 1ffa61bd6b..a6f8b3555c 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -87,5 +87,10 @@ See [the example report](report-examples/html-report-v2.html). * [#4280](https://github.com/pmd/pmd/pull/4280): \[apex] Deprecate ApexRootNode.getApexVersion - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4285](https://github.com/pmd/pmd/pull/4285): \[java] CommentDefaultAccessModifier - add co.elastic.clients.util.VisibleForTesting as default suppressed annotation - [Matthew Luckam](https://github.com/mluckam) (@mluckam) +### Stats +* 107 commits +* 19 closed tickets & PRs +* Days since last release: 27 + {% endtocmaker %} From de1b12b06026df65d4460139c16e8938359d9be2 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 28 Jan 2023 10:31:46 +0100 Subject: [PATCH 18/28] [maven-release-plugin] prepare release pmd_releases/6.54.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-dart/pom.xml | 2 +- pmd-dist/pom.xml | 2 +- pmd-doc/pom.xml | 2 +- pmd-fortran/pom.xml | 2 +- pmd-gherkin/pom.xml | 2 +- pmd-go/pom.xml | 2 +- pmd-groovy/pom.xml | 2 +- pmd-html/pom.xml | 2 +- pmd-java/pom.xml | 2 +- pmd-java8/pom.xml | 2 +- pmd-javascript/pom.xml | 2 +- pmd-jsp/pom.xml | 2 +- pmd-kotlin/pom.xml | 2 +- pmd-lang-test/pom.xml | 2 +- pmd-lua/pom.xml | 2 +- pmd-matlab/pom.xml | 2 +- pmd-modelica/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-modules/pmd-scala-common/pom.xml | 2 +- pmd-scala-modules/pmd-scala_2.12/pom.xml | 2 +- pmd-scala-modules/pmd-scala_2.13/pom.xml | 2 +- pmd-scala/pom.xml | 2 +- pmd-swift/pom.xml | 2 +- pmd-test-schema/pom.xml | 2 +- pmd-test/pom.xml | 2 +- pmd-visualforce/pom.xml | 2 +- pmd-vm/pom.xml | 2 +- pmd-xml/pom.xml | 2 +- pom.xml | 6 +++--- 39 files changed, 41 insertions(+), 41 deletions(-) diff --git a/pmd-apex-jorje/pom.xml b/pmd-apex-jorje/pom.xml index 0654287dc8..6244914775 100644 --- a/pmd-apex-jorje/pom.xml +++ b/pmd-apex-jorje/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-apex/pom.xml b/pmd-apex/pom.xml index b4198c43de..6933fc7604 100644 --- a/pmd-apex/pom.xml +++ b/pmd-apex/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index 87eeb56382..f850ccc8b7 100644 --- a/pmd-core/pom.xml +++ b/pmd-core/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-cpp/pom.xml b/pmd-cpp/pom.xml index 6c1afc3598..f132d50d44 100644 --- a/pmd-cpp/pom.xml +++ b/pmd-cpp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-cs/pom.xml b/pmd-cs/pom.xml index ed0b08c8a2..9d425c7439 100644 --- a/pmd-cs/pom.xml +++ b/pmd-cs/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-dart/pom.xml b/pmd-dart/pom.xml index a641064570..450ae88cb6 100644 --- a/pmd-dart/pom.xml +++ b/pmd-dart/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-dist/pom.xml b/pmd-dist/pom.xml index 31d205d621..63743a6015 100644 --- a/pmd-dist/pom.xml +++ b/pmd-dist/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-doc/pom.xml b/pmd-doc/pom.xml index cd9448586f..4022007d23 100644 --- a/pmd-doc/pom.xml +++ b/pmd-doc/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-fortran/pom.xml b/pmd-fortran/pom.xml index 3939016bdb..2d36fe8803 100644 --- a/pmd-fortran/pom.xml +++ b/pmd-fortran/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-gherkin/pom.xml b/pmd-gherkin/pom.xml index 28401eb2f8..0f2aee3a51 100644 --- a/pmd-gherkin/pom.xml +++ b/pmd-gherkin/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-go/pom.xml b/pmd-go/pom.xml index 9280e5b98a..0db393d4c4 100644 --- a/pmd-go/pom.xml +++ b/pmd-go/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-groovy/pom.xml b/pmd-groovy/pom.xml index 76e95aaa07..c5896b0231 100644 --- a/pmd-groovy/pom.xml +++ b/pmd-groovy/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-html/pom.xml b/pmd-html/pom.xml index d0a06c1448..fd0a2ab5ce 100644 --- a/pmd-html/pom.xml +++ b/pmd-html/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index 986b04f583..7a088d855e 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-java8/pom.xml b/pmd-java8/pom.xml index a6fa49cf5e..81eb8961f3 100644 --- a/pmd-java8/pom.xml +++ b/pmd-java8/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-javascript/pom.xml b/pmd-javascript/pom.xml index 0afc0b2071..dd9df3182e 100644 --- a/pmd-javascript/pom.xml +++ b/pmd-javascript/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-jsp/pom.xml b/pmd-jsp/pom.xml index e8af172953..ee6c472f1a 100644 --- a/pmd-jsp/pom.xml +++ b/pmd-jsp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-kotlin/pom.xml b/pmd-kotlin/pom.xml index 7bd1af3de1..96053b3301 100644 --- a/pmd-kotlin/pom.xml +++ b/pmd-kotlin/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-lang-test/pom.xml b/pmd-lang-test/pom.xml index 0e01a8bf7a..e4ffcbe29b 100644 --- a/pmd-lang-test/pom.xml +++ b/pmd-lang-test/pom.xml @@ -12,7 +12,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-lua/pom.xml b/pmd-lua/pom.xml index 0ce33c4086..80d88e1713 100644 --- a/pmd-lua/pom.xml +++ b/pmd-lua/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-matlab/pom.xml b/pmd-matlab/pom.xml index bb3f871216..99859dd630 100644 --- a/pmd-matlab/pom.xml +++ b/pmd-matlab/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-modelica/pom.xml b/pmd-modelica/pom.xml index 771db5a6e3..43f20822fd 100644 --- a/pmd-modelica/pom.xml +++ b/pmd-modelica/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-objectivec/pom.xml b/pmd-objectivec/pom.xml index 4ea684ec5b..c5d12cf226 100644 --- a/pmd-objectivec/pom.xml +++ b/pmd-objectivec/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-perl/pom.xml b/pmd-perl/pom.xml index 252267fb0f..befec20a4a 100644 --- a/pmd-perl/pom.xml +++ b/pmd-perl/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-php/pom.xml b/pmd-php/pom.xml index 3de37211c9..52a07e14ea 100644 --- a/pmd-php/pom.xml +++ b/pmd-php/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-plsql/pom.xml b/pmd-plsql/pom.xml index 75812ca1af..ed8bc66d8a 100644 --- a/pmd-plsql/pom.xml +++ b/pmd-plsql/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-python/pom.xml b/pmd-python/pom.xml index b53670897b..704bf8402d 100644 --- a/pmd-python/pom.xml +++ b/pmd-python/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-ruby/pom.xml b/pmd-ruby/pom.xml index ef7af6efe5..b4843a27c8 100644 --- a/pmd-ruby/pom.xml +++ b/pmd-ruby/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-scala-modules/pmd-scala-common/pom.xml b/pmd-scala-modules/pmd-scala-common/pom.xml index 56801dfc25..a32c6c912b 100644 --- a/pmd-scala-modules/pmd-scala-common/pom.xml +++ b/pmd-scala-modules/pmd-scala-common/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../../pom.xml diff --git a/pmd-scala-modules/pmd-scala_2.12/pom.xml b/pmd-scala-modules/pmd-scala_2.12/pom.xml index b8cc9a7840..382beeda1e 100644 --- a/pmd-scala-modules/pmd-scala_2.12/pom.xml +++ b/pmd-scala-modules/pmd-scala_2.12/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd-scala-common - 6.54.0-SNAPSHOT + 6.54.0 ../pmd-scala-common/pom.xml diff --git a/pmd-scala-modules/pmd-scala_2.13/pom.xml b/pmd-scala-modules/pmd-scala_2.13/pom.xml index 7bf9a750c6..a8e2f5d1b5 100644 --- a/pmd-scala-modules/pmd-scala_2.13/pom.xml +++ b/pmd-scala-modules/pmd-scala_2.13/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd-scala-common - 6.54.0-SNAPSHOT + 6.54.0 ../pmd-scala-common/pom.xml diff --git a/pmd-scala/pom.xml b/pmd-scala/pom.xml index 6b60904692..29d7d6f1e9 100644 --- a/pmd-scala/pom.xml +++ b/pmd-scala/pom.xml @@ -9,7 +9,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-swift/pom.xml b/pmd-swift/pom.xml index 11b83f4f83..5efd449317 100644 --- a/pmd-swift/pom.xml +++ b/pmd-swift/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-test-schema/pom.xml b/pmd-test-schema/pom.xml index 8eac17a2eb..c0cc5bee84 100644 --- a/pmd-test-schema/pom.xml +++ b/pmd-test-schema/pom.xml @@ -11,7 +11,7 @@ pmd net.sourceforge.pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-test/pom.xml b/pmd-test/pom.xml index 4cdcedeb2e..f7fea595b4 100644 --- a/pmd-test/pom.xml +++ b/pmd-test/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-visualforce/pom.xml b/pmd-visualforce/pom.xml index 6c0495a877..b1972c9a4c 100644 --- a/pmd-visualforce/pom.xml +++ b/pmd-visualforce/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-vm/pom.xml b/pmd-vm/pom.xml index 34f47a0933..3232c8c94e 100644 --- a/pmd-vm/pom.xml +++ b/pmd-vm/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pmd-xml/pom.xml b/pmd-xml/pom.xml index 48702f5049..4cd155829e 100644 --- a/pmd-xml/pom.xml +++ b/pmd-xml/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 ../pom.xml diff --git a/pom.xml b/pom.xml index 09b203bbd0..59b209cebf 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.sourceforge.pmd pmd - 6.54.0-SNAPSHOT + 6.54.0 pom PMD @@ -55,7 +55,7 @@ scm:git:git://github.com/pmd/pmd.git scm:git:ssh://git@github.com/pmd/pmd.git https://github.com/pmd/pmd - HEAD + pmd_releases/6.54.0 @@ -76,7 +76,7 @@ - 2022-12-31T17:22:09Z + 2023-01-28T09:18:59Z 7 From 5772440a794022c79841c59512061c498771fdee Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 28 Jan 2023 10:31:53 +0100 Subject: [PATCH 19/28] [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-dart/pom.xml | 2 +- pmd-dist/pom.xml | 2 +- pmd-doc/pom.xml | 2 +- pmd-fortran/pom.xml | 2 +- pmd-gherkin/pom.xml | 2 +- pmd-go/pom.xml | 2 +- pmd-groovy/pom.xml | 2 +- pmd-html/pom.xml | 2 +- pmd-java/pom.xml | 2 +- pmd-java8/pom.xml | 2 +- pmd-javascript/pom.xml | 2 +- pmd-jsp/pom.xml | 2 +- pmd-kotlin/pom.xml | 2 +- pmd-lang-test/pom.xml | 2 +- pmd-lua/pom.xml | 2 +- pmd-matlab/pom.xml | 2 +- pmd-modelica/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-modules/pmd-scala-common/pom.xml | 2 +- pmd-scala-modules/pmd-scala_2.12/pom.xml | 2 +- pmd-scala-modules/pmd-scala_2.13/pom.xml | 2 +- pmd-scala/pom.xml | 2 +- pmd-swift/pom.xml | 2 +- pmd-test-schema/pom.xml | 2 +- pmd-test/pom.xml | 2 +- pmd-visualforce/pom.xml | 2 +- pmd-vm/pom.xml | 2 +- pmd-xml/pom.xml | 2 +- pom.xml | 6 +++--- 39 files changed, 41 insertions(+), 41 deletions(-) diff --git a/pmd-apex-jorje/pom.xml b/pmd-apex-jorje/pom.xml index 6244914775..61c2f3a3a9 100644 --- a/pmd-apex-jorje/pom.xml +++ b/pmd-apex-jorje/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-apex/pom.xml b/pmd-apex/pom.xml index 6933fc7604..fa4a3c7e43 100644 --- a/pmd-apex/pom.xml +++ b/pmd-apex/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index f850ccc8b7..97b052393e 100644 --- a/pmd-core/pom.xml +++ b/pmd-core/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-cpp/pom.xml b/pmd-cpp/pom.xml index f132d50d44..9aba2af8c3 100644 --- a/pmd-cpp/pom.xml +++ b/pmd-cpp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-cs/pom.xml b/pmd-cs/pom.xml index 9d425c7439..5eb8c400e4 100644 --- a/pmd-cs/pom.xml +++ b/pmd-cs/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-dart/pom.xml b/pmd-dart/pom.xml index 450ae88cb6..76636bd9b6 100644 --- a/pmd-dart/pom.xml +++ b/pmd-dart/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-dist/pom.xml b/pmd-dist/pom.xml index 63743a6015..b73688e0c7 100644 --- a/pmd-dist/pom.xml +++ b/pmd-dist/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-doc/pom.xml b/pmd-doc/pom.xml index 4022007d23..10dd4cca36 100644 --- a/pmd-doc/pom.xml +++ b/pmd-doc/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-fortran/pom.xml b/pmd-fortran/pom.xml index 2d36fe8803..88ab37a18e 100644 --- a/pmd-fortran/pom.xml +++ b/pmd-fortran/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-gherkin/pom.xml b/pmd-gherkin/pom.xml index 0f2aee3a51..40ccafd326 100644 --- a/pmd-gherkin/pom.xml +++ b/pmd-gherkin/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-go/pom.xml b/pmd-go/pom.xml index 0db393d4c4..4d7fc9763e 100644 --- a/pmd-go/pom.xml +++ b/pmd-go/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-groovy/pom.xml b/pmd-groovy/pom.xml index c5896b0231..2c9ec3bdf4 100644 --- a/pmd-groovy/pom.xml +++ b/pmd-groovy/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-html/pom.xml b/pmd-html/pom.xml index fd0a2ab5ce..d21c126714 100644 --- a/pmd-html/pom.xml +++ b/pmd-html/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index 7a088d855e..17a1bec21d 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-java8/pom.xml b/pmd-java8/pom.xml index 81eb8961f3..2058844748 100644 --- a/pmd-java8/pom.xml +++ b/pmd-java8/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-javascript/pom.xml b/pmd-javascript/pom.xml index dd9df3182e..a19ac4e058 100644 --- a/pmd-javascript/pom.xml +++ b/pmd-javascript/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-jsp/pom.xml b/pmd-jsp/pom.xml index ee6c472f1a..0b022ed4bc 100644 --- a/pmd-jsp/pom.xml +++ b/pmd-jsp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-kotlin/pom.xml b/pmd-kotlin/pom.xml index 96053b3301..39f9e0ab01 100644 --- a/pmd-kotlin/pom.xml +++ b/pmd-kotlin/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-lang-test/pom.xml b/pmd-lang-test/pom.xml index e4ffcbe29b..3cc84fd5a4 100644 --- a/pmd-lang-test/pom.xml +++ b/pmd-lang-test/pom.xml @@ -12,7 +12,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-lua/pom.xml b/pmd-lua/pom.xml index 80d88e1713..f0f410e8bb 100644 --- a/pmd-lua/pom.xml +++ b/pmd-lua/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-matlab/pom.xml b/pmd-matlab/pom.xml index 99859dd630..c328c0ceb2 100644 --- a/pmd-matlab/pom.xml +++ b/pmd-matlab/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-modelica/pom.xml b/pmd-modelica/pom.xml index 43f20822fd..249911156d 100644 --- a/pmd-modelica/pom.xml +++ b/pmd-modelica/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-objectivec/pom.xml b/pmd-objectivec/pom.xml index c5d12cf226..a9bd1f1451 100644 --- a/pmd-objectivec/pom.xml +++ b/pmd-objectivec/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-perl/pom.xml b/pmd-perl/pom.xml index befec20a4a..466a465ba2 100644 --- a/pmd-perl/pom.xml +++ b/pmd-perl/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-php/pom.xml b/pmd-php/pom.xml index 52a07e14ea..2329a8d0f4 100644 --- a/pmd-php/pom.xml +++ b/pmd-php/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-plsql/pom.xml b/pmd-plsql/pom.xml index ed8bc66d8a..66a4693dca 100644 --- a/pmd-plsql/pom.xml +++ b/pmd-plsql/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-python/pom.xml b/pmd-python/pom.xml index 704bf8402d..18d1062e76 100644 --- a/pmd-python/pom.xml +++ b/pmd-python/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-ruby/pom.xml b/pmd-ruby/pom.xml index b4843a27c8..af896d7af7 100644 --- a/pmd-ruby/pom.xml +++ b/pmd-ruby/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-scala-modules/pmd-scala-common/pom.xml b/pmd-scala-modules/pmd-scala-common/pom.xml index a32c6c912b..b456383e83 100644 --- a/pmd-scala-modules/pmd-scala-common/pom.xml +++ b/pmd-scala-modules/pmd-scala-common/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../../pom.xml diff --git a/pmd-scala-modules/pmd-scala_2.12/pom.xml b/pmd-scala-modules/pmd-scala_2.12/pom.xml index 382beeda1e..f693007074 100644 --- a/pmd-scala-modules/pmd-scala_2.12/pom.xml +++ b/pmd-scala-modules/pmd-scala_2.12/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd-scala-common - 6.54.0 + 6.55.0-SNAPSHOT ../pmd-scala-common/pom.xml diff --git a/pmd-scala-modules/pmd-scala_2.13/pom.xml b/pmd-scala-modules/pmd-scala_2.13/pom.xml index a8e2f5d1b5..2794f13d81 100644 --- a/pmd-scala-modules/pmd-scala_2.13/pom.xml +++ b/pmd-scala-modules/pmd-scala_2.13/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd-scala-common - 6.54.0 + 6.55.0-SNAPSHOT ../pmd-scala-common/pom.xml diff --git a/pmd-scala/pom.xml b/pmd-scala/pom.xml index 29d7d6f1e9..25f52ba1a9 100644 --- a/pmd-scala/pom.xml +++ b/pmd-scala/pom.xml @@ -9,7 +9,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-swift/pom.xml b/pmd-swift/pom.xml index 5efd449317..d5c7bb0c26 100644 --- a/pmd-swift/pom.xml +++ b/pmd-swift/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-test-schema/pom.xml b/pmd-test-schema/pom.xml index c0cc5bee84..e665f2f3a2 100644 --- a/pmd-test-schema/pom.xml +++ b/pmd-test-schema/pom.xml @@ -11,7 +11,7 @@ pmd net.sourceforge.pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-test/pom.xml b/pmd-test/pom.xml index f7fea595b4..774a0d866e 100644 --- a/pmd-test/pom.xml +++ b/pmd-test/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-visualforce/pom.xml b/pmd-visualforce/pom.xml index b1972c9a4c..6bf536c8ee 100644 --- a/pmd-visualforce/pom.xml +++ b/pmd-visualforce/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-vm/pom.xml b/pmd-vm/pom.xml index 3232c8c94e..b424b224d4 100644 --- a/pmd-vm/pom.xml +++ b/pmd-vm/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pmd-xml/pom.xml b/pmd-xml/pom.xml index 4cd155829e..eebf49c330 100644 --- a/pmd-xml/pom.xml +++ b/pmd-xml/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 59b209cebf..d541e5033b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.sourceforge.pmd pmd - 6.54.0 + 6.55.0-SNAPSHOT pom PMD @@ -55,7 +55,7 @@ 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.54.0 + HEAD @@ -76,7 +76,7 @@ - 2023-01-28T09:18:59Z + 2023-01-28T09:31:52Z 7 From 625a1cc7f0d0d9c75785cd356995134b73d38c24 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 28 Jan 2023 10:51:02 +0100 Subject: [PATCH 20/28] Prepare next development version [skip ci] --- docs/_config.yml | 6 +- docs/pages/release_notes.md | 72 ----------------------- docs/pages/release_notes_old.md | 100 ++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 75 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index 47f173009f..eeef2bc8d6 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,9 +1,9 @@ repository: pmd/pmd pmd: - version: 6.54.0 - previous_version: 6.53.0 - date: 28-January-2023 + version: 6.55.0-SNAPSHOT + previous_version: 6.54.0 + date: 25-February-2023 release_type: minor # release types: major, minor, bugfix diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a6f8b3555c..b8f8783555 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -14,83 +14,11 @@ This is a {{ site.pmd.release_type }} release. ### New and noteworthy -#### New report format html-report-v2.xslt - -Thanks to @mohan-chinnappan-n a new PMD report format has been added which features a data table -with charting functions. It uses an XSLT stylesheet to convert PMD's XML format into HTML. - -See [the example report](report-examples/html-report-v2.html). - ### Fixed Issues -* apex-bestpractices - * [#2669](https://github.com/pmd/pmd/issues/2669): \[apex] UnusedLocalVariable false positive in dynamic SOQL -* core - * [#4026](https://github.com/pmd/pmd/issues/4026): \[cli] Filenames printed as absolute paths in the report despite parameter `--short-names` - * [#4279](https://github.com/pmd/pmd/issues/4279): \[core] Can not set ruleset property value to empty - * [#4329](https://github.com/pmd/pmd/pull/4329): \[core] Refactor usage of snakeyaml - * [#4340](https://github.com/pmd/pmd/issues/4340): \[core] Allow to filter found matches in CPDReport -* java - * [#4364](https://github.com/pmd/pmd/issues/4364): \[java] Parsing error with textblock containing quote followed by two backslashes -* testing - * [#4236](https://github.com/pmd/pmd/issues/4236): \[test] kotest logs look broken ### API Changes -#### PMD CLI - -* PMD now supports a new `--relativize-paths-with` flag (or short `-z`), which replaces `--short-names`. - It serves the same purpose: Shortening the pathnames in the reports. However, with the new flag it's possible - to explicitly define one or more pathnames that should be used as the base when creating relative paths. - The old flag `--short-names` is deprecated. - -#### Deprecated APIs - -##### For removal - -* {% jdoc !!apex::lang.apex.ast.ApexRootNode#getApexVersion() %} has been deprecated for removal. The version returned is - always `Version.CURRENT`, as the apex compiler integration doesn't use additional information which Apex version - actually is used. Therefore, this method can't be used to determine the Apex version of the project - that is being analyzed. -* {% jdoc !!core::cpd.CPDConfiguration#setEncoding(java.lang.String) %} and - {% jdoc !!core::cpd.CPDConfiguration#getEncoding() %}. Use the methods - {% jdoc core::AbstractConfiguration#getSourceEncoding() %} and - {% jdoc core::AbstractConfiguration#setSourceEncoding(java.lang.String) %} instead. Both are available - for `CPDConfiguration` which extends `AbstractConfiguration`. -* {% jdoc test::cli.BaseCLITest %} and {% jdoc test::cli.BaseCPDCLITest %} have been deprecated for removal without - replacement. CLI tests should be done in pmd-core only (and in PMD7 in pmd-cli). Individual language modules - shouldn't need to test the CLI integration logic again. Instead, the individual language modules should test their - functionality as unit tests. -* {% jdoc core::cpd.CPDConfiguration.LanguageConverter %} - -* {% jdoc !!core::lang.document.FileCollector#addZipFile(java.nio.file.Path) %} has been deprecated. It is replaced - by {% jdoc !!core::lang.document.FileCollector#addZipFileWithContent(java.nio.file.Path) %} which directly adds the - content of the zip file for analysis. - -* {% jdoc !!core::PMDConfiguration#setReportShortNames(boolean) %} and - {% jdoc !!core::PMDConfiguration#isReportShortNames() %} have been deprecated for removal. - Use {% jdoc !!core::PMDConfiguration#addRelativizeRoot(java.nio.file.Path) %} instead. - -##### Internal APIs - -* {% jdoc core::renderers.CSVWriter %} -* Some fields in {% jdoc test::ant.AbstractAntTestHelper %} - -##### Experimental APIs - -* CPDReport has a new method which limited mutation of a given report: - * {%jdoc core::cpd.CPDReport#filterMatches(net.sourceforge.pmd.util.Predicate) %} creates a new CPD report - with some matches removed with a given predicate based filter. - ### External Contributions -* [#4110](https://github.com/pmd/pmd/pull/4110): \[apex] Feature/unused variable bind false positive with dynamic SOQL - [Thomas Prouvot](https://github.com/tprouvot) (@tprouvot) -* [#4125](https://github.com/pmd/pmd/pull/4125): \[core] New report format html-report-v2.xslt to provide html with datatable and chart features - [Mohan Chinnappan](https://github.com/mohan-chinnappan-n) - (@mohan-chinnappan-n) -* [#4280](https://github.com/pmd/pmd/pull/4280): \[apex] Deprecate ApexRootNode.getApexVersion - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) -* [#4285](https://github.com/pmd/pmd/pull/4285): \[java] CommentDefaultAccessModifier - add co.elastic.clients.util.VisibleForTesting as default suppressed annotation - [Matthew Luckam](https://github.com/mluckam) (@mluckam) - -### Stats -* 107 commits -* 19 closed tickets & PRs -* Days since last release: 27 {% endtocmaker %} diff --git a/docs/pages/release_notes_old.md b/docs/pages/release_notes_old.md index 4c1007043c..833117888e 100644 --- a/docs/pages/release_notes_old.md +++ b/docs/pages/release_notes_old.md @@ -5,6 +5,106 @@ permalink: pmd_release_notes_old.html Previous versions of PMD can be downloaded here: https://github.com/pmd/pmd/releases +## 28-January-2023 - 6.54.0 + +The PMD team is pleased to announce PMD 6.54.0. + +This is a minor release. + +### Table Of Contents + +* [New and noteworthy](#new-and-noteworthy) + * [New report format html-report-v2.xslt](#new-report-format-html-report-v2.xslt) +* [Fixed Issues](#fixed-issues) +* [API Changes](#api-changes) + * [PMD CLI](#pmd-cli) + * [Deprecated APIs](#deprecated-apis) + * [For removal](#for-removal) + * [Internal APIs](#internal-apis) + * [Experimental APIs](#experimental-apis) +* [External Contributions](#external-contributions) +* [Stats](#stats) + +### New and noteworthy + +#### New report format html-report-v2.xslt + +Thanks to @mohan-chinnappan-n a new PMD report format has been added which features a data table +with charting functions. It uses an XSLT stylesheet to convert PMD's XML format into HTML. + +See [the example report](report-examples/html-report-v2.html). + +### Fixed Issues +* apex-bestpractices + * [#2669](https://github.com/pmd/pmd/issues/2669): \[apex] UnusedLocalVariable false positive in dynamic SOQL +* core + * [#4026](https://github.com/pmd/pmd/issues/4026): \[cli] Filenames printed as absolute paths in the report despite parameter `--short-names` + * [#4279](https://github.com/pmd/pmd/issues/4279): \[core] Can not set ruleset property value to empty + * [#4329](https://github.com/pmd/pmd/pull/4329): \[core] Refactor usage of snakeyaml + * [#4340](https://github.com/pmd/pmd/issues/4340): \[core] Allow to filter found matches in CPDReport +* java + * [#4364](https://github.com/pmd/pmd/issues/4364): \[java] Parsing error with textblock containing quote followed by two backslashes +* testing + * [#4236](https://github.com/pmd/pmd/issues/4236): \[test] kotest logs look broken + +### API Changes + +#### PMD CLI + +* PMD now supports a new `--relativize-paths-with` flag (or short `-z`), which replaces `--short-names`. + It serves the same purpose: Shortening the pathnames in the reports. However, with the new flag it's possible + to explicitly define one or more pathnames that should be used as the base when creating relative paths. + The old flag `--short-names` is deprecated. + +#### Deprecated APIs + +##### For removal + +* ApexRootNode#getApexVersion has been deprecated for removal. The version returned is + always `Version.CURRENT`, as the apex compiler integration doesn't use additional information which Apex version + actually is used. Therefore, this method can't be used to determine the Apex version of the project + that is being analyzed. +* CPDConfiguration#setEncoding and + CPDConfiguration#getEncoding. Use the methods + getSourceEncoding and + setSourceEncoding instead. Both are available + for `CPDConfiguration` which extends `AbstractConfiguration`. +* BaseCLITest and BaseCPDCLITest have been deprecated for removal without + replacement. CLI tests should be done in pmd-core only (and in PMD7 in pmd-cli). Individual language modules + shouldn't need to test the CLI integration logic again. Instead, the individual language modules should test their + functionality as unit tests. +* CPDConfiguration.LanguageConverter + +* FileCollector#addZipFile has been deprecated. It is replaced + by FileCollector#addZipFileWithContent which directly adds the + content of the zip file for analysis. + +* PMDConfiguration#setReportShortNames and + PMDConfiguration#isReportShortNames have been deprecated for removal. + Use PMDConfiguration#addRelativizeRoot instead. + +##### Internal APIs + +* CSVWriter +* Some fields in AbstractAntTestHelper + +##### Experimental APIs + +* CPDReport has a new method which limited mutation of a given report: + * filterMatches creates a new CPD report + with some matches removed with a given predicate based filter. + +### External Contributions +* [#4110](https://github.com/pmd/pmd/pull/4110): \[apex] Feature/unused variable bind false positive with dynamic SOQL - [Thomas Prouvot](https://github.com/tprouvot) (@tprouvot) +* [#4125](https://github.com/pmd/pmd/pull/4125): \[core] New report format html-report-v2.xslt to provide html with datatable and chart features - [Mohan Chinnappan](https://github.com/mohan-chinnappan-n) - (@mohan-chinnappan-n) +* [#4280](https://github.com/pmd/pmd/pull/4280): \[apex] Deprecate ApexRootNode.getApexVersion - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) +* [#4285](https://github.com/pmd/pmd/pull/4285): \[java] CommentDefaultAccessModifier - add co.elastic.clients.util.VisibleForTesting as default suppressed annotation - [Matthew Luckam](https://github.com/mluckam) (@mluckam) + +### Stats +* 107 commits +* 19 closed tickets & PRs +* Days since last release: 27 + ## 31-December-2022 - 6.53.0 The PMD team is pleased to announce PMD 6.53.0. From 49d35d0973d91dcd6526f67433ce701f2e291644 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 28 Jan 2023 10:55:19 +0100 Subject: [PATCH 21/28] Bump pmd from 6.53.0 to 6.54.0 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index d541e5033b..eab11df3e3 100644 --- a/pom.xml +++ b/pom.xml @@ -427,22 +427,22 @@ net.sourceforge.pmd pmd-core - 6.53.0 + 6.54.0 net.sourceforge.pmd pmd-java - 6.53.0 + 6.54.0 net.sourceforge.pmd pmd-jsp - 6.53.0 + 6.54.0 net.sourceforge.pmd pmd-javascript - 6.53.0 + 6.54.0 From bfba2202197595c829fb06704424d87a9cfe46dc Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 30 Jan 2023 09:40:32 +0100 Subject: [PATCH 22/28] Fix unit test --- .../pmd/lang/java/types/IteratorUtilCopy.txt | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.txt index 27b5408843..1059bd7a39 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.txt @@ -23,19 +23,19 @@ +- FieldDeclaration[] | +- ModifierList[] | +- PrimitiveType[@TypeMirror = "int"] - | +- VariableDeclarator[@TypeMirror = "void"] + | +- VariableDeclarator[] | +- VariableDeclaratorId[@Name = "MATCH_ANY", @TypeMirror = "int"] | +- NumericLiteral[@TypeMirror = "int"] +- FieldDeclaration[] | +- ModifierList[] | +- PrimitiveType[@TypeMirror = "int"] - | +- VariableDeclarator[@TypeMirror = "void"] + | +- VariableDeclarator[] | +- VariableDeclaratorId[@Name = "MATCH_ALL", @TypeMirror = "int"] | +- NumericLiteral[@TypeMirror = "int"] +- FieldDeclaration[] | +- ModifierList[] | +- PrimitiveType[@TypeMirror = "int"] - | +- VariableDeclarator[@TypeMirror = "void"] + | +- VariableDeclarator[] | +- VariableDeclaratorId[@Name = "MATCH_NONE", @TypeMirror = "int"] | +- NumericLiteral[@TypeMirror = "int"] +- ConstructorDeclaration[] @@ -93,7 +93,7 @@ | +- LocalVariableDeclaration[] | | +- ModifierList[] | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "T"] | | +- MethodCall[@Failed = false, @Function = "java.util.Iterator.next() -> T", @MethodName = "next", @TypeMirror = "T", @Unchecked = false, @VarargsCall = false] | | +- VariableAccess[@Name = "iter", @TypeMirror = "java.util.Iterator"] @@ -132,7 +132,7 @@ | | +- ClassOrInterfaceType[@TypeMirror = "java.util.List"] | | | +- TypeArguments[] | | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "tmp", @TypeMirror = "java.util.List"] | | +- MethodCall[@Failed = false, @Function = "IteratorUtilCopy. toList(java.util.Iterator) -> java.util.List", @MethodName = "toList", @TypeMirror = "java.util.List", @Unchecked = false, @VarargsCall = false] | | +- ArgumentList[] @@ -193,7 +193,7 @@ | | | +- TypeArguments[] | | | +- WildcardType[@TypeMirror = "? extends R"] | | | +- ClassOrInterfaceType[@TypeMirror = "R"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "current", @TypeMirror = "java.util.Iterator"] | | +- NullLiteral[@TypeMirror = "null"] | +- MethodDeclaration[@Name = "computeNext"] @@ -230,7 +230,7 @@ | | | | +- TypeArguments[] | | | | +- WildcardType[@TypeMirror = "? extends R"] | | | | +- ClassOrInterfaceType[@TypeMirror = "R"] - | | | +- VariableDeclarator[@TypeMirror = "void"] + | | | +- VariableDeclarator[] | | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "java.util.Iterator"] | | | +- MethodCall[@Failed = false, @Function = "java.util.function.Function>.apply(capture#... of ? super T) -> capture#... of ? extends @Nullable java.util.Iterator", @MethodName = "apply", @TypeMirror = "capture#... of ? extends @Nullable java.util.Iterator", @Unchecked = false, @VarargsCall = false] | | | +- VariableAccess[@Name = "f", @TypeMirror = "java.util.function.Function>"] @@ -304,7 +304,7 @@ | | | +- TypeArguments[] | | | +- WildcardType[@TypeMirror = "? extends R"] | | | +- ClassOrInterfaceType[@TypeMirror = "R"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "current", @TypeMirror = "java.util.Iterator"] | | +- NullLiteral[@TypeMirror = "null"] | +- MethodDeclaration[@Name = "computeNext"] @@ -342,7 +342,7 @@ | | +- LocalVariableDeclaration[] | | | +- ModifierList[] | | | +- ClassOrInterfaceType[@TypeMirror = "R"] - | | | +- VariableDeclarator[@TypeMirror = "void"] + | | | +- VariableDeclarator[] | | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "R"] | | | +- MethodCall[@Failed = false, @Function = "java.util.Iterator.next() -> capture#... of ? extends R", @MethodName = "next", @TypeMirror = "capture#... of ? extends R", @Unchecked = false, @VarargsCall = false] | | | +- VariableAccess[@Name = "iter", @TypeMirror = "java.util.Iterator"] @@ -435,7 +435,7 @@ | | +- LocalVariableDeclaration[] | | | +- ModifierList[] | | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | | +- VariableDeclarator[@TypeMirror = "void"] + | | | +- VariableDeclarator[] | | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "T"] | | | +- MethodCall[@Failed = false, @Function = "java.util.Iterator.next() -> capture#... of ? extends T", @MethodName = "next", @TypeMirror = "capture#... of ? extends T", @Unchecked = false, @VarargsCall = false] | | | +- VariableAccess[@Name = "it", @TypeMirror = "java.util.Iterator"] @@ -448,7 +448,7 @@ | | +- LocalVariableDeclaration[] | | | +- ModifierList[] | | | +- ClassOrInterfaceType[@TypeMirror = "R"] - | | | +- VariableDeclarator[@TypeMirror = "void"] + | | | +- VariableDeclarator[] | | | +- VariableDeclaratorId[@Name = "map", @TypeMirror = "R"] | | | +- MethodCall[@Failed = false, @Function = "java.util.function.Function.apply(capture#... of ? super T) -> capture#... of ? extends R", @MethodName = "apply", @TypeMirror = "capture#... of ? extends R", @Unchecked = false, @VarargsCall = false] | | | +- VariableAccess[@Name = "mapper", @TypeMirror = "java.util.function.Function"] @@ -514,7 +514,7 @@ | | +- LocalVariableDeclaration[] | | | +- ModifierList[] | | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | | +- VariableDeclarator[@TypeMirror = "void"] + | | | +- VariableDeclarator[] | | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "T"] | | | +- MethodCall[@Failed = false, @Function = "java.util.Iterator.next() -> capture#... of ? extends T", @MethodName = "next", @TypeMirror = "capture#... of ? extends T", @Unchecked = false, @VarargsCall = false] | | | +- VariableAccess[@Name = "it", @TypeMirror = "java.util.Iterator"] @@ -809,7 +809,7 @@ | | +- ClassOrInterfaceType[@TypeMirror = "java.util.Set"] | | | +- TypeArguments[] | | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "seen", @TypeMirror = "java.util.Set"] | | +- ConstructorCall[@Failed = false, @Function = "java.util.HashSet.new() -> java.util.HashSet", @MethodName = "new", @TypeMirror = "java.util.HashSet", @Unchecked = false, @VarargsCall = false] | | +- ClassOrInterfaceType[@TypeMirror = "java.util.HashSet"] @@ -842,7 +842,7 @@ | | +- ClassOrInterfaceType[@TypeMirror = "java.util.List"] | | | +- TypeArguments[] | | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "list", @TypeMirror = "java.util.List"] | | +- ConstructorCall[@Failed = false, @Function = "java.util.ArrayList.new() -> java.util.ArrayList", @MethodName = "new", @TypeMirror = "java.util.ArrayList", @Unchecked = false, @VarargsCall = false] | | +- ClassOrInterfaceType[@TypeMirror = "java.util.ArrayList"] @@ -883,7 +883,7 @@ | | +- ClassOrInterfaceType[@TypeMirror = "java.util.List"] | | | +- TypeArguments[] | | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "list", @TypeMirror = "java.util.List"] | | +- ConstructorCall[@Failed = false, @Function = "java.util.ArrayList.new() -> java.util.ArrayList", @MethodName = "new", @TypeMirror = "java.util.ArrayList", @Unchecked = false, @VarargsCall = false] | | +- ClassOrInterfaceType[@TypeMirror = "java.util.ArrayList"] @@ -897,7 +897,7 @@ | | +- LocalVariableDeclaration[] | | | +- ModifierList[] | | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | | +- VariableDeclarator[@TypeMirror = "void"] + | | | +- VariableDeclarator[] | | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "T"] | | | +- MethodCall[@Failed = false, @Function = "java.util.Iterator.next() -> capture#... of ? extends T", @MethodName = "next", @TypeMirror = "capture#... of ? extends T", @Unchecked = false, @VarargsCall = false] | | | +- VariableAccess[@Name = "it", @TypeMirror = "java.util.Iterator"] @@ -947,7 +947,7 @@ | +- LocalVariableDeclaration[] | | +- ModifierList[] | | +- PrimitiveType[@TypeMirror = "int"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "count", @TypeMirror = "int"] | | +- NumericLiteral[@TypeMirror = "int"] | +- WhileStatement[] @@ -981,7 +981,7 @@ | +- LocalVariableDeclaration[] | | +- ModifierList[] | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "T"] | | +- NullLiteral[@TypeMirror = "null"] | +- WhileStatement[] @@ -1102,7 +1102,7 @@ | +- FieldDeclaration[] | | +- ModifierList[] | | +- PrimitiveType[@TypeMirror = "int"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "yielded", @TypeMirror = "int"] | | +- NumericLiteral[@TypeMirror = "int"] | +- MethodDeclaration[@Name = "computeNext"] @@ -1178,7 +1178,7 @@ | +- FieldDeclaration[] | | +- ModifierList[] | | +- PrimitiveType[@TypeMirror = "int"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "yielded", @TypeMirror = "int"] | | +- NumericLiteral[@TypeMirror = "int"] | +- MethodDeclaration[@Name = "computeNext"] @@ -1252,7 +1252,7 @@ | +- FieldDeclaration[] | | +- ModifierList[] | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "T"] | | +- VariableAccess[@Name = "seed", @TypeMirror = "T"] | +- MethodDeclaration[@Name = "computeNext"] @@ -1391,7 +1391,7 @@ | +- LocalVariableDeclaration[] | | +- ModifierList[] | | +- PrimitiveType[@TypeMirror = "boolean"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "kindAny", @TypeMirror = "boolean"] | | +- InfixExpression[@TypeMirror = "boolean"] | | +- VariableAccess[@Name = "matchKind", @TypeMirror = "int"] @@ -1399,7 +1399,7 @@ | +- LocalVariableDeclaration[] | | +- ModifierList[] | | +- PrimitiveType[@TypeMirror = "boolean"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "kindAll", @TypeMirror = "boolean"] | | +- InfixExpression[@TypeMirror = "boolean"] | | +- VariableAccess[@Name = "matchKind", @TypeMirror = "int"] @@ -1412,7 +1412,7 @@ | | +- LocalVariableDeclaration[] | | | +- ModifierList[] | | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | | +- VariableDeclarator[@TypeMirror = "void"] + | | | +- VariableDeclarator[] | | | +- VariableDeclaratorId[@Name = "value", @TypeMirror = "T"] | | | +- MethodCall[@Failed = false, @Function = "java.util.Iterator.next() -> capture#... of ? extends T", @MethodName = "next", @TypeMirror = "capture#... of ? extends T", @Unchecked = false, @VarargsCall = false] | | | +- VariableAccess[@Name = "iterator", @TypeMirror = "java.util.Iterator"] @@ -1420,7 +1420,7 @@ | | +- LocalVariableDeclaration[] | | | +- ModifierList[] | | | +- PrimitiveType[@TypeMirror = "boolean"] - | | | +- VariableDeclarator[@TypeMirror = "void"] + | | | +- VariableDeclarator[] | | | +- VariableDeclaratorId[@Name = "match", @TypeMirror = "boolean"] | | | +- MethodCall[@Failed = false, @Function = "java.util.function.Predicate.test(capture#... of ? super T) -> boolean", @MethodName = "test", @TypeMirror = "boolean", @Unchecked = false, @VarargsCall = false] | | | +- VariableAccess[@Name = "pred", @TypeMirror = "java.util.function.Predicate"] @@ -1462,7 +1462,7 @@ | | +- FieldDeclaration[] | | | +- ModifierList[] | | | +- PrimitiveType[@TypeMirror = "boolean"] - | | | +- VariableDeclarator[@TypeMirror = "void"] + | | | +- VariableDeclarator[] | | | +- VariableDeclaratorId[@Name = "done", @TypeMirror = "boolean"] | | +- MethodDeclaration[@Name = "hasNext"] | | | +- ModifierList[] @@ -1548,7 +1548,7 @@ | | +- ClassOrInterfaceType[@TypeMirror = "java.util.ListIterator"] | | | +- TypeArguments[] | | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "li", @TypeMirror = "java.util.ListIterator"] | | +- MethodCall[@Failed = false, @Function = "java.util.List.listIterator(int) -> java.util.ListIterator", @MethodName = "listIterator", @TypeMirror = "java.util.ListIterator", @Unchecked = false, @VarargsCall = false] | | +- VariableAccess[@Name = "lst", @TypeMirror = "java.util.List"] @@ -1629,7 +1629,7 @@ | +- FieldDeclaration[] | | +- ModifierList[] | | +- ClassOrInterfaceType[@TypeMirror = "IteratorUtilCopy$AbstractIterator$State"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "state", @TypeMirror = "IteratorUtilCopy$AbstractIterator$State"] | | +- FieldAccess[@Name = "NOT_READY", @TypeMirror = "IteratorUtilCopy$AbstractIterator$State"] | | +- TypeExpression[@TypeMirror = "IteratorUtilCopy$AbstractIterator$State"] @@ -1637,7 +1637,7 @@ | +- FieldDeclaration[] | | +- ModifierList[] | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "T"] | | +- NullLiteral[@TypeMirror = "null"] | +- MethodDeclaration[@Name = "hasNext"] @@ -1779,13 +1779,13 @@ +- FieldDeclaration[] | +- ModifierList[] | +- PrimitiveType[@TypeMirror = "int"] - | +- VariableDeclarator[@TypeMirror = "void"] + | +- VariableDeclarator[] | +- VariableDeclaratorId[@Name = "numYielded", @TypeMirror = "int"] | +- NumericLiteral[@TypeMirror = "int"] +- FieldDeclaration[] | +- ModifierList[] | +- ClassOrInterfaceType[@TypeMirror = "T"] - | +- VariableDeclarator[@TypeMirror = "void"] + | +- VariableDeclarator[] | +- VariableDeclaratorId[@Name = "currentValue", @TypeMirror = "T"] +- MethodDeclaration[@Name = "next"] | +- ModifierList[] @@ -1797,7 +1797,7 @@ | +- LocalVariableDeclaration[] | | +- ModifierList[] | | +- ClassOrInterfaceType[@TypeMirror = "T"] - | | +- VariableDeclarator[@TypeMirror = "void"] + | | +- VariableDeclarator[] | | +- VariableDeclaratorId[@Name = "next", @TypeMirror = "T"] | | +- MethodCall[@Failed = false, @Function = "IteratorUtilCopy$AbstractIterator.next() -> T", @MethodName = "next", @TypeMirror = "T", @Unchecked = false, @VarargsCall = false] | | +- SuperExpression[@TypeMirror = "IteratorUtilCopy$AbstractIterator"] From ecd8acf3b115f78e2bf1121e9521806ed4f9ba3c Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 30 Jan 2023 09:50:48 +0100 Subject: [PATCH 23/28] [doc] Update release notes (#4317) --- docs/pages/7_0_0_release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/7_0_0_release_notes.md b/docs/pages/7_0_0_release_notes.md index bd9506cc4d..9ef91f07b4 100644 --- a/docs/pages/7_0_0_release_notes.md +++ b/docs/pages/7_0_0_release_notes.md @@ -255,6 +255,8 @@ The following previously deprecated rules have been finally removed: * [#4079](https://github.com/pmd/pmd/issues/4079): \[cli] Split off CLI implementation into a pmd-cli submodule * apex-design * [#2667](https://github.com/pmd/pmd/issues/2667): \[apex] Integrate nawforce/ApexLink to build robust Unused rule +* java + * [#4317](https://github.com/pmd/pmd/issues/4317): \[java] Some AST nodes should not be TypeNodes * java-bestpractices * [#342](https://github.com/pmd/pmd/issues/342): \[java] AccessorMethodGeneration: Name clash with another public field not properly handled * [#755](https://github.com/pmd/pmd/issues/755): \[java] AccessorClassGeneration false positive for private constructors From 0469719424114d74156ce012d2617fcc31c91e5c Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 30 Jan 2023 10:30:44 +0100 Subject: [PATCH 24/28] Fix compile errors --- .../src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java | 2 +- pmd-core/src/test/java/net/sourceforge/pmd/cli/ZipFileTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java index ddce7c5cf2..6a1c855246 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java @@ -18,11 +18,11 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.internal.util.FileCollectionUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; import net.sourceforge.pmd.lang.document.FileCollector; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.log.internal.NoopReporter; class PMDFilelistTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cli/ZipFileTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cli/ZipFileTest.java index e260f65f9d..cbf9ab007d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cli/ZipFileTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cli/ZipFileTest.java @@ -16,8 +16,8 @@ import org.junit.Test; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.util.IOUtil; public class ZipFileTest { From adf6766288b5191a12f1c879e513e3d79bf93ed6 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 30 Jan 2023 10:42:26 +0100 Subject: [PATCH 25/28] Fix unit tests --- .../net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.java | 1 - 1 file changed, 1 deletion(-) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.java b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.java index f9a49c17be..7c30ffa1a6 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.java +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/types/IteratorUtilCopy.java @@ -22,7 +22,6 @@ import java.util.function.Predicate; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import net.sourceforge.pmd.util.AssertionUtil; public final class IteratorUtilCopy { From 78d7033dc469f985109a3bb57e640f0ce596234f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 30 Jan 2023 10:45:52 +0100 Subject: [PATCH 26/28] Fix compile errors --- pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java index f95c39afc7..87ec854b7a 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java @@ -42,9 +42,9 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.cli.internal.CliExitCode; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.MockRule; -import net.sourceforge.pmd.util.IOUtil; import com.github.stefanbirkner.systemlambda.SystemLambda; From bac878f884236bd73f9c7f1ddd0872f7d1d15d47 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 30 Jan 2023 11:10:32 +0100 Subject: [PATCH 27/28] [doc] Update release notes (#2873) --- docs/pages/7_0_0_release_notes.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/pages/7_0_0_release_notes.md b/docs/pages/7_0_0_release_notes.md index 9ef91f07b4..fcca1fc63d 100644 --- a/docs/pages/7_0_0_release_notes.md +++ b/docs/pages/7_0_0_release_notes.md @@ -247,6 +247,7 @@ The following previously deprecated rules have been finally removed: * [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule * core * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command + * [#2873](https://github.com/pmd/pmd/issues/2873): \[core] Utility classes in pmd 7 * [#3203](https://github.com/pmd/pmd/issues/3203): \[core] Replace RuleViolationFactory implementations with ViolationDecorator * [#3902](https://github.com/pmd/pmd/issues/3902): \[core] Violation decorators * [#4035](https://github.com/pmd/pmd/issues/4035): \[core] ConcurrentModificationException in DefaultRuleViolationFactory @@ -354,6 +355,19 @@ The following previously deprecated rules have been finally removed: has been moved into the same package {% jdoc_package ant::ant %}. You'll need to update your taskdef entries in your build.xml files with the FQCN {% jdoc !!ant::ant.CPDTask %} if you use it anywhere. +* Utility classes in {% jdoc_package core::util %}, that have previously marked as `@InternalApi` have been finally + moved to {% jdoc_package core::internal.util %}. This includes ClasspathClassLoader, FileFinder, FileUtil, and + IOUtil. + +* The following utility classes in {% jdoc_package core::util %} are now considered public API: + * {% jdoc core::util.AssertionUtil %} + * {% jdoc core::util.CollectionUtil %} + * {% jdoc core::util.ContextedAssertionError %} + * {% jdoc core::util.ContextedStackOverflowError %} + * {% jdoc core::util.GraphUtil %} + * {% jdoc core::util.IteratorUtil %} + * {% jdoc core::util.StringUtil %} + #### Metrics framework The metrics framework has been made simpler and more general. From f9bd34ac21ca3cce15657a872c3d5cb7117a7c76 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 30 Jan 2023 12:32:51 +0100 Subject: [PATCH 28/28] [doc] Update release notes (#4367) --- docs/pages/7_0_0_release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/7_0_0_release_notes.md b/docs/pages/7_0_0_release_notes.md index bd9506cc4d..508282249e 100644 --- a/docs/pages/7_0_0_release_notes.md +++ b/docs/pages/7_0_0_release_notes.md @@ -255,6 +255,8 @@ The following previously deprecated rules have been finally removed: * [#4079](https://github.com/pmd/pmd/issues/4079): \[cli] Split off CLI implementation into a pmd-cli submodule * apex-design * [#2667](https://github.com/pmd/pmd/issues/2667): \[apex] Integrate nawforce/ApexLink to build robust Unused rule +* java + * [#4367](https://github.com/pmd/pmd/issues/4367): \[java] Move testrule TypeResTest into internal * java-bestpractices * [#342](https://github.com/pmd/pmd/issues/342): \[java] AccessorMethodGeneration: Name clash with another public field not properly handled * [#755](https://github.com/pmd/pmd/issues/755): \[java] AccessorClassGeneration false positive for private constructors