Fix detection of ruby versions through the gemfile below 2.7 #13112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some things going on here:
If I have a gemspec saying
target_ruby_version ">= 2.6"
, what RuboCop will actually use is 2.7 because it is the default version. All versions prior are simply discarded, even if rubocop is able to provide accurate results for these older versions.There were tests for this but I believe that they lost what they actually were testing against during some refactor, somewhere here: #9515, #10629, and the PRs removing and reading analysis for older rubies.
This test for example used to check that the returned ruby version is 2.4 and not 2.3 which it didn't know how to analyse at one point (i.e. don't select versions below what we are currently supporting):
Now it checks that 2.7 is the returned version, which doesn't make much sense since older versions are able to be analysed.
For the
< 3.0.0
case, I think its ok to select the earliest version supported (currently 2.0). Selecting 2.7 (or whatever the default may be in the future) surely isn't the intention.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.