Module: CodeclimateBatch

Defined in:
lib/codeclimate_batch.rb,
lib/codeclimate_batch/version.rb

Constant Summary collapse

VERSION =
"0.5.0"

Class Method Summary collapse

Class Method Details

.startObject

Start TestReporter with appropriate settings. Note that Code Climate only accepts reports from the default branch (usually master, but can be changed) but records coverage on all PRs and displays their coverage difference



8
9
10
11
12
13
14
# File 'lib/codeclimate_batch.rb', line 8

def start
  return if travis? && (outside_default_branch? && !pull_request?)
  ENV['CODECLIMATE_TO_FILE'] = '1' # write results to file since we need to combine them before sending
  gem 'codeclimate-test-reporter', '>= 0.4.8' # get CODECLIMATE_TO_FILE support and avoid deprecations
  require 'codeclimate-test-reporter'
  CodeClimate::TestReporter.start
end

.unify(coverage_files) ⇒ Object



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

def unify(coverage_files)
  initial, *rest = coverage_files
  report = load(initial)
  rest.each do |file|
    merge_source_files(report.fetch("source_files"), load(file).fetch("source_files"))
  end
  recalculate_counters(report)
  report
end