Parentheses Inspections & Intentions
You know the “Unnecessary Parentheses” inspection? IntelliJ IDEA has had it for quite some time. And if you were a user of the InspectionGadgets plugin since before it was bundled with IntelliJ IDEA, you know it even longer. The inspection reports any parentheses which do not alter the default evaluation order of an expression. For example:
It’s a nice inspection, but it may be a little greedy. I write code not only for the compiler, but also to be read by me and other people. Sometimes the parentheses highlighted by the inspection do have a use other than modifying the order of evaluation: they serve to clarify the expression.
Often while reading some new or old code, I encounter complex expressions which are quite hard to understand, especially so when they don’t have any parentheses to clarify the evaluation order. Take for example the following (still quite simple) code:
The new “Add Clarifying Parentheses” intention can help understand complex expressions, by adding a few well placed parentheses. This intention is available in Demetra since build #5218. While strictly unnecessary, with parentheses understanding the expression takes a little less brainpower.
I think there should be an option in the “Unnecessary Parentheses” inspection to ignore clarifying parentheses, don’t you agree?
Subscribe to Blog updates
Thanks, we've got you!
Profile on the Fly With the IntelliJ Profiler
At JetBrains, we believe that profiling should be simple and accessible to all developers, regardless of their level of expertise. That’s why the IntelliJ Profiler puts ease of use and seamless integration at the forefront of its mission. In previous releases, we introduced a range of features to s…
History of Gradle Delegation Process in IntelliJ IDEA
Nowadays, a build tool is an essential part of any project, and IntelliJ IDEA integrates with the majority of them. Among the most popular build tools is Gradle. We’d like to give a brief historical overview of its integration with IntelliJ IDEA and the delegation process implemented inside the I…
How to Work With Protobuf-Maven Projects in IntelliJ IDEA
Protobuf, short for Protocol Buffers, is a language-agnostic data serialization format developed by Google. It is designed to efficiently and reliably serialize structured data to communicate between different systems and programming languages. Protobuf offers a compact binary representation of data…
Turbocharge Lombok annotations with IntelliJ IDEA
If you’re a professional Java developer, you probably use IntelliJ IDEA as your IDE and Lombok as the framework that handles the Java boilerplate. What you probably didn’t know is that not only do these 2 technologies work well on their own, but when combined, they’re even more efficient than when u…