-
-
Notifications
You must be signed in to change notification settings - Fork 724
Rubocop
Rubocop is a linter that helps us enforce consistency in coding style.
There is script to do the below steps quickly: see instructions inside script/rubocop-autocorrect.sh
In order to fix all the existing occurrences of a cop, we need to run Rubocop with the --auto-correct
flag and regenerate the .rubocop_todo.yml
to remove the previous exclusion of that same cop.
So first, fix the violations of that particular cop like so:
bundle exec rubocop --auto-correct --only <cop_name> path/to/file
Where <cop_name>
is the identifier of the cop. Something like Layout/BlockEndNewline
, the one we fixed in https://github.com/openfoodfoundation/openfoodnetwork/pull/2063. You will find their names in .rubocop_todo.
Now, that these violations are fixed, we have to get rid of them in the .rubocop_todo.yml. They are no longer true.
To do that, go check the header of that file. It specifies how to do it:
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 1400`
# on 2018-01-20 12:46:57 +0100 using RuboCop version 0.49.1.
so, just run:
bundle exec rubocop --auto-gen-config --exclude-limit 1400
Notice that we must precede the command with bundle exec
in order for ruby to pick the rubocop version from the app's Gemfile.
We're done. Stash all these changes, commit and push them here. Then, open a pull request so that we can all review them. Congratulations 🎉! by making our codebase closer to our style guide you are one step closer to heaven 👼
Development environment setup
- Pipeline development process
- Bug severity
- Feature template (epic)
- Internationalisation (i18n)
- Dependency updates
Development
- Developer Guidelines
- The process of review, test, merge and deploy
- Making a great commit
- Making a great pull request
- Code Conventions
- Database migrations
- Testing and Rspec Tips
- Automated Testing Gotchas
- Rubocop
- Angular and OFN
- Feature toggles
- Stimulus and Turbo
Testing
- Testing process
- OFN Testing Documentation (Handbooks)
- Continuous Integration
- Parallelized test suite with knapsack
- Karma
Releasing
Specific features
Data and APIs
Instance-specific configuration
External services
Design