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

Issue #12486: NoWhitespaceAfter shouldn't check synchronized method #12487

Merged
merged 3 commits into from Dec 10, 2022

Conversation

nrmancuso
Copy link
Member

@nrmancuso nrmancuso commented Dec 2, 2022

@nrmancuso nrmancuso force-pushed the issue-12486 branch 2 times, most recently from 88852dc to a82a5b4 Compare December 2, 2022 05:09
@nrmancuso nrmancuso self-assigned this Dec 2, 2022
@nrmancuso nrmancuso changed the title Issue 12486 Issue #12486: NoWhitespaceAfter shouldn't check synchronized method Dec 2, 2022
@nrmancuso
Copy link
Member Author

Github, generate report

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2022

https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/a82a5b4_2022131510/reports/diff/index.html

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
Copy link
Member Author

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
Copy link
Member Author

@nrmancuso nrmancuso Dec 2, 2022

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

class InputNoWhitespaceAfterTestSynchronized {
void method2()
{
synchronized(this) {
}
}
public void synchronized_() {
synchronized(this) {}
synchronized
(this) {}
synchronized (this) {} // violation
}
}

@nrmancuso nrmancuso marked this pull request as ready for review December 2, 2022 16:43
@nrmancuso nrmancuso assigned strkkk and unassigned nrmancuso Dec 2, 2022
@strkkk strkkk assigned romani and unassigned strkkk Dec 5, 2022
@romani romani assigned rnveach and unassigned romani Dec 6, 2022
@rnveach rnveach assigned romani and unassigned rnveach Dec 6, 2022
Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nrmancuso nrmancuso force-pushed the issue-12486 branch 3 times, most recently from f1bbb8f to c291a50 Compare December 7, 2022 16:01
@checkstyle checkstyle deleted a comment from github-actions bot Dec 7, 2022
@nrmancuso
Copy link
Member Author

Github, generate site

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It

@nrmancuso
Copy link
Member Author

Github, generate site

@romani romani merged commit 5bacbd6 into checkstyle:master Dec 10, 2022
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

Successfully merging this pull request may close these issues.

NoWhitespaceAfter false positive on synchronized method
4 participants