-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 some linters specifically for the Gemfile #3600
Comments
I think this is a great idea. Some of those checks will need configurability, of course. (For instance, where I work apps are required to pull from the local gem server, not rubygems.) A check specifically for this vulnerability would be cool, too. |
Interesting. I hadn't heard of that vulnerability. I think it'd be worthwhile to have a check for it. I'll add it to the list in my original post. |
I agree. I'd accept Gemfile linters if someone is willing to write them. :-) |
I'll give this one a go |
The DuplicatedGem cop checks for duplicate gem entries in Gemfiles.
See also rubocop#3657 rubocop#3600 Goal ---- Auto Correct not sorted gems. e.g. ```ruby gem 'b' gem 'd' gem 'c' gem 'a' gem 'a' gem 'b' gem 'c' gem 'd' ``` Note ----- I added `autocorrect_source_with_loop` test helper method to execute auto-correction with loop. This method is based on do_inspection_loop. https://github.com/bbatsov/rubocop/blob/ed4aeb845bfcaaff0648d365c5b46a2e725347f7/lib/rubocop/runner.rb#L179-L202
See also #3657 #3600 Goal ---- Auto Correct not sorted gems. e.g. ```ruby gem 'b' gem 'd' gem 'c' gem 'a' gem 'a' gem 'b' gem 'c' gem 'd' ``` Note ----- I added `autocorrect_source_with_loop` test helper method to execute auto-correction with loop. This method is based on do_inspection_loop. https://github.com/bbatsov/rubocop/blob/ed4aeb845bfcaaff0648d365c5b46a2e725347f7/lib/rubocop/runner.rb#L179-L202
The idea of enforcing an order in a |
@RKushnir, the new cop enforces ordering of groups of adjacent gems, not the whole Gemfile. No one has reported it breaking their app in the six months since it was added. |
@mikegee I see, I didn't immediately grasp what is a group. Then it assumes the dependent gems are placed in different "batches". So if you need to enforce a specific order, you have to put a newline between them. |
We've got some cops in this group already, so I guess we can close this one. |
I don't understand why gems have to be sorted alphabetically. |
@vassilevsky They don't have to be. You can disable that linter config (cop). The reason you might want it is so that you can quickly scan down the list visually and see whether a gem is there or not. |
Yeah that's one reason to have them sorted :) |
It'd be awesome if there were some linters specifically geared towards the Gemfile.
There's probably a bunch of ones that could be made, but here's some ideas off the top of my head:
source 'http://rubygems.org'
at the top of the fileThe text was updated successfully, but these errors were encountered: