$ global variable is unresoved reference in multi-file application

Have a ruby application with multiple files.  Have some $ global variables defined in one of the files.Reference is found in file where defined, but in all other files it is marked as unresolved reference.More of an anyonance then an issue, but is there some way to resolve this?
7 comments

Hi,

do you require the file which defines this vars in other files?

Regards, Oleg.

0
Of course I 'require' the file somewhere, the code does work.  I did take a quick look and the global $ variable reference is found in both the file where defined and in the file with the require statement for my global definition file  However, I have multiple files in the project where neither of the above is the case and the global variable is used, which is a valid usage model.  It would make sense, to me at least, for RubyMine to recognize a defined global $ variable in any project file as valid for a project scope when doing inspection.  It seems however that each file in the project is inspected independently for variable references
0

Hi,

I'm sure your code does work I just try to understand how the variable is supposed to become available in the particular script
to understand what RubyMine is missing.

Regards, Oleg.

P.S. we can not treat globals from one script as available in another for all cases because not everyone use them this way.

0
Take a project that has 4 files : main.rb, gblopt.rb and projectAcode.rb, projectA_unit1.rb  glbopt.rb defines global variable $foo  main.rb has require statement for gblopt.rb then require statement for projectAcode.rb  projectAcode.rb has require statement for projectA_unit1.rb  projectA_unit1.rb uses $foo, which is valid as it's a defined global variable   Since projectA_unit1.rb is a branch of main.rb require tree, I think RubyMine should be able resolve this reference
0

Hi,

you are right untill you will call projectA_unit1.rb directrly.  And RubyMine can not be sure that this is not the case :(
We have some assumptions for Rails apps, but not for a regular Ruby apps.

Oleg.

0
Since, as you say, RubyMine can't be certain how to resolve this, perhaps a future revision can add a 'suppress for variable' option to ruby inspection optionssuppressing for each statment is, IMO, too messy and time consuming, supressing for whole method/class/project is more then I want
0

We will think what we can do here.

Regards, Oleg.

0

Please sign in to leave a comment.