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

Autocorrect Rubocop issues #12026

Merged
merged 4 commits into from
Jan 10, 2024
Merged

Conversation

dacook
Copy link
Member

@dacook dacook commented Jan 9, 2024

What? Why?

I tried running the autocorrect script one more time, because it's been a couple of months. It looped through about 20, and only a few had corrections, so I think it's safe to say it

What should we test?

No testing needed for safe autocorrects

Inspecting 1530 files
.....................................................................................................................................................................................................................................................................................................................................................W.................................................................................................................................................................................................................................................W..........................................................................................................................................................................................................................................................W.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/models/spree/preferences/preferable_class_methods.rb:73:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}" instead.
        "preferred_#{name}".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:77:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}=" instead.
        "preferred_#{name}=".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:81:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"prefers_#{name}?" instead.
        "prefers_#{name}?".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:85:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"prefers_#{name}=" instead.
        "prefers_#{name}=".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:89:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}_default" instead.
        "preferred_#{name}_default".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:93:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}_type" instead.
        "preferred_#{name}_type".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable_class_methods.rb:97:9: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"preferred_#{name}_description" instead.
        "preferred_#{name}_description".to_sym
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/sets/product_set.rb:121:28: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"variant_#{error.attribute}" instead.
        product.errors.add("variant_#{error.attribute}".to_sym, error.message)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/spree/core/environment_extension.rb:11:24: W: [Corrected] Lint/SymbolConversion: Unnecessary symbol conversion; use :"#{name}=" instead.
        create_method( "#{name}=".to_sym ) { |val|
                       ^^^^^^^^^^^^^^^^^

1530 files inspected, 9 offenses detected, 9 offenses corrected
Inspecting 1530 files
.................................................................................................................................................................................C................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.......................................................................................................................

Offenses:

app/helpers/shop_helper.rb:48:43: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
    no_open_order_cycles?(order_cycles) &&
                                          ^
app/helpers/shop_helper.rb:48:44: C: [Corrected] Style/RedundantLineContinuation: Redundant line continuation.
    no_open_order_cycles?(order_cycles) && \ ...
                                           ^
spec/system/admin/configuration/content_spec.rb:35:64: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
    expect(page).to have_selector :link, "markdown link", href:
                                                               ^
spec/system/admin/configuration/content_spec.rb:35:65: C: [Corrected] Style/RedundantLineContinuation: Redundant line continuation.
    expect(page).to have_selector :link, "markdown link", href: \ ...
                                                                ^

1530 files inspected, 4 offenses detected, 4 offenses corrected
@dacook dacook added the technical changes only These pull requests do not contain user facing changes and are grouped in release notes label Jan 9, 2024
@dacook
Copy link
Member Author

dacook commented Jan 9, 2024

Interestingly, a couple of the fixes didn't commit with the script. I don't know why, I don't think I was doing anything else at the time.

...
1530 files inspected, 1089 offenses detected, 348 offenses autocorrectable
Created .rubocop_todo.yml.
No corrections made for Style/RedundantParentheses. Skipping.

Trying to autocorrect safely: Style/RedundantReturn
Phase 1 of 2: run Layout/LineLength cop (skipped because the default Layout/LineLength:Max is overridden)
Phase 2 of 2: run all cops
Inspecting 1530 files
...
1530 files inspected, 1088 offenses detected, 347 offenses autocorrectable
Created .rubocop_todo.yml.
No corrections made for Style/RedundantReturn. Skipping.

But there was a changed file, so I manually committed it.

@dacook dacook self-assigned this Jan 9, 2024
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, it's so cool that we can now easily harness Rubocop to improve our code quality.

Fast forward to 2026 and Rubocop will solve all deprecation warnings for us while Dependabot bumps the Rails version without issues.

@mkllnk mkllnk merged commit d197251 into openfoodfoundation:master Jan 10, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical changes only These pull requests do not contain user facing changes and are grouped in release notes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Fix Rubocop issues with safe auto-correct
3 participants