Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make custom cop inherit RuboCop::Cop::Base #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

koic
Copy link

@koic koic commented Feb 9, 2023

Follow rubocop/rubocop#7868.

The legacy Cop::Cop API is soft deprecated and this PR use new Cop::Base API instead.

maintain any RuboCop extensions, as the legacy API will be removed in RuboCop 2.0.

https://metaredux.com/posts/2020/10/21/rubocop-1-0.html

And this PR suppresses the following RuboCop offenses.

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.

@koic koic requested a review from a team as a code owner February 9, 2023 04:03
@koic koic changed the title Use cop base api Use Cop::Base API Feb 9, 2023
@CLAassistant
Copy link

CLAassistant commented Feb 9, 2023

CLA assistant check
All committers have signed the CLA.

@koic
Copy link
Author

koic commented Feb 9, 2023

NOTE: I found out that deprecated API is used at rubocop/rubocop#11554.

Follow rubocop/rubocop#7868.

The legacy `Cop::Cop` API is soft deprecated and this PR use
new `Cop::Base` API instead.

> maintain any RuboCop extensions, as the legacy API will be removed in
> RuboCop 2.0.

https://metaredux.com/posts/2020/10/21/rubocop-1-0.html
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.
@koic koic changed the title Use Cop::Base API Make custom cop inherit RuboCop::Cop::Base Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants