Magic digital sonar violation on JPA annotation
•
Java
We are using sonar to manage our code quality I have problems with the violation of "magic number" in JPA notes, such as:
@NotNull @Size(min = 1,max = 300) @Column(name = "NAME")
Is this a real violation of annotation?
If not, how do we deal with this sonar violation?
Solution
If this number appears in the comment, the magic number violation cannot be understood With all due respect, this is a false positive. You can deal with it in two ways
public final class MAGICNUMBER { public static final int L8000 = 8000; public static final int L300 = 300;
}
Then you can use it in your class
@NotNull @Size(min = 1,max = MAGICNUMBER.L300) @Column(name = "NAME")
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码