From 500487a3529028302995cf6b1e6190bb0e599806 Mon Sep 17 00:00:00 2001 From: Ross Cooperman Date: Fri, 17 Aug 2018 09:50:21 -0400 Subject: [PATCH 1/3] Add support for rubocop >= 0.53.0 --- .rubocop_schema.53.yml | 38 +++++++++++++++++++ .../autocorrect_configuration.rb | 12 ++++-- spec/unit/autocorrect_configuration_spec.rb | 6 +++ 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 .rubocop_schema.53.yml 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..5e74455 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?(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 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)) From 52daab292f9325b8e0e2c4c59af5b7b0b3dac775 Mon Sep 17 00:00:00 2001 From: Ross Cooperman Date: Fri, 17 Aug 2018 09:51:25 -0400 Subject: [PATCH 2/3] Fix config comment --- .rubocop_schema.53.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop_schema.53.yml b/.rubocop_schema.53.yml index 501ea86..7d6be78 100644 --- a/.rubocop_schema.53.yml +++ b/.rubocop_schema.53.yml @@ -1,4 +1,4 @@ -# Configuration for Rubocop >= 0.49.0 +# Configuration for Rubocop >= 0.53.0 Layout/AlignHash: EnforcedColonStyle: 'key' From 59bb603909cb66b4bf13935033d5848389935583 Mon Sep 17 00:00:00 2001 From: Ross Cooperman Date: Fri, 17 Aug 2018 10:02:13 -0400 Subject: [PATCH 3/3] As of 0.50.0 rubocop also no longer wants encoding headers --- spec/integration/integration_spec.rb | 2 -- spec/test-app/db/schema.rb | 2 -- 2 files changed, 4 deletions(-) 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/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.