Module: CodeclimateBatch

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

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.startObject

code climate only accepts reports from master but records coverage on all PRs -> wasted time



6
7
8
9
10
11
12
# File 'lib/codeclimate_batch.rb', line 6

def start
  return if ENV['TRAVIS'] && (ENV['TRAVIS_BRANCH'] != 'master' || ENV['TRAVIS_PULL_REQUEST'].to_i != 0)
  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



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

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