Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Jruby built-in global variables #466

Closed
phs opened this issue Sep 6, 2013 · 6 comments
Closed

Support Jruby built-in global variables #466

phs opened this issue Sep 6, 2013 · 6 comments

Comments

@phs
Copy link

phs commented Sep 6, 2013

The white list of global variables accepted by the global variable cop should either be configurable or include standard globals from jruby:

config/setup_load_paths.rb:13:1: C: Do not introduce global variables.
$CLASSPATH << File.expand_path('../../classes', __FILE__)
^^^^^^^^^^
@phs
Copy link
Author

phs commented Sep 6, 2013

As a workaround for rubocop noobs (like me), you can bracket the reference as so to get by:

# rubocop : disable AvoidGlobalVars
$CLASSPATH << File.expand_path('../../classes', __FILE__)
# rubocop : enable AvoidGlobalVars

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 8, 2013

Is there a list of the JRuby specific global vars somewhere?

@phs
Copy link
Author

phs commented Sep 8, 2013

Yea, I couldn't find one either. The only one I'm using is $CLASSPATH.

How about it, @headius?

@headius
Copy link

headius commented Sep 8, 2013

Hmm...I don't know if we have compiled a list, but there's not many. A quick scan of all "$..." strings in JRuby gave me this list:

$CLASSPATH = mutable JRuby-local classpath array
$JRUBY_VERSION = JRuby version
$JRUBY_REVISION = JRuby git revision
$ENV_JAVA = JVM properties as a Hash-like

When using BSF to script Java: $bsf

And when ant support is loaded: $project

We also define all the aliases in English.rb immediately at startup ($LOADED_FEATURES, etc).

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 9, 2013

Thanks, @headius! I hope someday MRI will follow your lead and also define the aliases by default.

@phs
Copy link
Author

phs commented Sep 10, 2013

Looks awesome, thanks! This might be a typo though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants