From 3329a9f6d8d7aa6f9e37c33f6d4cc650ab6ea117 Mon Sep 17 00:00:00 2001 From: commitay Date: Fri, 8 Jun 2018 10:15:32 +1000 Subject: [PATCH] text_cop: require cargo to use `install` instead of `build` --- Library/Homebrew/rubocops/text_cop.rb | 4 ++++ Library/Homebrew/test/rubocops/text_cop_spec.rb | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Library/Homebrew/rubocops/text_cop.rb b/Library/Homebrew/rubocops/text_cop.rb index 701cb548f4..e9b648e281 100644 --- a/Library/Homebrew/rubocops/text_cop.rb +++ b/Library/Homebrew/rubocops/text_cop.rb @@ -53,6 +53,10 @@ module RuboCop next if parameters_passed?(d, /vendor-only/) problem "use \"dep\", \"ensure\", \"-vendor-only\"" end + + find_method_with_args(body_node, :system, "cargo", "build") do + problem "use \"cargo\", \"install\", \"--root\", prefix" + 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 52881bfa13..3f5d8f10a1 100644 --- a/Library/Homebrew/test/rubocops/text_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/text_cop_spec.rb @@ -191,5 +191,19 @@ describe RuboCop::Cop::FormulaAudit::Text do end RUBY end + + it "When cargo build is executed" do + expect_offense(<<~RUBY) + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + homepage "http://example.com" + + def install + system "cargo", "build" + ^^^^^^^^^^^^^^^^^^^^^^^ use \"cargo\", \"install\", \"--root\", prefix + end + end + RUBY + end end end