-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Lint/RedundantWithIndex
cop aware of offset argument
#4977
Make Lint/RedundantWithIndex
cop aware of offset argument
#4977
Conversation
Follow up of rubocop#4796 (comment). Actually, it is only `with_index` method that accepts an offset argument. `with_with_index` method doesn't accept offset argument. However, I think that the same AST will be low maintenance cost.
@@ -69,7 +69,7 @@ def message(node) | |||
end | |||
|
|||
def with_index_range(send) | |||
range_between(send.loc.selector.begin_pos, send.loc.selector.end_pos) | |||
range_between(send.loc.selector.begin_pos, send.source.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually only works incidentally because processed_source
happens to start at the beginning of the node, which is kind of frail. Would probably use send.loc.expression.end_pos
instead of send.source.length
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened a PR #4983. Thanks!
I think it's perfectly fine, since Hm. Except perhaps |
Follow up of rubocop#4977 (comment). This commit fixes the following potential problem. > This actually only works incidentally because processed_source happens > to start at the beginning of the node, which is kind of frail.
Oh... I overlooked this case 💦 I'd like to open a PR sometime. |
Follow up of #4977 (comment). This commit fixes the following potential problem. > This actually only works incidentally because processed_source happens > to start at the beginning of the node, which is kind of frail.
Follow up of #4796 (comment).
Actually, it is only
with_index
method that accepts an offset argument.with_with_index
method doesn't accept offset argument.However, I think that the same AST will be low maintenance cost.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).rake spec
) are passing.rake internal_investigation
.and description in grammatically correct, complete sentences.
rake generate_cops_documentation
(required only when you've added a new cop or changed the configuration/documentation of an existing cop).