diff --git a/.rubocop_schema.53.yml b/.rubocop_schema.53.yml new file mode 100644 index 0000000..501ea86 --- /dev/null +++ b/.rubocop_schema.53.yml @@ -0,0 +1,38 @@ +# Configuration for Rubocop >= 0.49.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 diff --git a/lib/fix_db_schema_conflicts/autocorrect_configuration.rb b/lib/fix_db_schema_conflicts/autocorrect_configuration.rb index 94e80e6..b0fe12e 100644 --- a/lib/fix_db_schema_conflicts/autocorrect_configuration.rb +++ b/lib/fix_db_schema_conflicts/autocorrect_configuration.rb @@ -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_version?(49) + '.rubocop_schema.yml' + elsif less_than_rubocop_version?(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_version?(version) + Gem.loaded_specs['rubocop'].version < Gem::Version.new("0.#{version}.0") end end end diff --git a/spec/integration/integration_spec.rb b/spec/integration/integration_spec.rb index 98bc314..20f1885 100644 --- a/spec/integration/integration_spec.rb +++ b/spec/integration/integration_spec.rb @@ -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. diff --git a/spec/test-app/Gemfile.lock b/spec/test-app/Gemfile.lock index c0941b9..504bbf5 100644 --- a/spec/test-app/Gemfile.lock +++ b/spec/test-app/Gemfile.lock @@ -1,8 +1,8 @@ PATH remote: ../.. specs: - fix-db-schema-conflicts (1.2.0) - rubocop (>= 0.36.0) + fix-db-schema-conflicts (3.0.2) + rubocop (>= 0.38.0) GEM remote: https://rubygems.org/ @@ -43,13 +43,14 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) - ast (2.2.0) + ast (2.4.0) builder (3.2.2) concurrent-ruby (1.0.1) erubis (2.7.0) globalid (0.3.6) activesupport (>= 4.1.0) i18n (0.7.0) + jaro_winkler (1.5.2) json (1.8.3) loofah (2.0.3) nokogiri (>= 1.5.9) @@ -60,9 +61,10 @@ GEM minitest (5.8.4) nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) - parser (2.3.0.6) - ast (~> 2.2) - powerpack (0.1.1) + parallel (1.13.0) + parser (2.6.0.0) + ast (~> 2.4.0) + powerpack (0.1.2) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) @@ -90,15 +92,17 @@ GEM activesupport (= 4.2.5.2) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rainbow (2.1.0) + rainbow (3.0.0) rake (11.1.1) - rubocop (0.38.0) - parser (>= 2.3.0.6, < 3.0) + rubocop (0.63.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.5, != 2.5.1.1) powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.7.5) + unicode-display_width (~> 1.4.0) + ruby-progressbar (1.10.0) sprockets (3.5.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -111,7 +115,7 @@ GEM thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) - unicode-display_width (1.0.2) + unicode-display_width (1.4.1) PLATFORMS ruby @@ -122,4 +126,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 1.10.6 + 1.17.1 diff --git a/spec/test-app/db/schema.rb b/spec/test-app/db/schema.rb index 2f5f687..d1311a0 100644 --- a/spec/test-app/db/schema.rb +++ b/spec/test-app/db/schema.rb @@ -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. diff --git a/spec/unit/autocorrect_configuration_spec.rb b/spec/unit/autocorrect_configuration_spec.rb index 7b492be..e21d86e 100644 --- a/spec/unit/autocorrect_configuration_spec.rb +++ b/spec/unit/autocorrect_configuration_spec.rb @@ -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))