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

34 lines
732 B
Crystal
Raw Normal View History

module Ameba::Rule::Lint
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
#
# YAML configuration example:
#
# ```
# DebuggerStatement:
# Enabled: true
# ```
#
2017-11-07 21:50:25 +00:00
struct DebuggerStatement < Base
2017-11-22 06:44:29 +00:00
properties do
description "Disallows calls to debugger"
2017-11-22 06:44:29 +00:00
end
MSG = "Possible forgotten debugger statement detected"
2017-11-01 12:42:58 +00:00
def test(source)
AST::NodeVisitor.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?
2018-06-10 21:15:12 +00:00
issue_for node, MSG
2017-11-01 12:42:58 +00:00
end
end
end