Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recover Ruby 2.1 code analysis using
TargetRubyVersion: 2.1
Follow up #10632 (comment). Reverts part of #5990 and #6101. Only the Ruby version (2.1) to runtime should have been dropped, not code analysis. This PR makes Ruby 2.1 code analysis with `TargetRubyVersion: 2.1`. It aims to solve essentially the same problem as #10626, #10632, #10640, and #10644.
- Loading branch information
Showing
9 changed files
with
125 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#10662](https://github.com/rubocop/rubocop/pull/10662): Recover Ruby 2.1 code analysis using `TargetRubyVersion: 2.1`. ([@koic][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RuboCop::Cop::Lint::RedundantRequireStatement, :config do | ||
it "registers an offense and corrects when using `require 'enumerator'`" do | ||
expect_offense(<<~RUBY) | ||
require 'enumerator' | ||
^^^^^^^^^^^^^^^^^^^^ Remove unnecessary `require` statement. | ||
require 'uri' | ||
RUBY | ||
context 'target ruby version < 2.2', :ruby21 do | ||
it "does not registers an offense when using `require 'enumerator'`" do | ||
expect_no_offenses(<<~RUBY) | ||
require 'enumerator' | ||
RUBY | ||
end | ||
end | ||
|
||
context 'target ruby version >= 2.2', :ruby22 do | ||
it "registers an offense and corrects when using `require 'enumerator'`" do | ||
expect_offense(<<~RUBY) | ||
require 'enumerator' | ||
^^^^^^^^^^^^^^^^^^^^ Remove unnecessary `require` statement. | ||
require 'uri' | ||
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
require 'uri' | ||
RUBY | ||
expect_correction(<<~RUBY) | ||
require 'uri' | ||
RUBY | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters