Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Infer TargetRubyVersion from .ruby_version file #195

Closed
blimmer opened this issue Mar 6, 2017 · 7 comments
Closed

Infer TargetRubyVersion from .ruby_version file #195

blimmer opened this issue Mar 6, 2017 · 7 comments

Comments

@blimmer
Copy link

blimmer commented Mar 6, 2017

Rubocop will default to reading the .ruby_version file if the TargetRubyVersion parameter is not present in your rubocop configuration. Here's the PR that implemented that behavior on the rubocop side.

It would be nice to add that behavior to this linter.

@maschwenk
Copy link
Contributor

maschwenk commented Mar 11, 2017

If you look at this PR (rubocop/rubocop#3261), they actually slightly modified the logic to make it so that if you define TargetRubyVersion, it'll still take precedence over .ruby-version. So, if you remove TargetRubyVersion from your .rubocop.yml you should see that this functionality already works, no new code required.

Let me know if it's working for you and I'll close the issue

@blimmer
Copy link
Author

blimmer commented Mar 11, 2017

I don't have TargetRubyVersion set in my rubocop config and I'm getting warnings about the safe navigation operator in my editor with a 2.3 ruby version file. When I run rubocop from the command line I don't get these errors.

@maschwenk
Copy link
Contributor

maschwenk commented Mar 11, 2017

Ahh I see what's happening. The problem is that the linter is running rubocop in the directory that the file being linted is located. So if you're linting a file in /specs and .ruby-version is in the root folder, it's running rubocop in /specs and therefore not finding the .ruby-version file. I will investigate further.

@blimmer
Copy link
Author

blimmer commented Mar 11, 2017

Ah sure that makes sense. Thanks for investigating!

@chrishough
Copy link

+1

@maschwenk
Copy link
Contributor

Please let me know if the fix above resolved your issue. Thanks!

@blimmer
Copy link
Author

blimmer commented Mar 19, 2017

@maschwenk looks great! thank you, this is going to help me out a ton!!

@blimmer blimmer closed this as completed Mar 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants