diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1a3749ca63..b27a74dcc2 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -887,11 +887,6 @@ module Homebrew # TODO: check could be in RuboCop problem "Use pkgshare instead of (share#{Regexp.last_match(1)}\"#{formula.name}\")" end - - return unless @core_tap - - # TODO: check could be in RuboCop - problem "`env :std` in homebrew/core formulae is deprecated" if line.include?("env :std") end def audit_reverse_migration diff --git a/Library/Homebrew/rubocops/text.rb b/Library/Homebrew/rubocops/text.rb index c41fd4c913..eec390e5c9 100644 --- a/Library/Homebrew/rubocops/text.rb +++ b/Library/Homebrew/rubocops/text.rb @@ -79,6 +79,12 @@ module RuboCop find_method_with_args(body_node, :go_resource) do problem "`go_resource`s are deprecated. Please ask upstream to implement Go vendoring" end + + return unless formula_tap == "homebrew-core" + + find_method_with_args(body_node, :env, :std) do + problem "`env :std` in homebrew/core formulae is deprecated" + end end end end diff --git a/Library/Homebrew/test/.rubocop_todo.yml b/Library/Homebrew/test/.rubocop_todo.yml index 18986235db..59e8c081af 100644 --- a/Library/Homebrew/test/.rubocop_todo.yml +++ b/Library/Homebrew/test/.rubocop_todo.yml @@ -21,7 +21,7 @@ RSpec/InstanceVariable: - 'utils/git_spec.rb' - 'version_spec.rb' -# Offense count: 74 +# Offense count: 75 RSpec/MultipleDescribes: Exclude: - 'ENV_spec.rb' @@ -94,6 +94,7 @@ RSpec/MultipleDescribes: - 'rubocops/class_spec.rb' - 'rubocops/formula_desc_spec.rb' - 'rubocops/lines_spec.rb' + - 'rubocops/text_spec.rb' - 'rubocops/urls_spec.rb' - 'software_spec_spec.rb' - 'tap_spec.rb' diff --git a/Library/Homebrew/test/rubocops/text_spec.rb b/Library/Homebrew/test/rubocops/text_spec.rb index 561ff18f9e..b464f7ef51 100644 --- a/Library/Homebrew/test/rubocops/text_spec.rb +++ b/Library/Homebrew/test/rubocops/text_spec.rb @@ -228,3 +228,20 @@ describe RuboCop::Cop::FormulaAudit::Text do end end end + +describe RuboCop::Cop::FormulaAuditStrict::Text do + subject(:cop) { described_class.new } + + context "When auditing formula text" do + it "when deprecated `env :std` is present in homebrew-core" do + expect_offense(<<~RUBY, "/homebrew-core/") + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + + env :std + ^^^^^^^^ `env :std` in homebrew/core formulae is deprecated + end + RUBY + end + end +end