Add new Bundler/GemComment cop#6109
Conversation
bf69179 to
3e05cc6
Compare
|
Such a cop should definitely have some whitelist of gems that don't require any explanations (generally because they are very widely used and everyone knows them or simply because they are part of some framework). |
4008d75 to
07223d3
Compare
07223d3 to
7e86351
Compare
|
Thank you for looking at this PR! I added a |
|
Yay! Thank you for reviewing and merging this! \o/ |
|
@sunny I LOVE the idea for this cop. ❤ How difficult would it be to add an option to this cop for an inline comment versus a comment above the line? Example: # This is my gem description
gem 'foo'versus gem 'foo' # This is my gem descriptionWhen you have a Gemfile that has a long list of gems, adding the comment above can end up making the Gemfile both extremely long, as well as more difficult to parse (inline comments can be lined up so as to be easy to scan). |
|
Does this take into account inline comments? |
|
This does not take into account inline comments, since I don't think they help readability in Gemfiles. My "style" of Gemfiles looks more like this, usually: # This is my gem description that is welcome to be very long.
# Also this can span multiple lines so that you can say which version is
# supported and why you decided on a specific version and what issues
# are blocking the update.
gem 'foo', git: 'git@github.com:sunny/foo', require: false@jfelchner However, feel free to add an option to support inline comments, if you wish, it shouldn't be that hard! |
|
We use inline comments by copying the first line of the description from rubygems.org. Example: gem 'oj', '3.6.8' # The fastest JSON parser and object serializer.
gem 'patron', '0.13.1' # Ruby HTTP client library based on libcurl
gem 'pg', '1.1.3' # Pg is the Ruby interface to the PostgreSQL RDBMS |
|
@rhymes that's pretty cool 😎 I prefer to leave comments addressing why the gem was installed in this project and why we're on a particular branch or version, if applicable. Basically, I try to avoid comments that are duplicative with the gem's readme. For instance: # Get results from the FooBar API over HTTP
# 0.14 has a bug (https://github.com/patron/patron/issue/42)
gem 'patron', '0.13.1' |
|
@mikegee that makes perfect sense! |
This cop helps our team make sure all
gemdeclarations inside aGemfilehave a comment that describes why this gem was added to the project.Bad:
Good:
The cop is disabled by default so as not to break in codebases that do not enforce this behavior.
Before submitting the PR make sure the following are checked:
[Fix #issue-number](if the related issue exists).master(if not - rebase it).and description in grammatically correct, complete sentences.
rake defaultorrake parallel. It executes all tests and RuboCop for itself, and generates the documentation.