Skip to content

Commit 4dc1e5c

Browse files
parkerfinchkoic
authored andcommitted
[Fix #240] Disable Performance/Casecmp cop
This cop suggests an incorrect fix when code involves non-ASCII characters. Disabling it by default makes this risky behavior opt-in rather than opt-out.
1 parent dd698b2 commit 4dc1e5c

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#240](https://github.com/rubocop/rubocop-performance/issues/240): Disable `Performance/Casecmp` cop by default. ([@parkerfinch][])

config/default.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ Performance/Casecmp:
5555
Description: >-
5656
Use `casecmp` rather than `downcase ==`, `upcase ==`, `== downcase`, or `== upcase`..
5757
Reference: 'https://github.com/fastruby/fast-ruby#stringcasecmp-vs--stringcasecmp-vs-stringdowncase---code'
58-
Enabled: true
58+
Enabled: false
5959
Safe: false
6060
VersionAdded: '0.36'
61+
VersionChanged: '<<next>>'
6162

6263
Performance/ChainArrayAllocation:
6364
Description: >-

lib/rubocop/cop/performance/casecmp.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ module Performance
66
# Identifies places where a case-insensitive string comparison
77
# can better be implemented using `casecmp`.
88
#
9+
# This cop is disabled by default because `String#casecmp` only works with
10+
# ASCII characters. See https://github.com/rubocop/rubocop/issues/9753.
11+
#
12+
# If you are working only with ASCII characters, then this cop can be
13+
# safely enabled.
14+
#
915
# @safety
1016
# This cop is unsafe because `String#casecmp` and `String#casecmp?` behave
1117
# differently when using Non-ASCII characters.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy