Class: CC::Analyzer::Formatters::PlainTextFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/cc/analyzer/formatters/plain_text_formatter.rb

Constant Summary

Constants inherited from Formatter

Formatter::InvalidFormatterError

Instance Method Summary collapse

Methods inherited from Formatter

#close, #initialize, #write

Constructor Details

This class inherits a constructor from CC::Analyzer::Formatters::Formatter

Instance Method Details

#engine_running(engine, &block) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/cc/analyzer/formatters/plain_text_formatter.rb', line 39

def engine_running(engine, &block)
  super(engine) do
    result = with_spinner("Running #{current_engine.name}: ", &block)
    if result.skipped?
      puts(colorize("Skipped #{current_engine.name}: #{result.stderr}", :yellow))
    end
  end
end

#failed(output) ⇒ Object



48
49
50
51
52
53
# File 'lib/cc/analyzer/formatters/plain_text_formatter.rb', line 48

def failed(output)
  spinner.stop("Failed")
  puts colorize("\nAnalysis failed with the following output:", :red)
  puts output
  exit 1
end

#finishedObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cc/analyzer/formatters/plain_text_formatter.rb', line 13

def finished
  puts

  issues_by_path.each do |path, file_issues|
    puts colorize("== #{path} (#{pluralize(file_issues.size, "issue")}) ==", :yellow)

    IssueSorter.new(file_issues).by_location.each do |issue|
      if (location = issue["location"])
        source_buffer = @filesystem.source_buffer_for(location["path"])
        print(colorize(LocationDescription.new(source_buffer, location, ": "), :cyan))
      end

      print(issue["description"])
      print(colorize(" [#{issue["engine_name"]}]", "#333333"))
      puts
    end
    puts
  end

  print(colorize("Analysis complete! Found #{pluralize(issues.size, "issue")}", :green))
  unless warnings.empty?
    print(colorize(" and #{pluralize(warnings.size, "warning")}", :green))
  end
  puts(colorize(".", :green))
end

#startedObject



9
10
11
# File 'lib/cc/analyzer/formatters/plain_text_formatter.rb', line 9

def started
  puts colorize("Starting analysis", :green)
end