Mark RuleViolation::getPackageName etc. as DeprecatedUntil700

This commit is contained in:
Andreas Dangel committed 2023-01-16 11:02:37 +01:00
1 parent 084a262071
commit be9f22ab52
3 files changed
+11 -3

No files matched your search

@@ -7,6 +7,7 @@ package net.sourceforge.pmd;
import java.util.Comparator;
import java.util.Map;
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
import net.sourceforge.pmd.lang.document.FileLocation;
/**
@@ -144,6 +145,7 @@ public interface RuleViolation {
* @deprecated Use {@link #PACKAGE_NAME}
*/
@Deprecated
@DeprecatedUntil700
default String getPackageName() {
return getAdditionalInfo().get(PACKAGE_NAME);
}
@@ -155,6 +157,7 @@ public interface RuleViolation {
* @deprecated Use {@link #CLASS_NAME}
*/
@Deprecated
@DeprecatedUntil700
default String getClassName() {
return getAdditionalInfo().get(CLASS_NAME);
}
@@ -166,6 +169,7 @@ public interface RuleViolation {
* @deprecated Use {@link #METHOD_NAME}
*/
@Deprecated
@DeprecatedUntil700
default String getMethodName() {
return getAdditionalInfo().get(METHOD_NAME);
}
@@ -177,6 +181,7 @@ public interface RuleViolation {
* @deprecated Use {@link #VARIABLE_NAME}
*/
@Deprecated
@DeprecatedUntil700
default String getVariableName() {
return getAdditionalInfo().get(VARIABLE_NAME);
}
@@ -259,7 +259,9 @@ public class TextColorRenderer extends AbstractAccumulatingRenderer {
}
private static String keyFor(RuleViolation rv) {
return StringUtils.isNotBlank(rv.getPackageName()) ? rv.getPackageName() + '.' + rv.getClassName() : "";
String packageName = rv.getAdditionalInfo().getOrDefault(RuleViolation.PACKAGE_NAME, "");
String className = rv.getAdditionalInfo().getOrDefault(RuleViolation.CLASS_NAME, "");
return StringUtils.isNotBlank(packageName) ? packageName + '.' + className : "";
}
@@ -51,6 +51,7 @@ public class YAHTMLRenderer extends AbstractAccumulatingRenderer {
private void addViolation(RuleViolation violation) {
String packageName = violation.getAdditionalInfo().getOrDefault(RuleViolation.PACKAGE_NAME, "");
String className = violation.getAdditionalInfo().getOrDefault(RuleViolation.CLASS_NAME, "");
// report each part of the package name: e.g. net.sf.pmd.test will create nodes for
// net, net.sf, net.sf.pmd, and net.sf.pmd.test
@@ -72,10 +73,10 @@ public class YAHTMLRenderer extends AbstractAccumulatingRenderer {
}
// add one node per class collecting the actual violations
String fqClassName = packageName + "." + violation.getClassName();
String fqClassName = packageName + "." + className;
ReportNode classNode = reportNodesByPackage.get(fqClassName);
if (classNode == null) {
classNode = new ReportNode(packageName, violation.getClassName());
classNode = new ReportNode(packageName, className);
reportNodesByPackage.put(fqClassName, classNode);
}
classNode.addRuleViolation(violation);