tldr/pages/common/rubocop.md

33 lines
601 B
Markdown
Raw Permalink Normal View History

2018-03-19 12:42:38 +00:00
# rubocop
> Lint Ruby files.
2022-02-14 11:21:43 +00:00
> More information: <https://docs.rubocop.org/rubocop/usage/basic_usage.html>.
2018-03-19 12:42:38 +00:00
2018-03-19 14:34:19 +00:00
- Check all files in the current directory (including subdirectories):
2018-03-19 12:42:38 +00:00
`rubocop`
2018-03-19 14:34:19 +00:00
- Check one or more specific files or directories:
2018-03-19 12:42:38 +00:00
2018-03-19 14:49:56 +00:00
`rubocop {{path/to/file}} {{path/to/directory}}`
2018-03-19 12:42:38 +00:00
- Write output to file:
2018-03-19 14:49:56 +00:00
`rubocop --out {{path/to/file}}`
2018-03-19 12:42:38 +00:00
2018-03-19 14:34:55 +00:00
- View list of cops (linter rules):
2018-03-19 12:42:38 +00:00
`rubocop --show-cops`
- Exclude a cop:
`rubocop --except {{cop_1}} {{cop_2}}`
- Run only specified cops:
`rubocop --only {{cop_1}} {{cop_2}}`
- Auto-correct files (experimental):
`rubocop --auto-correct`