Skip to content

Issue #15003: Add new input file for pattern syntax in UnnecessaryPar…#15250

Merged
nrmancuso merged 1 commit into
checkstyle:masterfrom
checkstyle-GSoC25:unnec-parens
Jul 15, 2024
Merged

Issue #15003: Add new input file for pattern syntax in UnnecessaryPar…#15250
nrmancuso merged 1 commit into
checkstyle:masterfrom
checkstyle-GSoC25:unnec-parens

Conversation

@mahfouz72

Copy link
Copy Markdown
Member

closes #15003

Comment on lines 21 to +29
boolean result = (o instanceof String a) ?
(o instanceof String x) : (!(o instanceof String y));

boolean f = (o instanceof String x);
// violation above, 'Unnecessary parentheses around assignment right-hand side.'

boolean b = (!(o instanceof Rectangle(_, _)));
// violation above, 'Unnecessary parentheses around assignment right-hand side.'
boolean c = !(o instanceof Rectangle(_, _));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Given these new examples, shouldn't we have 2 violations on line 22 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, please open an issue for us to explore this more

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@nrmancuso nrmancuso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Add Check Support for Java 21 Record Pattern Syntax : UnnecessaryParenthesesCheck

2 participants