diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index 50177e17a7..019e30e7ef 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -26,7 +26,12 @@ This is a {{ site.pmd.release_type }} release.
* {% jdoc java::lang.java.JavaLanguageHandler %}
* {% jdoc java::lang.java.JavaLanguageParser %}
* {% jdoc java::lang.java.JavaDataFlowHandler %}
-
+* Implementations of {% jdoc core::lang.rule.RuleViolationFactory %} in each
+ language module, eg {% jdoc java::lang.java.rule.JavaRuleViolationFactory %}.
+ See javadoc of {% jdoc core::lang.rule.RuleViolationFactory %}.
+* Implementations of {% jdoc core::RuleViolation %} in each language module,
+ eg {% jdoc java::lang.java.rule.JavaRuleViolation %}. See javadoc of
+ {% jdoc core::RuleViolation %}.
##### For removal
diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/ApexRuleViolation.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/ApexRuleViolation.java
index b5019a908e..113328bcd9 100644
--- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/ApexRuleViolation.java
+++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/ApexRuleViolation.java
@@ -6,6 +6,8 @@ package net.sourceforge.pmd.lang.apex.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
+import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.apex.ast.CanSuppressWarnings;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
@@ -21,8 +23,12 @@ import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
*
Suppression indicator
*
* @param
+ *
+ * @deprecated See {@link RuleViolation}
*/
@SuppressWarnings("PMD.UseUtilityClass") // we inherit non-static methods...
+@Deprecated
+@InternalApi
public class ApexRuleViolation extends ParametricRuleViolation {
public ApexRuleViolation(Rule rule, RuleContext ctx, Node node, String message, int beginLine, int endLine) {
diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/ApexRuleViolationFactory.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/ApexRuleViolationFactory.java
index 1fd6ed544a..67cbe80c74 100644
--- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/ApexRuleViolationFactory.java
+++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/ApexRuleViolationFactory.java
@@ -7,9 +7,16 @@ package net.sourceforge.pmd.lang.apex.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
+import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
+/**
+ * @deprecated See {@link RuleViolationFactory}
+ */
+@Deprecated
+@InternalApi
public final class ApexRuleViolationFactory extends AbstractRuleViolationFactory {
public static final ApexRuleViolationFactory INSTANCE = new ApexRuleViolationFactory();
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java
index 7267ab4e1e..5873d6e4db 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java
@@ -6,7 +6,11 @@ package net.sourceforge.pmd;
/**
* A RuleViolation is created by a Rule when it identifies a violation of the
- * Rule constraints.
+ * Rule constraints. RuleViolations are simple data holders that are collected
+ * into a {@link Report}.
+ *
+ * Since PMD 6.21.0, implementations of this interface are considered internal
+ * API and hence deprecated. Clients should exclusively use this interface.
*
* @see Rule
*/
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleViolationFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleViolationFactory.java
index 68959d1df0..b2a74bcbe1 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleViolationFactory.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleViolationFactory.java
@@ -6,11 +6,16 @@ package net.sourceforge.pmd.lang.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
+import net.sourceforge.pmd.lang.LanguageVersionHandler;
import net.sourceforge.pmd.lang.ast.Node;
/**
* This class handles of producing a Language specific RuleViolation and adding
* to a Report.
+ *
+ *
Since PMD 6.21.0, implementations of this interface are considered internal
+ * API and hence deprecated. Clients should exclusively use this interface and obtain
+ * instances through {@link LanguageVersionHandler#getRuleViolationFactory()}.
*/
public interface RuleViolationFactory {
/**
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/JavaRuleViolation.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/JavaRuleViolation.java
index d544783cd4..09ae9715cc 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/JavaRuleViolation.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/JavaRuleViolation.java
@@ -9,6 +9,7 @@ import java.util.Set;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
+import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration;
@@ -37,7 +38,9 @@ import net.sourceforge.pmd.lang.symboltable.Scope;
*
Variable name
* Suppression indicator
*
+ * @deprecated See {@link RuleViolation}
*/
+@Deprecated
public class JavaRuleViolation extends ParametricRuleViolation {
public JavaRuleViolation(Rule rule, RuleContext ctx, JavaNode node, String message, int beginLine, int endLine) {
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/JavaRuleViolationFactory.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/JavaRuleViolationFactory.java
index 0c09a95cde..50cab205a7 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/JavaRuleViolationFactory.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/JavaRuleViolationFactory.java
@@ -7,11 +7,17 @@ package net.sourceforge.pmd.lang.java.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.JavaNode;
import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
+/**
+ * @deprecated See {@link RuleViolationFactory}
+ */
+@Deprecated
+@InternalApi
public final class JavaRuleViolationFactory extends AbstractRuleViolationFactory {
public static final RuleViolationFactory INSTANCE = new JavaRuleViolationFactory();
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DaaRuleViolation.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DaaRuleViolation.java
index 40dfc8b977..1ccb8b7dfd 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DaaRuleViolation.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DaaRuleViolation.java
@@ -6,6 +6,7 @@ package net.sourceforge.pmd.lang.java.rule.errorprone;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
+import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.JavaNode;
import net.sourceforge.pmd.lang.java.rule.JavaRuleViolation;
@@ -16,7 +17,9 @@ import net.sourceforge.pmd.lang.java.rule.JavaRuleViolation;
*
* @author Sven Jacob
* @author Brian Remedios
+ * @deprecated See {@link RuleViolation}
*/
+@Deprecated
public class DaaRuleViolation extends JavaRuleViolation {
private final String variableName;
diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptRuleViolationFactory.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptRuleViolationFactory.java
index 3deca0d4e3..55b3a08c3b 100644
--- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptRuleViolationFactory.java
+++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptRuleViolationFactory.java
@@ -7,11 +7,18 @@ package net.sourceforge.pmd.lang.ecmascript.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptNode;
import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
+import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
+/**
+ * @deprecated See {@link RuleViolationFactory}
+ */
+@Deprecated
+@InternalApi
public final class EcmascriptRuleViolationFactory extends AbstractRuleViolationFactory {
public static final EcmascriptRuleViolationFactory INSTANCE = new EcmascriptRuleViolationFactory();
@@ -27,7 +34,7 @@ public final class EcmascriptRuleViolationFactory extends AbstractRuleViolationF
@Override
protected RuleViolation createRuleViolation(Rule rule, RuleContext ruleContext, Node node, String message,
- int beginLine, int endLine) {
+ int beginLine, int endLine) {
return null; // FIXME
}
}
diff --git a/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/JspRuleViolationFactory.java b/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/JspRuleViolationFactory.java
index 8135d54f72..c32cf80bba 100644
--- a/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/JspRuleViolationFactory.java
+++ b/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/JspRuleViolationFactory.java
@@ -7,12 +7,18 @@ package net.sourceforge.pmd.lang.jsp.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.jsp.ast.JspNode;
import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
+/**
+ * @deprecated See {@link RuleViolationFactory}
+ */
+@Deprecated
+@InternalApi
public final class JspRuleViolationFactory extends AbstractRuleViolationFactory {
public static final RuleViolationFactory INSTANCE = new JspRuleViolationFactory();
diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/PLSQLRuleViolationFactory.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/PLSQLRuleViolationFactory.java
index f4adec6b2d..efc9d944c8 100644
--- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/PLSQLRuleViolationFactory.java
+++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/PLSQLRuleViolationFactory.java
@@ -7,11 +7,17 @@ package net.sourceforge.pmd.lang.plsql.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
+/**
+ * @deprecated See {@link RuleViolationFactory}
+ */
+@Deprecated
+@InternalApi
public final class PLSQLRuleViolationFactory extends AbstractRuleViolationFactory {
public static final RuleViolationFactory INSTANCE = new PLSQLRuleViolationFactory();
diff --git a/pmd-scala/src/main/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleViolationFactory.java b/pmd-scala/src/main/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleViolationFactory.java
index 73ec26099e..580ebd22c8 100644
--- a/pmd-scala/src/main/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleViolationFactory.java
+++ b/pmd-scala/src/main/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleViolationFactory.java
@@ -7,14 +7,17 @@ package net.sourceforge.pmd.lang.scala.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
/**
- * A RuleViolationFactory for Scala.
+ * @deprecated See {@link RuleViolationFactory}
*/
+@Deprecated
+@InternalApi
public class ScalaRuleViolationFactory extends AbstractRuleViolationFactory {
/**
* The shared singleton of this RuleViolationFactory.
diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/VfRuleViolationFactory.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/VfRuleViolationFactory.java
index 202394278e..eaacfbad68 100644
--- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/VfRuleViolationFactory.java
+++ b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/VfRuleViolationFactory.java
@@ -7,12 +7,18 @@ package net.sourceforge.pmd.lang.vf.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
import net.sourceforge.pmd.lang.vf.ast.VfNode;
+/**
+ * @deprecated See {@link RuleViolationFactory}
+ */
+@Deprecated
+@InternalApi
public final class VfRuleViolationFactory extends AbstractRuleViolationFactory {
public static final RuleViolationFactory INSTANCE = new VfRuleViolationFactory();
diff --git a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/VmRuleViolationFactory.java b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/VmRuleViolationFactory.java
index a12d347fa5..ef333209b0 100644
--- a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/VmRuleViolationFactory.java
+++ b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/VmRuleViolationFactory.java
@@ -7,12 +7,18 @@ package net.sourceforge.pmd.lang.vm.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
import net.sourceforge.pmd.lang.vm.ast.AbstractVmNode;
+/**
+ * @deprecated See {@link RuleViolationFactory}
+ */
+@Deprecated
+@InternalApi
public final class VmRuleViolationFactory extends AbstractRuleViolationFactory {
public static final RuleViolationFactory INSTANCE = new VmRuleViolationFactory();
diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlRuleViolationFactory.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlRuleViolationFactory.java
index 190ec2152a..c4fe01a4be 100644
--- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlRuleViolationFactory.java
+++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlRuleViolationFactory.java
@@ -7,12 +7,18 @@ package net.sourceforge.pmd.lang.xml.rule;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleViolation;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
import net.sourceforge.pmd.lang.xml.ast.XmlNode;
+/**
+ * @deprecated See {@link RuleViolationFactory}
+ */
+@Deprecated
+@InternalApi
public final class XmlRuleViolationFactory extends AbstractRuleViolationFactory {
public static final RuleViolationFactory INSTANCE = new XmlRuleViolationFactory();