Created
September 3, 2019 17:35
-
-
Save veelenga/d05eb5a3b346748ed4ba309cf79c73e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "ameba" | |
source = Ameba::Source.new %( | |
class Ameba::Internals | |
getter info : Info | |
def dump | |
puts info | |
end | |
end | |
), "source.cr" | |
module Ameba::Rule | |
# A rule that disallows calls to `puts` method. | |
struct NoPuts < Base | |
def test(source) | |
AST::NodeVisitor.new self, source | |
end | |
def test(source, node : Crystal::Call) | |
return unless node.name == "puts" | |
source.add_issue(self, node, "puts method is called") | |
end | |
end | |
end | |
rule = Ameba::Rule::NoPuts.new | |
rule.catch(source) | |
formatter = Ameba::Formatter::JSONFormatter.new(STDOUT) | |
formatter.started([source]) | |
formatter.source_finished(source) | |
formatter.finished([source]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment