Merge branch '7.0.x' into java-grammar
This commit is contained in:
commit
766ab453b8
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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<RuleViolation> {
|
||||
// a bit
|
||||
private final List<RuleViolation> violations = new ArrayList<>();
|
||||
private final List<ThreadSafeReportListener> listeners = new ArrayList<>();
|
||||
private List<ProcessingError> errors;
|
||||
private List<ConfigurationError> configErrors;
|
||||
private final List<ProcessingError> errors = new ArrayList<>();
|
||||
private final List<ConfigurationError> configErrors = new ArrayList<>();
|
||||
private long start;
|
||||
private long end;
|
||||
private List<SuppressedViolation> suppressedRuleViolations = new ArrayList<>();
|
||||
private final List<SuppressedViolation> suppressedRuleViolations = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new, initialized, empty report for the given file name.
|
||||
@ -68,7 +68,10 @@ public class Report implements Iterable<RuleViolation> {
|
||||
|
||||
/**
|
||||
* 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<RuleViolation> {
|
||||
* 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<String, Integer> getCountSummary() {
|
||||
Map<String, Integer> summary = new HashMap<>();
|
||||
for (RuleViolation rv : violationTree) {
|
||||
@ -197,6 +203,10 @@ public class Report implements Iterable<RuleViolation> {
|
||||
return summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The {@link ReportTree} is deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public ReportTree getViolationTree() {
|
||||
return this.violationTree;
|
||||
}
|
||||
@ -206,7 +216,10 @@ public class Report implements Iterable<RuleViolation> {
|
||||
*
|
||||
* @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<String, Integer> getSummary() {
|
||||
Map<String, Integer> summary = new HashMap<>();
|
||||
for (RuleViolation rv : violations) {
|
||||
@ -230,6 +243,12 @@ public class Report implements Iterable<RuleViolation> {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the suppressed violations.
|
||||
*
|
||||
* @deprecated Use {@link #getSuppressedViolations()} (be aware, that that method returns an unmodifiable list)
|
||||
*/
|
||||
@Deprecated
|
||||
public List<SuppressedViolation> getSuppressedRuleViolations() {
|
||||
return suppressedRuleViolations;
|
||||
}
|
||||
@ -296,9 +315,6 @@ public class Report implements Iterable<RuleViolation> {
|
||||
* 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<RuleViolation> {
|
||||
* 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<RuleViolation> {
|
||||
* @see AbstractAccumulatingRenderer
|
||||
*/
|
||||
public void merge(Report r) {
|
||||
Iterator<ProcessingError> i = r.errors();
|
||||
while (i.hasNext()) {
|
||||
addError(i.next());
|
||||
}
|
||||
Iterator<ConfigurationError> ce = r.configErrors();
|
||||
while (ce.hasNext()) {
|
||||
addConfigError(ce.next());
|
||||
}
|
||||
Iterator<RuleViolation> 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<SuppressedViolation> 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<RuleViolation> {
|
||||
*
|
||||
* @return <code>true</code> if there were any processing errors,
|
||||
* <code>false</code> 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<RuleViolation> {
|
||||
*
|
||||
* @return <code>true</code> if there were any configuration errors,
|
||||
* <code>false</code> 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<RuleViolation> {
|
||||
*
|
||||
* @return <code>true</code> if no violations have been reported,
|
||||
* <code>false</code> 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<RuleViolation> {
|
||||
* Returns an iteration over the reported violations.
|
||||
*
|
||||
* @return an iterator
|
||||
*
|
||||
* @deprecated The {@link ReportTree} is deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public Iterator<RuleViolation> treeIterator() {
|
||||
return violationTree.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getViolations()}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Iterator<RuleViolation> iterator() {
|
||||
return violations.iterator();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable list of violations that were suppressed.
|
||||
*/
|
||||
public final List<SuppressedViolation> getSuppressedViolations() {
|
||||
return Collections.unmodifiableList(suppressedRuleViolations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable list of violations that have been
|
||||
* recorded until now. None of those violations were suppressed.
|
||||
*
|
||||
* <p>The violations list is sorted with {@link RuleViolationComparator#INSTANCE}.
|
||||
*/
|
||||
public final List<RuleViolation> getViolations() {
|
||||
return Collections.unmodifiableList(violations);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable list of processing errors that have been
|
||||
* recorded until now.
|
||||
*/
|
||||
public final List<ProcessingError> getProcessingErrors() {
|
||||
return Collections.unmodifiableList(errors);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable list of configuration errors that have
|
||||
* been recorded until now.
|
||||
*/
|
||||
public final List<ConfigurationError> getConfigurationErrors() {
|
||||
return Collections.unmodifiableList(configErrors);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an iterator of the reported processing errors.
|
||||
*
|
||||
* @return the iterator
|
||||
*
|
||||
* @deprecated Use {@link #getProcessingErrors()}
|
||||
*/
|
||||
@Deprecated
|
||||
public Iterator<ProcessingError> errors() {
|
||||
return errors == null ? Collections.<ProcessingError>emptyIterator() : errors.iterator();
|
||||
return getProcessingErrors().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator of the reported configuration errors.
|
||||
*
|
||||
* @return the iterator
|
||||
* @deprecated Use {@link #getConfigurationErrors()}
|
||||
*/
|
||||
@Deprecated
|
||||
public Iterator<ConfigurationError> configErrors() {
|
||||
return configErrors == null ? Collections.<ConfigurationError>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<RuleViolation> {
|
||||
* 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<RuleViolation> {
|
||||
* 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<RuleViolation> {
|
||||
* 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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
||||
|
@ -167,7 +167,11 @@ public class RuleContext {
|
||||
* <code>null</code>
|
||||
* @return <code>true</code> if the attribute was set, <code>false</code>
|
||||
* 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 <code>null</code> 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 <code>null</code> 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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
|
||||
|
||||
|
@ -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<DataFlowNode> DATAFLOW_KEY = DataMap.simpleDataKey("dataflow.cache");
|
||||
|
@ -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<VariableAccess> getVariableAccess();
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
|
||||
|
@ -19,7 +19,9 @@ import java.util.logging.Logger;
|
||||
* </p>
|
||||
*
|
||||
* @author raik
|
||||
* @deprecated See {@link DataFlowNode}
|
||||
*/
|
||||
@Deprecated
|
||||
public class SequenceChecker {
|
||||
private static final Logger LOGGER = Logger.getLogger(SequenceChecker.class.getName());
|
||||
private static Status root;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -4,6 +4,10 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.dfa;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link DataFlowNode}
|
||||
*/
|
||||
@Deprecated
|
||||
public class StackObject {
|
||||
|
||||
private NodeType type;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<DataFlowNode> {
|
||||
|
||||
private final List<DataFlowNode> list;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -228,6 +228,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul
|
||||
* @see Rule#setPriority(RulePriority)
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public ParserOptions getParserOptions() {
|
||||
return new ParserOptions();
|
||||
}
|
||||
|
@ -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("<center><h2>Summary</h2></center>" + PMD.EOL);
|
||||
writer.write("<table align=\"center\" cellspacing=\"0\" cellpadding=\"3\">" + PMD.EOL);
|
||||
writer.write("<tr><th>Rule name</th><th>Number of violations</th></tr>" + PMD.EOL);
|
||||
Map<String, Integer> summary = report.getSummary();
|
||||
for (Map.Entry<String, Integer> entry : summary.entrySet()) {
|
||||
Map<String, MutableInt> summary = getSummary(report);
|
||||
for (Entry<String, MutableInt> entry : summary.entrySet()) {
|
||||
String ruleName = entry.getKey();
|
||||
writer.write("<tr><td>");
|
||||
writer.write(ruleName);
|
||||
@ -70,4 +76,19 @@ public class SummaryHTMLRenderer extends AbstractAccumulatingRenderer {
|
||||
}
|
||||
writer.write("</table>" + PMD.EOL);
|
||||
}
|
||||
|
||||
private static Map<String, MutableInt> getSummary(Report report) {
|
||||
Map<String, MutableInt> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<ProcessingError> errors = IteratorUtil.toList(context.getReport().errors());
|
||||
List<ProcessingError> 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);
|
||||
|
@ -14,14 +14,18 @@
|
||||
<build>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/test/resources</directory>
|
||||
<directory>${project.basedir}/src/test/resources</directory>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/test/java</directory>
|
||||
<directory>${project.basedir}/src/test/java</directory>
|
||||
<includes>
|
||||
<include>**/testdata/**/*.java</include>
|
||||
</includes>
|
||||
</testResource>
|
||||
<!-- Adding kotlin files to test resources, so that checkstyle verifies the license header -->
|
||||
<testResource>
|
||||
<directory>${project.basedir}/src/test/kotlin</directory>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/test/kotlin</directory>
|
||||
<includes>
|
||||
@ -31,7 +35,7 @@
|
||||
</testResources>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
@ -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;
|
||||
|
@ -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<DataFlowNode> dataFlow, Node node) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user