Skip to content
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 Layout/EmptyLineAfterGuardClause accept RuboCop directive after guard clause #9608

Closed
ojab opened this issue Mar 16, 2021 · 0 comments
Closed
Labels

Comments

@ojab
Copy link
Contributor

@ojab ojab commented Mar 16, 2021

Expected behavior

#9146, but I can reproduce it with rubocop-1.11.0 with config:

require:
  - rubocop-performance

AllCops:
  NewCops: enable
  TargetRubyVersion: 3.0

Style/FrozenStringLiteralComment:
  Enabled: false

and code:

def xxx
  # rubocop:disable Performance/InefficientHashSearch
  # `rule` is a `Dry::Validation::Rule`, not a `Hash`
  return true if rule.keys.include?(@key_chain)
  # rubocop:enable Performance/InefficientHashSearch

  false
end

Actual behavior

$ rubocop --debug /tmp/tst.rb
For /tmp: configuration from /tmp/.rubocop.yml
configuration from /home/ojab/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-performance-1.10.1/config/default.yml
configuration from /home/ojab/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-performance-1.10.1/config/default.yml
Default configuration from /home/ojab/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.11.0/config/default.yml
Inspecting 1 file
Scanning /tmp/tst.rb
C

Offenses:

tst.rb:4:3: C: [Correctable] Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
  return true if rule.keys.include?(@key_chain)
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense auto-correctable

Steps to reproduce the problem

Run the code above with config above.

RuboCop version

$ rubocop -V
1.11.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 3.0.0 x86_64-linux)
  - rubocop-performance 1.10.1
@koic koic added the bug label Mar 16, 2021
koic added a commit to koic/rubocop that referenced this issue Mar 17, 2021
…rdClause`

Fixes rubocop#9608.

This PR fixes a false positive for `Layout/EmptyLineAfterGuardClause`
when using guard clause is after `rubocop:enable` comment.
koic added a commit to koic/rubocop that referenced this issue Mar 25, 2021
…rdClause`

Fixes rubocop#9608.

This PR fixes a false positive for `Layout/EmptyLineAfterGuardClause`
when using guard clause is after `rubocop:enable` comment.
koic added a commit to koic/rubocop that referenced this issue Mar 25, 2021
…rdClause`

Fixes rubocop#9608.

This PR fixes a false positive for `Layout/EmptyLineAfterGuardClause`
when using guard clause is after `rubocop:enable` comment.
bbatsov added a commit that referenced this issue Mar 25, 2021
Fixes #9608.

This PR fixes a false positive for `Layout/EmptyLineAfterGuardClause`
when using guard clause is after `rubocop:enable` comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants