diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 5ca26c168e..b720241476 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -55,6 +55,8 @@ datetime field. * [#1845](https://github.com/pmd/pmd/issues/1845): \[java] Regression in MethodReturnsInternalArray not handling enums * java-design * [#1094](https://github.com/pmd/pmd/issues/1094): \[java] UseUtilityClass should be LombokAware +* java-errorprone + * [#1853](https://github.com/pmd/pmd/issues/1853): \[java] False positive for NonStaticInitializer in anonymous class * java-multithreading * [#1814](https://github.com/pmd/pmd/issues/1814): \[java] UnsynchronizedStaticFormatter documentation and implementation wrong * [#1815](https://github.com/pmd/pmd/issues/1815): \[java] False negative in UnsynchronizedStaticFormatter diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index 7e59da309f..19e5edc60a 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -2505,10 +2505,11 @@ confusing. 3 + diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonStaticInitializer.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonStaticInitializer.xml index cb058c6169..d66001be47 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonStaticInitializer.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonStaticInitializer.xml @@ -1,28 +1,101 @@ - + - + bad 1 + ]]> + - + static initializers are OK 0 + ]]> + + + Allowed in anonymous classes + 0 + + + + + Flag in local class + 1 + 3 + + + + + Allowed in enum constant + 1 + 7 + + + + + Flag in nested local class + 1 + 7 + + +