Underlined variables.

Answered

Recently noticed that in some situations, there is an emphasis on variables. Perhaps this appeared after updating to version 2018.2.
I did not notice this before. What is it and can it be turned off? And is it worth it?

 

IntelliJ IDEA 2018.2 (Community Edition)
Build #IC-182.3684.101, built on July 24, 2018
JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

15 comments
Comment actions Permalink

This is an interesting new code quality feature, but it seems to operate differently from the normal code warnings.

IntelliJ doesn't display a clickable light bulb to the left offering the option of disabling the warning for the variable / method / class level.

Can I change something in my config to enable that optional suppression?

If not, is there a @SuppressWarnings() label that I can employ manually?

Thanks

0
Comment actions Permalink

Hello Adam,

Actually it's not an inspection. Do you need to completely disable underlining?

 

0
Comment actions Permalink

OK. Are you saying that if it's not an inspection, I can't disable it in the code for the one or two situations where I don't want to see it, as I would for any of inspection? 

I don't want to disable it completely.

However where I'm really concerned about variable re-assignment, I just make the variable final. 

1
Comment actions Permalink

Yse, it's not possible to suppress it for custom place in code.

0
Comment actions Permalink

I guess I'll disable it then. I've got too many variables in my code that are, well, variable! 

3
Comment actions Permalink

To be honest, this is a very unwelcome feature... Could you guys disable it by default?

It will make `board[i][i]` looks like `board[i][j]` during when looping a 2d array. It took me 38 minutes to debug during leetcode contest. 

 

1
Comment actions Permalink

Let me put more comments on this feature. If a developer doesn't want a variable to be reassigned, I will use final keyword to enforce it. It's a compiler error, which is safer and more effective. You can also use const in c++, but c# doesn't have this feature....

A underscore warning is really unnecessary.

However, I do like Intellij. 

2
Comment actions Permalink

Thanks for your feedback, I've submitted a usability problem you can vote for: https://youtrack.jetbrains.com/issue/IDEA-207835.

1
Comment actions Permalink

Thank you, Serge.  This has been bothering me for months.  If anyone else ends up here trying to disable this anti-feature, please go vote for the issue above.  I suggested just changing it to an inspection which I can't imagine anyone would have a problem with.

Now I'll go disable it.

1
Comment actions Permalink

Been trying to hunt down the issue regarding that underline.

Hope this gets turned off by default too.

1
Comment actions Permalink

Phew, at least you can turn it off. :)

1
Comment actions Permalink

In Java, it might be useful for parameters, for a control variable in the for loop this is just ridiculous. I am turning this off.

1
Comment actions Permalink

There is black dotted underlining happening that does not relate to static parameters.  For example, I am calling a java static function from groovy and the function name is underlined.  This feature should be disabled until a "what am I thinking?" addition is added at least pointing to what is triggering the underline even if there is no code correction.  The other annoying thing about this is it looks very similar to the "can't find declaration" notification, which is something that we shouldn't ignore.  In the original example, control click enters the function, so it is obviously either an internal glitch or something different.

1
Comment actions Permalink

Jeff,

Any inspection could be disabled by hovering on the underlined word and clicking the light bulb. See https://i.imgur.com/7MvDCeD.png

This post is about reassigned local variables. So, If your question is not related to reassigned local variables, it is better to create a new post. 

Thank you. 

0

Please sign in to leave a comment.