From d37510998743e0b60ea6a22accfd89b04f307767 Mon Sep 17 00:00:00 2001 From: Brandon High Date: Fri, 26 Feb 2021 11:10:53 -0800 Subject: [PATCH 1/2] Fix new linter issues from 1.10 --- .../cop/i18n/gettext/decorate_function_message_spec.rb | 4 +--- .../decorate_string_formatting_using_interpolation_spec.rb | 4 +--- .../gettext/decorate_string_formatting_using_percent_spec.rb | 4 +--- spec/rubocop/cop/i18n/gettext/decorate_string_spec.rb | 4 +--- .../decorate_string_formatting_using_interpolation_spec.rb | 4 +--- spec/rubocop/cop/i18n/rails_i18n/decorate_string_spec.rb | 4 +--- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/spec/rubocop/cop/i18n/gettext/decorate_function_message_spec.rb b/spec/rubocop/cop/i18n/gettext/decorate_function_message_spec.rb index 87f193e..0501177 100644 --- a/spec/rubocop/cop/i18n/gettext/decorate_function_message_spec.rb +++ b/spec/rubocop/cop/i18n/gettext/decorate_function_message_spec.rb @@ -2,9 +2,7 @@ require 'spec_helper' -describe RuboCop::Cop::I18n::GetText::DecorateFunctionMessage do - let(:config) { RuboCop::Config.new } - subject(:cop) { described_class.new(config) } +describe RuboCop::Cop::I18n::GetText::DecorateFunctionMessage, :config, :config do before(:each) do investigate(cop, source) end diff --git a/spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation_spec.rb b/spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation_spec.rb index 1c9ba16..7beaf3a 100644 --- a/spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation_spec.rb +++ b/spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation_spec.rb @@ -2,9 +2,7 @@ require 'spec_helper' -describe RuboCop::Cop::I18n::GetText::DecorateStringFormattingUsingInterpolation do - let(:config) { RuboCop::Config.new } - subject(:cop) { described_class.new(config) } +describe RuboCop::Cop::I18n::GetText::DecorateStringFormattingUsingInterpolation, :config, :config do before(:each) do investigate(cop, source) end diff --git a/spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent_spec.rb b/spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent_spec.rb index 56f91d4..77b5782 100644 --- a/spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent_spec.rb +++ b/spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent_spec.rb @@ -2,9 +2,7 @@ require 'spec_helper' -describe RuboCop::Cop::I18n::GetText::DecorateStringFormattingUsingPercent do - let(:config) { RuboCop::Config.new } - subject(:cop) { described_class.new(config) } +describe RuboCop::Cop::I18n::GetText::DecorateStringFormattingUsingPercent, :config, :config do before(:each) do investigate(cop, source) end diff --git a/spec/rubocop/cop/i18n/gettext/decorate_string_spec.rb b/spec/rubocop/cop/i18n/gettext/decorate_string_spec.rb index 7e8ffda..46ddb9b 100644 --- a/spec/rubocop/cop/i18n/gettext/decorate_string_spec.rb +++ b/spec/rubocop/cop/i18n/gettext/decorate_string_spec.rb @@ -2,9 +2,7 @@ require 'spec_helper' -describe RuboCop::Cop::I18n::GetText::DecorateString do - let(:config) { RuboCop::Config.new } - subject(:cop) { described_class.new(config) } +describe RuboCop::Cop::I18n::GetText::DecorateString, :config, :config do before(:each) do investigate(cop, source) end diff --git a/spec/rubocop/cop/i18n/rails_i18n/decorate_string_formatting_using_interpolation_spec.rb b/spec/rubocop/cop/i18n/rails_i18n/decorate_string_formatting_using_interpolation_spec.rb index b741018..6c72ca3 100644 --- a/spec/rubocop/cop/i18n/rails_i18n/decorate_string_formatting_using_interpolation_spec.rb +++ b/spec/rubocop/cop/i18n/rails_i18n/decorate_string_formatting_using_interpolation_spec.rb @@ -2,9 +2,7 @@ require 'spec_helper' -describe RuboCop::Cop::I18n::RailsI18n::DecorateStringFormattingUsingInterpolation do - let(:config) { RuboCop::Config.new } - subject(:cop) { described_class.new(config) } +describe RuboCop::Cop::I18n::RailsI18n::DecorateStringFormattingUsingInterpolation, :config, :config do before(:each) do investigate(cop, source) end diff --git a/spec/rubocop/cop/i18n/rails_i18n/decorate_string_spec.rb b/spec/rubocop/cop/i18n/rails_i18n/decorate_string_spec.rb index ec7b27e..f215a42 100644 --- a/spec/rubocop/cop/i18n/rails_i18n/decorate_string_spec.rb +++ b/spec/rubocop/cop/i18n/rails_i18n/decorate_string_spec.rb @@ -2,9 +2,7 @@ require 'spec_helper' -describe RuboCop::Cop::I18n::RailsI18n::DecorateString do - let(:config) { RuboCop::Config.new } - subject(:cop) { described_class.new(config) } +describe RuboCop::Cop::I18n::RailsI18n::DecorateString, :config, :config do before(:each) do investigate(cop, source) end From 39dea90b10b398d414dfe57bcfdaccebe2368cbe Mon Sep 17 00:00:00 2001 From: Brandon High Date: Fri, 26 Feb 2021 11:13:49 -0800 Subject: [PATCH 2/2] Enable NewCops and ignore DuplicateBranch false positive --- .rubocop.yml | 1 + lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index b8da595..ad1a448 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,7 @@ require: AllCops: TargetRubyVersion: 2.5 + NewCops: enable Metrics/BlockLength: Exclude: diff --git a/lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb b/lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb index 773a5c0..6ccfe6d 100644 --- a/lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb +++ b/lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb @@ -122,7 +122,7 @@ def regexp_from_string_type when 'sentence' then SENTENCE_REGEXP when 'fragmented_sentence' then FRAGMENTED_SENTENCE_REGEXP when 'fragment' then FRAGMENT_REGEXP - else + else # rubocop:disable Lint/DuplicateBranch SENTENCE_REGEXP end end