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)
|
2017-11-06 18:54:58 +00:00
|
|
|
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?
|
|
|
|
|
2017-11-07 20:02:51 +00:00
|
|
|
source.error self, node.location,
|
2017-11-01 12:42:58 +00:00
|
|
|
"Possible forgotten debugger statement detected"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|