Commit 2c358b4b authored by Robert Speicher's avatar Robert Speicher

Merge branch 'cop-gem-fetcher' into 'master'

Cop for gem fetched from a git source

Closes #27311

See merge request !8856
parents d4246054 78a3bba6
---
title: Cop for gem fetched from a git source
merge_request: 8856
author: Adam Pahlevi
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
require_relative 'migration_helpers'
require_relative 'cop/migration/add_index'
require_relative 'cop/migration/column_with_default'
require_relative 'cop/gem_fetcher'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment