Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rubocop >= 0.53.0 #33

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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