Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Jruby 18.104.22.168 how to set Rubocop TargetRubyVersion #4813
I am in doubt about jruby and MRI compatibility on a project where we are using Rubocop to lint the code.
Also there are very few tests in that specific project, and I am worried that Rubocop autofixes could potentially make breaking changes.
My rubocop config is now:
Is this correct?
A little more background: I recently saw rubocop autofix suggestions for a few new cops, and I was thinking about if these changes were breaking behaviour. Here is an example:
@jesperronn does it make the same recommendation when run from MRI? I guess I would try against both and see if different stuff is recommended. I think that conversion will work (and is an icky suggestion IMHO -- ! with &. is super confusing to me) . I tried this and both JRuby and MRI works:
[" ", "d"].each do |s| ENV["LAWS"] = s ret = if ENV["LAWS"] && !ENV["LAWS"].match(/\A\s*\z/) puts "old true" end p ret ret = if !ENV["LAWS"]&.match(/\A\s*\z/) puts "new true" end p ret end
@olleolleolle thanks for sharing the compatibility table. Really helpful, also when updating.
A final thought could be to add in a future version, help for rubocop so that you would actually trigger s specific TargetRubyVersion based on the compatibility table.
That way, you could write (in .rubocop.yml):
and it could (behind the scenes) translate it into mri 2.3
(I know this is not a feature request for this project, so closing the thread here :)