From 8a021a5f8ccd454de6885af9c9397a564ec70e81 Mon Sep 17 00:00:00 2001 From: Alistair McKinnell Date: Tue, 15 May 2018 01:57:31 -0400 Subject: [PATCH 1/3] Configuration to support Rubocop 0.53 The Style/TrailingCommaInLiteral cop has been replaced by: - Style/TrailingCommaInArrayLiteral - Style/TrailingCommaInHashLiteral --- .rubocop_schema.53.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) 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..7d6be78 --- /dev/null +++ b/.rubocop_schema.53.yml @@ -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 From 61b941109bc5aaf5ca8f19e12ff9ab19d1d7250e Mon Sep 17 00:00:00 2001 From: Alistair McKinnell Date: Tue, 15 May 2018 01:57:54 -0400 Subject: [PATCH 2/3] Add option to choose configuration for Rubocop 0.53.0 --- .../autocorrect_configuration.rb | 12 +++++++++++- spec/unit/autocorrect_configuration_spec.rb | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/fix_db_schema_conflicts/autocorrect_configuration.rb b/lib/fix_db_schema_conflicts/autocorrect_configuration.rb index 94e80e6..587cc80 100644 --- a/lib/fix_db_schema_conflicts/autocorrect_configuration.rb +++ b/lib/fix_db_schema_conflicts/autocorrect_configuration.rb @@ -5,7 +5,13 @@ def self.load end def load - at_least_rubocop_49? ? '.rubocop_schema.49.yml' : '.rubocop_schema.yml' + if at_least_rubocop_53? + '.rubocop_schema.53.yml' + elsif at_least_rubocop_49? + '.rubocop_schema.49.yml' + else + '.rubocop_schema.yml' + end end private @@ -13,5 +19,9 @@ def load def at_least_rubocop_49? Gem::Version.new('0.49.0') <= Gem.loaded_specs['rubocop'].version end + + def at_least_rubocop_53? + Gem::Version.new('0.53.0') <= Gem.loaded_specs['rubocop'].version + end end end diff --git a/spec/unit/autocorrect_configuration_spec.rb b/spec/unit/autocorrect_configuration_spec.rb index 7b492be..64b89b7 100644 --- a/spec/unit/autocorrect_configuration_spec.rb +++ b/spec/unit/autocorrect_configuration_spec.rb @@ -10,12 +10,18 @@ expect(autocorrect_config.load).to eq('.rubocop_schema.yml') end - it 'for versions 0.49.0 and above' do + it 'for versions 0.49.0 up to but not including 0.53.0' do installed_rubocop(version: '0.49.0') 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 4172392392e1a8d907f7ab673cb5ddd9a4a31940 Mon Sep 17 00:00:00 2001 From: Alistair McKinnell Date: Tue, 15 May 2018 01:58:07 -0400 Subject: [PATCH 3/3] Drop the leading UFT-8 encoding comment --- spec/integration/integration_spec.rb | 1 - spec/test-app/db/schema.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/spec/integration/integration_spec.rb b/spec/integration/integration_spec.rb index 98bc314..10bbe83 100644 --- a/spec/integration/integration_spec.rb +++ b/spec/integration/integration_spec.rb @@ -20,7 +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 diff --git a/spec/test-app/db/schema.rb b/spec/test-app/db/schema.rb index 2f5f687..7e85f37 100644 --- a/spec/test-app/db/schema.rb +++ b/spec/test-app/db/schema.rb @@ -1,4 +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