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
Issue #12486: NoWhitespaceAfter shouldn't check synchronized method #12487
Conversation
88852dc
to
a82a5b4
Compare
Github, generate report |
Did not go through all of the violations, but spot checked each project and it looks good. |
checkWhitespace = false; | ||
} | ||
return checkWhitespace; | ||
final boolean isSynchronizedMethod = ast.getType() == TokenTypes.LITERAL_SYNCHRONIZED |
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.
If synchronized
is used for a method, it is a modifier and therefore doesn't have children. If synchronized
is used in a synchronized statement, it has RPAREN, etc. as children.
private final Object lock = new Object(); | ||
|
||
void m1() { | ||
synchronized (lock) {} // violation |
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 bunch of variations on this can already be found in
Lines 11 to 24 in edcc686
class InputNoWhitespaceAfterTestSynchronized { | |
void method2() | |
{ | |
synchronized(this) { | |
} | |
} | |
public void synchronized_() { | |
synchronized(this) {} | |
synchronized | |
(this) {} | |
synchronized (this) {} // violation | |
} | |
} |
src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheck.java
Show resolved
Hide resolved
...tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterSynchronized.java
Show resolved
Hide resolved
a82a5b4
to
7377e1b
Compare
...tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterSynchronized.java
Outdated
Show resolved
Hide resolved
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.
f1bbb8f
to
c291a50
Compare
Github, generate site |
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.
It
src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheck.java
Outdated
Show resolved
Hide resolved
c291a50
to
6dac755
Compare
Github, generate site |
Closes #12486
Diff Regression config: https://gist.githubusercontent.com/nrmancuso/8875948c95d7ad62310b0ecd72c527ff/raw/df0c55c7670d01c7db1ba09bc8219c96c67b85c9/config.xml