Skip to content

Commit

Permalink
Merge pull request #104 from koic/mark_unsafe_for_performance_casecmp
Browse files Browse the repository at this point in the history
[Fix #101] Mark unsafe for `Performance/Casecmp` cop
  • Loading branch information
koic authored May 7, 2020
2 parents dcba577 + e2c1647 commit c4d4496
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Changes

* [#103](https://github.com/rubocop-hq/rubocop-performance/pull/103): **(BREAKING)** Drop support for Ruby 2.3. ([@koic][])
* [#101](https://github.com/rubocop-hq/rubocop-performance/issues/101): Mark unsafe for `Performance/Casecmp` cop. ([@koic][])

## 1.5.2 (2019-12-25)

Expand Down
1 change: 1 addition & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Performance/Casecmp:
Use `casecmp` rather than `downcase ==`, `upcase ==`, `== downcase`, or `== upcase`..
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
Enabled: true
Safe: false
VersionAdded: '0.36'

Performance/ChainArrayAllocation:
Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/performance/casecmp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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.
#
# @example
# # bad
Expand Down
4 changes: 3 additions & 1 deletion manual/cops_performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ AutoCorrect | `false` | Boolean

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Enabled | Yes | Yes | 0.36 | -
Enabled | No | Yes | 0.36 | -

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.

### Examples

Expand Down

0 comments on commit c4d4496

Please sign in to comment.