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

non-local exit from iterator without return value has a false positive with #define_method. #2272

Closed
robotdana opened this issue Sep 23, 2015 · 1 comment

Comments

@robotdana
Copy link
Contributor

[:method_one, :method_two].each do |method_name|
  define_method(method_name) do
    return if predicate?
  end
end

is flagged with:

Non-local exit from iterator, without return value. next, break, Array#find, Array#any?, etc. is preferred.
rubocop -V
0.34.2 (using Parser 2.2.2.6, running on ruby 2.2.2 x86_64-darwin14)
(and current master)
@alexdowad
Copy link
Contributor

Just opening a PR which fixes this.

bbatsov added a commit that referenced this issue Oct 29, 2015
[Fix #2272] `Lint/NonLocalExitFromIterator` doesn't warn about block passed to `Module#define_method`
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

No branches or pull requests

2 participants