From 29c311bc2d29e78664d24093adc8659dbdc67f62 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Thu, 9 Feb 2023 12:53:23 +0900 Subject: [PATCH] Suppress RuboCop offenses This commit suppresses the following RuboCop offenses. ```console Offenses: lib/rubocop/cop/i18n/gettext/decorate_string.rb:7:11: C: InternalAffairs/CopDescription: Description should be started with a word such as verb instead of This cop .... # This cop is looks for strings that appear to be sentences but are not decorated. ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb:7:11: C: InternalAffairs/CopDescription: Description should be started with a word such as verb instead of This cop .... # This cop is looks for strings that appear to be sentences but are not decorated. ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb:121:29: C: InternalAffairs/UndefinedConfig: EnforcedSentenceType is not defined in the configuration for I18n/RailsI18n/DecorateString in config/default.yml. case cop_config['EnforcedSentenceType'].to_s.downcase ^^^^^^^^^^^^^^^^^^^^^^ lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb:131:35: C: InternalAffairs/UndefinedConfig: Regexp is not defined in the configuration for I18n/RailsI18n/DecorateString in config/default.yml. Regexp.new(cop_config['Regexp']) if cop_config['Regexp'] ^^^^^^^^ lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb:131:60: C: InternalAffairs/UndefinedConfig: Regexp is not defined in the configuration for I18n/RailsI18n/DecorateString in config/default.yml. Regexp.new(cop_config['Regexp']) if cop_config['Regexp'] ^^^^^^^^ lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb:147:44: C: InternalAffairs/UndefinedConfig: IgnoreExceptions is not defined in the configuration for I18n/RailsI18n/DecorateString in config/default.yml. return false unless cop_config['IgnoreExceptions'] ^^^^^^^^^^^^^^^^^^ rubocop-i18n.gemspec:6:1: W: [Correctable] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'. Gem::Specification.new do |spec| ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/spec_helper.rb:13:19: C: [Correctable] Style/RedundantConstantBase: Remove redundant ::. unless defined?(::TestQueue) ^^ spec/spec_helper.rb:25:23: C: [Correctable] Style/YodaCondition: Reverse the order of the operands RUBY_ENGINE == v.to_s. v.is_a?(Symbol) ? RUBY_ENGINE == v.to_s : v ^^^^^^^^^^^^^^^^^^^^^ 23 files inspected, 9 offenses detected, 3 offenses autocorrectable ``` NOTE: This commit make MFA enabled in rubocop-i18n.gemspec so releases to rubygems.org will require MFA. --- .rubocop.yml | 4 ++++ lib/rubocop/cop/i18n/gettext/decorate_string.rb | 2 +- lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb | 2 +- rubocop-i18n.gemspec | 4 ++++ spec/spec_helper.rb | 4 ++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ad1a448..2715211 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,10 @@ AllCops: TargetRubyVersion: 2.5 NewCops: enable +# rubocop-i18n does not have config/default. +InternalAffairs/UndefinedConfig: + Enabled: false + Metrics/BlockLength: Exclude: # Exclude the spec directory because the rspec DSL results in long blocks diff --git a/lib/rubocop/cop/i18n/gettext/decorate_string.rb b/lib/rubocop/cop/i18n/gettext/decorate_string.rb index f382cd0..2be13de 100644 --- a/lib/rubocop/cop/i18n/gettext/decorate_string.rb +++ b/lib/rubocop/cop/i18n/gettext/decorate_string.rb @@ -4,7 +4,7 @@ module RuboCop module Cop module I18n module GetText - # This cop is looks for strings that appear to be sentences but are not decorated. + # Looks for strings that appear to be sentences but are not decorated. # Sentences are determined by the STRING_REGEXP. (Upper case character, at least one space, # and sentence punctuation at the end) # diff --git a/lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb b/lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb index 5add13c..cbf5ce6 100644 --- a/lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb +++ b/lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb @@ -4,7 +4,7 @@ module RuboCop module Cop module I18n module RailsI18n - # This cop is looks for strings that appear to be sentences but are not decorated. + # Looks for strings that appear to be sentences but are not decorated. # Sentences are determined by the SENTENCE_REGEXP. (Upper case character, at least one space, # and sentence punctuation at the end) # diff --git a/rubocop-i18n.gemspec b/rubocop-i18n.gemspec index 3861f68..c3aa1e9 100644 --- a/rubocop-i18n.gemspec +++ b/rubocop-i18n.gemspec @@ -23,6 +23,10 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.5.8' + spec.metadata = { + 'rubygems_mfa_required' => 'true' + } + spec.add_development_dependency 'bundler', '>= 1.17.3' spec.add_development_dependency 'pry', '~> 0.13.1' spec.add_development_dependency 'rake', '>= 12.3.3' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ca2533f..8dd0977 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,7 +10,7 @@ # to individual examples or groups you care about by tagging them with # `:focus` metadata. When nothing is tagged with `:focus`, all examples # get run. - unless defined?(::TestQueue) + unless defined?(TestQueue) # See. https://github.com/tmm1/test-queue/issues/60#issuecomment-281948929 config.filter_run :focus config.run_all_when_everything_filtered = true @@ -22,7 +22,7 @@ Kernel.srand config.seed broken_filter = lambda do |v| - v.is_a?(Symbol) ? RUBY_ENGINE == v.to_s : v + v.is_a?(Symbol) ? v.to_s == RUBY_ENGINE : v end config.filter_run_excluding broken: broken_filter