bottle_block_cop: remove
This commit is contained in:
parent
0c38ceb6f6
commit
44873fd4c8
@ -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"
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user