shard-ameba/src/ameba/rules/debugger_statement.cr

21 lines
578 B
Crystal
Raw Normal View History

2017-11-01 12:42:58 +00:00
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