-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
undefined method `source' for nil:NilClass in ZeroLengthPredicate #3131
Comments
Actually the bug is with the cop showing offense for
This should not happen since the cop works on |
tejasbubane
added a commit
to tejasbubane/rubocop
that referenced
this issue
May 19, 2016
Closes rubocop#3131 `Style/ZeroLengthPredicate` cop recognized offense for variables with names `length` and `size`. eg. `size == 0` This PR fixes the issue.
9 tasks
Neodelf
pushed a commit
to Neodelf/rubocop
that referenced
this issue
Oct 15, 2016
…es (rubocop#3147) Closes rubocop#3131 `Style/ZeroLengthPredicate` cop recognized offense for variables with names `length` and `size`. eg. `size == 0` This PR fixes the issue.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
rubocop -a
completes without errorsActual behavior
rubocop -a
bails after parsing five of 20 files, with the attached stack trace (originating atzero_length_predicate.rb:65
).Steps to reproduce the problem
Run
rubocop -a
against the following source:Notes
@size
instead ofsize
fixes the problem, as does usingsize <= 0
instead ofsize == 0
.self.size
instead ofsize
does not fix the problem -- thoughself.size
gets autocorrected tosize
before it fails.empty?
method does not fix the problem (although it's likely that in that case the failure is in theempty?
method's ownsize == 0
check).# rubocop:disable Style/ZeroLengthPredicate
afterdef frob
, surprisingly, does not fix the problem.RuboCop version
Include the output of
rubocop -V
:The text was updated successfully, but these errors were encountered: