Reviewdog and RuboCop - otwcode/otwarchive GitHub Wiki
We use GitHub Actions to run RuboCop with Reviewdog (reviewdog/action-rubocop) on all pull requests. RuboCop is a linter that checks for code style errors and other things.
Rubocop can also be run locally with bundle exec rubocop path/to/file.rb
.
We have a number of custom cops for house rules.
RuboCop may occasionally flag issues that can't be addressed. This will look failing tests to anyone skimming the Pull Requests list, so it's a good idea to disable the inaccurate cop for the relevant lines. You can do this using a code comment.
If you only need to disable the cop for a single line, you can add the code comment at the end of that line. For example, if RuboCop complains about using regex instead of Cucumber expressions:
When /^I reorder the (\d+)(?:st|nd|rd|th) and (\d+)(?:st|nd|rd|th) work downwards in the series list$/ do |n1, n2| # rubocop:disable Cucumber/RegexStepName
If you need to disable it for multiple lines, you'll need two code comments: one above the first relevant line to disable Rubocop, and one below the last relevant line to reenable it:
# rubocop:disable Cucumber/RegexStepName When "I edit the tag {string}" do |tag| tag = Tag.find_by!(name: tag) visit tag_path(tag) within(".header") do click_link("Edit") end end # rubocop:enable Cucumber/RegexStepName
If you need to disable multiple cops for the same lines of code, refer to RuboCop's documentation on Disabling Cops within Source Code.