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

Lint/AssignmentInCondition regression causing false positive #3520

Closed
savef opened this issue Sep 21, 2016 · 3 comments
Closed

Lint/AssignmentInCondition regression causing false positive #3520

savef opened this issue Sep 21, 2016 · 3 comments

Comments

@savef
Copy link
Contributor

savef commented Sep 21, 2016

The following code will raise an offence for the Lint/AssignmentInCondition cop:
foo if bar { |x| x.abc = nil }.value

This didn't used to happen in v0.42.0, but does with v0.43.0. I tracked the commit that causes the breaking change to b0d8e0c.


RuboCop version

$ rubocop -V
0.43.0 (using Parser 2.3.1.3, running on ruby 2.3.1 x86_64-linux)
@savef
Copy link
Contributor Author

savef commented Sep 21, 2016

@Drenmi

@savef savef changed the title Lint/AssignmentInCondition regression Lint/AssignmentInCondition regression causing false positive Sep 21, 2016
@Drenmi
Copy link
Collaborator

Drenmi commented Sep 22, 2016

Thanks for the report @savef! This would suggest we're missing some test cases. 😀

I will have a look at this as soon as I have time. If someone else wants to pick it up before that may happen, please feel free.

savef added a commit to savef/rubocop that referenced this issue Sep 23, 2016
This was broken in b0d8e0c which was simply a refactoring commit. It looks like part of the code was omitted accidentally when porting to the new block. Specifically, the part which was dropped was: https://github.com/bbatsov/rubocop/blob/78de463f33992bce5b1ecf40e311958ad773bad5/lib/rubocop/cop/lint/assignment_in_condition.rb#L35-L38

I've ported the missing checks to the `#skip_children?` method, and added a test which would've caught the regression.
bbatsov pushed a commit that referenced this issue Sep 23, 2016
This was broken in b0d8e0c which was simply a refactoring commit. It looks like part of the code was omitted accidentally when porting to the new block. Specifically, the part which was dropped was: https://github.com/bbatsov/rubocop/blob/78de463f33992bce5b1ecf40e311958ad773bad5/lib/rubocop/cop/lint/assignment_in_condition.rb#L35-L38

I've ported the missing checks to the `#skip_children?` method, and added a test which would've caught the regression.
@savef
Copy link
Contributor Author

savef commented Sep 23, 2016

Sorted.

@savef savef closed this as completed Sep 23, 2016
mikezter added a commit to mikezter/rubocop that referenced this issue Sep 28, 2016
* bbatsov/master: (80 commits)
  [Fix rubocop#3540] Make `Style/GuardClause` register offense for instance & singleton methods
  [Fix rubocop#3436] issue related to Rails/SaveBang when returning non-bang call from the parent method
  Allow `#to_yml` to produce single-quoted strings
  Add support for StyleGuideBaseURL and update rules
  Add spec for the existing style guide URL implementation
  Fix the changelog
  Edited regular expression for normal case to fix issues rubocop#3514 and rubocop#3516 (rubocop#3524)
  Add a rake task for generation a new cop (rubocop#3533)
  [Fix rubocop#3510] Various bug fixes for SafeNavigation (rubocop#3517)
  [Fix rubocop#3512] Change error message of `Lint/UnneededSplatExpansion` for array (rubocop#3526)
  Fix false positive in `Lint/AssignmentInCondition` (rubocop#3520) (rubocop#3529)
  Rename a mismatched filename (rubocop#3523)
  Fix a broken changelog entry
  [Fix rubocop#3511] Style/TernaryParentheses false positive (rubocop#3513)
  Fix the release notes for 0.43
  Cut 0.43.0
  [Fix rubocop#3462] Don't flag single-line methods
  Fix false negatives in `Rails/NotNullColumn` cop (rubocop#3508)
  Remove unused doubled methods (rubocop#3509)
  [Fix rubocop#3485] Make OneLineConditional cop ignore empty else (rubocop#3487)
  ...
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
…bocop#3529)

This was broken in b0d8e0c which was simply a refactoring commit. It looks like part of the code was omitted accidentally when porting to the new block. Specifically, the part which was dropped was: https://github.com/bbatsov/rubocop/blob/78de463f33992bce5b1ecf40e311958ad773bad5/lib/rubocop/cop/lint/assignment_in_condition.rb#L35-L38

I've ported the missing checks to the `#skip_children?` method, and added a test which would've caught the regression.
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