From 44873fd4c85897ba056b48a8105617af186896fb Mon Sep 17 00:00:00 2001 From: commitay Date: Wed, 4 Jul 2018 21:25:43 +1000 Subject: [PATCH] bottle_block_cop: remove --- Library/Homebrew/rubocops.rb | 1 - Library/Homebrew/rubocops/bottle_block_cop.rb | 29 ------------ .../test/rubocops/bottle_block_cop_spec.rb | 47 ------------------- 3 files changed, 77 deletions(-) delete mode 100644 Library/Homebrew/rubocops/bottle_block_cop.rb delete mode 100644 Library/Homebrew/test/rubocops/bottle_block_cop_spec.rb diff --git a/Library/Homebrew/rubocops.rb b/Library/Homebrew/rubocops.rb index f1923ee654..e0a532363a 100644 --- a/Library/Homebrew/rubocops.rb +++ b/Library/Homebrew/rubocops.rb @@ -1,4 +1,3 @@ -require_relative "./rubocops/bottle_block_cop" require_relative "./rubocops/formula_desc_cop" require_relative "./rubocops/components_order_cop" require_relative "./rubocops/components_redundancy_cop" diff --git a/Library/Homebrew/rubocops/bottle_block_cop.rb b/Library/Homebrew/rubocops/bottle_block_cop.rb deleted file mode 100644 index 3cfde01ad6..0000000000 --- a/Library/Homebrew/rubocops/bottle_block_cop.rb +++ /dev/null @@ -1,29 +0,0 @@ -require_relative "./extend/formula_cop" - -module RuboCop - module Cop - module FormulaAuditStrict - # This cop audits `bottle` block in Formulae - # - # - `rebuild` should be used instead of `revision` in `bottle` block - - class BottleBlock < FormulaCop - MSG = "Use rebuild instead of revision in bottle block".freeze - - def audit_formula(_node, _class_node, _parent_class_node, body_node) - bottle = find_block(body_node, :bottle) - return if bottle.nil? || block_size(bottle).zero? - problem "Use rebuild instead of revision in bottle block" if method_called_in_block?(bottle, :revision) - end - - def autocorrect(node) - lambda do |corrector| - correction = node.source.sub("revision", "rebuild") - corrector.insert_before(node.source_range, correction) - corrector.remove(node.source_range) - end - end - end - end - end -end diff --git a/Library/Homebrew/test/rubocops/bottle_block_cop_spec.rb b/Library/Homebrew/test/rubocops/bottle_block_cop_spec.rb deleted file mode 100644 index e0982dcbab..0000000000 --- a/Library/Homebrew/test/rubocops/bottle_block_cop_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require_relative "../../rubocops/bottle_block_cop" - -describe RuboCop::Cop::FormulaAuditStrict::BottleBlock do - subject(:cop) { described_class.new } - - context "When auditing Bottle Block" do - it "When there is revision in bottle block" do - expect_offense(<<~RUBY) - class Foo < Formula - url 'http://example.com/foo-1.0.tgz' - bottle do - cellar :any - revision 2 - ^^^^^^^^^^ Use rebuild instead of revision in bottle block - end - end - RUBY - end - end - - context "When auditing Bottle Block with auto correct" do - it "When there is revision in bottle block" do - source = <<~EOS - class Foo < Formula - url 'http://example.com/foo-1.0.tgz' - bottle do - cellar :any - revision 2 - end - end - EOS - - corrected_source = <<~EOS - class Foo < Formula - url 'http://example.com/foo-1.0.tgz' - bottle do - cellar :any - rebuild 2 - end - end - EOS - - new_source = autocorrect_source(source) - expect(new_source).to eq(corrected_source) - end - end -end