Ameba::Runner - ameba 1.7.0

# class Ameba::Runner

- Ameba::Runner
- Reference
- Object

##
Overview

Represents a runner for inspecting source 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

- .new(config : Config)

  Instantiates a runner using a `config`.

##
Instance Method Summary

- #explain(location, output = STDOUT)

  Explains an issue at a specified location.

- #root : Path

  Project root path.

- #run

  Performs the inspection.

- #sources : Array(Source)

  A list of sources to run inspection on.

- #success?

  Indicates whether the last inspection successful or not.

- #version : SemanticVersion | Nil

  Returns an ameba version up to which the rules should be run.

- #version=(version : SemanticVersion | Nil)

  Returns an ameba version up to which the rules should be run.

##
Constructor Detail

def self.new(config : Config) #

Instantiates a runner using a `config`.

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

    runner = Ameba::Runner.new(config)

##
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(Crystal::Location.new(file, line, column))

def root : Path #

Project root path.

def run #

Performs the inspection. Iterates through all sources and tests them 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

def sources : Array(Source) #

A list of sources to run inspection on.

def success? #

Indicates whether the last inspection successful or not. It returns `true` if no issues are found, `false` otherwise.

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

def version : SemanticVersion | Nil #

Returns an ameba version up to which the rules should be run.

def version=(version : SemanticVersion | Nil) #

Returns an ameba version up to which the rules should be run.