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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Changes

* [#5977](https://github.com/rubocop-hq/rubocop/issues/5977): Warn for Performance Cops. ([@koic][])

## 0.66.0 (2019-03-18)

### New features
Expand Down
12 changes: 12 additions & 0 deletions exe/rubocop
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ require 'benchmark'
cli = RuboCop::CLI.new
result = 0

if defined?(Bundler)
gemfile_lock = Bundler.read_file(Bundler.default_lockfile)
parser = Bundler::LockfileParser.new(gemfile_lock)

unless parser.dependencies['rubocop-performance']
warn Rainbow(<<-MESSAGE.strip_indent).yellow.to_s
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 The above .to_s method is used to prevent the following errors for JRuby 9.2.

% bundle exec rspec ./spec/rubocop/cli/cli_options_spec.rb:210
Run options: include {:focus=>true, :locations=>{"./spec/rubocop/cli/cli_options_spec.rb"=>[210]}}

Randomized with seed 11663
TypeError: wrong argument type Rainbow::NullPresenter (expected String)
    warn at org/jruby/common/RubyWarnings.java:224
    warn at org/jruby/RubyKernel.java:1247
    warn at org/jruby/RubyKernel.java:1234
  <main> at /Users/koic/src/github.com/rubocop-hq/rubocop/exe/rubocop:17
F

Failures:

  1) RuboCop::CLI --only when one cop is given accepts cop names from plugins
     Got 2 failures from failure aggregation block.
     # ./spec/support/cli_spec_behavior.rb:27:in `block in <main>'
     # ./lib/rubocop/rspec/shared_contexts.rb:27:in `block in <main>'
     # ./lib/rubocop/path_util.rb:67:in `chdir'
     # ./lib/rubocop/rspec/shared_contexts.rb:26:in `block in <main>'
     # ./lib/rubocop/rspec/shared_contexts.rb:8:in `block in <main>'

     1.1) Failure/Error: expect($CHILD_STATUS.success?).to be_truthy

            expected: truthy value
                 got: false
          # ./spec/rubocop/cli/cli_options_spec.rb:210:in `block in <main>'

     1.2) Failure/Error:
                    expect(output)
                      .to eq(<<-RESULT.strip_indent)
                        Inspecting 2 files
                        ..

                        2 files inspected, no offenses detected
                      RESULT

https://circleci.com/gh/rubocop-hq/rubocop/42485

[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
MESSAGE
end
end

time = Benchmark.realtime do
result = cli.run
end
Expand Down
2 changes: 2 additions & 0 deletions manual/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ See [development](development.md).

#### Known Custom Cops

* [rubocop-performance](https://github.com/rubocop-hq/rubocop-performance) -
Performance optimization analysis
* [rubocop-rspec](https://github.com/rubocop-hq/rubocop-rspec) -
RSpec-specific analysis
* [rubocop-thread_safety](https://github.com/covermymeds/rubocop-thread_safety) -
Expand Down
15 changes: 15 additions & 0 deletions manual/migrate_performance_cops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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
2 changes: 2 additions & 0 deletions rubocop.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ Gem::Specification.new do |s|

s.add_development_dependency('bundler', '>= 1.3.0', '< 3.0')
s.add_development_dependency('rack', '>= 2.0')

s.post_install_message = File.read('manual/migrate_performance_cops.md')
end