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

Enhancement: make Style/GuardClause aware of dynamic methods #12128

Closed
vlad-pisanov opened this issue Aug 17, 2023 · 0 comments · Fixed by #12129
Closed

Enhancement: make Style/GuardClause aware of dynamic methods #12128

vlad-pisanov opened this issue Aug 17, 2023 · 0 comments · Fixed by #12129

Comments

@vlad-pisanov
Copy link

Currently, Style/GuardClause only looks at statically-defined methods, and skips those defined via define_method or define_singleton_method:

def foo
  if cond
    42   # Style/GuardClause flagged ✔️
  end
end

define_method(:bar) do
  if cond
    42   # Style/GuardClause ignores 😔
  end
end
koic added a commit to koic/rubocop that referenced this issue Aug 17, 2023
Fixes rubocop#12128.

This PR makes `Style/GuardClause` aware of `define_method`.
bbatsov pushed a commit that referenced this issue Sep 28, 2023
Fixes #12128.

This PR makes `Style/GuardClause` aware of `define_method`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants