class RuboCop::Cop::Packaging::GemspecGit


end
spec.executables = Dir.glob(“bin/*”).map{ |f| File.basename(f) }
spec.files = Dir.glob(“lib/*/”)
Gem::Specification.new do |spec|
# good
end
spec.executables = ‘git ls-files – bin/*`.split(“n”).map{ |f| File.basename(f) }
spec.files = `git ls-files – lib/`.split(“n”)
Gem::Specification.new do |spec|
# bad
end
spec.files = Rake::FileList[“*/”].exclude(*File.read(“.gitignore”).split)
Gem::Specification.new do |spec|
require “rake/file_list”
# good
end
end
`git ls-files -z`.split(“\x0”).reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.files = Dir.chdir(File.expand_path(__dir__)) do
Gem::Specification.new do |spec|
# bad
end
spec.files = Dir[“lib/*/”, “LICENSE”, “README.md”]
Gem::Specification.new do |spec|
# good
end
spec.files = `git ls-files`.split(“n”)
Gem::Specification.new do |spec|
# bad
@example
`Dir.glob`, or `Rake::FileList` instead.
and suggests to use a plain Ruby alternative, like `Dir`,
This cop flags the usage of `git ls-files` in gemspec
:nodoc:
:nodoc:
:nodoc:

def on_new_investigation

Processing of the AST happens here.

https://github.com/rubocop-hq/rubocop/blob/59543c8e2b66bff249de131fa9105f3eb11e9edb/lib/rubocop/cop/cop.rb#L13-L25
More about the `#investigate` method can be found here:
Extended from the Cop class.
def on_new_investigation
  return if processed_source.blank?
  xstr(processed_source.ast).each do |node|
    add_offense(
      node.loc.expression,
      message: MSG
    )
  end
end

def starts_with_git?(str)

It is used to find strings which start with "git".
This method is called from inside `#def_node_search`.
def starts_with_git?(str)
  str.start_with?("git")
end