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

Layout/LineLength Says Corrected But Not Correcting #9230

Closed
jshah opened this issue Dec 15, 2020 · 4 comments
Closed

Layout/LineLength Says Corrected But Not Correcting #9230

jshah opened this issue Dec 15, 2020 · 4 comments

Comments

@jshah
Copy link

jshah commented Dec 15, 2020

Rubocop says it's auto-correcting a Layout/LineLength error but the file does not get auto-corrected.

> rubocop -a spec/factories/authentications.rb
spec/factories/authentications.rb:2241:121: C: [Corrected] Layout/LineLength: Line is too long [126/120]
              { 'sql' => 'update table set sku=:sku, price=:price where user_id=:pkey;', 'category' => 'SQL Server Records' },
                                                                                                                        ^^^^^^

In my previous rubocop version (0.84), Layout/LineLength was never correctable.

Expected behavior

Doesn't think Layout/LineLength is auto-correctable.

Actual behavior

Tries to correct line and doesn't even work.

❯ rubocop --debug -a spec/factories/authentications.rb
For /Users/jshah/code/dgapp: configuration from /Users/jshah/code/dgapp/.rubocop.yml
configuration from /Users/jshah/.rbenv/versions/2.6.6/gemsets/dgapp/gems/rubocop-rails-2.9.0/config/default.yml
configuration from /Users/jshah/.rbenv/versions/2.6.6/gemsets/dgapp/gems/rubocop-rails-2.9.0/config/default.yml
Default configuration from /Users/jshah/.rbenv/versions/2.6.6/gemsets/dgapp/gems/rubocop-1.5.2/config/default.yml
Inheriting configuration from /Users/jshah/code/dgapp/.rubocop_todo.yml
Inspecting 1 file
Scanning /Users/jshah/code/dgapp/spec/factories/authentications.rb
Loading cache from /Users/jshah/.cache/rubocop_cache/77796e83e2d7c09f6cff3e597eae70621d8d6afb/284dfa8f0276b702be6b3b9b688b22a2fad18991/38f0528caa6cf1f62ac759fee52f7348bd9ef268
C

Offenses:

spec/factories/authentications.rb:2241:121: C: [Corrected] Layout/LineLength: Line is too long. [126/120]
              { 'sql' => 'update table set sku=:sku, price=:price where user_id=:pkey;', 'category' => 'SQL Server Records' },
                                                                                                                        ^^^^^^

1 file inspected, 1 offense detected, 1 offense corrected
Finished in 1.1515010000148322 seconds

Afterwards, file shows no changes.

Steps to reproduce the problem

Layout/LineLength greater than allowed then run rubocop -a <file>

RuboCop version

❯ rubocop -V
1.5.2 (using Parser 2.7.2.0, rubocop-ast 1.3.0, running on ruby 2.6.6 x86_64-darwin19)
  - rubocop-rails 2.9.0
@koic
Copy link
Member

koic commented Dec 15, 2020

The issue may have been resolved by latest RuboCop 1.6. Can you update to the latest RuboCop version?
If that doesn't work, can you provide executable reproduction code? Thank you.

@dvandersluis
Copy link
Member

Yeah this should be fixed by #9190.

@jshah
Copy link
Author

jshah commented Dec 15, 2020

Thanks, I'll give this a go today.

@jshah
Copy link
Author

jshah commented Dec 15, 2020

Looks like 1.6.1 is actually auto-correcting. This is great!

Closing

@jshah jshah closed this as completed Dec 15, 2020
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

3 participants