Module: Hashira::CLI::FailOn

Defined in:
lib/hashira/cli/fail_on.rb

Constant Summary collapse

MEASURES =
(Hashira::Pipeline::ANALYZERS - %i[coupling smells]).map(&:to_s).freeze
KINDS =
{
  "cycles" => "cycle", "sdp" => "sdp_violation", "dupe" => "duplication",
  **Hashira::Pipeline::STRUCTURAL.to_h { [it, it] },
  **MEASURES.to_h { [it, it] },
  "smells" => Hashira::Pipeline::SMELLS, **Hashira::Pipeline::SMELLS.to_h { [it, it] }
}.freeze
OWNERS =
{
  **Hashira::Pipeline::STRUCTURAL.to_h { [it, :coupling] },
  **MEASURES.to_h { [it, it.to_sym] },
  **Hashira::Pipeline::SMELLS.to_h { [it, :smells] }
}.freeze

Class Method Summary collapse

Class Method Details

.kind(name) ⇒ Object



32
33
34
35
36
# File 'lib/hashira/cli/fail_on.rb', line 32

def kind(name)
  KINDS.fetch(name) do
    raise(Hashira::Error, "unknown --fail-on kind #{name.inspect} (use: #{KINDS.keys.join(", ")})")
  end
end

.owner(kind) ⇒ Object



30
# File 'lib/hashira/cli/fail_on.rb', line 30

def owner(kind) = OWNERS.fetch(kind)

.parse(list) ⇒ Object

Raises:



23
24
25
26
27
28
# File 'lib/hashira/cli/fail_on.rb', line 23

def parse(list)
  return [] if list.to_s.empty?
  kinds = list.split(",").flat_map { Array(kind(it.strip)) }.uniq
  raise(Hashira::Error, "--fail-on needs at least one kind") if kinds.empty?
  kinds
end