-
Notifications
You must be signed in to change notification settings - Fork 39
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
Exempt @RequestAttribute
from RequestMappingAnnotation
check
#189
Conversation
@RequestAttribute
from RequestMappingAnnotation
check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tnx @ddeya! And congrats on your first Error Prone Support PR 😄
I don't have the code checked out right now, but don't mind applying these changes myself later :)
isType(ANN_PACKAGE_PREFIX + "RequestParam"), | ||
isType(ANN_PACKAGE_PREFIX + "RequestAttribute"))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 Let's keep the list sorted :)
isType(ANN_PACKAGE_PREFIX + "RequestParam"), | |
isType(ANN_PACKAGE_PREFIX + "RequestAttribute"))), | |
isType(ANN_PACKAGE_PREFIX + "RequestAttribute"), | |
isType(ANN_PACKAGE_PREFIX + "RequestParam"))), |
" A properRequestParam(@RequestParam String param);", | ||
"", | ||
" @RequestMapping", | ||
" A properRequestAttribute(@RequestAttribute String param);", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then similarly here (also tweaked the parameter name):
" A properRequestParam(@RequestParam String param);", | |
"", | |
" @RequestMapping", | |
" A properRequestAttribute(@RequestAttribute String param);", | |
" A properRequestAttribute(@RequestAttribute String attribute);", | |
"", | |
" @RequestMapping", | |
" A properRequestParam(@RequestParam String param);", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied the suggestions.
Aha now I see @Stephan202 reviewed it as well 😅.
Anyway, thanks for opening a PR in error-prone-support
🚀🚀🚀 !
@@ -65,7 +65,8 @@ public final class RequestMappingAnnotation extends BugChecker implements Method | |||
isType(ANN_PACKAGE_PREFIX + "PathVariable"), | |||
isType(ANN_PACKAGE_PREFIX + "RequestBody"), | |||
isType(ANN_PACKAGE_PREFIX + "RequestHeader"), | |||
isType(ANN_PACKAGE_PREFIX + "RequestParam"))), | |||
isType(ANN_PACKAGE_PREFIX + "RequestParam"), | |||
isType(ANN_PACKAGE_PREFIX + "RequestAttribute"))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ Moving this up to retain sorting :).
@@ -56,6 +57,9 @@ void identification() { | |||
" A properRequestParam(@RequestParam String param);", | |||
"", | |||
" @RequestMapping", | |||
" A properRequestAttribute(@RequestAttribute String param);", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" A properRequestAttribute(@RequestAttribute String param);", | |
" A properRequestAttribute(@RequestAttribute String attribute);", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Also moving up to retain sorting 😄)
Suggested commit message:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see my sorting suggestions weren't correct. Tnx for doing the right thing @rickie 😄
(Tweaked the suggested commit message. Avoided "exemption" because the connotation doesn't quite match, I think. |
@Stephan202 @rickie Thanks both for the suggestions, have been a little busy since yesterday so I couldn't check earlier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Congrats @ddeya 💪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we didn't do it for the other annotations, but wouldn't it be more correct to verify that it's not triggered for any occurrence of @{Patch,Post, ...}Mapping
? Either way, not a blocker.
🚀 Nice! |
@nathankooij yeah, the test tries to assert a bit of everything, without enumerating the full Cartesian product 👍 |
Since it is a valid use case, we should allow this case and exempt @RequestAttribute from the RequestMappingAnnotation check.