options_cop: make audits non-strict
This commit is contained in:
		
							parent
							
								
									57f7b8a8a4
								
							
						
					
					
						commit
						cbae07cd0f
					
				@ -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" &&
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user