-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
AllowRegexpMatch
option to `Performance/RedundantEqualityCompar…
…isonBlock` Follow up #340. This PR adds `AllowRegexpMatch` option to `Performance/RedundantEqualityComparisonBlock`. ```ruby # `AllowRegexpMatch: true` (default) # good items.all? { |item| item =~ pattern } items.all? { |item| item.match?(pattern) } # `AllowRegexpMatch: false` # bad items.all? { |item| item =~ pattern } items.all? { |item| item.match?(pattern) } ``` `AllowRegexpMatch: false` by default because `regexp.match?('string')` often used in block changes to the opposite result: ```ruby [/pattern/].all? { |regexp| regexp.match?('pattern') } # => true [/pattern/].all? { |regexp| regexp =~ 'pattern' } # => true [/pattern/].all?('pattern') # => false ```
- Loading branch information
Showing
4 changed files
with
69 additions
and
26 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...allow_regexp_match_option_to_performance_redundant_equality_comparison_block.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#347](https://github.com/rubocop/rubocop-performance/pull/347): Add `AllowRegexpMatch` option to `Performance/RedundantEqualityComparisonBlock`. ([@koic][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters