From 490dc9118e2f7bfe2c0fb81fe49c3c52a6402157 Mon Sep 17 00:00:00 2001 From: commitay Date: Fri, 8 Jun 2018 00:07:07 +1000 Subject: [PATCH] text_cop: require `dep ensure` to use `-vendor-only` --- Library/Homebrew/rubocops/text_cop.rb | 5 +++++ Library/Homebrew/test/rubocops/text_cop_spec.rb | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Library/Homebrew/rubocops/text_cop.rb b/Library/Homebrew/rubocops/text_cop.rb index 1546a9cc3c..701cb548f4 100644 --- a/Library/Homebrew/rubocops/text_cop.rb +++ b/Library/Homebrew/rubocops/text_cop.rb @@ -48,6 +48,11 @@ module RuboCop find_method_with_args(body_node, :system, "go", "get") do problem "Do not use `go get`. Please ask upstream to implement Go vendoring" end + + find_method_with_args(body_node, :system, "dep", "ensure") do |d| + next if parameters_passed?(d, /vendor-only/) + problem "use \"dep\", \"ensure\", \"-vendor-only\"" + end end end end diff --git a/Library/Homebrew/test/rubocops/text_cop_spec.rb b/Library/Homebrew/test/rubocops/text_cop_spec.rb index 1b2d61d0c8..52881bfa13 100644 --- a/Library/Homebrew/test/rubocops/text_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/text_cop_spec.rb @@ -177,5 +177,19 @@ describe RuboCop::Cop::FormulaAudit::Text do end RUBY end + + it "When dep ensure is used without `-vendor-only`" do + expect_offense(<<~RUBY) + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + homepage "http://example.com" + + def install + system "dep", "ensure" + ^^^^^^^^^^^^^^^^^^^^^^ use \"dep\", \"ensure\", \"-vendor-only\" + end + end + RUBY + end end end