In IntellyJ Idea I have installed SonarLint.
Code analizer says that I have to remove the "NamedEntityGraphs" wrapper from this annotation group. Here is my code:
@NamedEntityGraphs({
@NamedEntityGraph(
name = Application.ONLY_NAME,
attributeNodes = {
@NamedAttributeNode("foo"),
@NamedAttributeNode("bar")
}
),
@NamedEntityGraph(name = Application.FULL,
attributeNodes = {
@NamedAttributeNode("foo"),
@NamedAttributeNode("bar"),
@NamedAttributeNode("buzz")
}
)
})
public class SomeClass { ... }
Here are the arguments from SonarLint:
Annotation repetitions should not be wrapped Code smell, Minor, java:S1710
Before Java 8 if you needed to use multiple instances of the same annotation, they had to be wrapped in a container annotation. With Java 8, that's no longer necessary, allowing for cleaner, more readable code. Note that this rule is automatically disabled when the project's sonar.java.source is lower than 8.
Noncompliant Code Example
@SomeAnnotations({ // Noncompliant
@SomeAnnotation(..a..)
@SomeAnnotation(..b..)
@SomeAnnotation(..c..)
})
public class SomeClass { ... }
Compliant Solution
@SomeAnnotation(..a..)
@SomeAnnotation(..b..)
@SomeAnnotation(..c..)
public class SomeClass { ... }
QUESTION:
Does enybody know how to organize @NamedEntityGraphs in order to get complient code?