Skip to content

Commit 945f1e8

Browse files
authored
Merge pull request #33 from rosscooperman/fix-rubocop-deprecation-warnings
Add support for rubocop >= 0.53.0
2 parents d5400c9 + 59bb603 commit 945f1e8

File tree

5 files changed

+53
-7
lines changed

5 files changed

+53
-7
lines changed

.rubocop_schema.53.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Configuration for Rubocop >= 0.53.0
2+
3+
Layout/AlignHash:
4+
EnforcedColonStyle: 'key'
5+
EnforcedHashRocketStyle: 'key'
6+
7+
Layout/ExtraSpacing:
8+
# When true, allows most uses of extra spacing if the intent is to align
9+
# things with the previous or next line, not counting empty lines or comment
10+
# lines.
11+
AllowForAlignment: false
12+
13+
Layout/SpaceBeforeFirstArg:
14+
Enabled: true
15+
16+
Style/NumericLiterals:
17+
Enabled: false
18+
19+
Metrics/BlockNesting:
20+
Max: 2
21+
22+
Style/WordArray:
23+
Enabled: false
24+
25+
Style/TrailingCommaInArrayLiteral:
26+
EnforcedStyleForMultiline: 'comma'
27+
28+
Style/TrailingCommaInHashLiteral:
29+
EnforcedStyleForMultiline: 'comma'
30+
31+
Style/TrailingCommaInArguments:
32+
EnforcedStyleForMultiline: 'comma'
33+
34+
Style/HashSyntax:
35+
EnforcedStyle: 'ruby19'
36+
37+
Style/StringLiterals:
38+
EnforcedStyle: double_quotes

lib/fix_db_schema_conflicts/autocorrect_configuration.rb

+9-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ def self.load
55
end
66

77
def load
8-
at_least_rubocop_49? ? '.rubocop_schema.49.yml' : '.rubocop_schema.yml'
8+
if less_than_rubocop?(49)
9+
'.rubocop_schema.yml'
10+
elsif less_than_rubocop?(53)
11+
'.rubocop_schema.49.yml'
12+
else
13+
'.rubocop_schema.53.yml'
14+
end
915
end
1016

1117
private
1218

13-
def at_least_rubocop_49?
14-
Gem::Version.new('0.49.0') <= Gem.loaded_specs['rubocop'].version
19+
def less_than_rubocop?(ver)
20+
Gem.loaded_specs['rubocop'].version < Gem::Version.new("0.#{ver}.0")
1521
end
1622
end
1723
end

spec/integration/integration_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
def reference_db_schema
2222
<<-RUBY
23-
# encoding: UTF-8
24-
2523
# This file is auto-generated from the current state of the database. Instead
2624
# of editing this file, please use the migrations feature of Active Record to
2725
# incrementally modify your database, and then regenerate this schema definition.

spec/test-app/db/schema.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
# This file is auto-generated from the current state of the database. Instead
42
# of editing this file, please use the migrations feature of Active Record to
53
# incrementally modify your database, and then regenerate this schema definition.

spec/unit/autocorrect_configuration_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
expect(autocorrect_config.load).to eq('.rubocop_schema.49.yml')
1717
end
1818

19+
it 'for versions 0.53.0 and above' do
20+
installed_rubocop(version: '0.53.0')
21+
22+
expect(autocorrect_config.load).to eq('.rubocop_schema.53.yml')
23+
end
24+
1925
def installed_rubocop(version:)
2026
allow(Gem).to receive_message_chain(:loaded_specs, :[], :version)
2127
.and_return(Gem::Version.new(version))

0 commit comments

Comments
 (0)