Module: SolargraphTestCoverage::DiagnosticMessages

Included in:
ExampleStatusReporter, TestCoverageReporter
Defined in:
lib/solargraph_test_coverage/diagnostic_messages.rb

Instance Method Summary collapse

Instance Method Details

#branch_coverage_warning(report) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/solargraph_test_coverage/diagnostic_messages.rb', line 16

def branch_coverage_warning(report)
  return unless Config.branch_coverage?

  {
    range: range(report[:line] - 1, 0, report[:line] - 1, @source.code.lines[report[:line] - 1].length),
    severity: Solargraph::Diagnostics::Severities::WARNING,
    source: 'TestCoverage',
    message: "'#{report[:type].upcase}' branch is missing test coverage"
  }
end

#debug_message(exception) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/solargraph_test_coverage/diagnostic_messages.rb', line 60

def debug_message(exception)
  {
    range: range(0, 0, 0, @source.code.lines[0].length),
    severity: Solargraph::Diagnostics::Severities::ERROR,
    source: 'SolargraphTestCoverage Plugin',
    message: "DEBUG: (ChildFailedError) #{exception.message}"
  }
end

#example_failing_error(example) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/solargraph_test_coverage/diagnostic_messages.rb', line 49

def example_failing_error(example)
  return unless Config.example_failing_coverage?

  {
    range: range(example[:line_number], 0, example[:line_number], @source.code.lines[example[:line_number]].length),
    severity: Solargraph::Diagnostics::Severities::ERROR,
    source: 'ExampleStatus',
    message: example[:message]
  }
end

#line_coverage_warning(line) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/solargraph_test_coverage/diagnostic_messages.rb', line 5

def line_coverage_warning(line)
  return unless Config.line_coverage?

  {
    range: range(line, 0, line, @source.code.lines[line].length),
    severity: Solargraph::Diagnostics::Severities::WARNING,
    source: 'TestCoverage',
    message: 'Line is missing test coverage'
  }
end

#test_failing_errorObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/solargraph_test_coverage/diagnostic_messages.rb', line 27

def test_failing_error
  return unless Config.test_failing_coverage?

  {
    range: range(0, 0, 0, @source.code.lines[0].length),
    severity: Solargraph::Diagnostics::Severities::ERROR,
    source: 'TestCoverage',
    message: 'Unit Test is currently failing.'
  }
end

#test_missing_errorObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/solargraph_test_coverage/diagnostic_messages.rb', line 38

def test_missing_error
  return unless Config.test_missing_coverage?

  {
    range: range(0, 0, 0, @source.code.lines[0].length),
    severity: Solargraph::Diagnostics::Severities::HINT,
    source: 'TestCoverage',
    message: "No test file found at '#{FileHelpers.relative_test_file(@filename)}'"
  }
end