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

Not safe applied cops 'Style/Next' and 'Style/SafeNavigation' at the same time #6812

Closed
ghost opened this issue Mar 5, 2019 · 1 comment
Closed

Comments

@ghost
Copy link

ghost commented Mar 5, 2019

Hello,

Running rubocop (0.65.0) on this code 'with the --safe-auto-correct option) break it :

      user = User.where(email: email).first
      if user
        user.notifications.create(
          title: 'abc'
        )
      end

Result in :

      next unless useruser&.notifications&.create(
        title: 'abc'
      )

Cops applied : "Style/Next" then "Style/SafeNavigation"
Code is broken by the "useruser" new variable, like both cops where applied on the same original code.

But, if i run those cops one after the other with the "--only" option, i got this result :

      next unless user
      user.notifications.create(
         title: 'abc'
      )

No code broken, and "Style/SafeNavigation" become unnecessary.

Best regards

@Darhazer
Copy link
Member

Darhazer commented May 1, 2019

This issue is the same as #6738 and it's fixed in Rubocop 0.68.1

@Darhazer Darhazer closed this as completed May 1, 2019
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

1 participant