Skip to content

Commit

Permalink
[Fix #5977] Remove Performance cops
Browse files Browse the repository at this point in the history
Fixes #5977.

This PR removes Performance cops from RuboCop core.

These cops were transferred to rubocop-hq/rubocop-performance repository.
https://github.com/rubocop-hq/rubocop-performance
  • Loading branch information
koic authored and bbatsov committed Apr 8, 2019
1 parent cea41c6 commit 98c30a6
Show file tree
Hide file tree
Showing 61 changed files with 17 additions and 7,580 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Expand Up @@ -3,6 +3,7 @@
inherit_from: .rubocop_todo.yml
require:
- rubocop/cop/internal_affairs
- rubocop-performance
- rubocop-rspec

AllCops:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Changes

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

## 0.67.2 (2019-04-05)

### Bug fixes
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -9,6 +9,7 @@ gem 'pry'
gem 'pry-byebug' if RUBY_ENGINE == 'ruby'
gem 'rake', '~> 12.0'
gem 'rspec', '~> 3.7'
gem 'rubocop-performance', '~> 1.0.0'
gem 'rubocop-rspec', '~> 1.32.0'
gem 'simplecov', '~> 0.10'
gem 'test-queue'
Expand Down
210 changes: 0 additions & 210 deletions config/default.yml
Expand Up @@ -2000,216 +2000,6 @@ Naming/VariableNumber:
- normalcase
- non_integer

#################### Performance ###########################

Performance/Caller:
Description: >-
Use `caller(n..n)` instead of `caller`.
Enabled: true
VersionAdded: '0.49'

Performance/CaseWhenSplat:
Description: >-
Reordering `when` conditions with a splat to the end
of the `when` branches can improve performance.
Enabled: false
AutoCorrect: false
SafeAutoCorrect: false
VersionAdded: '0.34'
VersionChanged: '0.59'

Performance/Casecmp:
Description: >-
Use `casecmp` rather than `downcase ==`, `upcase ==`, `== downcase`, or `== upcase`..
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
Enabled: true
VersionAdded: '0.36'

Performance/ChainArrayAllocation:
Description: >-
Instead of chaining array methods that allocate new arrays, mutate an
existing array.
Reference: 'https://twitter.com/schneems/status/1034123879978029057'
Enabled: false
VersionAdded: '0.59'

Performance/CompareWithBlock:
Description: 'Use `sort_by(&:foo)` instead of `sort { |a, b| a.foo <=> b.foo }`.'
Enabled: true
VersionAdded: '0.46'

Performance/Count:
Description: >-
Use `count` instead of `select...size`, `reject...size`,
`select...count`, `reject...count`, `select...length`,
and `reject...length`.
# This cop has known compatibility issues with `ActiveRecord` and other
# frameworks. ActiveRecord's `count` ignores the block that is passed to it.
# For more information, see the documentation in the cop itself.
# If you understand the known risk, you can disable `SafeMode`.
SafeMode: true
Enabled: true
VersionAdded: '0.31'
VersionChanged: '0.39'

Performance/Detect:
Description: >-
Use `detect` instead of `select.first`, `find_all.first`,
`select.last`, and `find_all.last`.
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
# This cop has known compatibility issues with `ActiveRecord` and other
# frameworks. `ActiveRecord` does not implement a `detect` method and `find`
# has its own meaning. Correcting `ActiveRecord` methods with this cop
# should be considered unsafe.
SafeMode: true
Enabled: true
VersionAdded: '0.30'
VersionChanged: '0.39'

Performance/DoubleStartEndWith:
Description: >-
Use `str.{start,end}_with?(x, ..., y, ...)`
instead of `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Enabled: true
VersionAdded: '0.36'
VersionChanged: '0.48'
# Used to check for `starts_with?` and `ends_with?`.
# These methods are defined by `ActiveSupport`.
IncludeActiveSupportAliases: false

Performance/EndWith:
Description: 'Use `end_with?` instead of a regex match anchored to the end of a string.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
# This will change to a new method call which isn't guaranteed to be on the
# object. Switching these methods has to be done with knowledge of the types
# of the variables which rubocop doesn't have.
SafeAutoCorrect: false
AutoCorrect: false
Enabled: true
VersionAdded: '0.36'
VersionChanged: '0.44'

Performance/FixedSize:
Description: 'Do not compute the size of statically sized objects except in constants'
Enabled: true
VersionAdded: '0.35'

Performance/FlatMap:
Description: >-
Use `Enumerable#flat_map`
instead of `Enumerable#map...Array#flatten(1)`
or `Enumberable#collect..Array#flatten(1)`
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
Enabled: true
VersionAdded: '0.30'
EnabledForFlattenWithoutParams: false
# If enabled, this cop will warn about usages of
# `flatten` being called without any parameters.
# This can be dangerous since `flat_map` will only flatten 1 level, and
# `flatten` without any parameters can flatten multiple levels.

Performance/InefficientHashSearch:
Description: 'Use `key?` or `value?` instead of `keys.include?` or `values.include?`'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashkey-instead-of-hashkeysinclude-code'
Enabled: true
VersionAdded: '0.56'
Safe: false

Performance/OpenStruct:
Description: 'Use `Struct` instead of `OpenStruct`.'
Enabled: false
VersionAdded: '0.61'
Safe: false

Performance/RangeInclude:
Description: 'Use `Range#cover?` instead of `Range#include?`.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code'
Enabled: true
VersionAdded: '0.36'
Safe: false

Performance/RedundantBlockCall:
Description: 'Use `yield` instead of `block.call`.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#proccall-and-block-arguments-vs-yieldcode'
Enabled: true
VersionAdded: '0.36'

Performance/RedundantMatch:
Description: >-
Use `=~` instead of `String#match` or `Regexp#match` in a context where the
returned `MatchData` is not needed.
Enabled: true
VersionAdded: '0.36'

Performance/RedundantMerge:
Description: 'Use Hash#[]=, rather than Hash#merge! with a single key-value pair.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code'
Enabled: true
VersionAdded: '0.36'
# Max number of key-value pairs to consider an offense
MaxKeyValuePairs: 2

Performance/RegexpMatch:
Description: >-
Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`,
`Regexp#===`, or `=~` when `MatchData` is not used.
Reference: 'https://github.com/JuanitoFatas/fast-ruby#regexp-vs-stringmatch-vs-string-vs-stringmatch-code-'
Enabled: true
VersionAdded: '0.47'

Performance/ReverseEach:
Description: 'Use `reverse_each` instead of `reverse.each`.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
Enabled: true
VersionAdded: '0.30'

Performance/Size:
Description: >-
Use `size` instead of `count` for counting
the number of elements in `Array` and `Hash`.
Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraylength-vs-arraysize-vs-arraycount-code'
Enabled: true
VersionAdded: '0.30'

Performance/StartWith:
Description: 'Use `start_with?` instead of a regex match anchored to the beginning of a string.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
# This will change to a new method call which isn't guaranteed to be on the
# object. Switching these methods has to be done with knowledge of the types
# of the variables which rubocop doesn't have.
SafeAutoCorrect: false
AutoCorrect: false
Enabled: true
VersionAdded: '0.36'
VersionChanged: '0.44'

Performance/StringReplacement:
Description: >-
Use `tr` instead of `gsub` when you are replacing the same
number of characters. Use `delete` instead of `gsub` when
you are deleting characters.
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
Enabled: true
VersionAdded: '0.33'

Performance/TimesMap:
Description: 'Checks for .times.map calls.'
AutoCorrect: false
Enabled: true
VersionAdded: '0.36'
VersionChanged: '0.50'
SafeAutoCorrect: false # see https://github.com/rubocop-hq/rubocop/issues/4658

Performance/UnfreezeString:
Description: 'Use unary plus to get an unfrozen string literal.'
Enabled: true
VersionAdded: '0.50'

Performance/UriDefaultParser:
Description: 'Use `URI::DEFAULT_PARSER` instead of `URI::Parser.new`.'
Enabled: true
VersionAdded: '0.50'

#################### Rails #################################

# By default, the rails cops are not run. Override in project or home
Expand Down
26 changes: 0 additions & 26 deletions lib/rubocop.rb
Expand Up @@ -369,32 +369,6 @@
require_relative 'rubocop/cop/naming/variable_name'
require_relative 'rubocop/cop/naming/variable_number'

require_relative 'rubocop/cop/performance/caller'
require_relative 'rubocop/cop/performance/case_when_splat'
require_relative 'rubocop/cop/performance/casecmp'
require_relative 'rubocop/cop/performance/count'
require_relative 'rubocop/cop/performance/detect'
require_relative 'rubocop/cop/performance/double_start_end_with'
require_relative 'rubocop/cop/performance/end_with'
require_relative 'rubocop/cop/performance/fixed_size'
require_relative 'rubocop/cop/performance/flat_map'
require_relative 'rubocop/cop/performance/inefficient_hash_search'
require_relative 'rubocop/cop/performance/open_struct'
require_relative 'rubocop/cop/performance/range_include'
require_relative 'rubocop/cop/performance/redundant_block_call'
require_relative 'rubocop/cop/performance/redundant_match'
require_relative 'rubocop/cop/performance/redundant_merge'
require_relative 'rubocop/cop/performance/regexp_match'
require_relative 'rubocop/cop/performance/reverse_each'
require_relative 'rubocop/cop/performance/size'
require_relative 'rubocop/cop/performance/compare_with_block'
require_relative 'rubocop/cop/performance/start_with'
require_relative 'rubocop/cop/performance/string_replacement'
require_relative 'rubocop/cop/performance/times_map'
require_relative 'rubocop/cop/performance/unfreeze_string'
require_relative 'rubocop/cop/performance/uri_default_parser'
require_relative 'rubocop/cop/performance/chain_array_allocation'

require_relative 'rubocop/cop/style/access_modifier_declarations'
require_relative 'rubocop/cop/style/alias'
require_relative 'rubocop/cop/style/and_or'
Expand Down
7 changes: 0 additions & 7 deletions lib/rubocop/config.rb
Expand Up @@ -26,9 +26,6 @@ class Config
RUBY_VERSION_FILENAME = '.ruby-version'.freeze
DEFAULT_RAILS_VERSION = 5.0
OBSOLETE_COPS = {
'Performance/LstripRstrip' =>
'The `Performance/LstripRstrip` cop has been moved ' \
'to `Style/Strip`',
'Style/FlipFlop' =>
'The `Style/FlipFlop` cop has been moved to `Lint/FlipFlop`.',
'Style/TrailingComma' =>
Expand Down Expand Up @@ -113,10 +110,6 @@ class Config
'Lint/DefEndAlignment' =>
'The `Lint/DefEndAlignment` cop has been renamed to ' \
'`Layout/DefEndAlignment`.',
'Performance/HashEachMethods' =>
'The `Performance/HashEachMethods` cop has been removed ' \
'since it no longer provides performance benefits in ' \
'modern rubies.',
'Style/MethodMissing' =>
'The `Style/MethodMissing` cop has been split into ' \
'`Style/MethodMissingSuper` and `Style/MissingRespondToMissing`.'
Expand Down
69 changes: 0 additions & 69 deletions lib/rubocop/cop/performance/caller.rb

This file was deleted.

0 comments on commit 98c30a6

Please sign in to comment.