Skip to content

Commit

Permalink
restore <=2.2 linting support
Browse files Browse the repository at this point in the history
  • Loading branch information
searls committed Jul 9, 2019
1 parent ce1c34b commit 7ac5c3d
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ of Ruby (by inspecting `RUBY_VERSION` at runtime. But if you want to lock it
down, you can specify `ruby_version` in `.standard.yml`.

```
ruby_version: 2.3.0
ruby_version: 1.8.7
```
See
Expand Down
57 changes: 57 additions & 0 deletions config/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,63 @@ Performance/UnfreezeString:
Performance/UriDefaultParser:
Enabled: true

Performance/Caller:
Enabled: true

Performance/CompareWithBlock:
Enabled: true

Performance/Count:
Enabled: true

Performance/Detect:
Enabled: true

Performance/DoubleStartEndWith:
Enabled: true

Performance/EndWith:
Enabled: true

Performance/FixedSize:
Enabled: true

Performance/FlatMap:
Enabled: true

Performance/InefficientHashSearch:
Enabled: true

Performance/RangeInclude:
Enabled: true

Performance/RedundantMatch:
Enabled: true

Performance/RedundantMerge:
Enabled: true

Performance/RegexpMatch:
Enabled: true

Performance/ReverseEach:
Enabled: true

Performance/Size:
Enabled: true

Performance/StartWith:
Enabled: true

Performance/StringReplacement:
Enabled: true

Performance/UnfreezeString:
Enabled: true

Performance/UriDefaultParser:
Enabled: true

Rails/ActionFilter:
Enabled: true
EnforcedStyle: action
Expand Down
8 changes: 8 additions & 0 deletions config/ruby-1.8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
inherit_from: ./ruby-1.9.yml

Style/Lambda:
Enabled: false

Style/HashSyntax:
EnforcedStyle: hash_rockets

4 changes: 4 additions & 0 deletions config/ruby-1.9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
inherit_from: ./ruby-2.2.yml

Style/Encoding:
Enabled: false
8 changes: 8 additions & 0 deletions config/ruby-2.2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
inherit_from: ./base.yml

AllCops:
TargetRubyVersion: 2.3 # The oldest supported

Layout:
IndentHeredoc:
Enabled: false
4 changes: 0 additions & 4 deletions config/ruby-2.3.yml

This file was deleted.

8 changes: 6 additions & 2 deletions lib/standard/creates_config_store/assigns_rubocop_yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ def call(config_store, standard_config)
private

def rubocop_yaml_path(desired_version)
file_name = if desired_version < Gem::Version.new("2.4")
"ruby-2.3.yml"
file_name = if desired_version < Gem::Version.new("1.9")
"ruby-1.8.yml"
elsif desired_version < Gem::Version.new("2.0")
"ruby-1.9.yml"
elsif desired_version < Gem::Version.new("2.3")
"ruby-2.2.yml"
else
"base.yml"
end
Expand Down
10 changes: 9 additions & 1 deletion test/standard/builds_config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_decked_out_standard_yaml
), result.rubocop_options

expected_config = RuboCop::ConfigStore.new.tap do |config_store|
config_store.options_config = path("config/ruby-2.3.yml")
config_store.options_config = path("config/ruby-1.8.yml")
options_config = config_store.instance_variable_get("@options_config")
options_config["AllCops"]["Exclude"] |= [path("test/fixture/config/y/monkey/**/*")]
options_config["Fake/Lol"] = {"Exclude" => [path("test/fixture/config/y/neat/cool.rb")]}
Expand All @@ -67,6 +67,14 @@ def test_single_line_ignore
}, result.rubocop_config_store.for("").to_h
end

def test_19
result = @subject.call([], path("test/fixture/config/w"))

assert_equal DEFAULT_OPTIONS, result.rubocop_options

assert_equal config_store("test/fixture/config/w", "config/ruby-1.9.yml", 2.3), result.rubocop_config_store.for("").to_h
end

def test_specified_standard_yaml_overrides_local
result = @subject.call(["--config", "test/fixture/lol.standard.yml"], path("test/fixture/config/z"))

Expand Down

0 comments on commit 7ac5c3d

Please sign in to comment.