resources.report.rules.pmd.DataflowAnomalyAnalysis.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sanity4j Show documentation
Show all versions of sanity4j Show documentation
Sanity4J was created to simplify running multiple static code
analysis tools on the Java projects. It provides a single entry
point to run all the selected tools and produce a consolidated
report, which presents all findings in an easily accessible
manner.
The newest version!
DataflowAnomalyAnalysis
DataflowAnomalyAnalysis
aflowAnomalyAnalysis">DataflowAnomalyAnalysis
Since: PMD 3.9
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. UR - Anomaly: There is a reference to a variable that was not defined before. This is a bug and leads to an error.
2. DU - Anomaly: A recently defined variable is undefined. These anomalies may appear in normal source text.
3. DD - Anomaly: A recently defined variable is redefined. This is ominous but don't have to be a bug.
This rule is defined by the following Java class:
net.sourceforge.pmd.dfa.DaaRule
Example:
public class Foo {
public void foo() {
int buz = 5;
buz = 6; // redefinition of buz -> dd-anomaly
foo(buz);
buz = 2;
} // buz is undefined when leaving scope -> du-anomaly
}
This rule has the following properties:
Name Default value Description
maxviolations
100
The maximum number of violations per class.
maxpaths
1000
The maximum number of checked paths per method. A lower value will increase the performance of the rule but may decrease the number of found anomalies.