question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Codacy: "Unnecessary parentheses around expression" warnings are too strict

See original GitHub issue

Recently, Codacy starts complaining about “unnecessary parentheses” used in boolean expressions, Things like e.g. shown in following screenshot:

image

The underlying rule is Checkstyle_UnnecessaryParentheses:

image

I agree that this is in general a useful rules, and I also agree that in the given examples the parenthesis shall be removed.

But for boolean expressions like the above I find the parentheses extremely helpful for understanding the logic behind them - although they are maybe not be strictly necessary because of operator precedence?

Would it be ok to “lighten” that rule?

And on a second note: if yes, how can I do that??? AFAICS Codacy uses our checkstyle rule file, but Jenkins does not complain about these things…

A third thing: I miss edit rights for Codacy, it always tells me I have to be “admin” to do something. Is there any way to change this?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
eddiemuccommented, Aug 6, 2021

In PR #11425 I see many other examples of “unnecessary parenthesis” which I frankly find quite useful for code readability.

What about just removing this rule completely from checkstyle?

0reactions
bekunocommented, Aug 9, 2021

Before we do it - a question raised to me - could we have a negative behavior without this rule?

If I’m not mistaken the worst that could happen would be some unnecessary parentheses, making the code less readable. But there should no functional impact (e. g. performance penalty), as the compiler removes those unnecessary parentheses. So no blocker from this side, AFAICS.

So it’s the same perception that I have. Then lets remove the entry for UnnecessaryParentheses.

I would leave the Checkstyle configuration on CI (for PR) as it is now. That means to not fail on severity" =“info”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Integration with ESLint JavaScript Linter - Codacy | Blog
A popular linter for the JavaScript community, ESL Lint is now supported by Codacy static analysis tool making it very easy to write...
Read more >
Add option to allow unnecessary paretheses for Boolean ...
I think adding parentheses around OR ( || ) clauses in a boolean expression containing AND && ) clauses makes the expression easier...
Read more >
code patterns – Codacy | Blog - RSSing.com
These rules relate to using strict mode. strict – controls location of Use Strict Directives. Variables. These rules have to do with variable...
Read more >
Why does codacy give `Unnecessary block` error for function ...
We are using codacy for static code analysis. On pushing a change to the js file, where we are declaring a function that...
Read more >
Java static code analysis: Redundant pairs of parentheses ...
Java static code analysis. Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your JAVA code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found