class Ameba::Config

Overview

A configuration entry for Ameba::Runner.

Config can be loaded from configuration YAML file and adjusted.

config = Config.load
config.formatter = my_formatter

By default config loads .ameba.yml file in a current directory.

Included Modules

Defined in:

ameba/config.cr

Constant Summary

AVAILABLE_FORMATTERS = {progress: Formatter::DotFormatter, todo: Formatter::TODOFormatter, flycheck: Formatter::FlycheckFormatter, silent: Formatter::BaseFormatter, disabled: Formatter::DisabledFormatter, json: Formatter::JSONFormatter}
DEFAULT_GLOBS = ["**/*.cr", "!lib"] of ::String
PATH = ".ameba.yml"

Class Method Summary

Instance Method Summary

Instance methods inherited from module Ameba::GlobUtils

expand(globs) expand, find_files_by_globs(globs) find_files_by_globs

Class Method Detail

def self.formatter_names #

[View source]
def self.load(path = PATH, colors = true) #

Loads YAML configuration file by path.

config = Ameba::Config.load

[View source]

Instance Method Detail

def autocorrect=(autocorrect : Bool) #

Returns true if correctable issues should be autocorrected.


[View source]
def autocorrect? : Bool #

Returns true if correctable issues should be autocorrected.


[View source]
def excluded : Array(String) #

Represents a list of paths to exclude from globs. Can have wildcards.

config = Ameba::Config.load
config.excluded = ["spec", "src/server/*.cr"]

[View source]
def excluded=(excluded : Array(String)) #

Represents a list of paths to exclude from globs. Can have wildcards.

config = Ameba::Config.load
config.excluded = ["spec", "src/server/*.cr"]

[View source]
def formatter : Formatter::BaseFormatter #

Returns a formatter to be used while inspecting files. If formatter is not set, it will return default formatter.

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

[View source]
def formatter=(name : String | Symbol) #

Sets formatter by name.

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

[View source]
def formatter=(formatter : Formatter::BaseFormatter) #

Returns a formatter to be used while inspecting files. If formatter is not set, it will return default formatter.

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

[View source]
def globs : Array(String) #

Returns a list of paths (with wildcards) to files. Represents a list of sources to be inspected. If globs are not set, it will return default list of files.

config = Ameba::Config.load
config.globs = ["**/*.cr"]
config.globs

[View source]
def globs=(globs : Array(String)) #

Returns a list of paths (with wildcards) to files. Represents a list of sources to be inspected. If globs are not set, it will return default list of files.

config = Ameba::Config.load
config.globs = ["**/*.cr"]
config.globs

[View source]
def rules : Array(Rule::Base) #

[View source]
def severity : Ameba::Severity #

[View source]
def severity=(severity : Ameba::Severity) #

[View source]
def sources #

Returns a list of sources matching globs and excluded sections.

config = Ameba::Config.load
config.sources # => list of default sources
config.globs = ["**/*.cr"]
config.excluded = ["spec"]
config.sources # => list of sources pointing to files found by the wildcards

[View source]
def update_rule(name, enabled = true, excluded = nil) #

Updates rule properties.

config = Ameba::Config.load
config.update_rule "MyRuleName", enabled: false

[View source]
def update_rules(names, enabled = true, excluded = nil) #

Updates rules properties.

config = Ameba::Config.load
config.update_rules %w(Rule1 Rule2), enabled: true

also it allows to update groups of rules:

config.update_rules %w(Group1 Group2), enabled: true

[View source]