Skip to content

Add good and bad examples to all cops

!236 (merged) adds a cop to enforce "# good" and "# bad" examples for each cop.

These are still missing from a few cops in this repo. These will be used to eventually generate documentation, so we should add these examples.

After doing so we can run bundle exec rubocop --regenerate-todo to update the .rubocop_todo.yml file.

Implementation

Each cop should have a description which includes good and bad examples of what the developer should do. Here's a good example of this: https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/blob/master/lib/rubocop/cop/layout/line_break_after_final_mixin.rb

  • For this task, each cop in this repo (found in lib/rubocop/cop/) should have a description as well as at least 1 good or bad example
  • Go to each cop, make sure you understand the functionality and purpose of the cop
  • Add the description and a good and bad example
  • Try adding the good and bad example to the codebase. You should see RuboCop complain with the bad example, but not with the good example
  • Create an MR

You do not have to do all cops in one go. If you prefer, you can do as many or as few as you like and create an MR, and either get to the rest later, or leave them for someone else.

Feel free to assign me (@knejad) as a reviewer to any MRs you create for this issue, or mention me if you need any help.

Edited by Keeyan Nejad