From 8dc21bb043dd83c49730a69da5df9be7d311bae7 Mon Sep 17 00:00:00 2001 From: Oleksii Dykov Date: Tue, 23 Jan 2024 22:30:00 +0200 Subject: [PATCH 1/6] AvoidProhibitedMethodsUsage - Fix deprecated warnings --- .../arch4u/pmd/AvoidProhibitedMethodsUsage.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/dgroup/arch4u/pmd/AvoidProhibitedMethodsUsage.java b/src/main/java/io/github/dgroup/arch4u/pmd/AvoidProhibitedMethodsUsage.java index eb7bd16..45da065 100644 --- a/src/main/java/io/github/dgroup/arch4u/pmd/AvoidProhibitedMethodsUsage.java +++ b/src/main/java/io/github/dgroup/arch4u/pmd/AvoidProhibitedMethodsUsage.java @@ -30,8 +30,7 @@ import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; import net.sourceforge.pmd.lang.java.rule.AbstractPoorMethodCall; import net.sourceforge.pmd.lang.java.symboltable.JavaNameOccurrence; -import net.sourceforge.pmd.lang.java.xpath.TypeIsExactlyFunction; -import net.sourceforge.pmd.lang.java.xpath.TypeIsFunction; +import net.sourceforge.pmd.lang.java.types.TypeTestUtil; import net.sourceforge.pmd.lang.symboltable.NameOccurrence; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; @@ -91,11 +90,9 @@ public Object visit(final ASTVariableDeclaratorId node, final Object data) { for (final NameOccurrence usage : node.getUsages()) { final JavaNameOccurrence occurrence = (JavaNameOccurrence) usage; if (this.isNotedMethod(occurrence.getNameForWhichThisIsAQualifier())) { - this.addViolation( - data, occurrence.getLocation(), new String[]{ + this.asCtx(data).addViolation(occurrence.getLocation(), this.getProperty(CLASS), - occurrence.getNameForWhichThisIsAQualifier().getImage(), - } + occurrence.getNameForWhichThisIsAQualifier().getImage() ); } } @@ -113,9 +110,9 @@ private boolean hasNotedClass(final ASTVariableDeclaratorId node) { final String typename = this.getProperty(CLASS); final ASTType typenode = node.getTypeNode(); if (this.getProperty(CHECK_SUBTYPES)) { - noted = TypeIsFunction.typeIs(typenode, typename); + noted = TypeTestUtil.isA(typename, typenode); } else { - noted = TypeIsExactlyFunction.typeIsExactly(typenode, typename); + noted = TypeTestUtil.isExactlyA(typename, typenode); } return noted; } From f5668b7a6eab3777d59e06c2407c229597e8edd7 Mon Sep 17 00:00:00 2001 From: Oleksii Dykov Date: Tue, 23 Jan 2024 22:37:16 +0200 Subject: [PATCH 2/6] MissingMandatoryAnnotation - Fix deprecated warnings --- .../io/github/dgroup/arch4u/pmd/MissingMandatoryAnnotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/dgroup/arch4u/pmd/MissingMandatoryAnnotation.java b/src/main/java/io/github/dgroup/arch4u/pmd/MissingMandatoryAnnotation.java index f887299..e904dc1 100644 --- a/src/main/java/io/github/dgroup/arch4u/pmd/MissingMandatoryAnnotation.java +++ b/src/main/java/io/github/dgroup/arch4u/pmd/MissingMandatoryAnnotation.java @@ -75,7 +75,7 @@ public MissingMandatoryAnnotation() { public Object visit(final ASTMethodDeclaration mthd, final Object data) { final Optional restannot = this.getRestAnnotation(mthd); if (restannot.isPresent() && this.hasNoMandatoryAnnotation(mthd)) { - this.addViolation(data, restannot.get()); + asCtx(data).addViolation(restannot.get()); } return super.visit(mthd, data); } From 87398f1524767eb7a9e517a0d4359186259fa67c Mon Sep 17 00:00:00 2001 From: Oleksii Dykov Date: Tue, 23 Jan 2024 22:37:28 +0200 Subject: [PATCH 3/6] ObfuscationRequired - Fix deprecated warnings --- .../java/io/github/dgroup/arch4u/pmd/ObfuscationRequired.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/dgroup/arch4u/pmd/ObfuscationRequired.java b/src/main/java/io/github/dgroup/arch4u/pmd/ObfuscationRequired.java index 1a5b118..d4f356b 100644 --- a/src/main/java/io/github/dgroup/arch4u/pmd/ObfuscationRequired.java +++ b/src/main/java/io/github/dgroup/arch4u/pmd/ObfuscationRequired.java @@ -106,7 +106,7 @@ public Object visit(final ASTVariableDeclaratorId vardecl, final Object data) { getArguments(occurrence) .stream() .filter(this::hasSensitiveData) - .forEach(arg -> this.addViolation(data, arg)); + .forEach(arg -> asCtx(data).addViolation(arg)); } } return data; From cb29ee08c67a9494124ca9c41bc49033d9512dfc Mon Sep 17 00:00:00 2001 From: Oleksii Dykov Date: Tue, 23 Jan 2024 22:37:39 +0200 Subject: [PATCH 4/6] PotentiallyThreadLocalPollutionByMdc - Fix deprecated warnings --- .../arch4u/pmd/PotentiallyThreadLocalPollutionByMdc.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/dgroup/arch4u/pmd/PotentiallyThreadLocalPollutionByMdc.java b/src/main/java/io/github/dgroup/arch4u/pmd/PotentiallyThreadLocalPollutionByMdc.java index 84a5ba8..3c3171e 100644 --- a/src/main/java/io/github/dgroup/arch4u/pmd/PotentiallyThreadLocalPollutionByMdc.java +++ b/src/main/java/io/github/dgroup/arch4u/pmd/PotentiallyThreadLocalPollutionByMdc.java @@ -39,6 +39,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTPrimarySuffix; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; +import net.sourceforge.pmd.lang.java.types.TypeTestUtil; import net.sourceforge.pmd.lang.java.xpath.TypeIsFunction; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; @@ -82,7 +83,7 @@ public Object visit(final ASTMethodDeclaration mthd, final Object data) { .filter(this::isMdc) .forEach(this::updateMap); for (final ASTPrimaryExpression expression : this.keymap.values()) { - this.addViolation(data, expression); + asCtx(data).addViolation(expression); } return data; } @@ -95,7 +96,7 @@ public Object visit(final ASTMethodDeclaration mthd, final Object data) { private boolean isMdc(final ASTPrimaryPrefix prefix) { return this.getProperty(MDC_CLASSES) .stream() - .anyMatch(mdc -> TypeIsFunction.typeIs(prefix, mdc)); + .anyMatch(mdc -> TypeTestUtil.isA(mdc, prefix)); } /** From 544b2af0e6716720c7784861c8d5b45587810b49 Mon Sep 17 00:00:00 2001 From: Oleksii Dykov Date: Tue, 23 Jan 2024 22:37:51 +0200 Subject: [PATCH 5/6] UseExistingConstant - Fix deprecated warnings --- .../java/io/github/dgroup/arch4u/pmd/UseExistingConstant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/dgroup/arch4u/pmd/UseExistingConstant.java b/src/main/java/io/github/dgroup/arch4u/pmd/UseExistingConstant.java index 724df67..ebdd341 100644 --- a/src/main/java/io/github/dgroup/arch4u/pmd/UseExistingConstant.java +++ b/src/main/java/io/github/dgroup/arch4u/pmd/UseExistingConstant.java @@ -78,7 +78,7 @@ public Object visit(final ASTLiteral node, final Object data) { String image = node.getTextBlockContent(); image = image.substring(1, image.length() - 1); if (image.length() > 0 && this.pattern.matcher(image).find()) { - this.addViolation(data, node); + asCtx(data).addViolation(node); } } return data; From af529953c0a0ff8d324800b8983e380e9fe2dcaa Mon Sep 17 00:00:00 2001 From: Oleksii Dykov Date: Tue, 23 Jan 2024 22:38:05 +0200 Subject: [PATCH 6/6] WrongRestMethodSignature - Fix deprecated warnings --- .../io/github/dgroup/arch4u/pmd/WrongRestMethodSignature.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/dgroup/arch4u/pmd/WrongRestMethodSignature.java b/src/main/java/io/github/dgroup/arch4u/pmd/WrongRestMethodSignature.java index a21decd..1af7e64 100644 --- a/src/main/java/io/github/dgroup/arch4u/pmd/WrongRestMethodSignature.java +++ b/src/main/java/io/github/dgroup/arch4u/pmd/WrongRestMethodSignature.java @@ -60,7 +60,7 @@ public WrongRestMethodSignature() { @Override public Object visit(final ASTMethodDeclaration mthd, final Object data) { if (this.isRestMethod(mthd) && hasWrongSignature(mthd)) { - this.addViolation(data, mthd); + asCtx(data).addViolation(mthd); } return super.visit(mthd, data); }