mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
21 lines
578 B
Crystal
21 lines
578 B
Crystal
|
module Ameba::Rules
|
||
|
# A rule that disallows calls to debugger.
|
||
|
#
|
||
|
# This is because we don't want debugger breakpoints accidentally being
|
||
|
# committed into our codebase.
|
||
|
struct DebuggerStatement < Rule
|
||
|
def test(source)
|
||
|
AST::CallVisitor.new self, source
|
||
|
end
|
||
|
|
||
|
def test(source, node : Crystal::Call)
|
||
|
return unless node.name == "debugger" &&
|
||
|
node.args.empty? &&
|
||
|
node.obj.nil?
|
||
|
|
||
|
source.error self, node.location.try &.line_number,
|
||
|
"Possible forgotten debugger statement detected"
|
||
|
end
|
||
|
end
|
||
|
end
|