class Ameba::Runner

Overview

Represents a runner for inspecting sources files. Holds a list of rules to do inspection based on, list of sources to run inspection on and a formatter to prepare a report.

config = Ameba::Config.load
runner = Ameba::Runner.new config
runner.run.success? # => true or false

Defined in:

ameba/runner.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(config : Config) #

Instantiates a runner using a config.

config = Ameba::Config.load
config.files = files
config.formatter = formatter

Ameba::Runner.new config

[View source]

Instance Method Detail

def explain(location, output = STDOUT) #

Explains an issue at a specified location.

Runner should perform inspection before doing the explain. This is necessary to be able to find the issue at a specified location.

runner = Ameba::Runner.new config
runner.run
runner.explain({file: file, line: l, column: c})

[View source]
def run #

Performs the inspection. Iterates through all sources and test it using list of rules. If a specific rule fails on a specific source, it adds an issue to that source.

This action also notifies formatter when inspection is started/finished, and when a specific source started/finished to be inspected.

runner = Ameba::Runner.new config
runner.run # => returns runner again

[View source]
def sources : Array(Source) #

A list of sources to run inspection on.


[View source]
def success? #

Indicates whether the last inspection successful or not. It returns true if no issues matching severity in sources found, false otherwise.

runner = Ameba::Runner.new config
runner.run
runner.success? # => true or false

[View source]