fix pkgshare missing slash issue
This commit is contained in:
parent
55246d720e
commit
d8fb850fa9
@ -150,13 +150,13 @@ module RuboCop
|
||||
end
|
||||
|
||||
# Check whether value starts with the formula name and then a "/", " " or EOS
|
||||
def starts_with_formula_name?(value)
|
||||
value.match?(%r{#{Regexp.escape(@formula_name)}(/| |$)})
|
||||
def starts_with_formula_name?(value, prefix = "")
|
||||
value.match?(%r{^#{Regexp.escape(prefix + @formula_name)}(/| |$)})
|
||||
end
|
||||
|
||||
# Find "#{share}/foo"
|
||||
def_node_search :share_formula_name_dstr, <<~EOS
|
||||
$(dstr (begin (send nil? :share)) (str #starts_with_formula_name?))
|
||||
$(dstr (begin (send nil? :share)) (str #starts_with_formula_name?("/")))
|
||||
EOS
|
||||
|
||||
# Find share/"foo"
|
||||
|
||||
@ -449,5 +449,25 @@ describe RuboCop::Cop::FormulaAuditStrict::Text do
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "when formula name appears afer `share/\"bar\"`" do
|
||||
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||
class Foo < Formula
|
||||
def install
|
||||
ohai share/"bar/foo"
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "when formula name appears afer `\"\#{share}/bar\"`" do
|
||||
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb")
|
||||
class Foo < Formula
|
||||
def install
|
||||
ohai "\#{share}/bar/foo"
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user