rspec/rules/S3340/java/rule.adoc

60 lines
1.4 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
For optimal code readability, annotation arguments should be specified in the same order that they were declared in the annotation definition.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
@interface Pet {
String name();
String surname();
}
@Pet(surname ="", name="") // Noncompliant
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
@interface Pet {
String name();
String surname();
}
@Pet(name ="", surname="") // Compliant
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Reorder these annotation arguments to match their order of declaration.
'''
== Comments And Links
(visible only on this page)
=== on 1 Sep 2015, 12:30:47 Ann Campbell wrote:
In my editing, [~nicolas.peru], I haven't filled in a message. It's unclear to me whether you want to raise an issue per argument or an issue per annotation. So I've left that to you to fill in. :-)
=== on 23 Sep 2015, 13:34:36 Nicolas Peru wrote:
\[~ann.campbell.2] can you review message and mark as complete if it is ok for you ?
=== on 28 Sep 2015, 18:07:53 Ann Campbell wrote:
done [~nicolas.peru]
=== on 1 Oct 2019, 11:32:16 Michael Gumowski wrote:
This rule is deprecated, without alternative. Nothing in JVMLS, or JLS, guarantees that order of annotation members will be preserved once compiled. See SONARJAVA-3194 for more details.
endif::env-github,rspecator-view[]