Skip to content

Commit

Permalink
[Fix rubocop#111] Fix an error for Performance/DeletePrefix and `Pe…
Browse files Browse the repository at this point in the history
…rformance/DeleteSuffix`

Fixes rubocop#111.

This PR fixes an error for `Performance/DeletePrefix` and `Performance/DeleteSuffix` cops
when using autocorrection with RuboCop 0.81 or lower.
  • Loading branch information
koic committed May 22, 2020
1 parent 7caf6f5 commit 49ea20f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bug fixes

* [#111](https://github.com/rubocop-hq/rubocop-performance/issues/111): Fix an error for `Performance/DeletePrefix` and `Performance/DeleteSuffix` cops when using autocorrection with RuboCop 0.81 or lower. ([@koic][])

## 1.6.0 (2020-05-22)

### New features
Expand Down
4 changes: 3 additions & 1 deletion lib/rubocop/cop/performance/delete_prefix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def autocorrect(node)

new_code = "#{receiver.source}.#{good_method}(#{string_literal})"

corrector.replace(node, new_code)
# TODO: `source_range` is no longer required when RuboCop 0.81 or lower support will be dropped.
# https://github.com/rubocop-hq/rubocop/commit/82eb350d2cba16
corrector.replace(node.source_range, new_code)
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/rubocop/cop/performance/delete_suffix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def autocorrect(node)

new_code = "#{receiver.source}.#{good_method}(#{string_literal})"

corrector.replace(node, new_code)
# TODO: `source_range` is no longer required when RuboCop 0.81 or lower support will be dropped.
# https://github.com/rubocop-hq/rubocop/commit/82eb350d2cba16
corrector.replace(node.source_range, new_code)
end
end
end
Expand Down

0 comments on commit 49ea20f

Please # to comment.