Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Fix #111] Fix an error for Performance/DeletePrefix and Performance/DeleteSuffix cops #113

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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