-
-
Notifications
You must be signed in to change notification settings - Fork 277
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 FilePath check suffix when given a non-constant top-level node #1158
Make FilePath check suffix when given a non-constant top-level node #1158
Conversation
4398429
to
7f542e3
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.
Hey @topalovic 👋
Looks good, thank you!
This helps with the standard feature format: RSpec.feature "Some feature" do; end
7f542e3
to
c4646ff
Compare
(block | ||
$(send #rspec? _example_group $(const ...) $...) ... | ||
$(send #rspec? _example_group $_ $...) ... |
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.
Perhaps we can capture just the arguments and deconstruct when needed
$(send #rspec? _example_group $_ $...)
then the usage will be
example_group(node) do |send_node, arguments|
and inside ensure_correct_file_path
we would have
example_group, method_name, = *arguments
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.
Won't it result in an internal affairs offence?
# lib/rubocop/cop/rspec/expect_output.rb
# rubocop:disable InternalAffairs/NodeDestructuring
variable_name, _rhs = *node
# rubocop:enable InternalAffairs/NodeDestructuring
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.
Only when the variable name ends with node 😂
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'm not sure I'm up to snuff wrt "internal affairs" or parser
intricacies, so I would trust you to refactor the matcher according to your vision :-)
I'm primarily concerned with getting the fix out there, since my own team got burned by trusting RuboCop to warn about feature files without the suffix.
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.
Fair enough
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'm primarily concerned with getting the fix out there
It's released now, as v2.4.0.
I'm not sure why CircleCI doesn't pick up the build https://app.circleci.com/pipelines/github/rubocop/rubocop-rspec |
Currently,
RSpec/FilePath
matcher ignores non-constant top-level nodes.However, the standard feature format assumes string descriptions:
This can make feature files without a proper suffix go unnoticed and then ignored by the runner. Test it by creating a feature file without a suffix, e.g.
spec/features/some_feature.rb
.This PR makes the matcher more general by matching
_
instead ofconst
. If the top-level node is not a constant, we'll simply fall back to the basicspec_suffix_only?
check, regardless of the actual config flag.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).