rubocops/text: use rubocop v1 API
This commit is contained in:
parent
c18ffa84ca
commit
3bda457478
@ -10,17 +10,16 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
class Text < FormulaCop
|
class Text < FormulaCop
|
||||||
def audit_formula(node, _class_node, _parent_class_node, body_node)
|
extend AutoCorrector
|
||||||
@full_source_content = source_buffer(node).source
|
|
||||||
|
|
||||||
if match = @full_source_content.match(/^require ['"]formula['"]$/)
|
def audit_formula(node, _class_node, _parent_class_node, body_node)
|
||||||
@offensive_node = node
|
full_source_content = source_buffer(node).source
|
||||||
@source_buf = source_buffer(node)
|
|
||||||
@line_no = match.pre_match.count("\n") + 1
|
if match = full_source_content.match(/^require ['"]formula['"]$/)
|
||||||
@column = 0
|
range = source_range(source_buffer(node), match.pre_match.count("\n") + 1, 0, match[0].length)
|
||||||
@length = match[0].length
|
add_offense(range, message: "`#{match}` is now unnecessary") do |corrector|
|
||||||
@offense_source_range = source_range(@source_buf, @line_no, @column, @length)
|
corrector.remove(range_with_surrounding_space(range: range))
|
||||||
problem "`#{match}` is now unnecessary"
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !find_node_method_by_name(body_node, :plist_options) &&
|
if !find_node_method_by_name(body_node, :plist_options) &&
|
||||||
|
|||||||
@ -16,6 +16,13 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
homepage "https://brew.sh"
|
homepage "https://brew.sh"
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
|
expect_correction(<<~RUBY)
|
||||||
|
class Foo < Formula
|
||||||
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
|
homepage "https://brew.sh"
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "with both openssl and libressl optional dependencies" do
|
it "with both openssl and libressl optional dependencies" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user