diff options
author | Adam Pahlevi <adam.pahlevi@gmail.com> | 2017-01-28 11:33:38 +0700 |
---|---|---|
committer | Adam Pahlevi <adam.pahlevi@gmail.com> | 2017-01-31 09:24:15 +0700 |
commit | 78a3bba62e41831a1b4d994d040a0f8327a3e173 (patch) | |
tree | 894b0679163398d7bb08919299b72c69cc75592b /rubocop/cop | |
parent | 95ea14073542d88d8bfabef9a250e9160a7c2b9e (diff) | |
download | gitlab-ce-78a3bba62e41831a1b4d994d040a0f8327a3e173.tar.gz |
cop for gem fetched from a git source
code fix for aesthetic & conventions
remove unused proc
Diffstat (limited to 'rubocop/cop')
-rw-r--r-- | rubocop/cop/gem_fetcher.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/rubocop/cop/gem_fetcher.rb b/rubocop/cop/gem_fetcher.rb new file mode 100644 index 00000000000..4a63c760744 --- /dev/null +++ b/rubocop/cop/gem_fetcher.rb @@ -0,0 +1,28 @@ +module RuboCop + module Cop + # Cop that checks for all gems specified in the Gemfile, and will + # alert if any gem is to be fetched not from the RubyGems index. + # This enforcement is done so as to minimize external build + # dependencies and build times. + class GemFetcher < RuboCop::Cop::Cop + MSG = 'Do not use gems from git repositories, only use gems from RubyGems.' + + GIT_KEYS = [:git, :github] + + def on_send(node) + file_path = node.location.expression.source_buffer.name + return unless file_path.end_with?("Gemfile") + + 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 + if GIT_KEYS.include?(key_name) + add_offense(node, :selector) + end + end + end + end + end +end |