diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 264139c97b..8dc81d9ff7 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -25,10 +25,17 @@ This is a {{ site.pmd.release_type }} release. cases where the variable of the caught exception is reassigned. This practice is surprising and prevents further evolution of the code like multi-catch. +#### Deprecated Rules + +* The Java rule {% rule "java/errorprone/DataflowAnomalyAnalysis" %} (`java-errorprone`) + is deprecated in favour of {% rule "java/bestpractices/UnusedAssignment" %} (`java-bestpractices`), + which was introduced in PMD 6.26.0. + ### Fixed Issues * core * [#724](https://github.com/pmd/pmd/issues/724): \[core] Avoid parsing rulesets multiple times + * [#1962](https://github.com/pmd/pmd/issues/1962): \[core] Simplify Report API * [#2653](https://github.com/pmd/pmd/issues/2653): \[lang-test] Upgrade kotlintest to Kotest * java-bestpractices * [#2471](https://github.com/pmd/pmd/issues/2471): \[java] New Rule: AvoidReassigningCatchVariables @@ -36,6 +43,7 @@ This is a {{ site.pmd.release_type }} release. * java-errorprone * [#2431](https://github.com/pmd/pmd/issues/2431): \[java] InvalidLogMessageFormatRule throws IndexOutOfBoundsException when only logging exception message * [#2439](https://github.com/pmd/pmd/issues/2439): \[java] AvoidCatchingThrowable can not detect the case: catch (java.lang.Throwable t) + * [#2647](https://github.com/pmd/pmd/issues/2647): \[java] Deprecate rule DataFlowAnomalyAnalysis * java-performance * [#2441](https://github.com/pmd/pmd/issues/2441): \[java] RedundantFieldInitializer can not detect a special case for char initialize: `char foo = '\0';` @@ -49,9 +57,32 @@ This is a {{ site.pmd.release_type }} release. #### Deprecated API -##### For removal +* {% jdoc !!core::Rule#getParserOptions() %} +* {% jdoc !!core::lang.Parser#getParserOptions() %} +* {% jdoc !!core::lang.AbstractParser %} +* {% jdoc !!core::RuleContext#removeAttribute(java.lang.String) %} +* {% jdoc !!core::RuleContext#getAttribute(java.lang.String) %} +* {% jdoc !!core::RuleContext#setAttribute(java.lang.String, java.lang.Object) %} +* {% jdoc apex::lang.apex.ApexParserOptions %} +* {% jdoc !!java::lang.java.ast.ASTThrowStatement#getFirstClassOrInterfaceTypeImage() %} +* {% jdoc javascript::lang.ecmascript.EcmascriptParserOptions %} +* {% jdoc javascript::lang.ecmascript.rule.EcmascriptXPathRule %} +* {% jdoc xml::lang.xml.XmlParserOptions %} +* {% jdoc xml::lang.xml.rule.XmlXPathRule %} +* Properties of {% jdoc xml::lang.xml.rule.AbstractXmlRule %} -* {% jdoc !!pmd-java::lang.java.ast.ASTThrowStatement#getFirstClassOrInterfaceTypeImage() %} +* {% jdoc !!core::Report.ReadableDuration %} +* Many methods of {% jdoc !!core::Report %}. They are replaced by accessors + that produce a List. For example, {% jdoc !a!core::Report#iterator() %} + (and implementing Iterable) and {% jdoc !a!core::Report#isEmpty() %} are both + replaced by {% jdoc !a!core::Report#getViolations() %}. + +* The dataflow codebase is deprecated for removal in PMD 7. This + includes all code in the following packages, and their subpackages: + * {% jdoc_package plsql::lang.plsql.dfa %} + * {% jdoc_package java::lang.java.dfa %} + * {% jdoc_package core::lang.dfa %} + * and the class {% jdoc plsql::lang.plsql.PLSQLDataFlowHandler %} ### External Contributions diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java index a660af6eef..8d41b5d1ba 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java @@ -6,6 +6,10 @@ package net.sourceforge.pmd.lang.apex; import net.sourceforge.pmd.lang.ParserOptions; +/** + * @deprecated Not useful + */ +@Deprecated public class ApexParserOptions extends ParserOptions { // empty class for now, since we don't have extra options for Apex diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Report.java b/pmd-core/src/main/java/net/sourceforge/pmd/Report.java index ca702ec471..5de0f14057 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Report.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/Report.java @@ -1,4 +1,4 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ @@ -40,11 +40,11 @@ public class Report implements Iterable { // a bit private final List violations = new ArrayList<>(); private final List listeners = new ArrayList<>(); - private List errors; - private List configErrors; + private final List errors = new ArrayList<>(); + private final List configErrors = new ArrayList<>(); private long start; private long end; - private List suppressedRuleViolations = new ArrayList<>(); + private final List suppressedRuleViolations = new ArrayList<>(); /** * Creates a new, initialized, empty report for the given file name. @@ -68,7 +68,10 @@ public class Report implements Iterable { /** * Represents a duration. Useful for reporting processing time. + * + * @deprecated Not used within PMD. Rendering durations is format-specific. */ + @Deprecated public static class ReadableDuration { private final long duration; @@ -186,7 +189,10 @@ public class Report implements Iterable { * Calculate a summary of violation counts per fully classified class name. * * @return violations per class name + * + * @deprecated This is too specific. Not every violation has a qualified name. */ + @Deprecated public Map getCountSummary() { Map summary = new HashMap<>(); for (RuleViolation rv : violationTree) { @@ -197,6 +203,10 @@ public class Report implements Iterable { return summary; } + /** + * @deprecated The {@link ReportTree} is deprecated + */ + @Deprecated public ReportTree getViolationTree() { return this.violationTree; } @@ -206,7 +216,10 @@ public class Report implements Iterable { * * @return a Map summarizing the Report: String (rule name) -> Integer (count * of violations) + * + * @deprecated This is too specific, only used by one renderer. */ + @Deprecated public Map getSummary() { Map summary = new HashMap<>(); for (RuleViolation rv : violations) { @@ -230,6 +243,12 @@ public class Report implements Iterable { listeners.add(listener); } + /** + * Returns the suppressed violations. + * + * @deprecated Use {@link #getSuppressedViolations()} (be aware, that that method returns an unmodifiable list) + */ + @Deprecated public List getSuppressedRuleViolations() { return suppressedRuleViolations; } @@ -296,9 +315,6 @@ public class Report implements Iterable { * the error to add */ public void addConfigError(ConfigurationError error) { - if (configErrors == null) { - configErrors = new ArrayList<>(); - } configErrors.add(error); } @@ -309,9 +325,6 @@ public class Report implements Iterable { * the error to add */ public void addError(ProcessingError error) { - if (errors == null) { - errors = new ArrayList<>(); - } errors.add(error); } @@ -325,27 +338,25 @@ public class Report implements Iterable { * @see AbstractAccumulatingRenderer */ public void merge(Report r) { - Iterator i = r.errors(); - while (i.hasNext()) { - addError(i.next()); - } - Iterator ce = r.configErrors(); - while (ce.hasNext()) { - addConfigError(ce.next()); - } - Iterator v = r.iterator(); - while (v.hasNext()) { - RuleViolation violation = v.next(); + errors.addAll(r.errors); + configErrors.addAll(r.configErrors); + suppressedRuleViolations.addAll(r.suppressedRuleViolations); + + for (RuleViolation violation : r.getViolations()) { int index = Collections.binarySearch(violations, violation, RuleViolationComparator.INSTANCE); violations.add(index < 0 ? -index - 1 : index, violation); violationTree.addRuleViolation(violation); } - Iterator s = r.getSuppressedRuleViolations().iterator(); - while (s.hasNext()) { - suppressedRuleViolations.add(s.next()); - } } + + /** + * Checks whether there are no violations and no processing errors. + * That means, that PMD analysis yielded nothing to worry about. + * + * @deprecated Use {@link #getViolations()} or {@link #getProcessingErrors()} + */ + @Deprecated public boolean isEmpty() { return !violations.iterator().hasNext() && !hasErrors(); } @@ -355,9 +366,12 @@ public class Report implements Iterable { * * @return true if there were any processing errors, * false otherwise + * + * @deprecated Use {@link #getProcessingErrors()}.isEmpty() */ + @Deprecated public boolean hasErrors() { - return errors != null && !errors.isEmpty(); + return !getProcessingErrors().isEmpty(); } /** @@ -365,9 +379,12 @@ public class Report implements Iterable { * * @return true if there were any configuration errors, * false otherwise + * + * @deprecated Use {@link #getConfigurationErrors()}.isEmpty() */ + @Deprecated public boolean hasConfigErrors() { - return configErrors != null && !configErrors.isEmpty(); + return !getConfigurationErrors().isEmpty(); } /** @@ -375,7 +392,10 @@ public class Report implements Iterable { * * @return true if no violations have been reported, * false otherwise + * + * @deprecated The {@link ReportTree} is deprecated, use {@link #getViolations()}.isEmpty() instead. */ + @Deprecated public boolean treeIsEmpty() { return !violationTree.iterator().hasNext(); } @@ -384,39 +404,91 @@ public class Report implements Iterable { * Returns an iteration over the reported violations. * * @return an iterator + * + * @deprecated The {@link ReportTree} is deprecated */ + @Deprecated public Iterator treeIterator() { return violationTree.iterator(); } + /** + * @deprecated Use {@link #getViolations()} + */ + @Deprecated @Override public Iterator iterator() { return violations.iterator(); } + + /** + * Returns an unmodifiable list of violations that were suppressed. + */ + public final List getSuppressedViolations() { + return Collections.unmodifiableList(suppressedRuleViolations); + } + + /** + * Returns an unmodifiable list of violations that have been + * recorded until now. None of those violations were suppressed. + * + *

The violations list is sorted with {@link RuleViolationComparator#INSTANCE}. + */ + public final List getViolations() { + return Collections.unmodifiableList(violations); + } + + + /** + * Returns an unmodifiable list of processing errors that have been + * recorded until now. + */ + public final List getProcessingErrors() { + return Collections.unmodifiableList(errors); + } + + + /** + * Returns an unmodifiable list of configuration errors that have + * been recorded until now. + */ + public final List getConfigurationErrors() { + return Collections.unmodifiableList(configErrors); + } + + /** * Returns an iterator of the reported processing errors. * * @return the iterator + * + * @deprecated Use {@link #getProcessingErrors()} */ + @Deprecated public Iterator errors() { - return errors == null ? Collections.emptyIterator() : errors.iterator(); + return getProcessingErrors().iterator(); } /** * Returns an iterator of the reported configuration errors. * * @return the iterator + * @deprecated Use {@link #getConfigurationErrors()} */ + @Deprecated public Iterator configErrors() { - return configErrors == null ? Collections.emptyIterator() : configErrors.iterator(); + return getConfigurationErrors().iterator(); } /** * The number of violations. * * @return number of violations. + * + * @deprecated The {@link ReportTree} is deprecated */ + @Deprecated public int treeSize() { return violationTree.size(); } @@ -425,7 +497,10 @@ public class Report implements Iterable { * The number of violations. * * @return number of violations. + * + * @deprecated Use {@link #getViolations()} */ + @Deprecated public int size() { return violations.size(); } @@ -435,7 +510,10 @@ public class Report implements Iterable { * in the end. * * @see #getElapsedTimeInMillis() + * + * @deprecated Not used, {@link #getElapsedTimeInMillis()} will be removed */ + @Deprecated public void start() { start = System.currentTimeMillis(); } @@ -444,11 +522,17 @@ public class Report implements Iterable { * Mark the end time of the report. This is ued to get the elapsed time. * * @see #getElapsedTimeInMillis() + * @deprecated Not used, {@link #getElapsedTimeInMillis()} will be removed */ + @Deprecated public void end() { end = System.currentTimeMillis(); } + /** + * @deprecated Unused + */ + @Deprecated public long getElapsedTimeInMillis() { return end - start; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java index f2d9a09b9b..92b1fea733 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java @@ -258,7 +258,12 @@ public interface Rule extends PropertySource { * should return a new instance on each call. * * @return the parser options + * + * @deprecated This was never implemented and will never be. PMD + * cannot parse files once per rule. Let this method assume + * its default by not overriding it. */ + @Deprecated ParserOptions getParserOptions(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java index f7132e7db9..76f30aae84 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java @@ -167,7 +167,11 @@ public class RuleContext { * null * @return true if the attribute was set, false * otherwise. + * + * @deprecated Stateful methods of the rule context will be removed. + * Their interaction with incremental analysis are unspecified. */ + @Deprecated public boolean setAttribute(String name, Object value) { if (name == null) { throw new IllegalArgumentException("Parameter 'name' cannot be null."); @@ -194,7 +198,11 @@ public class RuleContext { * The attribute name. * @return The current attribute value, or null if the * attribute does not exist. + * + * @deprecated Stateful methods of the rule context will be removed. + * Their interaction with incremental analysis are unspecified. */ + @Deprecated public Object getAttribute(String name) { return this.attributes.get(name); } @@ -215,7 +223,11 @@ public class RuleContext { * The attribute name. * @return The current attribute value, or null if the * attribute does not exist. + * + * @deprecated Stateful methods of the rule context will be removed. + * Their interaction with incremental analysis are unspecified. */ + @Deprecated public Object removeAttribute(String name) { return this.attributes.remove(name); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java index 2634c0a4ba..e1057c9522 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java @@ -8,7 +8,10 @@ package net.sourceforge.pmd.lang; * This is a generic implementation of the Parser interface. * * @see Parser + * + * @deprecated This will become useless in PMD 7. Implement or use {@link Parser} directly */ +@Deprecated public abstract class AbstractParser implements Parser { protected final ParserOptions parserOptions; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/DataFlowHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/DataFlowHandler.java index b7c7dfab05..9b9d3bba48 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/DataFlowHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/DataFlowHandler.java @@ -6,16 +6,14 @@ package net.sourceforge.pmd.lang; import java.util.List; -import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.dfa.DataFlowNode; /** - * @deprecated This is internal API + * @deprecated See {@link DataFlowNode} */ @Deprecated -@InternalApi public interface DataFlowHandler { DataFlowHandler DUMMY = new DataFlowHandler() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java index 77c18e0a9b..1b9574e687 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java @@ -21,9 +21,13 @@ import net.sourceforge.pmd.lang.ast.RootNode; * @author Pieter_Van_Raemdonck - Application Engineers NV/SA - www.ae.be */ public interface Parser { + /** * Get the ParserOptions used by this Parser. + * + * @deprecated Parser options should be a parameter to {@link #parse(String, Reader)} */ + @Deprecated ParserOptions getParserOptions(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/AbstractDataFlowNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/AbstractDataFlowNode.java index da66a63fc1..190f742850 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/AbstractDataFlowNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/AbstractDataFlowNode.java @@ -17,7 +17,9 @@ import net.sourceforge.pmd.util.DataMap.SimpleDataKey; * Each data flow contains a set of DataFlowNodes. * * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public abstract class AbstractDataFlowNode implements DataFlowNode { static final SimpleDataKey DATAFLOW_KEY = DataMap.simpleDataKey("dataflow.cache"); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/DataFlowNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/DataFlowNode.java index c0c3219187..7bf549e6a8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/DataFlowNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/DataFlowNode.java @@ -10,6 +10,12 @@ import java.util.List; import net.sourceforge.pmd.lang.ast.Node; +/** + * @deprecated The data flow codebase will be removed in PMD 7. + * The feature is unreliable, hard to use, and the implementation is + * unmaintainable. See https://github.com/pmd/pmd/issues/2647 + */ +@Deprecated public interface DataFlowNode { List getVariableAccess(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Linker.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Linker.java index f3601bdfe4..f05e2c13df 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Linker.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Linker.java @@ -13,7 +13,9 @@ import net.sourceforge.pmd.lang.ast.Node; /** * @author raik Links data flow nodes to each other. + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class Linker { private static final Logger LOGGER = Logger.getLogger(Linker.class.getName()); private static final String CLASS_NAME = Linker.class.getCanonicalName(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/LinkerException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/LinkerException.java index a1300d7f03..6b82681b61 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/LinkerException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/LinkerException.java @@ -6,7 +6,9 @@ package net.sourceforge.pmd.lang.dfa; /** * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class LinkerException extends Exception { private static final long serialVersionUID = 3238380880636634352L; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/NodeType.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/NodeType.java index 458bc11aa8..e19d9989da 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/NodeType.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/NodeType.java @@ -8,7 +8,9 @@ package net.sourceforge.pmd.lang.dfa; * Represents the type (DFA-wise) of a DataFlowNode. * * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public enum NodeType { ROOT, diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceChecker.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceChecker.java index 0c6942a4fa..b3065b2a24 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceChecker.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceChecker.java @@ -19,7 +19,9 @@ import java.util.logging.Logger; *

* * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class SequenceChecker { private static final Logger LOGGER = Logger.getLogger(SequenceChecker.class.getName()); private static Status root; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceException.java index fbcda58d9f..b54a2084ff 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceException.java @@ -6,7 +6,9 @@ package net.sourceforge.pmd.lang.dfa; /** * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class SequenceException extends Exception { private static final long serialVersionUID = -3271242247181888687L; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StackObject.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StackObject.java index 271e8984fb..0201a9d2ef 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StackObject.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StackObject.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd.lang.dfa; +/** + * @deprecated See {@link DataFlowNode} + */ +@Deprecated public class StackObject { private NodeType type; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StartOrEndDataFlowNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StartOrEndDataFlowNode.java index 0eb7f33f98..bc5d1ab70a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StartOrEndDataFlowNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StartOrEndDataFlowNode.java @@ -6,6 +6,11 @@ package net.sourceforge.pmd.lang.dfa; import java.util.List; +/** + * + * @deprecated See {@link DataFlowNode} + */ +@Deprecated public class StartOrEndDataFlowNode extends AbstractDataFlowNode { private boolean isStartNode; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Structure.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Structure.java index 188d1c2621..f4e531e1d3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Structure.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Structure.java @@ -18,7 +18,9 @@ import net.sourceforge.pmd.lang.ast.Node; * data flow and 2 stacks to link the nodes to each other. * * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class Structure { private static final Logger LOGGER = Logger.getLogger(Structure.class.getName()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccess.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccess.java index 2676138530..1bd09bc69f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccess.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccess.java @@ -7,7 +7,9 @@ package net.sourceforge.pmd.lang.dfa; /** * @since Created on 14.07.2004 * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class VariableAccess { public static final int DEFINITION = 0; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccessException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccessException.java index 792d2cd366..ed3e4b69d7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccessException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccessException.java @@ -7,7 +7,9 @@ package net.sourceforge.pmd.lang.dfa; /** * @since Created on 14.07.2004 * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class VariableAccessException extends Exception { private static final long serialVersionUID = 7385246683069003412L; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/CurrentPath.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/CurrentPath.java index 86827e2ff0..07fe39c934 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/CurrentPath.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/CurrentPath.java @@ -11,6 +11,11 @@ import java.util.List; import net.sourceforge.pmd.lang.dfa.DataFlowNode; import net.sourceforge.pmd.lang.dfa.NodeType; +/** + * + * @deprecated See {@link DataFlowNode} + */ +@Deprecated public class CurrentPath implements Iterable { private final List list; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/DAAPathFinder.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/DAAPathFinder.java index ae12cc02dd..ccc7e08090 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/DAAPathFinder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/DAAPathFinder.java @@ -15,7 +15,9 @@ import net.sourceforge.pmd.lang.dfa.NodeType; * * @author raik * @since Created on 09.08.2004 + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class DAAPathFinder { private static final int MAX_PATHS = 5000; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/Executable.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/Executable.java index fb75065c1a..3a56747ff2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/Executable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/Executable.java @@ -4,12 +4,17 @@ package net.sourceforge.pmd.lang.dfa.pathfinder; +import net.sourceforge.pmd.lang.dfa.DataFlowNode; + /** * Will be executed if PathFinder finds a path. * * @author raik * @since Created on 09.08.2004 + * + * @deprecated See {@link DataFlowNode} */ +@Deprecated public interface Executable { void execute(CurrentPath path); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/PathElement.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/PathElement.java index 0bd6ebff9e..1fb3dc0000 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/PathElement.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/PathElement.java @@ -6,6 +6,11 @@ package net.sourceforge.pmd.lang.dfa.pathfinder; import net.sourceforge.pmd.lang.dfa.DataFlowNode; +/** + * + * @deprecated See {@link DataFlowNode} + */ +@Deprecated public class PathElement { public int currentChild; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java index 761ce3355b..f3922cf93b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java @@ -228,6 +228,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul * @see Rule#setPriority(RulePriority) */ @Override + @Deprecated public ParserOptions getParserOptions() { return new ParserOptions(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java index fb6d8cf272..8f4881669f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java @@ -5,9 +5,15 @@ package net.sourceforge.pmd.renderers; import java.io.IOException; +import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.lang3.mutable.MutableInt; import net.sourceforge.pmd.PMD; +import net.sourceforge.pmd.Report; +import net.sourceforge.pmd.RuleViolation; /** * Renderer to a summarized HTML format. @@ -59,8 +65,8 @@ public class SummaryHTMLRenderer extends AbstractAccumulatingRenderer { writer.write("

Summary

" + PMD.EOL); writer.write("" + PMD.EOL); writer.write("" + PMD.EOL); - Map summary = report.getSummary(); - for (Map.Entry entry : summary.entrySet()) { + Map summary = getSummary(report); + for (Entry entry : summary.entrySet()) { String ruleName = entry.getKey(); writer.write("
Rule nameNumber of violations
"); writer.write(ruleName); @@ -70,4 +76,19 @@ public class SummaryHTMLRenderer extends AbstractAccumulatingRenderer { } writer.write("
" + PMD.EOL); } + + private static Map getSummary(Report report) { + Map summary = new HashMap<>(); + for (RuleViolation rv : report.getViolations()) { + String name = rv.getRule().getName(); + MutableInt count = summary.get(name); + if (count == null) { + count = new MutableInt(0); + summary.put(name, count); + } + count.increment(); + } + return summary; + } + } 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 690e56914b..8a8fbd079b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java @@ -506,8 +506,8 @@ public class RuleSetTest { context.setIgnoreExceptions(true); // the default ruleset.apply(makeCompilationUnits(), context); - assertTrue("Report should have processing errors", context.getReport().hasErrors()); - List errors = IteratorUtil.toList(context.getReport().errors()); + List errors = context.getReport().getProcessingErrors(); + assertTrue("Report should have processing errors", !errors.isEmpty()); assertEquals("Errors expected", 1, errors.size()); assertEquals("Wrong error message", "RuntimeException: Test exception while applying rule", errors.get(0).getMsg()); assertTrue("Should be a RuntimeException", errors.get(0).getError() instanceof RuntimeException); diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index e00f9c2a08..3964cd3580 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -14,14 +14,18 @@ - ${basedir}/src/test/resources + ${project.basedir}/src/test/resources - ${basedir}/src/test/java + ${project.basedir}/src/test/java **/testdata/**/*.java + + + ${project.basedir}/src/test/kotlin + ${basedir}/src/test/kotlin @@ -31,7 +35,7 @@ - ${basedir}/src/main/resources + ${project.basedir}/src/main/resources true diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/DataFlowFacade.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/DataFlowFacade.java index 4068b26e12..647cb98357 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/DataFlowFacade.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/DataFlowFacade.java @@ -5,6 +5,7 @@ package net.sourceforge.pmd.lang.java.dfa; import net.sourceforge.pmd.lang.DataFlowHandler; +import net.sourceforge.pmd.lang.dfa.DataFlowNode; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; @@ -15,7 +16,10 @@ import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter; * constructors. * * @author raik + * + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class DataFlowFacade extends JavaParserVisitorAdapter { private StatementAndBraceFinder sbf; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/JavaDataFlowNode.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/JavaDataFlowNode.java index 76c3f0a054..74ba8dcf94 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/JavaDataFlowNode.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/JavaDataFlowNode.java @@ -12,6 +12,10 @@ import net.sourceforge.pmd.lang.dfa.DataFlowNode; import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; +/** + * @deprecated See {@link DataFlowNode} + */ +@Deprecated public class JavaDataFlowNode extends AbstractDataFlowNode { public JavaDataFlowNode(List dataFlow, Node node) { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/StatementAndBraceFinder.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/StatementAndBraceFinder.java index a6c3fe2961..3857f5864d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/StatementAndBraceFinder.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/StatementAndBraceFinder.java @@ -9,6 +9,7 @@ import java.util.logging.Logger; import net.sourceforge.pmd.lang.DataFlowHandler; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.dfa.DataFlowNode; import net.sourceforge.pmd.lang.dfa.Linker; import net.sourceforge.pmd.lang.dfa.LinkerException; import net.sourceforge.pmd.lang.dfa.NodeType; @@ -43,7 +44,9 @@ import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter; * to link the nodes. * * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class StatementAndBraceFinder extends JavaParserVisitorAdapter { private static final Logger LOGGER = Logger.getLogger(StatementAndBraceFinder.class.getName()); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/VariableAccessVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/VariableAccessVisitor.java index 5cd37a67f2..58e5d5fdf9 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/VariableAccessVisitor.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/dfa/VariableAccessVisitor.java @@ -37,7 +37,9 @@ import net.sourceforge.pmd.lang.symboltable.NameOccurrence; * * @since Created on 14.07.2004 * @author raik, Sven Jacob + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class VariableAccessVisitor extends JavaParserVisitorAdapter { public void compute(ASTMethodDeclaration node) { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DataflowAnomalyAnalysisRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DataflowAnomalyAnalysisRule.java index 94373f6149..08e27365c4 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DataflowAnomalyAnalysisRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/DataflowAnomalyAnalysisRule.java @@ -24,6 +24,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; import net.sourceforge.pmd.lang.java.internal.JavaProcessingStage; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; +import net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedAssignmentRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; @@ -33,7 +34,10 @@ import net.sourceforge.pmd.properties.PropertyFactory; * * @author raik * @author Sven Jacob + * + * @deprecated Replaced by {@link UnusedAssignmentRule} */ +@Deprecated public class DataflowAnomalyAnalysisRule extends AbstractJavaRule implements Executable { private static final PropertyDescriptor MAX_PATH_DESCRIPTOR = PropertyFactory.intProperty("maxPaths") diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index ad1383d8ca..45a37d7af0 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -1159,12 +1159,16 @@ public class JuniorClass extends SeniorClass { since="3.9" message="Found ''{0}''-anomaly for variable ''{1}'' (lines ''{2}''-''{3}'')." class="net.sourceforge.pmd.lang.java.rule.errorprone.DataflowAnomalyAnalysisRule" + dfa="true" + deprecated="true" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dataflowanomalyanalysis"> The dataflow analysis tracks local definitions, undefinitions and references to variables on different paths on the data flow. From those informations there can be found various problems. 1. DU - Anomaly: A recently defined variable is undefined. These anomalies may appear in normal source text. 2. DD - Anomaly: A recently defined variable is redefined. This is ominous but don't have to be a bug. + +This rule is deprecated. Use {% rule "java/bestpractices/UnusedAssignment" %} in category bestpractices instead. 5 diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java index cbeb75e1a6..a7081ee721 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java @@ -16,7 +16,10 @@ import net.sourceforge.pmd.lang.ParserOptions; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; - +/** + * @deprecated Will be removed in 7.0 TODO refactor this into language versions? + */ +@Deprecated public class EcmascriptParserOptions extends ParserOptions { public enum Version { diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptXPathRule.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptXPathRule.java index 4b5ea7f839..86bac22a3f 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptXPathRule.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptXPathRule.java @@ -12,7 +12,10 @@ import net.sourceforge.pmd.lang.ecmascript.EcmascriptParserOptions.Version; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; - +/** + * @deprecated Parser options are deprecated, use {@link XPathRule} directly + */ +@Deprecated public class EcmascriptXPathRule extends XPathRule { private static final PropertyDescriptor RECORDING_COMMENTS_DESCRIPTOR = EcmascriptParserOptions.RECORDING_COMMENTS_DESCRIPTOR; diff --git a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.kt b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.kt index 3f0e783d82..6e27f75fe7 100644 --- a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.kt +++ b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.kt @@ -1,3 +1,7 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + package com.github.shyiko.ktlint.internal var x = 0 diff --git a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.txt b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.txt index 0ffae05d93..eddecf1f34 100644 --- a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.txt +++ b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.txt @@ -1,5 +1,5 @@ [Image] or [Truncated image[ Bcol Ecol -L3 +L7 [var] 1 4 [x] 5 6 [=] 7 8 diff --git a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/imports.kt b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/imports.kt index 3f284aa546..b35619b85b 100644 --- a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/imports.kt +++ b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/imports.kt @@ -1,3 +1,7 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + import java.math.BigInteger import java.math.BigInteger as BigInt import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm diff --git a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.kt b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.kt index 58bd764e53..065a7ffe9a 100644 --- a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.kt +++ b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.kt @@ -1,3 +1,7 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + package com.github.shyiko.ktlint.internal var x = 0 diff --git a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.txt b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.txt index a2f684d832..190142ecc8 100644 --- a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.txt +++ b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.txt @@ -1,10 +1,10 @@ [Image] or [Truncated image[ Bcol Ecol -L3 +L7 [var] 1 4 [x] 5 6 [=] 7 8 [0] 9 10 -L5 +L9 [fun] 1 4 [increment1] 5 15 [(] 15 16 @@ -14,7 +14,7 @@ L5 [+=] 22 24 [1] 25 26 [}] 27 28 -L6 +L10 [fun] 1 4 [increment2] 5 15 [(] 15 16 @@ -24,7 +24,7 @@ L6 [+=] 22 24 [1] 25 26 [}] 27 28 -L7 +L11 [fun] 1 4 [increment3] 5 15 [(] 15 16 @@ -34,7 +34,7 @@ L7 [+=] 22 24 [1] 25 26 [}] 27 28 -L8 +L12 [fun] 1 4 [increment4] 5 15 [(] 15 16 @@ -44,7 +44,7 @@ L8 [+=] 22 24 [1] 25 26 [}] 27 28 -L9 +L13 [fun] 1 4 [increment5] 5 15 [(] 15 16 @@ -54,7 +54,7 @@ L9 [+=] 22 24 [1] 25 26 [}] 27 28 -L10 +L14 [fun] 1 4 [increment6] 5 15 [(] 15 16 @@ -64,7 +64,7 @@ L10 [+=] 22 24 [1] 25 26 [}] 27 28 -L11 +L15 [fun] 1 4 [increment7] 5 15 [(] 15 16 @@ -74,7 +74,7 @@ L11 [+=] 22 24 [1] 25 26 [}] 27 28 -L12 +L16 [fun] 1 4 [increment8] 5 15 [(] 15 16 @@ -84,7 +84,7 @@ L12 [+=] 22 24 [1] 25 26 [}] 27 28 -L13 +L17 [fun] 1 4 [increment9] 5 15 [(] 15 16 @@ -94,7 +94,7 @@ L13 [+=] 22 24 [1] 25 26 [}] 27 28 -L14 +L18 [fun] 1 4 [increment10] 5 16 [(] 16 17 @@ -104,7 +104,7 @@ L14 [+=] 23 25 [1] 26 27 [}] 28 29 -L15 +L19 [fun] 1 4 [increment11] 5 16 [(] 16 17 @@ -114,7 +114,7 @@ L15 [+=] 23 25 [1] 26 27 [}] 28 29 -L16 +L20 [fun] 1 4 [increment12] 5 16 [(] 16 17 @@ -124,7 +124,7 @@ L16 [+=] 23 25 [1] 26 27 [}] 28 29 -L17 +L21 [fun] 1 4 [increment13] 5 16 [(] 16 17 @@ -134,7 +134,7 @@ L17 [+=] 23 25 [1] 26 27 [}] 28 29 -L18 +L22 [fun] 1 4 [increment14] 5 16 [(] 16 17 @@ -144,7 +144,7 @@ L18 [+=] 23 25 [1] 26 27 [}] 28 29 -L19 +L23 [fun] 1 4 [increment15] 5 16 [(] 16 17 @@ -154,7 +154,7 @@ L19 [+=] 23 25 [1] 26 27 [}] 28 29 -L20 +L24 [fun] 1 4 [increment16] 5 16 [(] 16 17 @@ -164,7 +164,7 @@ L20 [+=] 23 25 [1] 26 27 [}] 28 29 -L21 +L25 [fun] 1 4 [increment17] 5 16 [(] 16 17 @@ -174,7 +174,7 @@ L21 [+=] 23 25 [1] 26 27 [}] 28 29 -L22 +L26 [fun] 1 4 [increment18] 5 16 [(] 16 17 @@ -184,7 +184,7 @@ L22 [+=] 23 25 [1] 26 27 [}] 28 29 -L23 +L27 [fun] 1 4 [increment19] 5 16 [(] 16 17 @@ -194,7 +194,7 @@ L23 [+=] 23 25 [1] 26 27 [}] 28 29 -L24 +L28 [fun] 1 4 [increment20] 5 16 [(] 16 17 diff --git a/pmd-lang-test/pom.xml b/pmd-lang-test/pom.xml index 14293f98a1..7f85947472 100644 --- a/pmd-lang-test/pom.xml +++ b/pmd-lang-test/pom.xml @@ -18,6 +18,15 @@ ${project.basedir}/src/main/kotlin + + + ${project.basedir}/src/test/resources + + + + ${project.basedir}/src/main/kotlin + + diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLDataFlowHandler.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLDataFlowHandler.java index 8f61ed7a51..9d8c451bc5 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLDataFlowHandler.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLDataFlowHandler.java @@ -12,6 +12,10 @@ import net.sourceforge.pmd.lang.dfa.DataFlowNode; import net.sourceforge.pmd.lang.plsql.ast.ASTLabelledStatement; import net.sourceforge.pmd.lang.plsql.dfa.PLSQLDataFlowNode; +/** + * @deprecated See {@link DataFlowNode} + */ +@Deprecated public class PLSQLDataFlowHandler implements DataFlowHandler { @Override public DataFlowNode createDataFlowNode(List dataFlow, Node node) { diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/DataFlowFacade.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/DataFlowFacade.java index cec8d75ecd..58f515e099 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/DataFlowFacade.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/DataFlowFacade.java @@ -8,6 +8,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import net.sourceforge.pmd.lang.DataFlowHandler; +import net.sourceforge.pmd.lang.dfa.DataFlowNode; import net.sourceforge.pmd.lang.plsql.ast.ASTCompoundTriggerBlock; import net.sourceforge.pmd.lang.plsql.ast.ASTInput; import net.sourceforge.pmd.lang.plsql.ast.ASTMethodDeclaration; @@ -22,7 +23,9 @@ import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitorAdapter; * constructors. * * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class DataFlowFacade extends PLSQLParserVisitorAdapter { private static final String CLASS_PATH = DataFlowFacade.class.getCanonicalName(); private static final Logger LOGGER = Logger.getLogger(DataFlowFacade.class.getName()); diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/PLSQLDataFlowNode.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/PLSQLDataFlowNode.java index b1c4db193d..989b2973aa 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/PLSQLDataFlowNode.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/PLSQLDataFlowNode.java @@ -13,6 +13,10 @@ import net.sourceforge.pmd.lang.plsql.ast.ASTProgramUnit; import net.sourceforge.pmd.lang.plsql.ast.ASTTriggerUnit; import net.sourceforge.pmd.lang.plsql.ast.ASTTypeMethod; +/** + * @deprecated See {@link DataFlowNode} + */ +@Deprecated public class PLSQLDataFlowNode extends AbstractDataFlowNode { public PLSQLDataFlowNode(List dataFlow, Node node) { diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/StatementAndBraceFinder.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/StatementAndBraceFinder.java index 626bd85ac5..1a7daaffce 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/StatementAndBraceFinder.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/StatementAndBraceFinder.java @@ -10,6 +10,7 @@ import java.util.logging.Logger; import net.sourceforge.pmd.lang.DataFlowHandler; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.dfa.DataFlowNode; import net.sourceforge.pmd.lang.dfa.Linker; import net.sourceforge.pmd.lang.dfa.LinkerException; import net.sourceforge.pmd.lang.dfa.NodeType; @@ -53,7 +54,9 @@ import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitorAdapter; * to link the nodes. * * @author raik + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class StatementAndBraceFinder extends PLSQLParserVisitorAdapter { private static final Logger LOGGER = Logger.getLogger(StatementAndBraceFinder.class.getName()); diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/VariableAccessVisitor.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/VariableAccessVisitor.java index 459be495d4..4de3a98cec 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/VariableAccessVisitor.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/dfa/VariableAccessVisitor.java @@ -34,7 +34,9 @@ import net.sourceforge.pmd.lang.symboltable.NameOccurrence; * type of access of a variable. * * @author raik, Sven Jacob + * @deprecated See {@link DataFlowNode} */ +@Deprecated public class VariableAccessVisitor extends PLSQLParserVisitorAdapter { public void compute(ASTMethodDeclaration node) { diff --git a/pmd-scala-modules/pmd-scala-common/pom.xml b/pmd-scala-modules/pmd-scala-common/pom.xml index b40777dd21..60daacafd8 100644 --- a/pmd-scala-modules/pmd-scala-common/pom.xml +++ b/pmd-scala-modules/pmd-scala-common/pom.xml @@ -28,6 +28,10 @@ ../pmd-scala-common/src/test/resources + + + ../pmd-scala-common/src/test/kotlin + diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java index b53e4d83be..3f0a0dd349 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java @@ -15,48 +15,53 @@ import net.sourceforge.pmd.lang.ParserOptions; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +/** + * @deprecated Parser options will be removed with 7.0, these options + * will assume their default values then. + */ +@Deprecated public class XmlParserOptions extends ParserOptions { // Note: The UI order values are chosen to be larger than those built into // XPathRule. public static final PropertyDescriptor COALESCING_DESCRIPTOR = PropertyFactory.booleanProperty("coalescing") - .desc("Specifies that the XML parser convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node.") + .desc("deprecated!Specifies that the XML parser convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node.") .defaultValue(false) .build(); public static final PropertyDescriptor EXPAND_ENTITY_REFERENCES_DESCRIPTOR = PropertyFactory.booleanProperty("expandEntityReferences") - .desc("Specifies that the XML parser expand entity reference nodes.") + .desc("deprecated!Specifies that the XML parser expand entity reference nodes.") .defaultValue(true) .build(); public static final PropertyDescriptor IGNORING_COMMENTS_DESCRIPTOR = PropertyFactory.booleanProperty("ignoringComments") - .desc("Specifies that the XML parser ignore comments.") + .desc("deprecated!Specifies that the XML parser ignore comments.") .defaultValue(false) .build(); public static final PropertyDescriptor IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = PropertyFactory.booleanProperty("ignoringElementContentWhitespace") - .desc("Specifies that the XML parser eliminate whitespace in element content. Setting this to 'true' will force validating.") + .desc("deprecated!Specifies that the XML parser eliminate whitespace in element content. Setting this to 'true' will force validating.") .defaultValue(false) .build(); public static final PropertyDescriptor NAMESPACE_AWARE_DESCRIPTOR = PropertyFactory.booleanProperty("namespaceAware") - .desc("Specifies that the XML parser will provide support for XML namespaces.") + .desc("deprecated!Specifies that the XML parser will provide support for XML namespaces.") .defaultValue(true) .build(); public static final PropertyDescriptor VALIDATING_DESCRIPTOR = PropertyFactory.booleanProperty("validating") - .desc("Specifies that the XML parser will validate documents as they are parsed. This only works for DTDs.") + .desc("deprecated!Specifies that the XML parser will validate documents as they are parsed. This only works for DTDs.") .defaultValue(false) .build(); public static final PropertyDescriptor XINCLUDE_AWARE_DESCRIPTOR = PropertyFactory.booleanProperty("xincludeAware") - .desc("Specifies that the XML parser will process XInclude markup.") + .desc("deprecated!Specifies that the XML parser will process XInclude markup.") .defaultValue(false) .build(); public static final PropertyDescriptor LOOKUP_DESCRIPTOR_DTD = PropertyFactory.booleanProperty("xincludeAware") - .desc("Specifies whether XML parser will attempt to lookup the DTD.") + .desc("deprecated!Specifies whether XML parser will attempt to lookup the DTD.") .defaultValue(false) .build(); diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.java index 88f43d7e85..7aac852637 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.java @@ -23,12 +23,19 @@ import net.sourceforge.pmd.properties.PropertyDescriptor; */ public class AbstractXmlRule extends AbstractRule implements ImmutableLanguage { + @Deprecated public static final PropertyDescriptor COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor EXPAND_ENTITY_REFERENCES_DESCRIPTOR = XmlParserOptions.EXPAND_ENTITY_REFERENCES_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor IGNORING_COMMENTS_DESCRIPTOR = XmlParserOptions.IGNORING_COMMENTS_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = XmlParserOptions.IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor NAMESPACE_AWARE_DESCRIPTOR = XmlParserOptions.NAMESPACE_AWARE_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor VALIDATING_DESCRIPTOR = XmlParserOptions.VALIDATING_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor XINCLUDE_AWARE_DESCRIPTOR = XmlParserOptions.XINCLUDE_AWARE_DESCRIPTOR; public AbstractXmlRule() { diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java index 598ac6c56a..8dfca21a12 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java @@ -11,14 +11,25 @@ import net.sourceforge.pmd.lang.xml.XmlLanguageModule; import net.sourceforge.pmd.lang.xml.XmlParserOptions; import net.sourceforge.pmd.properties.PropertyDescriptor; +/** + * @deprecated Parser options are deprecated, use {@link XPathRule} directly + */ +@Deprecated public class XmlXPathRule extends XPathRule { + @Deprecated public static final PropertyDescriptor COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor EXPAND_ENTITY_REFERENCES_DESCRIPTOR = XmlParserOptions.EXPAND_ENTITY_REFERENCES_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor IGNORING_COMMENTS_DESCRIPTOR = XmlParserOptions.IGNORING_COMMENTS_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = XmlParserOptions.IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor NAMESPACE_AWARE_DESCRIPTOR = XmlParserOptions.NAMESPACE_AWARE_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor VALIDATING_DESCRIPTOR = XmlParserOptions.VALIDATING_DESCRIPTOR; + @Deprecated public static final PropertyDescriptor XINCLUDE_AWARE_DESCRIPTOR = XmlParserOptions.XINCLUDE_AWARE_DESCRIPTOR; public XmlXPathRule() { diff --git a/pom.xml b/pom.xml index bfada66b61..02b27aed02 100644 --- a/pom.xml +++ b/pom.xml @@ -117,6 +117,15 @@ + + + ${project.basedir}/src/test/resources + + + + ${project.basedir}/src/test/kotlin + + @@ -356,9 +365,10 @@ /net/sourceforge/pmd/pmd-checkstyle-suppressions.xml true + ${project.build.sourceDirectory} - **/*.properties,**/*.less + **/*.properties,**/*.less,**/*.kt