mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
25 lines
654 B
Ruby
25 lines
654 B
Ruby
# typed: strict
|
|
# frozen_string_literal: true
|
|
|
|
module RuboCop
|
|
module Cop
|
|
module Homebrew
|
|
class ShellCommandStub < Base
|
|
MSG = "Shell command stubs must have a `.sh` counterpart."
|
|
RESTRICT_ON_SEND = [:include].freeze
|
|
|
|
sig { params(node: AST::SendNode).void }
|
|
def on_send(node)
|
|
return if node.first_argument&.const_name != "ShellCommand"
|
|
|
|
stub_path = Pathname.new(processed_source.file_path)
|
|
sh_cmd_path = Pathname.new("#{stub_path.dirname}/#{stub_path.basename(".rb")}.sh")
|
|
return if sh_cmd_path.exist?
|
|
|
|
add_offense(node)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|