Skip to content

Commit

Permalink
Merge pull request #212 from koic/enable_autocorrect_for_sart_with_an…
Browse files Browse the repository at this point in the history
…d_end_with

Enable auto-correct for `Performance/StartWith` and `Performance/EndWith` cops
  • Loading branch information
koic committed Feb 17, 2021
2 parents 250fbee + 45a8171 commit 199f360
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
### Changes

* [#205](https://github.com/rubocop-hq/rubocop-performance/issues/205): Update `Performance/ConstantRegexp` to allow memoized regexps. ([@dvandersluis][])
* [#212](https://github.com/rubocop-hq/rubocop-performance/pull/212): Enable unsafe auto-correct for `Performance/StartWith` and `Performance/EndWith` cops by default. ([@koic][])

## 1.9.2 (2021-01-01)

Expand Down
6 changes: 2 additions & 4 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ Performance/EndWith:
# 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
SafeMultiline: true
VersionAdded: '0.36'
VersionChanged: '1.6'
VersionChanged: '1.10'

Performance/FixedSize:
Description: 'Do not compute the size of statically sized objects except in constants.'
Expand Down Expand Up @@ -276,11 +275,10 @@ Performance/StartWith:
# 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
SafeMultiline: true
VersionAdded: '0.36'
VersionChanged: '1.6'
VersionChanged: '1.10'

Performance/StringInclude:
Description: 'Use `String#include?` instead of a regex match with literal-only pattern.'
Expand Down
12 changes: 2 additions & 10 deletions docs/modules/ROOT/pages/cops_performance.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ str.end_with?(var1, var2)
| Yes
| Yes (Unsafe)
| 0.36
| 1.6
| 1.10
|===

This cop identifies unnecessary use of a regex where `String#end_with?` would suffice.
Expand Down Expand Up @@ -836,10 +836,6 @@ for receiver is multiline string.
|===
| Name | Default value | Configurable values

| AutoCorrect
| `false`
| Boolean

| SafeMultiline
| `true`
| Boolean
Expand Down Expand Up @@ -1659,7 +1655,7 @@ str.squeeze!('a')
| Yes
| Yes (Unsafe)
| 0.36
| 1.6
| 1.10
|===

This cop identifies unnecessary use of a regex where `String#start_with?` would suffice.
Expand Down Expand Up @@ -1715,10 +1711,6 @@ for receiver is multiline string.
|===
| Name | Default value | Configurable values

| AutoCorrect
| `false`
| Boolean

| SafeMultiline
| `true`
| Boolean
Expand Down

0 comments on commit 199f360

Please sign in to comment.