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

Autofix Ruby code style #64

Merged
merged 9 commits into from
Oct 24, 2017
Merged

Autofix Ruby code style #64

merged 9 commits into from
Oct 24, 2017

Conversation

paulgoetze
Copy link
Contributor

Fixes #63.

Using the added config to autocorrect the code base with Rubocop.

Frozen String literal comment was ignored for now, because it let's the
test fail (String.strip! is used in installer).
urls = jars_lock_from_class_loader
if urls and urls.size > 0
if !urls&.empty?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems wrong ;)

Copy link
Contributor Author

@paulgoetze paulgoetze Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkristian Yeah, right? ;) But it’s valid syntax since Ruby v2.3.0 and in JRuby since v9.1 (see "safe navigation operator" in jruby/jruby#3479). But I figure it will break for a Ruby language level below v2.3.0, so, I’ll change it back.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I did not know this syntax :) but let's stick to older syntax for older jruby

result << dep if dep && dep.scope == :runtime
File.read(file).each_line do |line|
dep = Dependency.new(line)
result << dep if dep&.scope == :runtime
Copy link
Contributor Author

@paulgoetze paulgoetze Oct 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same safe navigation operator syntax here (and below in the same file).

The save navigation operator (&.) is supported since Ruby v2.3.0
(JRuby v9.1.0.0, see jruby/jruby#3479).
So these autocorrection would fail for lower versions, like 9.0.5.0,
which is e.g. used by Travis CI.
@paulgoetze
Copy link
Contributor Author

Hm, looks like the <<~ operator for multiline comments was also introduced with Ruby 2.3.0. Reverting this as well...

Multiline HEREDOC was introduced in Ruby v2.3.0.
This allows to support JRuby with Ruby language level < v2.3.0
(JRuby < v9.1.0.0).
__dir__ was introduced in Ruby v2.0.0.
The latest Rubocop only works with Ruby language levels <=2.1.
If we wanted to support 1.9 we would have to use Rubocop v0.41.2.
I just disabled the Ruby >1.9 configs in .rubocop.yml in order to be
able to use a recent Rubocop version.
@paulgoetze
Copy link
Contributor Author

@mkristian I guess I covered all compatibility issues. Still, there are two settings (openJDK7 & 8 for GOAL=test) that fail with an error:

#<NameError: uninitialized constant Jopenssl::Version::BOUNCY_CASTLE_VERSION>

I can’t really find anything syntax-related hints. So, any ideas why these fail?

@mkristian
Copy link
Owner

yes, they are not related to the any syntax change. great that you took up the pain to make the patch working on older version of jruby as well. let me see if I can fix/work this bouncy-castle problem.

@mkristian mkristian merged commit 5cd9a74 into mkristian:master Oct 24, 2017
@paulgoetze paulgoetze deleted the fix/ruby-code-style branch December 17, 2017 18:16
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

Successfully merging this pull request may close these issues.

None yet

2 participants