π Parent Note
π€ What is rubocop?
β
π rubocop document
β
RuboCop is a Ruby static code analyzer (a.k.a. linter) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide.
β
π€ How to use?
β
put the .rubocop.yml
on app directory and run following command.
β
bundle exec rubocop --config .rubocop.yml
β
then, get the results like this.
β
path/to/file.rb::11.1 C: Layout/TrailingWhitespace: Trailing whitespace detected.
273 files inspected, 1 offenses detected
β
It means that rubocop detects White Space which should be removed at the end of the line at row11, 1char, and the violation is only 1 in 273 files.
β
β
π€ How to fix it?
β
1. Google with the detected message
β
When you google with Layout/TrailingWhitespace, you'll see following explanation, then fix it.
β
# The line in this example contains spaces after the 0.
# bad
x = 0
β
# The line in this example ends directly after the 0.
# good
x = 0
β
2. Auto correct
use -a
option.
β
bundle exec rubocop -a
β
You can find other options on the π document.
β
Top comments (0)