From cbae07cd0f0134b342a327e6ca2dea1ddf4d1610 Mon Sep 17 00:00:00 2001 From: commitay Date: Sat, 27 Oct 2018 21:47:58 +1000 Subject: [PATCH] options_cop: make audits non-strict --- Library/Homebrew/rubocops/options_cop.rb | 12 ++-------- .../test/rubocops/options_cop_spec.rb | 24 ++++++++----------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/Library/Homebrew/rubocops/options_cop.rb b/Library/Homebrew/rubocops/options_cop.rb index ddd08e6866..98b6002f52 100644 --- a/Library/Homebrew/rubocops/options_cop.rb +++ b/Library/Homebrew/rubocops/options_cop.rb @@ -6,6 +6,7 @@ module RuboCop # This cop audits `options` in Formulae. class Options < FormulaCop DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so 32-bit options are deprecated.".freeze + UNI_DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so universal options are deprecated.".freeze def audit_formula(_node, _class_node, _parent_class_node, body_node) option_call_nodes = find_every_method_call_by_name(body_node, :option) @@ -13,20 +14,11 @@ module RuboCop option = parameters(option_call).first problem DEPRECATION_MSG if regex_match_group(option, /32-bit/) end - end - end - end - module FormulaAuditStrict - class Options < FormulaCop - DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so universal options are deprecated.".freeze - - def audit_formula(_node, _class_node, _parent_class_node, body_node) - option_call_nodes = find_every_method_call_by_name(body_node, :option) option_call_nodes.each do |option_call| offending_node(option_call) option = string_content(parameters(option_call).first) - problem DEPRECATION_MSG if option == "universal" + problem UNI_DEPRECATION_MSG if option == "universal" if option !~ /with(out)?-/ && option != "cxx11" && diff --git a/Library/Homebrew/test/rubocops/options_cop_spec.rb b/Library/Homebrew/test/rubocops/options_cop_spec.rb index ef0e824bb5..a6942745d0 100644 --- a/Library/Homebrew/test/rubocops/options_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/options_cop_spec.rb @@ -3,21 +3,17 @@ require "rubocops/options_cop" describe RuboCop::Cop::FormulaAudit::Options do subject(:cop) { described_class.new } - it "reports an offense when using the 32-bit option" do - expect_offense(<<~RUBY) - class Foo < Formula - url 'https://example.com/foo-1.0.tgz' - option "32-bit", "with 32-bit" - ^^^^^^ macOS has been 64-bit only since 10.6 so 32-bit options are deprecated. - end - RUBY - end -end + context "When auditing options" do + it "reports an offense when using the 32-bit option" do + expect_offense(<<~RUBY) + class Foo < Formula + url 'https://example.com/foo-1.0.tgz' + option "with-32-bit" + ^^^^^^ macOS has been 64-bit only since 10.6 so 32-bit options are deprecated. + end + RUBY + end -describe RuboCop::Cop::FormulaAuditStrict::Options do - subject(:cop) { described_class.new } - - context "When auditing options strictly" do it "with universal" do expect_offense(<<~RUBY) class Foo < Formula