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

[Fix #11556] Fix a false positive for Lint/Debugger #11557

Merged
merged 1 commit into from
Feb 10, 2023

Conversation

koic
Copy link
Member

@koic koic commented Feb 8, 2023

Fixes #11556.

This PR fixes a false positive for Lint/Debugger when p is an argument of method call. Basically, debugger methods are not used as a method argument without arguments.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@koic koic force-pushed the fix_a_false_positive_for_lint_debugger branch from 8c5d0a0 to 8cf787d Compare February 9, 2023 01:59
@bbatsov
Copy link
Collaborator

bbatsov commented Feb 9, 2023

Looks okay, sans the CI failures.

I'm starting to wonder, though, if it was a good idea to mix the debug methods that actually start some debugger (and don't take arguments) with print debugging methods (which take some arguments), as for them we could just check if they are invoked without any arguments. Anyways, the fix will do for now.

Fixes rubocop#11556.

This PR fixes a false positive for `Lint/Debugger` when `p` is an argument of method call.
Basically, debugger methods are not used as a method argument without arguments.
@koic koic force-pushed the fix_a_false_positive_for_lint_debugger branch from 8cf787d to bf0f8a4 Compare February 9, 2023 09:34
@koic
Copy link
Member Author

koic commented Feb 9, 2023

the debug methods that actually start some debugger (and don't take arguments) with print debugging methods (which take some arguments)

Ah, it may have been better to distinguish between them. For now, I'd like to look feedback after #11556 issue is resolved.

@bbatsov bbatsov merged commit 0699f73 into rubocop:master Feb 10, 2023
@koic koic deleted the fix_a_false_positive_for_lint_debugger branch February 10, 2023 16:26
koic added a commit to koic/rubocop that referenced this pull request Feb 10, 2023
This PR rolls back the print debug default configuration (rubocop#11518) of `Lint/Debugger`
based on the following feedback.

- rubocop#11557 (comment)
- rubocop#11552 (comment)
- rubocop#11518 (comment)

It seems like it was a bad idea to mix debugger and print debug methods by default.

This PR updates `Lint/Debugger` cop defaults to handle only debugger methods as per the cop name.
OTOH, it leaves the logic in rubocop#11557 to prevent false positives when user configures
print debug methods. e.g. rubocop#11517 (comment)
bbatsov pushed a commit that referenced this pull request Feb 11, 2023
This PR rolls back the print debug default configuration (#11518) of `Lint/Debugger`
based on the following feedback.

- #11557 (comment)
- #11552 (comment)
- #11518 (comment)

It seems like it was a bad idea to mix debugger and print debug methods by default.

This PR updates `Lint/Debugger` cop defaults to handle only debugger methods as per the cop name.
OTOH, it leaves the logic in #11557 to prevent false positives when user configures
print debug methods. e.g. #11517 (comment)
@Greg-Myers-SB
Copy link

Greg-Myers-SB commented Feb 23, 2023

I'm not sure this was intentional but this appears to have changed the behaviour of using pretty_print pp MyCode used to trigger, now it no longer does.
I'm not sure if PrettyPrint was supposed to trigger this rule in the first place though?

Just seen e66e3c7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive in Lint/Debugger
3 participants