Skip to content

Commit

Permalink
Merge pull request #33 from rosscooperman/fix-rubocop-deprecation-war…
Browse files Browse the repository at this point in the history
…nings

Add support for rubocop >= 0.53.0
  • Loading branch information
bak1an authored Feb 12, 2019
2 parents d5400c9 + 59bb603 commit 945f1e8
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
38 changes: 38 additions & 0 deletions .rubocop_schema.53.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Configuration for Rubocop >= 0.53.0

Layout/AlignHash:
EnforcedColonStyle: 'key'
EnforcedHashRocketStyle: 'key'

Layout/ExtraSpacing:
# When true, allows most uses of extra spacing if the intent is to align
# things with the previous or next line, not counting empty lines or comment
# lines.
AllowForAlignment: false

Layout/SpaceBeforeFirstArg:
Enabled: true

Style/NumericLiterals:
Enabled: false

Metrics/BlockNesting:
Max: 2

Style/WordArray:
Enabled: false

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: 'comma'

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: 'comma'

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: 'comma'

Style/HashSyntax:
EnforcedStyle: 'ruby19'

Style/StringLiterals:
EnforcedStyle: double_quotes
12 changes: 9 additions & 3 deletions lib/fix_db_schema_conflicts/autocorrect_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ def self.load
end

def load
at_least_rubocop_49? ? '.rubocop_schema.49.yml' : '.rubocop_schema.yml'
if less_than_rubocop?(49)
'.rubocop_schema.yml'
elsif less_than_rubocop?(53)
'.rubocop_schema.49.yml'
else
'.rubocop_schema.53.yml'
end
end

private

def at_least_rubocop_49?
Gem::Version.new('0.49.0') <= Gem.loaded_specs['rubocop'].version
def less_than_rubocop?(ver)
Gem.loaded_specs['rubocop'].version < Gem::Version.new("0.#{ver}.0")
end
end
end
2 changes: 0 additions & 2 deletions spec/integration/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

def reference_db_schema
<<-RUBY
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
Expand Down
2 changes: 0 additions & 2 deletions spec/test-app/db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: UTF-8

# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/autocorrect_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
expect(autocorrect_config.load).to eq('.rubocop_schema.49.yml')
end

it 'for versions 0.53.0 and above' do
installed_rubocop(version: '0.53.0')

expect(autocorrect_config.load).to eq('.rubocop_schema.53.yml')
end

def installed_rubocop(version:)
allow(Gem).to receive_message_chain(:loaded_specs, :[], :version)
.and_return(Gem::Version.new(version))
Expand Down

0 comments on commit 945f1e8

Please sign in to comment.