rubocop: Missing top-level class documentation comment.
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
^^^^^
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 17
Documentationshould not be nested underAllCops. It’s a top-level key.@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.I have the same problem. I have added comment before class
Using this doesn’t work for me:
However, removing
AllCopsdoes the trick:Can I ask what WOULD be the correct way to write my class definition so that it passes the rubocop check?
Because it’s a good practice to document top-level (non-namespace) classes and modules. Feel free to disable the check.
@nghiabk change #Your comment into # Your comment that will solve your problem, rubocop wants space between command tag and the description
@bbatsov, why I need to insert the comment before User model & ApplicationController?
This way you duplicate “convention over configuration” principle
According to the document, I think we should use
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)
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
mastercops can also be disabled for particular files/folder).I came across this issue via Google, but before that I was struggling to figure out how to disable the class docs warning.
Should
Documentationbe added tohttps://github.com/bbatsov/rubocop/blob/master/config/default.yml? The README directs people there to discover the default options.