Class: LintTrappings::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/lint_trappings/report.rb

Overview

Contains information about all lints detected during a scan.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, lints, documents) ⇒ Report

Returns a new instance of Report.

Parameters:



14
15
16
17
18
# File 'lib/lint_trappings/report.rb', line 14

def initialize(config, lints, documents)
  @config = config
  @lints = lints.sort_by { |lint| [lint.path, lint.source_range.begin.line] }
  @documents_inspected = documents
end

Instance Attribute Details

#documents_inspectedArray<String> (readonly)

Returns List of files that were inspected.

Returns:

  • (Array<String>)

    List of files that were inspected.



9
10
11
# File 'lib/lint_trappings/report.rb', line 9

def documents_inspected
  @documents_inspected
end

#lintsArray<LintTrappings::Lint]

List of lints that were found.

Returns:



6
7
8
# File 'lib/lint_trappings/report.rb', line 6

def lints
  @lints
end

Instance Method Details

#fail_severitiesObject



24
25
26
# File 'lib/lint_trappings/report.rb', line 24

def fail_severities
  @fail_severities ||= severities.select { |_severity, action| action == 'fail' }.keys
end

#failuresObject



36
37
38
39
40
41
# File 'lib/lint_trappings/report.rb', line 36

def failures
  @failures ||=
    begin
      @lints.select { |lint| fail_severities.include?(lint.severity) }
    end
end

#failures?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/lint_trappings/report.rb', line 32

def failures?
  failures.any?
end

#severitiesObject



20
21
22
# File 'lib/lint_trappings/report.rb', line 20

def severities
  @severities ||= @config.fetch('severities', error: 'fail', warning: 'warn')
end

#success?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/lint_trappings/report.rb', line 54

def success?
  lints.empty?
end

#warn_severitiesObject



28
29
30
# File 'lib/lint_trappings/report.rb', line 28

def warn_severities
  @warn_severities ||= severities.select { |_severity, action| action == 'warn' }.keys
end

#warningsObject



47
48
49
50
51
52
# File 'lib/lint_trappings/report.rb', line 47

def warnings
  @warnings ||=
    begin
      @lints.select { |lint| warn_severities.include?(lint.severity) }
    end
end

#warnings?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/lint_trappings/report.rb', line 43

def warnings?
  warnings.any?
end