-
Notifications
You must be signed in to change notification settings - Fork 441
Rubocop
We have two Rubocop setups, one for the rails application (located in src/api/
)
and one for all the other ruby code (located in the root directory of the repository).
Each setup has two rake tasks, one for generating the Rubocop todo configuration
and one for running Rubocop with this configuration.
All the Rubocop configuration that affects both, the rails code and the other ruby code,
goes into .rubocop.yml
. All configuration that only affects rails, like rails cops,
goes into src/api/.rubocop.yml
.
This runs Rubocop with the current configuration.
rake dev:lint:rubocop:all # Run both Rubocop tasks
rake dev:lint:rubocop:rails
rake dev:lint:rubocop:root
This updates the .rubocop_todo.yml
file.
rake dev:lint:rubocop:auto_gen_config:all # Update both configurations
rake dev:lint:rubocop:auto_gen_config:rails
rake dev:lint:rubocop:auto_gen_config:root
rake dev:lint:rubocop:autocorrect # Autocorrects offenses for both configurations
Apart from using the rake task, you can as normally run Rubocop in your own. When running it from the src/api
directory, do not forget to include the option --ignore-parent-exclusion
. Otherwise the .rubocop.yml
in the root directory will be loaded, consecuently excluding the src/api
directory and not inspecting any file.
For example, if you want to autocorrect the offenses only in the src/api
directory showing the name of the cops which produces the offenses, you could run from that directory:
bundle exec rubocop -aD --ignore-parent-exclusion
Splitting the fixes per RuboCop offense makes this a lot easier to review and understand what happened. This PR is a good example.
- Development Environment Overview
- Development Environment Tips & Tricks
- Spec-Tips
- Code Style
- Rubocop
- Testing with VCR
- Authentication
- Authorization
- Autocomplete
- BS Requests
- Events
- ProjectLog
- Notifications
- Feature Toggles
- Build Results
- Attrib classes
- Flags
- The BackendPackage Cache
- Maintenance classes
- Cloud uploader
- Delayed Jobs
- Staging Workflow
- StatusHistory
- OBS API
- Owner Search
- Search
- Links
- Distributions
- Repository
- Data Migrations
- next_rails
- Ruby Update
- Rails Profiling
- Installing a local LDAP-server
- Remote Pairing Setup Guide
- Factory Dashboard
- osc
- Setup an OBS Development Environment on macOS
- Run OpenQA smoketest locally
- Responsive Guidelines
- Importing database dumps
- Problem Statement & Solution
- Kickoff New Stuff
- New Swagger API doc
- Documentation and Communication
- GitHub Actions
- How to Introduce Software Design Patterns
- Query Objects
- Services
- View Components
- RFC: Core Components
- RFC: Decorator Pattern
- RFC: Backend models