-
-
Notifications
You must be signed in to change notification settings - Fork 283
Add a new cop RSpec/Output
#2129
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
base: master
Are you sure you want to change the base?
Conversation
|
|
|
I did some grepping around the |
|
This is succeeding for me locally with no file changes. I wonder why. |
| | `{"RuboCop" => "rubocop", "RSpec" => "rspec"}` | ||
| | `{"RuboCop"=>"rubocop", "RSpec"=>"rspec"}` |
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.
Could you please regenerate the documentation, but using Ruby 3.4?
I’ve opened #2130 to mitigate this problem for future contributors.
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 installed Ruby 3.4 and then it formatted things differently so that must be it. I rebased and pushed those changes.
This is based on the `Rails/Output` cop with three minor changes. 1. Autocorrection is removed as the expectation is that the print statement will be removed by the user. 2. The message is changed. 3. The cop runs only on spec files.
b205673 to
9152c2a
Compare
|
|
||
| module RuboCop | ||
| module Cop | ||
| # NOTE: This is the same as the `Rails/Output` cop with minor changes. |
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.
Could you please delete this comment? It will diverge significantly from the actual Rails/Output cop in the future.
| # rubocop:disable Metrics/CyclomaticComplexity | ||
| def on_send(node) | ||
| return if node.parent&.call_type? || node.block_node | ||
| return if !output?(node) && !io_output?(node) | ||
| return if node.arguments.any? { |arg| arg.type?(:hash, :block_pass) } | ||
|
|
||
| range = offense_range(node) | ||
|
|
||
| add_offense(range) | ||
| end | ||
| # rubocop:enable Metrics/CyclomaticComplexity |
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.
Could you please add the directive to the specific line where the offense occurs, instead of using a range?
| # rubocop:disable Metrics/CyclomaticComplexity | |
| def on_send(node) | |
| return if node.parent&.call_type? || node.block_node | |
| return if !output?(node) && !io_output?(node) | |
| return if node.arguments.any? { |arg| arg.type?(:hash, :block_pass) } | |
| range = offense_range(node) | |
| add_offense(range) | |
| end | |
| # rubocop:enable Metrics/CyclomaticComplexity | |
| def on_send(node) # rubocop:disable Metrics/CyclomaticComplexity | |
| return if node.parent&.call_type? || node.block_node | |
| return if !output?(node) && !io_output?(node) | |
| return if node.arguments.any? { |arg| arg.type?(:hash, :block_pass) } | |
| range = offense_range(node) | |
| add_offense(range) | |
| end |
Closes #2128
This is based on the
Rails/Outputcop with three minor changes.Before submitting the PR make sure the following are checked:
master(if not - rebase it).CHANGELOG.mdif 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: pendinginconfig/default.yml.Enabled: truein.rubocop.yml.VersionAdded: "<<next>>"indefault/config.yml.If you have modified an existing cop's configuration options:
VersionChanged: "<<next>>"inconfig/default.yml.