diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/rubocops/lines_cop.rb | 164 | ||||
| -rw-r--r-- | Library/Homebrew/test/rubocops/lines_cop_spec.rb | 1044 |
2 files changed, 612 insertions, 596 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb index 0491845b5..7e434d755 100644 --- a/Library/Homebrew/rubocops/lines_cop.rb +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -54,6 +54,87 @@ module RuboCop end end + class AssertStatements < FormulaCop + def audit_formula(_node, _class_node, _parent_class_node, body_node) + find_every_method_call_by_name(body_node, :assert).each do |method| + if method_called_ever?(method, :include?) && !method_called_ever?(method, :!) + problem "Use `assert_match` instead of `assert ...include?`" + end + + if method_called_ever?(method, :exist?) && !method_called_ever?(method, :!) + problem "Use `assert_predicate <path_to_file>, :exist?` instead of `#{method.source}`" + end + + if method_called_ever?(method, :exist?) && method_called_ever?(method, :!) + problem "Use `refute_predicate <path_to_file>, :exist?` instead of `#{method.source}`" + end + + if method_called_ever?(method, :executable?) && !method_called_ever?(method, :!) + problem "Use `assert_predicate <path_to_file>, :executable?` instead of `#{method.source}`" + end + end + end + end + + class OptionDeclarations < FormulaCop + def audit_formula(_node, _class_node, _parent_class_node, body_node) + if find_method_def(body_node, :options) + problem "Use new-style option definitions" + end + + find_instance_method_call(body_node, :build, :without?) do |method| + next unless unless_modifier?(method.parent) + correct = method.source.gsub("out?", "?") + problem "Use if #{correct} instead of unless #{method.source}" + end + + find_instance_method_call(body_node, :build, :with?) do |method| + next unless unless_modifier?(method.parent) + correct = method.source.gsub("?", "out?") + problem "Use if #{correct} instead of unless #{method.source}" + end + + find_instance_method_call(body_node, :build, :with?) do |method| + next unless negated?(method.parent) + problem "Don't negate 'build.with?': use 'build.without?'" + end + + find_instance_method_call(body_node, :build, :without?) do |method| + next unless negated?(method.parent) + problem "Don't negate 'build.without?': use 'build.with?'" + end + + find_instance_method_call(body_node, :build, :without?) do |method| + arg = parameters(method).first + next unless match = regex_match_group(arg, /-?-?without-(.*)/) + problem "Don't duplicate 'without': Use `build.without? \"#{match[1]}\"` to check for \"--without-#{match[1]}\"" + end + + find_instance_method_call(body_node, :build, :with?) do |method| + arg = parameters(method).first + next unless match = regex_match_group(arg, /-?-?with-(.*)/) + problem "Don't duplicate 'with': Use `build.with? \"#{match[1]}\"` to check for \"--with-#{match[1]}\"" + end + + find_instance_method_call(body_node, :build, :include?) do |method| + arg = parameters(method).first + next unless match = regex_match_group(arg, /with(out)?-(.*)/) + problem "Use build.with#{match[1]}? \"#{match[2]}\" instead of build.include? 'with#{match[1]}-#{match[2]}'" + end + + find_instance_method_call(body_node, :build, :include?) do |method| + arg = parameters(method).first + next unless match = regex_match_group(arg, /\-\-(.*)/) + problem "Reference '#{match[1]}' without dashes" + end + end + + def unless_modifier?(node) + return false unless node.if_type? + node.modifier_form? && node.unless? + end + end + class Miscellaneous < FormulaCop def audit_formula(_node, _class_node, _parent_class_node, body_node) # FileUtils is included in Formula @@ -115,7 +196,7 @@ module RuboCop # Prefer formula path shortcuts in strings formula_path_strings(body_node, :share) do |p| next unless match = regex_match_group(p, %r{(/(man))/?}) - problem "\"\#\{share}#{match[1]}\" should be \"\#{#{match[2]}}\"" + problem "\"\#{share}#{match[1]}\" should be \"\#{#{match[2]}}\"" end formula_path_strings(body_node, :prefix) do |p| @@ -215,10 +296,6 @@ module RuboCop problem "Use new-style test definitions (test do)" end - if find_method_def(body_node, :options) - problem "Use new-style option definitions" - end - find_method_with_args(body_node, :skip_clean, :all) do problem <<-EOS.undent.chomp `skip_clean :all` is deprecated; brew no longer strips symbols @@ -226,6 +303,10 @@ module RuboCop EOS end + if find_method_def(@processed_source.ast) + problem "Define method #{method_name(@offensive_node)} in the class body, not at the top-level" + end + find_instance_method_call(body_node, :build, :universal?) do next if @formula_name == "wine" problem "macOS has been 64-bit only since 10.6 so build.universal? is deprecated." @@ -239,24 +320,6 @@ module RuboCop problem 'Use "depends_on :x11" instead of "ENV.x11"' end - find_every_method_call_by_name(body_node, :assert).each do |method| - if method_called_ever?(method, :include?) && !method_called_ever?(method, :!) - problem "Use `assert_match` instead of `assert ...include?`" - end - - if method_called_ever?(method, :exist?) && !method_called_ever?(method, :!) - problem "Use `assert_predicate <path_to_file>, :exist?` instead of `#{method.source}`" - end - - if method_called_ever?(method, :exist?) && method_called_ever?(method, :!) - problem "Use `refute_predicate <path_to_file>, :exist?` instead of `#{method.source}`" - end - - if method_called_ever?(method, :executable?) && !method_called_ever?(method, :!) - problem "Use `assert_predicate <path_to_file>, :executable?` instead of `#{method.source}`" - end - end - find_every_method_call_by_name(body_node, :depends_on).each do |method| next unless method_called?(method, :new) problem "`depends_on` can take requirement classes instead of instances" @@ -282,61 +345,6 @@ module RuboCop next unless match = regex_match_group(param, fileutils_methods) problem "Use the `#{match}` Ruby method instead of `#{method.source}`" end - - if find_method_def(@processed_source.ast) - problem "Define method #{method_name(@offensive_node)} in the class body, not at the top-level" - end - - find_instance_method_call(body_node, :build, :without?) do |method| - next unless unless_modifier?(method.parent) - correct = method.source.gsub("out?", "?") - problem "Use if #{correct} instead of unless #{method.source}" - end - - find_instance_method_call(body_node, :build, :with?) do |method| - next unless unless_modifier?(method.parent) - correct = method.source.gsub("?", "out?") - problem "Use if #{correct} instead of unless #{method.source}" - end - - find_instance_method_call(body_node, :build, :with?) do |method| - next unless negated?(method.parent) - problem "Don't negate 'build.with?': use 'build.without?'" - end - - find_instance_method_call(body_node, :build, :without?) do |method| - next unless negated?(method.parent) - problem "Don't negate 'build.without?': use 'build.with?'" - end - - find_instance_method_call(body_node, :build, :without?) do |method| - arg = parameters(method).first - next unless match = regex_match_group(arg, /-?-?without-(.*)/) - problem "Don't duplicate 'without': Use `build.without? \"#{match[1]}\"` to check for \"--without-#{match[1]}\"" - end - - find_instance_method_call(body_node, :build, :with?) do |method| - arg = parameters(method).first - next unless match = regex_match_group(arg, /-?-?with-(.*)/) - problem "Don't duplicate 'with': Use `build.with? \"#{match[1]}\"` to check for \"--with-#{match[1]}\"" - end - - find_instance_method_call(body_node, :build, :include?) do |method| - arg = parameters(method).first - next unless match = regex_match_group(arg, /with(out)?-(.*)/) - problem "Use build.with#{match[1]}? \"#{match[2]}\" instead of build.include? 'with#{match[1]}-#{match[2]}'" - end - - find_instance_method_call(body_node, :build, :include?) do |method| - arg = parameters(method).first - next unless match = regex_match_group(arg, /\-\-(.*)/) - problem "Reference '#{match[1]}' without dashes" - end - end - - def unless_modifier?(node) - return false unless node.if_type? - node.modifier_form? && node.unless? end def modifier?(node) diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb index df4085721..9705e8278 100644 --- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb @@ -7,7 +7,7 @@ describe RuboCop::Cop::FormulaAudit::Lines do subject(:cop) { described_class.new } context "When auditing lines" do - it "with correctable deprecated dependencies" do + it "correctable deprecated dependencies usage" do formulae = [{ "dependency" => :automake, "correct" => "automake", @@ -36,11 +36,11 @@ describe RuboCop::Cop::FormulaAudit::Lines do else offense = ":#{formula["dependency"]} is deprecated" end - expected_offenses = [{ message: offense, - severity: :convention, - line: 3, - column: 2, - source: source }] + expected_offenses = [{ message: offense, + severity: :convention, + line: 3, + column: 2, + source: source }] inspect_source(source) @@ -56,7 +56,7 @@ describe RuboCop::Cop::FormulaAudit::ClassInheritance do subject(:cop) { described_class.new } context "When auditing lines" do - it "with no space in class inheritance" do + it "inconsistent space in class inheritance" do source = <<-EOS.undent class Foo<Formula desc "foo" @@ -64,11 +64,11 @@ describe RuboCop::Cop::FormulaAudit::ClassInheritance do end EOS - expected_offenses = [{ message: "Use a space in class inheritance: class Foo < Formula", - severity: :convention, - line: 1, - column: 10, - source: source }] + expected_offenses = [{ message: "Use a space in class inheritance: class Foo < Formula", + severity: :convention, + line: 1, + column: 10, + source: source }] inspect_source(source, "/homebrew-core/Formula/foo.rb") @@ -83,7 +83,7 @@ describe RuboCop::Cop::FormulaAudit::Comments do subject(:cop) { described_class.new } context "When auditing formula" do - it "with commented cmake call" do + it "commented cmake call" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -92,11 +92,11 @@ describe RuboCop::Cop::FormulaAudit::Comments do end EOS - expected_offenses = [{ message: "Please remove default template comments", - severity: :convention, - line: 4, - column: 2, - source: source }] + expected_offenses = [{ message: "Please remove default template comments", + severity: :convention, + line: 4, + column: 2, + source: source }] inspect_source(source) @@ -105,7 +105,7 @@ describe RuboCop::Cop::FormulaAudit::Comments do end end - it "with default template comments" do + it "default template comments" do source = <<-EOS.undent class Foo < Formula # PLEASE REMOVE @@ -114,11 +114,11 @@ describe RuboCop::Cop::FormulaAudit::Comments do end EOS - expected_offenses = [{ message: "Please remove default template comments", - severity: :convention, - line: 2, - column: 2, - source: source }] + expected_offenses = [{ message: "Please remove default template comments", + severity: :convention, + line: 2, + column: 2, + source: source }] inspect_source(source) @@ -127,7 +127,7 @@ describe RuboCop::Cop::FormulaAudit::Comments do end end - it "with commented out depends_on" do + it "commented out depends_on" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -136,11 +136,11 @@ describe RuboCop::Cop::FormulaAudit::Comments do end EOS - expected_offenses = [{ message: 'Commented-out dependency "foo"', - severity: :convention, - line: 4, - column: 2, - source: source }] + expected_offenses = [{ message: 'Commented-out dependency "foo"', + severity: :convention, + line: 4, + column: 2, + source: source }] inspect_source(source) @@ -151,347 +151,337 @@ describe RuboCop::Cop::FormulaAudit::Comments do end end -describe RuboCop::Cop::FormulaAudit::Miscellaneous do +describe RuboCop::Cop::FormulaAudit::AssertStatements do subject(:cop) { described_class.new } - context "When auditing formula" do - it "with FileUtils" do - source = <<-EOS.undent + it "assert ...include usage" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - FileUtils.mv "hello" + assert File.read("inbox").include?("Sample message 1") end - EOS + EOS - expected_offenses = [{ message: "Don't need 'FileUtils.' before mv", - severity: :convention, - line: 4, - column: 2, - source: source }] + expected_offenses = [{ message: "Use `assert_match` instead of `assert ...include?`", + severity: :convention, + line: 4, + column: 9, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with long inreplace block vars" do - source = <<-EOS.undent + it "assert ...exist? without a negation" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - inreplace "foo" do |longvar| - somerandomCall(longvar) - end + assert File.exist? "default.ini" end - EOS + EOS - expected_offenses = [{ message: "\"inreplace <filenames> do |s|\" is preferred over \"|longvar|\".", - severity: :convention, - line: 4, - column: 2, - source: source }] + expected_offenses = [{ message: 'Use `assert_predicate <path_to_file>, :exist?` instead of `assert File.exist? "default.ini"`', + severity: :convention, + line: 4, + column: 9, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with invalid rebuild" do - source = <<-EOS.undent + it "assert ...exist? with a negation" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - bottle do - rebuild 0 - sha256 "fe0679b932dd43a87fd415b609a7fbac7a069d117642ae8ebaac46ae1fb9f0b3" => :sierra - end + assert !File.exist?("default.ini") end - EOS + EOS - expected_offenses = [{ message: "'rebuild 0' should be removed", - severity: :convention, - line: 5, - column: 4, - source: source }] + expected_offenses = [{ message: 'Use `refute_predicate <path_to_file>, :exist?` instead of `assert !File.exist?("default.ini")`', + severity: :convention, + line: 4, + column: 9, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with OS.linux? check" do - source = <<-EOS.undent + it "assert ...executable? without a negation" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - bottle do - if OS.linux? - nil - end - sha256 "fe0679b932dd43a87fd415b609a7fbac7a069d117642ae8ebaac46ae1fb9f0b3" => :sierra - end + assert File.executable? f end - EOS + EOS - expected_offenses = [{ message: "Don't use OS.linux?; Homebrew/core only supports macOS", - severity: :convention, - line: 5, - column: 7, - source: source }] + expected_offenses = [{ message: "Use `assert_predicate <path_to_file>, :executable?` instead of `assert File.executable? f`", + severity: :convention, + line: 4, + column: 9, + source: source }] - inspect_source(source, "/homebrew-core/") + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end +end - it "with fails_with :llvm" do - source = <<-EOS.undent +describe RuboCop::Cop::FormulaAudit::OptionDeclarations do + subject(:cop) { described_class.new } + + it "unless build.without? conditional" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - bottle do - sha256 "fe0679b932dd43a87fd415b609a7fbac7a069d117642ae8ebaac46ae1fb9f0b3" => :sierra - end - fails_with :llvm do - build 2335 - cause "foo" + def post_install + return unless build.without? "bar" end end - EOS + EOS - expected_offenses = [{ message: "'fails_with :llvm' is now a no-op so should be removed", - severity: :convention, - line: 7, - column: 2, - source: source }] + expected_offenses = [{ message: 'Use if build.with? "bar" instead of unless build.without? "bar"', + severity: :convention, + line: 5, + column: 18, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with def test" do - source = <<-EOS.undent + it "unless build.with? conditional" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - - def test - assert_equals "1", "1" + def post_install + return unless build.with? "bar" end end - EOS + EOS - expected_offenses = [{ message: "Use new-style test definitions (test do)", - severity: :convention, - line: 5, - column: 2, - source: source }] + expected_offenses = [{ message: 'Use if build.without? "bar" instead of unless build.with? "bar"', + severity: :convention, + line: 5, + column: 18, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with def options" do - source = <<-EOS.undent + it "negated build.with? conditional" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - - def options - [["--bar", "desc"]] + def post_install + return if !build.with? "bar" end end - EOS + EOS - expected_offenses = [{ message: "Use new-style option definitions", - severity: :convention, - line: 5, - column: 2, - source: source }] + expected_offenses = [{ message: "Don't negate 'build.with?': use 'build.without?'", + severity: :convention, + line: 5, + column: 14, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with deprecated skip_clean call" do - source = <<-EOS.undent + it "negated build.without? conditional" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - skip_clean :all + def post_install + return if !build.without? "bar" + end end - EOS + EOS - expected_offenses = [{ message: <<-EOS.undent.chomp, - `skip_clean :all` is deprecated; brew no longer strips symbols - Pass explicit paths to prevent Homebrew from removing empty folders. - EOS - severity: :convention, - line: 4, - column: 2, - source: source }] + expected_offenses = [{ message: "Don't negate 'build.without?': use 'build.with?'", + severity: :convention, + line: 5, + column: 14, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with build.universal?" do - source = <<-EOS.undent + it "unnecessary build.without? conditional" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - if build.universal? - "foo" + def post_install + return if build.without? "--without-bar" end end - EOS + EOS - expected_offenses = [{ message: "macOS has been 64-bit only since 10.6 so build.universal? is deprecated.", - severity: :convention, - line: 4, - column: 5, - source: source }] + expected_offenses = [{ message: "Don't duplicate 'without': Use `build.without? \"bar\"` to check for \"--without-bar\"", + severity: :convention, + line: 5, + column: 30, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with build.universal? exempted formula" do - source = <<-EOS.undent - class Wine < Formula + it "unnecessary build.with? conditional" do + source = <<-EOS.undent + class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - if build.universal? - "foo" + def post_install + return if build.with? "--with-bar" end end - EOS + EOS - inspect_source(source, "/homebrew-core/Formula/wine.rb") - expect(cop.offenses).to eq([]) + expected_offenses = [{ message: "Don't duplicate 'with': Use `build.with? \"bar\"` to check for \"--with-bar\"", + severity: :convention, + line: 5, + column: 27, + source: source }] + + inspect_source(source) + + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with ENV.universal_binary" do - source = <<-EOS.undent + it "build.include? conditional" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - if build? - ENV.universal_binary + def post_install + return if build.include? "without-bar" end end - EOS + EOS - expected_offenses = [{ message: "macOS has been 64-bit only since 10.6 so ENV.universal_binary is deprecated.", - severity: :convention, - line: 5, - column: 5, - source: source }] + expected_offenses = [{ message: "Use build.without? \"bar\" instead of build.include? 'without-bar'", + severity: :convention, + line: 5, + column: 30, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with ENV.universal_binary 2" do - source = <<-EOS.undent + it "build.include? with dashed args conditional" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - if build? - ENV.x11 + def post_install + return if build.include? "--bar" end end - EOS + EOS - expected_offenses = [{ message: 'Use "depends_on :x11" instead of "ENV.x11"', - severity: :convention, - line: 5, - column: 5, - source: source }] + expected_offenses = [{ message: "Reference 'bar' without dashes", + severity: :convention, + line: 5, + column: 30, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end - it "with ruby-macho alternatives" do - source = <<-EOS.undent + it "def options usage" do + source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - system "install_name_tool", "-id" + + def options + [["--bar", "desc"]] + end end - EOS + EOS - expected_offenses = [{ message: 'Use ruby-macho instead of calling "install_name_tool"', - severity: :convention, - line: 4, - column: 10, - source: source }] + expected_offenses = [{ message: "Use new-style option definitions", + severity: :convention, + line: 5, + column: 2, + source: source }] - inspect_source(source) + inspect_source(source) - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) end + end +end - it "with ruby-macho alternatives audit exempted formula" do - source = <<-EOS.undent - class Cctools < Formula - desc "foo" - url 'http://example.com/foo-1.0.tgz' - system "install_name_tool", "-id" - end - EOS - - inspect_source(source, "/homebrew-core/Formula/cctools.rb") - expect(cop.offenses).to eq([]) - end +describe RuboCop::Cop::FormulaAudit::Miscellaneous do + subject(:cop) { described_class.new } - it "with npm install without language::Node args" do + context "When auditing formula" do + it "FileUtils usage" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - system "npm", "install" + FileUtils.mv "hello" end EOS - expected_offenses = [{ message: "Use Language::Node for npm install args", - severity: :convention, - line: 4, - column: 2, - source: source }] + expected_offenses = [{ message: "Don't need 'FileUtils.' before mv", + severity: :convention, + line: 4, + column: 2, + source: source }] inspect_source(source) @@ -500,33 +490,22 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with npm install without language::Node args in kibana" do - source = <<-EOS.undent - class KibanaAT44 < Formula - desc "foo" - url 'http://example.com/foo-1.0.tgz' - system "npm", "install" - end - EOS - - inspect_source(source, "/homebrew-core/Formula/kibana@4.4.rb") - expect(cop.offenses).to eq([]) - end - - it "with assert include" do + it "long inreplace block vars" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - assert File.read("inbox").include?("Sample message 1") + inreplace "foo" do |longvar| + somerandomCall(longvar) + end end EOS - expected_offenses = [{ message: "Use `assert_match` instead of `assert ...include?`", - severity: :convention, - line: 4, - column: 9, - source: source }] + expected_offenses = [{ message: "\"inreplace <filenames> do |s|\" is preferred over \"|longvar|\".", + severity: :convention, + line: 4, + column: 2, + source: source }] inspect_source(source) @@ -535,20 +514,23 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "assert ...exist? without a negation" do + it "invalid rebuild statement" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - assert File.exist? "default.ini" + bottle do + rebuild 0 + sha256 "fe0679b932dd43a87fd415b609a7fbac7a069d117642ae8ebaac46ae1fb9f0b3" => :sierra + end end EOS - expected_offenses = [{ message: 'Use `assert_predicate <path_to_file>, :exist?` instead of `assert File.exist? "default.ini"`', - severity: :convention, - line: 4, - column: 9, - source: source }] + expected_offenses = [{ message: "'rebuild 0' should be removed", + severity: :convention, + line: 5, + column: 4, + source: source }] inspect_source(source) @@ -557,42 +539,53 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "assert ...exist? with a negation" do + it "OS.linux? check" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - assert !File.exist?("default.ini") + bottle do + if OS.linux? + nil + end + sha256 "fe0679b932dd43a87fd415b609a7fbac7a069d117642ae8ebaac46ae1fb9f0b3" => :sierra + end end EOS - expected_offenses = [{ message: 'Use `refute_predicate <path_to_file>, :exist?` instead of `assert !File.exist?("default.ini")`', - severity: :convention, - line: 4, - column: 9, - source: source }] + expected_offenses = [{ message: "Don't use OS.linux?; Homebrew/core only supports macOS", + severity: :convention, + line: 5, + column: 7, + source: source }] - inspect_source(source) + inspect_source(source, "/homebrew-core/") expected_offenses.zip(cop.offenses).each do |expected, actual| expect_offense(expected, actual) end end - it "assert ...executable? without a negation" do + it "fails_with :llvm block" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - assert File.executable? f + bottle do + sha256 "fe0679b932dd43a87fd415b609a7fbac7a069d117642ae8ebaac46ae1fb9f0b3" => :sierra + end + fails_with :llvm do + build 2335 + cause "foo" + end end EOS - expected_offenses = [{ message: "Use `assert_predicate <path_to_file>, :executable?` instead of `assert File.executable? f`", - severity: :convention, - line: 4, - column: 9, - source: source }] + expected_offenses = [{ message: "'fails_with :llvm' is now a no-op so should be removed", + severity: :convention, + line: 7, + column: 2, + source: source }] inspect_source(source) @@ -601,20 +594,23 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "depends_on with an instance as an argument" do + it "def test deprecated usage" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - depends_on FOO::BAR.new + + def test + assert_equals "1", "1" + end end EOS - expected_offenses = [{ message: "`depends_on` can take requirement classes instead of instances", - severity: :convention, - line: 4, - column: 13, - source: source }] + expected_offenses = [{ message: "Use new-style test definitions (test do)", + severity: :convention, + line: 5, + column: 2, + source: source }] inspect_source(source) @@ -623,20 +619,23 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with old style OS check" do + it "deprecated skip_clean call" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - depends_on :foo if MacOS.snow_leopard? + skip_clean :all end EOS - expected_offenses = [{ message: "\"MacOS.snow_leopard?\" is deprecated, use a comparison to MacOS.version instead", - severity: :convention, - line: 4, - column: 21, - source: source }] + expected_offenses = [{ message: <<-EOS.undent.chomp, + `skip_clean :all` is deprecated; brew no longer strips symbols + Pass explicit paths to prevent Homebrew from removing empty folders. + EOS + severity: :convention, + line: 4, + column: 2, + source: source }] inspect_source(source) @@ -645,21 +644,22 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with non glob DIR" do + it "build.universal? deprecated usage" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - rm_rf Dir["src/{llvm,test,librustdoc,etc/snapshot.pyc}"] - rm_rf Dir["src/snapshot.pyc"] + if build.universal? + "foo" + end end EOS - expected_offenses = [{ message: "Dir([\"src/snapshot.pyc\"]) is unnecessary; just use \"src/snapshot.pyc\"", - severity: :convention, - line: 5, - column: 13, - source: source }] + expected_offenses = [{ message: "macOS has been 64-bit only since 10.6 so build.universal? is deprecated.", + severity: :convention, + line: 4, + column: 5, + source: source }] inspect_source(source) @@ -668,44 +668,37 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with system call to fileUtils Method" do + it "build.universal? deprecation exempted formula" do source = <<-EOS.undent - class Foo < Formula + class Wine < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - system "mkdir", "foo" + if build.universal? + "foo" + end end EOS - expected_offenses = [{ message: "Use the `mkdir` Ruby method instead of `system \"mkdir\", \"foo\"`", - severity: :convention, - line: 4, - column: 10, - source: source }] - - inspect_source(source) - - expected_offenses.zip(cop.offenses).each do |expected, actual| - expect_offense(expected, actual) - end + inspect_source(source, "/homebrew-core/Formula/wine.rb") + expect(cop.offenses).to eq([]) end - it "with a top-level function def " do + it "deprecated ENV.universal_binary usage" do source = <<-EOS.undent - def test - nil - end class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' + if build? + ENV.universal_binary + end end EOS - expected_offenses = [{ message: "Define method test in the class body, not at the top-level", - severity: :convention, - line: 1, - column: 0, - source: source }] + expected_offenses = [{ message: "macOS has been 64-bit only since 10.6 so ENV.universal_binary is deprecated.", + severity: :convention, + line: 5, + column: 5, + source: source }] inspect_source(source) @@ -714,22 +707,22 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with unless build.without?" do + it "deprecated ENV.x11 usage" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - def post_install - return unless build.without? "bar" + if build? + ENV.x11 end end EOS - expected_offenses = [{ message: 'Use if build.with? "bar" instead of unless build.without? "bar"', - severity: :convention, - line: 5, - column: 18, - source: source }] + expected_offenses = [{ message: 'Use "depends_on :x11" instead of "ENV.x11"', + severity: :convention, + line: 5, + column: 5, + source: source }] inspect_source(source) @@ -738,22 +731,20 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with unless build.with?" do + it "ruby-macho alternative to install_name_tool usage" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - def post_install - return unless build.with? "bar" - end + system "install_name_tool", "-id" end EOS - expected_offenses = [{ message: 'Use if build.without? "bar" instead of unless build.with? "bar"', - severity: :convention, - line: 5, - column: 18, - source: source }] + expected_offenses = [{ message: 'Use ruby-macho instead of calling "install_name_tool"', + severity: :convention, + line: 4, + column: 10, + source: source }] inspect_source(source) @@ -762,22 +753,33 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with negated build.with?" do + it "ruby-macho alternatives audit exempted formula" do + source = <<-EOS.undent + class Cctools < Formula + desc "foo" + url 'http://example.com/foo-1.0.tgz' + system "install_name_tool", "-id" + end + EOS + + inspect_source(source, "/homebrew-core/Formula/cctools.rb") + expect(cop.offenses).to eq([]) + end + + it "npm install without language::Node args" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - def post_install - return if !build.with? "bar" - end + system "npm", "install" end EOS - expected_offenses = [{ message: "Don't negate 'build.with?': use 'build.without?'", - severity: :convention, - line: 5, - column: 14, - source: source }] + expected_offenses = [{ message: "Use Language::Node for npm install args", + severity: :convention, + line: 4, + column: 2, + source: source }] inspect_source(source) @@ -786,22 +788,33 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with negated build.with?" do + it "npm install without language::Node args in kibana(exempted formula)" do + source = <<-EOS.undent + class KibanaAT44 < Formula + desc "foo" + url 'http://example.com/foo-1.0.tgz' + system "npm", "install" + end + EOS + + inspect_source(source, "/homebrew-core/Formula/kibana@4.4.rb") + expect(cop.offenses).to eq([]) + end + + it "depends_on with an instance as argument" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - def post_install - return if !build.without? "bar" - end + depends_on FOO::BAR.new end EOS - expected_offenses = [{ message: "Don't negate 'build.without?': use 'build.with?'", - severity: :convention, - line: 5, - column: 14, - source: source }] + expected_offenses = [{ message: "`depends_on` can take requirement classes instead of instances", + severity: :convention, + line: 4, + column: 13, + source: source }] inspect_source(source) @@ -810,22 +823,20 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with duplicated build.without?" do + it "old style OS check" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - def post_install - return if build.without? "--without-bar" - end + depends_on :foo if MacOS.snow_leopard? end EOS - expected_offenses = [{ message: "Don't duplicate 'without': Use `build.without? \"bar\"` to check for \"--without-bar\"", - severity: :convention, - line: 5, - column: 30, - source: source }] + expected_offenses = [{ message: "\"MacOS.snow_leopard?\" is deprecated, use a comparison to MacOS.version instead", + severity: :convention, + line: 4, + column: 21, + source: source }] inspect_source(source) @@ -834,22 +845,21 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with duplicated build.with?" do + it "non glob DIR usage" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - def post_install - return if build.with? "--with-bar" - end + rm_rf Dir["src/{llvm,test,librustdoc,etc/snapshot.pyc}"] + rm_rf Dir["src/snapshot.pyc"] end EOS - expected_offenses = [{ message: "Don't duplicate 'with': Use `build.with? \"bar\"` to check for \"--with-bar\"", - severity: :convention, - line: 5, - column: 27, - source: source }] + expected_offenses = [{ message: 'Dir(["src/snapshot.pyc"]) is unnecessary; just use "src/snapshot.pyc"', + severity: :convention, + line: 5, + column: 13, + source: source }] inspect_source(source) @@ -858,22 +868,20 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with build.include?" do + it "system call to fileUtils Method" do source = <<-EOS.undent class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - def post_install - return if build.include? "without-bar" - end + system "mkdir", "foo" end EOS - expected_offenses = [{ message: "Use build.without? \"bar\" instead of build.include? 'without-bar'", - severity: :convention, - line: 5, - column: 30, - source: source }] + expected_offenses = [{ message: 'Use the `mkdir` Ruby method instead of `system "mkdir", "foo"`', + severity: :convention, + line: 4, + column: 10, + source: source }] inspect_source(source) @@ -882,22 +890,22 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with build.include? with dashed args" do + it "top-level function def outside class body" do source = <<-EOS.undent + def test + nil + end class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - def post_install - return if build.include? "--bar" - end end EOS - expected_offenses = [{ message: "Reference 'bar' without dashes", - severity: :convention, - line: 5, - column: 30, - source: source }] + expected_offenses = [{ message: "Define method test in the class body, not at the top-level", + severity: :convention, + line: 1, + column: 0, + source: source }] inspect_source(source) @@ -906,7 +914,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with using ARGV to check options" do + it "Using ARGV to check options" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -917,11 +925,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use build instead of ARGV to check options", - severity: :convention, - line: 5, - column: 14, - source: source }] + expected_offenses = [{ message: "Use build instead of ARGV to check options", + severity: :convention, + line: 5, + column: 14, + source: source }] inspect_source(source) @@ -930,7 +938,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with man+ " do + it 'man+"man8" usage' do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -941,11 +949,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "\"man+\"man8\"\" should be \"man8\"", - severity: :convention, - line: 5, - column: 22, - source: source }] + expected_offenses = [{ message: '"man+"man8"" should be "man8"', + severity: :convention, + line: 5, + column: 22, + source: source }] inspect_source(source) @@ -954,7 +962,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with hardcoded compiler 1 " do + it "hardcoded gcc compiler" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -965,11 +973,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use \"\#{ENV.cc}\" instead of hard-coding \"gcc\"", - severity: :convention, - line: 5, - column: 12, - source: source }] + expected_offenses = [{ message: "Use \"\#{ENV.cc}\" instead of hard-coding \"gcc\"", + severity: :convention, + line: 5, + column: 12, + source: source }] inspect_source(source) @@ -978,7 +986,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with hardcoded compiler 2 " do + it "hardcoded g++ compiler" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -989,11 +997,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use \"\#{ENV.cxx}\" instead of hard-coding \"g++\"", - severity: :convention, - line: 5, - column: 12, - source: source }] + expected_offenses = [{ message: "Use \"\#{ENV.cxx}\" instead of hard-coding \"g++\"", + severity: :convention, + line: 5, + column: 12, + source: source }] inspect_source(source) @@ -1002,7 +1010,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with hardcoded compiler 3 " do + it "hardcoded llvm-g++ compiler" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1013,11 +1021,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use \"\#{ENV.cxx}\" instead of hard-coding \"llvm-g++\"", - severity: :convention, - line: 5, - column: 28, - source: source }] + expected_offenses = [{ message: "Use \"\#{ENV.cxx}\" instead of hard-coding \"llvm-g++\"", + severity: :convention, + line: 5, + column: 28, + source: source }] inspect_source(source) @@ -1026,7 +1034,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with hardcoded compiler 4 " do + it "hardcoded gcc compiler" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1037,11 +1045,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use \"\#{ENV.cc}\" instead of hard-coding \"gcc\"", - severity: :convention, - line: 5, - column: 28, - source: source }] + expected_offenses = [{ message: "Use \"\#{ENV.cc}\" instead of hard-coding \"gcc\"", + severity: :convention, + line: 5, + column: 28, + source: source }] inspect_source(source) @@ -1050,7 +1058,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with formula path shortcut long form" do + it "formula path shortcut : man" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1061,11 +1069,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "\"\#\{share}/man\" should be \"\#{man}\"", - severity: :convention, - line: 5, - column: 17, - source: source }] + expected_offenses = [{ message: '"#{share}/man" should be "#{man}"', + severity: :convention, + line: 5, + column: 17, + source: source }] inspect_source(source) @@ -1074,7 +1082,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with formula path shortcut long form 1" do + it "formula path shortcut : libexec" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1085,11 +1093,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "\"\#\{prefix}/libexec\" should be \"\#{libexec}\"", - severity: :convention, - line: 5, - column: 18, - source: source }] + expected_offenses = [{ message: "\"\#\{prefix}/libexec\" should be \"\#{libexec}\"", + severity: :convention, + line: 5, + column: 18, + source: source }] inspect_source(source) @@ -1098,7 +1106,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with formula path shortcut long form 2" do + it "formula path shortcut : info" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1109,11 +1117,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "\"\#\{prefix}/share/info\" should be \"\#{info}\"", - severity: :convention, - line: 5, - column: 47, - source: source }] + expected_offenses = [{ message: "\"\#\{prefix}/share/info\" should be \"\#{info}\"", + severity: :convention, + line: 5, + column: 47, + source: source }] inspect_source(source) @@ -1122,7 +1130,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with formula path shortcut long form 3" do + it "formula path shortcut : man8" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1133,11 +1141,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "\"\#\{prefix}/share/man/man8\" should be \"\#{man8}\"", - severity: :convention, - line: 5, - column: 46, - source: source }] + expected_offenses = [{ message: "\"\#\{prefix}/share/man/man8\" should be \"\#{man8}\"", + severity: :convention, + line: 5, + column: 46, + source: source }] inspect_source(source) @@ -1146,7 +1154,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with dependecies which have to vendored" do + it "dependecies which have to vendored" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1155,11 +1163,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "lua modules should be vendored rather than use deprecated depends_on \"lpeg\" => :lua51`", - severity: :convention, - line: 4, - column: 24, - source: source }] + expected_offenses = [{ message: "lua modules should be vendored rather than use deprecated depends_on \"lpeg\" => :lua51`", + severity: :convention, + line: 4, + column: 24, + source: source }] inspect_source(source) @@ -1168,7 +1176,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with setting env manually" do + it "manually setting env" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1177,11 +1185,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use ENV instead of invoking 'export' to modify the environment", - severity: :convention, - line: 4, - column: 10, - source: source }] + expected_offenses = [{ message: "Use ENV instead of invoking 'export' to modify the environment", + severity: :convention, + line: 4, + column: 10, + source: source }] inspect_source(source) @@ -1190,7 +1198,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with dependencies with invalid options" do + it "dependencies with invalid options" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1199,11 +1207,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Dependency foo should not use option with-bar", - severity: :convention, - line: 4, - column: 13, - source: source }] + expected_offenses = [{ message: "Dependency foo should not use option with-bar", + severity: :convention, + line: 4, + column: 13, + source: source }] inspect_source(source) @@ -1212,7 +1220,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with inspecting version" do + it "inspecting version manually" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1223,11 +1231,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use 'build.head?' instead of inspecting 'version'", - severity: :convention, - line: 4, - column: 5, - source: source }] + expected_offenses = [{ message: "Use 'build.head?' instead of inspecting 'version'", + severity: :convention, + line: 4, + column: 5, + source: source }] inspect_source(source) @@ -1236,7 +1244,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with ENV.fortran" do + it "deprecated ENV.fortran usage" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1247,11 +1255,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use `depends_on :fortran` instead of `ENV.fortran`", - severity: :convention, - line: 5, - column: 4, - source: source }] + expected_offenses = [{ message: "Use `depends_on :fortran` instead of `ENV.fortran`", + severity: :convention, + line: 5, + column: 4, + source: source }] inspect_source(source) @@ -1260,7 +1268,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with ARGV.include? (--HEAD)" do + it "deprecated ARGV.include? (--HEAD) usage" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1271,11 +1279,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use \"if build.head?\" instead", - severity: :convention, - line: 5, - column: 26, - source: source }] + expected_offenses = [{ message: 'Use "if build.head?" instead', + severity: :convention, + line: 5, + column: 26, + source: source }] inspect_source(source) @@ -1284,7 +1292,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with MACOS_VERSION const" do + it "deprecated MACOS_VERSION const usage" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1295,11 +1303,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: "Use MacOS.version instead of MACOS_VERSION", - severity: :convention, - line: 5, - column: 14, - source: source }] + expected_offenses = [{ message: "Use MacOS.version instead of MACOS_VERSION", + severity: :convention, + line: 5, + column: 14, + source: source }] inspect_source(source) @@ -1308,7 +1316,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with if conditional dep" do + it "deprecated if build.with? conditional dependency" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1317,11 +1325,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: 'Replace depends_on "foo" if build.with? "with-foo" with depends_on "foo" => :optional', - severity: :convention, - line: 4, - column: 2, - source: source }] + expected_offenses = [{ message: 'Replace depends_on "foo" if build.with? "with-foo" with depends_on "foo" => :optional', + severity: :convention, + line: 4, + column: 2, + source: source }] inspect_source(source) @@ -1330,7 +1338,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with unless conditional dep and symbol" do + it "unless conditional dependency with build.without?" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1339,11 +1347,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: 'Replace depends_on :foo unless build.without? "foo" with depends_on :foo => :recommended', - severity: :convention, - line: 4, - column: 2, - source: source }] + expected_offenses = [{ message: 'Replace depends_on :foo unless build.without? "foo" with depends_on :foo => :recommended', + severity: :convention, + line: 4, + column: 2, + source: source }] inspect_source(source) @@ -1352,7 +1360,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end - it "with unless conditional dep with build.include?" do + it "unless conditional dependency with build.include?" do source = <<-EOS.undent class Foo < Formula desc "foo" @@ -1361,11 +1369,11 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end EOS - expected_offenses = [{ message: 'Replace depends_on :foo unless build.include? "without-foo" with depends_on :foo => :recommended', - severity: :convention, - line: 4, - column: 2, - source: source }] + expected_offenses = [{ message: 'Replace depends_on :foo unless build.include? "without-foo" with depends_on :foo => :recommended', + severity: :convention, + line: 4, + column: 2, + source: source }] inspect_source(source) |
