"remove braces" intention?

Looks like JavaScript has it, but Java not?

0
9 comments

At one point Java had it too (I implemented it). Because many users found it annoying it was removed. For people never removing braces, the intention to remove braces popping up in every place was quite frustrating. Personally I would vote for removing the intention from JavaScript too.

Bas

0
Avatar
Permanently deleted user

Bas,

What I would like to have is an inspection which removes superfluous
braces but leaves clarifying braces as is. For example after some heavy
refactoring you could end with some code like this:

if ((((flag)) && (((a + b)) == 0))

Instead of removing all braces I would like to end with this:

if (flag && ((a + b) == 0))

Bas Leijdekkers wrote:

At one point Java had it too (I implemented it). Because many users found it annoying it was removed. For people never removing braces, the intention to remove braces popping up in every place was quite frustrating. Personally I would vote for removing the intention from JavaScript too.

Bas


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0

Martin,

Actually, the unnecessary parentheses inspection should already work like this, but I see it has a bug. Please submit a JIRA ticket and I will see if I can get a fix in 8.0.1.

Bas

0

http://www.jetbrains.net/jira/browse/IDEADEV-32886
Fixed, but in the next minor release after 8.0.1, not in 8.0.1 itself. Please test.

Bas

0
Avatar
Permanently deleted user

Hello Bas,

Works much better now, thanks!

There's one thing left. Currently there's no possibility to simplify
this code:

String s = ((((a + b)) == 0)) ? "a" : "b";

To this:

String s = ((a + b) == 0) ? "a" : "b";

IMHO if the second checkbox is set then you should ignore the outermost
pair of parenthesis, but you should warn on any additional one.


Bas Leijdekkers wrote:

http://www.jetbrains.net/jira/browse/IDEADEV-32886
Fixed, but in the next minor release after 8.0.1, not in 8.0.1 itself. Please test.

Bas


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0

Hello Martin,

This now fixed also. Thanks for the report.

Bas


There's one thing left. Currently there's no possibility to simplify
this code:

String s = ((((a + b)) == 0)) ? "a" : "b";

To this:

String s = ((a + b) == 0) ? "a" : "b";

IMHO if the second checkbox is set then you should ignore the outermost
pair of parenthesis, but you should warn on any additional one.


Bas Leijdekkers wrote:

http://www.jetbrains.net/jira/browse/IDEADEV-32886
Fixed, but in the next minor release after 8.0.1, not in 8.0.1 itself. Please test.

Bas


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

>

0
Avatar
Permanently deleted user

Thanks Bas, works like a charm!

Bas Leijdekkers wrote:

Hello Martin,

This now fixed also. Thanks for the report.

Bas

>>

>> There's one thing left. Currently there's no possibility to simplify
>> this code:
>>
>> String s = ((((a + b)) == 0)) ? "a" : "b";
>>
>> To this:
>>
>> String s = ((a + b) == 0) ? "a" : "b";
>>
>> IMHO if the second checkbox is set then you should ignore the outermost
>> pair of parenthesis, but you should warn on any additional one.
>>
>>
>> Bas Leijdekkers wrote:
>>> http://www.jetbrains.net/jira/browse/IDEADEV-32886
>>> Fixed, but in the next minor release after 8.0.1, not in 8.0.1 itself. Please test.
>>>
>>> Bas
>> --
>> Martin Fuhrer
>> Fuhrer Engineering AG
>> http://www.fuhrer.com
>>

--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0
Avatar
Permanently deleted user

Hi,

How about an option that removes all redundant parentheses? I'm really into minimalism of punctuation.


Randall Schulz

0
Avatar
Permanently deleted user

Just uncheck both 'ignore...' checkboxes and you should get what you want.


Hi,

How about an option that removes all redundant parentheses? I'm really into minimalism of punctuation.


Randall Schulz

0

Please sign in to leave a comment.