For a first step of contribution to RuboCop :star2:
For Japanese: https://qiita.com/pocke/items/ade84e1f21629220715d
RuboCop has many cops. But not all cops have examples in the documentation. So, sometime we can't understand easily how a cop to work.
We can add examples easily.
For instance, Layout/SpaceInsideParens had not had any examples, but examples ware added by this pull-request #4827.
We need to do only three things to add examples for a cop.
First, add examples to cop's source code as a comment.
For instance, I added examples to lib/rubocop/cop/layout/space_inside_parens.rb in the Layout/SpaceInsideParens case. We can use specs to add examples.
Second, run bundle exec rake generate_cops_documentation. The task generates the documentation to manual/ directory from the comments in source code.
Third, git commit and git push and send a pull-request!
Note: Do not add [Fix #4910] prefix to commit message. Because the prefix closes this issue.
Take care of Metrics/LineLength! You can check it with bundle exec rake internal_investigation.
The list is generated by the following one-liner automatically.
$ ruby -ractive_support -ractive_support/core_ext -e 'cops=`rubocop --show-cops`.scan(/^\w+\/\w+/); examples = `git grep @example`.scan(%r!\w+/\w+\.rb!).map{|e|e[%r!^(.+)\.rb!, 1].camelize.gsub("::",?/)}; puts cops.-(examples).grep_v(/RSpec|Capybara|FactoryBot/).map{|c|"- #{c}"}.join("\n")'
The list contains some cops that don't need examples. For example, I think Metrics cops don't need any examples. Long line example does not make sense.
@pocke: I added checkboxes to your list, and removed the Metric ones. Hope that's okay. 馃檪
@pocke I missed the commit message #4910 and closed this Issue. However 35 cops still have no document.
% ruby -ractive_support -ractive_support/core_ext -e 'cops=`rubocop --show-cops`.scan(/^\w+\/\w+/); examples = `git grep @example`.scan(%r!\w+/\w+\.rb!).map{|e|e[%r!^(.+)\.rb!, 1].camelize.gsub("::",?/)}; puts cops.-(examples).grep_v(/RSpec|Capybara|FactoryGirl/).map{|c|"- #{c}"}.join("\n")' | wc -l
35
Would you please re-opening this Issue?
Reopened. Thank you!
I went to add documentation to Layout/InitialIndentation and it appears that an example already exists.
Lint/ScriptPermission already has an example as a comment in script_permission.rb
JSONLoad looks like it's already been documented.
Layout/SpaceAroundOperators as well has already been documented, can be checked off of the list above
It would be great if the step for running tests ("Run rake default or rake parallel. It executes all tests and RuboCop for itself, and generates the documentation.") was part of the steps above and not only present in the PR checklist.
Thanks all! I've updated the checklist.
I guess we can close this one now.