An annotation is given a value that is the default of that element anyway
What it finds
@Column(nullable = true) or @Autowired(required = true) repeat what the annotation says without arguments; the reader has to know the default to see that nothing is set.
Reported is an element set to its default value, for annotation types declared in this file and for a few well-known ones: required = true of Autowired and RequestParam, readOnly = false of Transactional, and nullable = true, unique = false, insertable = true and updatable = true of Column. The fix removes the element.
From the rule's source, default_annotation_argument.rs.
@interface Limit { int value() default 10; boolean strict() default false;}class Use { @Limit(value = 10)tx0 reports: default of the element int a; @Limit(value = 5, strict = false)tx0 reports: default of the element int b; @Autowired(required = true)tx0 reports: default of the element Object c;}@interface Autowired { boolean required() default true;} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:default-annotation-argument" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:default-annotation-argument] reason="..."tx0 explain tx0/java:default-annotation-argument shows the same in the terminal. Found a false positive? Report it.