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

[Fix #240] Disable Performance/Casecmp cop #241

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

## master (unreleased)

### Changes

* [#240](https://github.com/rubocop/rubocop-performance/issues/240): Retire `Performance/Casecmp` cop. ([@parkerfinch][])

## 1.11.2 (2021-05-05)

### Bug fixes
Expand Down Expand Up @@ -271,3 +275,4 @@
[@dvandersluis]: https://github.com/dvandersluis
[@ghiculescu]: https://github.com/ghiculescu
[@mfbmina]: https://github.com/mfbmina
[@parkerfinch]: https://github.com/parkerfinch
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ 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
Enabled: false
Safe: false
VersionAdded: '0.36'

Expand Down
10 changes: 7 additions & 3 deletions docs/modules/ROOT/pages/cops_performance.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ end
|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged

| Enabled
| Disabled
| No
| Yes (Unsafe)
| 0.36
Expand All @@ -292,8 +292,12 @@ end

This cop identifies places where a case-insensitive string comparison
can better be implemented using `casecmp`.
This cop is unsafe because `String#casecmp` and `String#casecmp?` behave
differently when using Non-ASCII characters.

This cop is disabled by default because `String#casecmp` only works with
ASCII characters. See https://github.com/rubocop/rubocop/issues/9753.

If you are working only with ASCII characters, then this cop can be
safely enabled.

=== Examples

Expand Down
8 changes: 6 additions & 2 deletions lib/rubocop/cop/performance/casecmp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ module Cop
module Performance
# This cop identifies places where a case-insensitive string comparison
# can better be implemented using `casecmp`.
# This cop is unsafe because `String#casecmp` and `String#casecmp?` behave
# differently when using Non-ASCII characters.
#
# This cop is disabled by default because `String#casecmp` only works with
# ASCII characters. See https://github.com/rubocop/rubocop/issues/9753.
#
# If you are working only with ASCII characters, then this cop can be
# safely enabled.
#
# @example
# # bad
Expand Down