Class: SolargraphTestCoverage::TestCoverageReporter

Inherits:
Solargraph::Diagnostics::Base
  • Object
show all
Includes:
DiagnosticMessages, ReporterGuards, ReporterHelpers
Defined in:
lib/solargraph_test_coverage/test_coverage_reporter.rb

Instance Method Summary collapse

Methods included from DiagnosticMessages

#branch_coverage_warning, #debug_message, #example_failing_error, #line_coverage_warning, #test_failing_error, #test_missing_error

Methods included from ReporterGuards

#exclude_file?, #in_test_dir?, #test_file_exists?, #test_support_file?, #using_debugger?

Methods included from ReporterHelpers

#branch_warnings, #example_failing_errors, #line_warnings, #run_test, #test_passing_error, #uncovered_lines

Instance Method Details

#diagnose(source, _api_map) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/solargraph_test_coverage/test_coverage_reporter.rb', line 10

def diagnose(source, _api_map)
  @source   = source
  @filename = source.location.filename

  return [] if source.code.empty? || using_debugger? || exclude_file? || in_test_dir?
  return [test_missing_error] unless test_file_exists?

  @results = run_test(FileHelpers.test_file(@filename))

  [line_warnings, branch_warnings, test_passing_error].flatten.compact
rescue ChildFailedError => e
  Config.debug? ? [debug_message(e)] : []
end