checkstyle / checkstyle/checkstyle

Unnecessary Parentheses does not report violation on assignment within conditional

Open
#8,239 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
9.6k
Forks
4.2k
Avg merge
22h 23m
Merged PRs (30d)
232

Description

Check documentation: https://checkstyle.org/config_coding.html#UnnecessaryParentheses

```
C:\Users\Shashwat\Documents>cat config.xml




C:\Users\Shashwat\Documents>cat Test.java
public class Test
{
public static void main(String[] args) {
int n=2;
if(((n=n%2))==0) // warning expected
System.out.println("yes");
}
}

C:\Users\Shashwat\Documents>javac Test.java
// no output

C:\Users\Shashwat\Documents>java -jar checkstyle-8.31-all.jar -c config.xml Test.java
Starting audit...
Audit done.
```

---------------

There is a redundant set of parentheses on line 5 which should have been reported.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.