Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all redundant annotation warnings to -AwarnRedundantAnnotations #966

Open
thisisalexandercook opened this issue Nov 3, 2024 · 1 comment
Assignees

Comments

@thisisalexandercook
Copy link
Collaborator

Some redundant annotations are not captured under the -AwarnRedundantAnnotation flag and are instead (1) ignored or (2) have a unique error message as brought up in #928 (comment). This is well documented in the test file below:

/*
Check for redundant annotations in the following locations
(+ means that CF correctly reports an expected warning in this location,
- means that CF doesn't report an expected warning in this location, mostly because the compiler
doesn't store all explicit annotations in the underlying TypeMirrors):
1. Field +
2. Local Variable +
3. Parameter (includes Receiver Parameter) +
4. Exception Parameter +
5. Resource Variable +
6. Return Type +
7. Enum Constant - (cannot get explicit annotations here)
8. Constructor Result - (cannot get explicit annotations here)
9. Wildcard upper bound and lower bound - (cannot get explicit annotations here)
10. Type Parameter upper bound and lower bound - (cannot get explicit annotations here)
11. Type (class, interface or Enum) - (cannot get explicit annotations here)
12. TypeCast - (cannot get explicit annotations here)
13. InstanceOf - (cannot get explicit annotations here)
14. Object Creation - (cannot get explicit annotations here)
15. Component Type - (cannot get explicit annotations here)
*/

It would be nice to have all of these cases homogenized under the redundant.anno message to (1) clean up message.properties and (2) reduce amount of redundant warnings when flag is not used.

@wmdietl wmdietl changed the title Moving all redundant annotation warnings to -AwarnRedundantAnnotations Move all redundant annotation warnings to -AwarnRedundantAnnotations Nov 7, 2024
@wmdietl
Copy link
Member

wmdietl commented Nov 7, 2024

Nice suggestion!
Instead of just using redundant.anno we could use that as common prefix and then e.g. output redundant.anno.nullness.on.enum.
That will allow turning on the warnings with -AwarnRedundantAnnotations and suppressing with a specific error key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants