Skip to content

Commit

Permalink
[java][doc] AvoidAssertAsIdentifier and AvoidEnumAsIdentifier - clari…
Browse files Browse the repository at this point in the history
…fy use case

Fixes pmd#4164
adangel committed Dec 19, 2022
1 parent 47128c8 commit 2cdef85
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/pages/release_notes.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@ This is a {{ site.pmd.release_type }} release.
### New and noteworthy

### Fixed Issues
* java-errorprone
* [#4164](https://github.com/pmd/pmd/issues/4164): \[java]\[doc] AvoidAssertAsIdentifier and AvoidEnumAsIdentifier - clarify use case

### API Changes

14 changes: 12 additions & 2 deletions pmd-java/src/main/resources/category/java/errorprone.xml
Original file line number Diff line number Diff line change
@@ -130,12 +130,17 @@ public class Violation {

<rule name="AvoidAssertAsIdentifier"
language="java"
maximumLanguageVersion="1.3"
since="3.4"
message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier">
<description>
Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
Use of the term `assert` will conflict with newer versions of Java since it is a reserved word.

Since Java 1.4, the token `assert` became a reserved word and using it as an identifier will
result in a compilation failure for Java 1.4 and later. This rule is therefore only useful
for old Java code before Java 1.4. It can be used to identify problematic code prior to a Java update.
</description>
<priority>2</priority>
<properties>
@@ -341,12 +346,17 @@ private void buz(String x) {}

<rule name="AvoidEnumAsIdentifier"
language="java"
maximumLanguageVersion="1.4"
since="3.4"
message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidenumasidentifier">
<description>
Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
Use of the term `enum` will conflict with newer versions of Java since it is a reserved word.

Since Java 1.5, the token `enum` became a reserved word and using it as an identifier will
result in a compilation failure for Java 1.5 and later. This rule is therefore only useful
for old Java code before Java 1.5. It can be used to identify problematic code prior to a Java update.
</description>
<priority>2</priority>
<properties>

0 comments on commit 2cdef85

Please sign in to comment.