-
-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new rails Schema Comment cop #568
Add new rails Schema Comment cop #568
Conversation
Even though your team might add a comment to all columns, I'm wondering if for wider use there should be a configuration option to specify tables/columns to ignore. |
Makes sense, but I'm not sure how configurations get to the cop. I'll see if I figure it out in the next few days. Thanks for the review. I will fix the specs and description tomorrow. |
It may be preferable to make the inspection of table comments and column comments as one cop. Maybe that cop name like |
I think I made all the changes with the exception of the configuration options. I'll work on that |
@andyw8 do you think this configuration is essential for a first version or we could launch as it is and improve later? |
No, not essential. |
Great. Just let me know if there is anything else that I missed that can be improved code, test or description wise :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes are purely cosmetic, to make the code slightly (and subjectively) more readable. It's clean and readable as is. Good job!
I'll make a note for myself to explicitly enable the cop on my current project.
❤️ Thank you!
Add `Rails/AddColumnComment` cop Update config/default.yml Co-authored-by: Andy Waite <[email protected]> Update lib/rubocop/cop/rails/schema_comment.rb Co-authored-by: Andy Waite <[email protected]> Update Rails/SchemaComment doc Add more column types to Rails/SchemaComment Improve SchemaComment specs Remove uncessary safe project config for SchemaComment Augment rails schema definitions and use Set Change constant into def_node_matcher @SchemaComment
Thanks! |
Hi, this is my first contribuiton here, so I'm sorry if got something wrong and I hope we can fix it together :)
The cop:
Some databases like MySQL and Postgres supports comments and Rails migrations also support adding it. Some teams follow the good practice of adding comments to new columns or tables whenever creating them. This cops enforces this behaviour, but is disabled by default since this practice may not be widely spread.
PS: If this cop is accepted, I will also create one for table comments
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.