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

[#5977] Warn for Performance Cops #6845

Merged
merged 1 commit into from
Mar 19, 2019

Commits on Mar 19, 2019

  1. [rubocop#5977] Warn for Performance Cops

    ### Summary
    
    This PR warns for Performance Cops.
    
    The following warning is displayed when the next released rubocop gem is installed.
    
    ```console
    # The following is an example for operation check.
    % rake build
    % gem install pkg/rubocop-0.66.0.gem
    Performance Cops will be removed from RuboCop 0.68. Use
    rubocop-performance gem instead.
    
    Put this in your Gemfile.
    
      gem 'rubocop-performance'
    
    And then execute:
    
      $ bundle install
    
    Put this into your .rubocop.yml.
    
      require: rubocop-performance
    
    More information: https://github.com/rubocop-hq/rubocop-performance
    Successfully installed rubocop-0.66.0
    1 gem installed
    ```
    
    The following warning is displayed if RuboCop is used with Bundler.
    
    ```consle
    % bundle exec rubocop
    [Warn] Performance Cops will be removed from RuboCop 0.68. Use rubocop-performance gem instead.
           https://github.com/rubocop-hq/rubocop/tree/master/manual/migrate_performance_cops.md
    ```
    
    The above warning will disappear when rubocop-performance gem is written to Gemfile.
    The rubocop-performance implementation takes precedence when rubocop-performance is
    written in Gemfile.
    
    And I prepared a simple migration manual (migrate_performance_cops.md)
    because I think that long warning sentences are not preferred.
    I think that referring to the link is good when runnning rubocop command.
    
    ### Other Infromation
    
    At first I tried to remove performance cops from RuboCop Core and
    add rubocop-performance gem as a dependency because of fallback.
    
    ```diff
    % git diff
    diff --git a/rubocop.gemspec b/rubocop.gemspec
    index bbbcca33f..09882b063 100644
    --- a/rubocop.gemspec
    +++ b/rubocop.gemspec
    @@ -38,6 +38,7 @@ Gem::Specification.new do |s|
       s.add_runtime_dependency('parser', '>= 2.5', '!= 2.5.1.1')
       s.add_runtime_dependency('psych', '>= 3.1.0')
       s.add_runtime_dependency('rainbow', '>= 2.2.2', '< 4.0')
    +  s.add_runtime_dependency('rubocop-performance')
       s.add_runtime_dependency('ruby-progressbar', '~> 1.7')
       s.add_runtime_dependency('unicode-display_width', '>= 1.4.0', '< 1.6')
    ```
    
    However, this cannot be resolved because it is cyclic.
    
    ```console
    % bundle install
    Fetching gem metadata from https://rubygems.org/........
    Fetching gem metadata from https://rubygems.org/.
    Resolving dependencies...
    Your bundle requires gems that depend on each other, creating an infinite loop.
    Please remove either gem 'rubocop' or gem 'rubocop-performance' and try again.
    ```
    
    So I'd like to display a warning before removing performance cops.
    
    I'd like to mitigate the impact on users this way.
    
    The next step is to remove performance cops and done rubocop#5977.
    koic committed Mar 19, 2019
    Configuration menu
    Copy the full SHA
    60b5a5f View commit details
    Browse the repository at this point in the history