Class: Gitlab::Styles::Rubocop::Cop::GemFetcher
- Inherits:
-
RuboCop::Cop::Cop
- Object
- RuboCop::Cop::Cop
- Gitlab::Styles::Rubocop::Cop::GemFetcher
- Defined in:
- lib/gitlab/styles/rubocop/cop/gem_fetcher.rb
Overview
This cop prevents usage of the ‘git` and `github` arguments to `gem` in a `Gemfile` in order to avoid additional points of failure beyond rubygems.org.
Constant Summary collapse
- MSG =
'Do not use gems from git repositories, only use gems from RubyGems.'.freeze
- GIT_KEYS =
[:git, :github].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gitlab/styles/rubocop/cop/gem_fetcher.rb', line 13 def on_send(node) return unless gemfile?(node) func_name = node.children[1] return unless func_name == :gem node.children.last.each_node(:pair) do |pair| key_name = pair.children[0].children[0].to_sym add_offense(node, location: pair.source_range, message: MSG) if GIT_KEYS.include?(key_name) end end |