I'm new to rubocop, and one function is annoying to me.
Why I get Missing top-level class documentation comment. before each class or module definition?
class UsersController < InheritedResources::Base
^^^^^
Because it's a good practice to document top-level (non-namespace) classes and modules. Feel free to disable the check.
@bbatsov, why I need to insert the comment before User model & ApplicationController?
This way you duplicate "convention over configuration" principle
You're thinking mostly in terms of your particular use-case. While in a webapp controller documentation might not be essential, it's crucial in many other apps and libraries. It's also a good practice to document models, helpers, service classes, etc. As I said - if you don't find a cop useful - just disable it (in master cops can also be disabled for particular files/folder).
@bbatsov, I tried
AllCops:
Includes:
- Rakefile
- config.ru
Excludes:
- db/**
- config/**
- script/**
Documentation:
Enabled: false
in my .rubocop.yml, but with no success.
Documentation should not be nested under AllCops. It's a top-level key.
Thanks! That solved!
I came across this issue via Google, but before that I was struggling to figure out how to disable the class docs warning.
Should Documentation be added to https://github.com/bbatsov/rubocop/blob/master/config/default.yml? The README directs people there to discover the default options.
Never mind. I just now noticed the enable/disable inherit_from references... I should have checked there first...
Can I ask what WOULD be the correct way to write my class definition so that it passes the rubocop check?
class LocationFeatureSchedule < ActiveRecord::BasePIOPS2
belongs_to :location
end
@justinschier You write a comment above it (describing what it is). If you feel that's unnecessary, you can add a # :nodoc: comment at the end of the first line.
Thanks @bbatsov always good to learn best practices
how to solve offences in rubocp
Using this doesn't work for me:
AllCops:
Documentation:
Enabled: false
However, removing AllCops does the trick:
Documentation:
Enabled: false
I have the same problem. I have added comment before class
#Your comment
class UsersController < InheritedResources::Base
@nghiabk change #Your comment into # Your comment
that will solve your problem, rubocop wants space between command tag and the description
According to the document, I think we should use
Style/Documentation:
Enabled: false
to avoid the doc checking, configure rules with type's name.

Otherwise, without the type's name, I will get this warning(I am working in version 0.88)
/xxxxxx/.rubocop.yml: Warning: no department given for Documentation.
This is the right one, thank you @lanzhiheng !
Most helpful comment
Documentationshould not be nested underAllCops. It's a top-level key.