From 2c647166b528bddcd203bf1a9487f50a57dce7d1 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 26 Apr 2024 12:59:38 +0200 Subject: [PATCH] chore: Use pmd 7.1.0 for checks (#195) * chore: Use pmd 7.1.0 for checks * [doc] Update release notes (#195) --- ReleaseNotes.md | 1 + .../pmd/eclipse/ui/views/ast/ASTViewPage.java | 10 ---------- .../ui/views/ast/NodeImageDeriver.java | 20 +++++++++---------- pom.xml | 2 +- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index cf80dc6c..ec8ef77c 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -17,6 +17,7 @@ This is a minor release. ### Merged pull requests * [#194](https://github.com/pmd/pmd-eclipse-plugin/pull/194): \[ci] Support macos on arm64/aarch64 +* [#195](https://github.com/pmd/pmd-eclipse-plugin/pull/195): chore: Use pmd 7.1.0 for checks ### API Changes diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java index 64534367..d3c25214 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java @@ -4,9 +4,7 @@ package net.sourceforge.pmd.eclipse.ui.views.ast; -import java.util.HashSet; import java.util.List; -import java.util.Set; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; @@ -47,7 +45,6 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.ParseException; import net.sourceforge.pmd.lang.ast.impl.AbstractNode; -import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.reporting.RuleViolation; @@ -72,13 +69,6 @@ public class ASTViewPage extends AbstractStructureInspectorPage { // private static Set keywords = new HashSet(); - private static Set> hiddenNodeTypes; - - static { - hiddenNodeTypes = new HashSet<>(); - hiddenNodeTypes.add(ASTImportDeclaration.class); - } - public ASTViewPage(IWorkbenchPart part, FileRecord record) { super(part, record); } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeImageDeriver.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeImageDeriver.java index bb77639b..775c4633 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeImageDeriver.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeImageDeriver.java @@ -27,7 +27,7 @@ */ public class NodeImageDeriver { - private static NodeImageDeriver compilationUnitDeriver = new NodeImageDeriver(ASTCompilationUnit.class) { + private static final NodeImageDeriver COMPILATION_UNIT_DERIVER = new NodeImageDeriver(ASTCompilationUnit.class) { @Override public String deriveFrom(Node node) { dumpComments((ASTCompilationUnit) node); @@ -35,7 +35,7 @@ public String deriveFrom(Node node) { } }; - private static NodeImageDeriver importDeriver = new NodeImageDeriver(ASTImportDeclaration.class) { + private static final NodeImageDeriver IMPORT_DERIVER = new NodeImageDeriver(ASTImportDeclaration.class) { @Override public String deriveFrom(Node node) { // TODO show package name as well? @@ -43,14 +43,14 @@ public String deriveFrom(Node node) { } }; - private static NodeImageDeriver methodDeclarationDeriver = new NodeImageDeriver(ASTMethodDeclaration.class) { + private static final NodeImageDeriver METHOD_DECLARATION_DERIVER = new NodeImageDeriver(ASTMethodDeclaration.class) { @Override public String deriveFrom(Node node) { return ASTUtil.getMethodLabel((ASTMethodDeclaration) node, true); } }; - private static NodeImageDeriver throwStatementDeriver = new NodeImageDeriver(ASTThrowStatement.class) { + private static final NodeImageDeriver THROW_STATEMENT_DERIVER = new NodeImageDeriver(ASTThrowStatement.class) { @Override public String deriveFrom(Node node) { final ASTClassType t = node.descendants(ASTClassType.class).first(); @@ -58,14 +58,14 @@ public String deriveFrom(Node node) { } }; - private static NodeImageDeriver fieldDeclarationDeriver = new NodeImageDeriver(ASTFieldDeclaration.class) { + private static final NodeImageDeriver FIELD_DECLARATION_DERIVER = new NodeImageDeriver(ASTFieldDeclaration.class) { @Override public String deriveFrom(Node node) { return ASTUtil.getFieldLabel((ASTFieldDeclaration) node); } }; - private static NodeImageDeriver localVariableDeclarationDeriver = new NodeImageDeriver( + private static final NodeImageDeriver LOCAL_VARIABLE_DECLARATION_DERIVER = new NodeImageDeriver( ASTLocalVariableDeclaration.class) { @Override public String deriveFrom(Node node) { @@ -73,16 +73,16 @@ public String deriveFrom(Node node) { } }; - private static NodeImageDeriver annotationDeriver = new NodeImageDeriver(ASTAnnotation.class) { + private static final NodeImageDeriver ANNOTATION_DERIVER = new NodeImageDeriver(ASTAnnotation.class) { @Override public String deriveFrom(Node node) { return ASTUtil.getAnnotationLabel((ASTAnnotation) node); } }; - private static final NodeImageDeriver[] ALL_DERIVERS = new NodeImageDeriver[] { importDeriver, - methodDeclarationDeriver, localVariableDeclarationDeriver, fieldDeclarationDeriver, annotationDeriver, - compilationUnitDeriver, throwStatementDeriver }; + private static final NodeImageDeriver[] ALL_DERIVERS = new NodeImageDeriver[] { IMPORT_DERIVER, + METHOD_DECLARATION_DERIVER, LOCAL_VARIABLE_DECLARATION_DERIVER, FIELD_DECLARATION_DERIVER, ANNOTATION_DERIVER, + COMPILATION_UNIT_DERIVER, THROW_STATEMENT_DERIVER }; private static final Map, NodeImageDeriver> DERIVERS_BY_TYPE = new HashMap<>( NodeImageDeriver.ALL_DERIVERS.length); diff --git a/pom.xml b/pom.xml index 832b8be3..16b8912a 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 10.14.0 3.3.1 3.22.0 - 7.0.0 + 7.1.0 .ci/files/pmd-eclipse-plugin.p12 ${basedir}/${keystorePath}