Merge branch 'pr-2065'

This commit is contained in:
Andreas Dangel
2019-10-13 15:44:59 +02:00
4 changed files with 11 additions and 8 deletions

View File

@ -24,6 +24,10 @@ This is a {{ site.pmd.release_type }} release.
the builder needs to end with "Builder", e.g. `newBuilder()` or `initBuilder()` works. This change
fixes a couple of false positives.
* The Java rule {% rule "java/errorprone/DataflowAnomalyAnalysis" %} (`java-errorprone`) doesn't check for
UR anomalies (undefined and then referenced) anymore. These checks were all false-positives, since actual
UR occurrences would lead to compile errors.
### Fixed Issues
* core
@ -39,6 +43,7 @@ This is a {{ site.pmd.release_type }} release.
* [#1912](https://github.com/pmd/pmd/issues/1912): \[java] Metrics not computed correctly with annotations
* java-errorprone
* [#336](https://github.com/pmd/pmd/issues/336): \[java] InvalidSlf4jMessageFormat applies to log4j2
* [#1636](https://github.com/pmd/pmd/issues/1636): \[java] Stop checking UR anomalies for DataflowAnomalyAnalysis
* doc
* [#2058](https://github.com/pmd/pmd/issues/2058): \[doc] CLI reference for `-norulesetcompatibility` shows a boolean default value
@ -80,6 +85,7 @@ This is a {{ site.pmd.release_type }} release.
* [#2012](https://github.com/pmd/pmd/pull/2012): \[java] Fixes 336, slf4j log4j2 support - [Mark Hall](https://github.com/markhall82)
* [#2032](https://github.com/pmd/pmd/pull/2032): \[core] Allow adding SourceCode directly into CPD - [Nathan Braun](https://github.com/nbraun-Google)
* [#2047](https://github.com/pmd/pmd/pull/2047): \[java] Fix computation of metrics with annotations - [Andi](https://github.com/andipabst)
* [#2065](https://github.com/pmd/pmd/pull/2065): \[java] Stop checking UR anomalies - [Carlos Macasaet](https://github.com/l0s)
{% endtocmaker %}

View File

@ -131,8 +131,6 @@ public class DataflowAnomalyAnalysisRule extends AbstractJavaRule implements Exe
if (va.accessTypeMatches(u.accessType) && va.isDefinition()) { // DD
addDaaViolation(rc, lastNode, "DD", va.getVariableName(), startLine, endLine);
} else if (u.accessType == VariableAccess.UNDEFINITION && va.isReference()) { // UR
addDaaViolation(rc, lastNode, "UR", va.getVariableName(), startLine, endLine);
} else if (u.accessType == VariableAccess.DEFINITION && va.isUndefinition()) { // DU
addDaaViolation(rc, firstNode, "DU", va.getVariableName(), startLine, endLine);
}

View File

@ -1120,9 +1120,8 @@ public class JuniorClass extends SeniorClass {
<description>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.
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.
</description>
<priority>5</priority>
<example>

View File

@ -50,7 +50,7 @@ public class Foo {
<description><![CDATA[
UR anomaly
]]></description>
<expected-problems>1</expected-problems>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
void bar() {
@ -80,8 +80,8 @@ public class Foo {
<test-code>
<description>#1393 PMD hanging during DataflowAnomalyAnalysis</description>
<!-- Note: due to https://sourceforge.net/p/pmd/bugs/1383/ the 6 problems are false positives! -->
<expected-problems>6</expected-problems>
<!-- Note: due to https://sourceforge.net/p/pmd/bugs/1383/ the 3 problems are false positives! -->
<expected-problems>3</expected-problems>
<code><![CDATA[
public class LoopTest {
public static void main(String[] args) {