How to suppress "local variable 'foo' can be uninitialized"


There is a "local variable 'foo' can be uninitialized" if I write like


foo if boolean_value

p foo


How can I suppress this warning?

I couldn't find configuration for it.



+1 ... Rubymine is complaining the value may be uninitialized when using the safe navigation operator or wrapping the variable access inside an if statement.


Hello, sorry for delay! could you please attach the screenshots of the code with inspection? I'm unable to reproduce unfortunately.



I can't suppress it, too.



would it be possible to provide a code sample?



See the image below.

I know that the variable can be uninitialized. But I just want to hide the warning.


@Mrtmrt15xn, you can invoke intention action (Alt+Enter) and suppress that inspection for the method.


This is one of the few places I see this warning mentioned. I still get this warning on Ruby 3.2.0 with RubyMine 2023.2.1, and have been seeing it for several versions. It must be a configuration issue, or something specific to my rails project. I can't seem to supress it as mentioned before. Any idea what triggers this warning, and what I can do to get rid of it? 


Tyrellj please use Alt+Enter to invoke a popup on the variable with options to suppress the inspection. You can for example suppress it for the method or for a statement.


Please sign in to leave a comment.