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

22 lines
559 B
Crystal
Raw Normal View History

2017-11-07 21:50:25 +00:00
module Ameba::Rule
2017-11-01 12:42:58 +00:00
# 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-07 21:50:25 +00:00
struct DebuggerStatement < Base
2017-11-01 12:42:58 +00:00
def test(source)
AST::Visitor.new self, source
2017-11-01 12:42:58 +00:00
end
def test(source, node : Crystal::Call)
return unless node.name == "debugger" &&
node.args.empty? &&
node.obj.nil?
source.error self, node.location,
2017-11-01 12:42:58 +00:00
"Possible forgotten debugger statement detected"
end
end
end