Merge pull request #5194 from commitay/options-cop
options_cop: make audits non-strict
This commit is contained in:
commit
0bdc43bad0
@ -6,6 +6,7 @@ module RuboCop
|
|||||||
# This cop audits `options` in Formulae.
|
# This cop audits `options` in Formulae.
|
||||||
class Options < FormulaCop
|
class Options < FormulaCop
|
||||||
DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so 32-bit options are deprecated.".freeze
|
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)
|
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 = find_every_method_call_by_name(body_node, :option)
|
||||||
@ -13,20 +14,11 @@ module RuboCop
|
|||||||
option = parameters(option_call).first
|
option = parameters(option_call).first
|
||||||
problem DEPRECATION_MSG if regex_match_group(option, /32-bit/)
|
problem DEPRECATION_MSG if regex_match_group(option, /32-bit/)
|
||||||
end
|
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|
|
option_call_nodes.each do |option_call|
|
||||||
offending_node(option_call)
|
offending_node(option_call)
|
||||||
option = string_content(parameters(option_call).first)
|
option = string_content(parameters(option_call).first)
|
||||||
problem DEPRECATION_MSG if option == "universal"
|
problem UNI_DEPRECATION_MSG if option == "universal"
|
||||||
|
|
||||||
if option !~ /with(out)?-/ &&
|
if option !~ /with(out)?-/ &&
|
||||||
option != "cxx11" &&
|
option != "cxx11" &&
|
||||||
|
|||||||
@ -3,21 +3,17 @@ require "rubocops/options_cop"
|
|||||||
describe RuboCop::Cop::FormulaAudit::Options do
|
describe RuboCop::Cop::FormulaAudit::Options do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
|
context "When auditing options" do
|
||||||
it "reports an offense when using the 32-bit option" do
|
it "reports an offense when using the 32-bit option" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url 'https://example.com/foo-1.0.tgz'
|
url 'https://example.com/foo-1.0.tgz'
|
||||||
option "32-bit", "with 32-bit"
|
option "with-32-bit"
|
||||||
^^^^^^ macOS has been 64-bit only since 10.6 so 32-bit options are deprecated.
|
^^^^^^ macOS has been 64-bit only since 10.6 so 32-bit options are deprecated.
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
describe RuboCop::Cop::FormulaAuditStrict::Options do
|
|
||||||
subject(:cop) { described_class.new }
|
|
||||||
|
|
||||||
context "When auditing options strictly" do
|
|
||||||
it "with universal" do
|
it "with universal" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user