Class: Packwerk::Formatters::DefaultOffensesFormatter

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
OffensesFormatter
Defined in:
lib/packwerk/formatters/default_offenses_formatter.rb

Constant Summary collapse

IDENTIFIER =
T.let("default", String)

Instance Method Summary collapse

Methods included from OffensesFormatter

all, find, included

Instance Method Details

#identifierObject



33
34
35
# File 'lib/packwerk/formatters/default_offenses_formatter.rb', line 33

def identifier
  IDENTIFIER
end

#show_offenses(offenses) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/packwerk/formatters/default_offenses_formatter.rb', line 14

def show_offenses(offenses)
  return "No offenses detected" if offenses.empty?

  <<~EOS
    #{offenses_list(offenses)}
    #{offenses_summary(offenses)}
  EOS
end

#show_stale_violations(offense_collection, file_set) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/packwerk/formatters/default_offenses_formatter.rb', line 24

def show_stale_violations(offense_collection, file_set)
  if offense_collection.stale_violations?(file_set)
    "There were stale violations found, please run `packwerk update-todo`"
  else
    "No stale violations detected"
  end
end

#show_strict_mode_violations(strict_mode_violations) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/packwerk/formatters/default_offenses_formatter.rb', line 38

def show_strict_mode_violations(strict_mode_violations)
  if strict_mode_violations.any?
    strict_mode_violations.compact.map { |offense| format_strict_mode_violation(offense) }.join("\n")
  else
    ""
  end
end