
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
73 lines
1.4 KiB
Plaintext
73 lines
1.4 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Through Java's evolution keywords have been added. While code that uses those words as identifiers may be compilable under older versions of Java, it will not be under modern versions.
|
|
|
|
Following keywords are marked as invalid identifiers
|
|
|
|
[frame=all]
|
|
[cols="^1,^1"]
|
|
|===
|
|
|Keyword|Added
|
|
|
|
|``++_++``|9
|
|
|``++enum++``|5.0
|
|
|===
|
|
|
|
|
|
``++assert++`` and ``++strictfp++`` are another example of valid identifiers which became keywords in later versions, but are not supported by this rule.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
public void doSomething() {
|
|
int enum = 42; // Noncompliant
|
|
String _ = ""; // Noncompliant
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
public void doSomething() {
|
|
int magic = 42;
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Rename this variable to something other than "XXX", which is a Java keyword.
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== is duplicated by: S3859
|
|
|
|
=== relates to: S1669
|
|
|
|
=== relates to: S2306
|
|
|
|
=== is related to: S1527
|
|
|
|
=== is related to: S1189
|
|
|
|
=== on 8 Aug 2013, 16:32:59 Freddy Mallet wrote:
|
|
Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-280
|
|
|
|
=== on 13 Aug 2019, 10:18:47 Michael Gumowski wrote:
|
|
Removing reference to JIRA ticket in rule description. See SONARJAVA-285 and SONARJAVA-3179 for rule limitation.
|
|
|
|
endif::env-github,rspecator-view[]
|