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
Fix false negative in RSpec/ExpectChange
cop with block style and chained method call
#1152
Conversation
RSpec/ExpectChange
cop for block style with chained method callRSpec/ExpectChange
cop with block style and chained method call
Rubocop failures are unrelated and shall be fixed in #1154 |
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.
Perfect, thank you!
ce61875
to
6cac7e1
Compare
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.
Conflicting files
CHANGELOG.md
Prevents from merging 🤷
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.
Thanks!
@@ -39,7 +39,7 @@ class ExpectChange < Base | |||
|
|||
# @!method expect_change_with_arguments(node) | |||
def_node_matcher :expect_change_with_arguments, <<-PATTERN | |||
(send nil? :change ({const send} nil? $_) (sym $_)) | |||
(send nil? :change $({const send} ...) (sym $_)) |
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.
Do we need to limit the argument of change at all?
Could be just (send nil? :change $_ (sym $_))
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 way it would also match change(@ivar, :method)
, change($global, :method)
, change(::Const, :count)
and other possible arguments.
I don't have a definitive list in my head, can there be any false positives? Something like change(-> {}, :call)
?
👍 for such a change granted a few more examples are added.
@tejasbubane Are you up for that, or would you prefer us to file a ticket for the future?
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.
Wondering if ${const send}
can be a drop-in replacement for$({const send} ...)
🤔
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.
Changed as per @Darhazer's suggestion.
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.
@bquorning What do you think?
@tejasbubane Wondering if you have the "allow maintainers to make changes" checkbox checked?
🤷 Added a couple of specs to cover cases if @ivar $gvar ::CBase etc. |
@pirj I have enabled it now |
This comment has been minimized.
This comment has been minimized.
Thank you! |
Thank you for expanding the test suite 🙇 |
Closes #1143
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).If you have created a new cop:
config/default.yml
.Enabled: pending
inconfig/default.yml
.VersionAdded
indefault/config.yml
to the next minor version.If you have modified an existing cop's configuration options:
VersionChanged
inconfig/default.yml
to the next major version.