Skip to content

Fix Rubocop Rails issues #11482

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

Open
21 of 23 tasks
Tracked by #6055
dacook opened this issue Sep 1, 2023 · 22 comments
Open
21 of 23 tasks
Tracked by #6055

Fix Rubocop Rails issues #11482

dacook opened this issue Sep 1, 2023 · 22 comments
Assignees
Labels
epic Group of issues hackathon Issues for upcoming hackathons tech debt

Comments

@dacook
Copy link
Member

dacook commented Sep 1, 2023

We use Rubocop to standardise our code, which can improve code quality and reduce confusion. When evaluating each rule, consider if it helps with those goals or not. Often the suggested autocorrection is fine, but some cops require more consideration and there may be a better solution, or it might be appropriate to disable them, rather than create unnecessary extra work.
If unsure, please ping @openfoodfoundation/core-devs to request an opinion.

Strategy to fix issues

The normal process to fix a style issue is:

  1. Choose a cop to work on, next on the list (but ⚠️ double check there isn't already a PR addressing the cop: https://github.com/openfoodfoundation/openfoodnetwork/pulls)
  2. Remove it from .rubocop_todo.yml and run rubocop to see the error(s).
  3. Evaluate the rule, and consider applying the suggested fix if it makes sense
    • It may be helpful to commit some fixes separately, or chunked together
    • If it's not a simple fix, it may be worth simply adding a rubocop:disable comment in some cases (disable only offending line where possible)

When a cop or group of cops is complete, open a pull request.

Issues

Most/all of these will require manual fixes.
Generated 27 Feb 2024, up to date as of 19 Mar 2025

@dacook
Copy link
Member Author

dacook commented Sep 1, 2023

Hi @macanudo527 , I see you've started on this so created an issue for tracking.

@macanudo527
Copy link
Collaborator

@dacook Can you assign this to me?

@RachL RachL moved this from All the things to In Dev 💪 in OFN Delivery board Feb 15, 2024
@dacook
Copy link
Member Author

dacook commented Feb 26, 2024

Hi @macanudo527 , how have you been? I hope you've had a fulfilling start to the year!
Just wondering if you'd like to pick this up this year, or if we should unassign for now?

@macanudo527 macanudo527 removed their assignment Feb 26, 2024
@macanudo527
Copy link
Collaborator

@dacook Yeah, I've just been too busy with everything. I'd like to work on it, but just can't.

@dacook
Copy link
Member Author

dacook commented Feb 26, 2024

No problems, that's totally understandable. All the best for this season, and I hope to see you again soon!

@sigmundpetersen sigmundpetersen moved this from In Dev 💪 to All the things in OFN Delivery board Mar 1, 2024
@github-project-automation github-project-automation bot moved this to To triage (By the maintainers) in Welcome New Developers! Mar 17, 2024
@dacook dacook moved this from To triage (By the maintainers) to Backend Hard in Welcome New Developers! Mar 17, 2024
@dacook dacook moved this from Backend Hard to Backend Easy in Welcome New Developers! Mar 17, 2024
@anthonyms
Copy link
Contributor

@dacook Kindly assign this to me.
Am I right in concluding that it is a subset of #6055?

@dacook dacook moved this from Backend Easy to In progress in Welcome New Developers! Mar 18, 2024
@dacook dacook moved this from All the things to In Dev 💪 in OFN Delivery board Mar 18, 2024
@dacook
Copy link
Member Author

dacook commented Mar 18, 2024

Great, yep, that's correct Anthony. Good luck!

@sigmundpetersen
Copy link
Contributor

@dacook maybe we could create sub-issues of the task list in the description?
Then each issue will check itself when a PR is merged towards it.

We can create them as we go. Just click to the far right of each checkbox.

@dacook
Copy link
Member Author

dacook commented Mar 19, 2024

Thanks Sigmund. Yes I hadn't bothered with this because I wasn't sure how big each of the items was. It's possible some are so small that they don't need to have a separate issue/pr..

@chahmedejaz chahmedejaz self-assigned this Jun 27, 2024
@RachL RachL moved this from In progress to Backend Easy in Welcome New Developers! Oct 1, 2024
@RachL RachL added the hackathon Issues for upcoming hackathons label Oct 1, 2024
@sigmundpetersen sigmundpetersen moved this from Dev ready 👋 to All the things 💤 in OFN Delivery board Nov 30, 2024
cyrillefr added a commit to cyrillefr/openfoodnetwork that referenced this issue Feb 17, 2025
…11482)

- When you define a uniqueness validation in Active Record model,
  you also should add a unique index for the column.
- Cf. https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsuniquevalidationwithoutindex
- Therefore : migration files to match DB structure and Ruby code.
@cyrillefr
Copy link
Contributor

Hello @dacook ,

The Rails/SquishedSQLHeredocs item is not in the .rubocop_todo.yml file anymore.
It has been fixed in 2023. It can be removed from the list.

Regarding the Rails/TransactionExitStatement, the offense will no longer be effective in Rails 7.2 upwards since the behaviour that has changed will be restored. (I don't know how to tag this item).

@dacook
Copy link
Member Author

dacook commented Feb 17, 2025

Thanks Cyrille, that's interesting, the list was last generated in 2024, I don't know why SquishedSQL was included then. 🤷
I've ticked SquishedSQL and crossed out TransactionExitStatement with a note about 7.2.

Thanks to your latest contribution, we're almost finished!

cyrillefr added a commit to cyrillefr/openfoodnetwork that referenced this issue Feb 18, 2025
…11482)

- When you define a uniqueness validation in Active Record model,
  you also should add a unique index for the column.
- Cf. https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsuniquevalidationwithoutindex
- Therefore : migration files to match DB structure and Ruby code.
@dacook
Copy link
Member Author

dacook commented Mar 3, 2025

Hi @cyrillefr , just wondering if you are planning to do any further work on this? If so I will assign the issue to you to avoid double-up with anyone else.

Edit: as you already have a PR open for this issue I've assigned you for now.

@cyrillefr
Copy link
Contributor

Hello @dacook ,

The Rails/LexicallyScopedActionFilter box can be checked with a reference to #13251 instead :)

That leaves this issue with the #13163 which is blocked and it will be done.

@dacook dacook moved this from Dev ready 👋 to In Progress ⚙ in OFN Delivery board Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Group of issues hackathon Issues for upcoming hackathons tech debt
Projects
Status: In Progress ⚙
Status: In progress
Development

No branches or pull requests

9 participants