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

22 lines
582 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.
2017-11-01 17:30:08 +00:00
#
2017-11-01 12:42:58 +00:00
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