Class: Ea::Cli::Command::Lint

Inherits:
Base
  • Object
show all
Defined in:
lib/ea/cli/command/lint.rb

Overview

ea lint FILE [--rule=NAME] [--severity=error|warning]

Runs the Ea::Lint::Engine over a parsed model and reports offenses. Exit 1 when errors are found.

Constant Summary collapse

COLUMNS =
%i[severity rule entity_name message].freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Ea::Cli::Command::Base

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
# File 'lib/ea/cli/command/lint.rb', line 13

def call
  offenses = engine.run(model)
  offenses = filter_by_rule(offenses)
  offenses = filter_by_severity(offenses)
  rows = offenses.map { |o| [o.severity, o.rule, o.entity_name, o.message] }
  formatter.render(rows, columns: COLUMNS)
  exit(1) if offenses.any?(&:error?)
end