Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 157c308

Browse files
committed
Merge pull request #50 from codeclimate/nocov-skip_token
Support 'skip_token' option
2 parents c79f005 + 46171d0 commit 157c308

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

lib/code_climate/test_reporter.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ def self.start
66
require "simplecov"
77
::SimpleCov.add_filter 'vendor'
88
::SimpleCov.formatter = Formatter
9-
::SimpleCov.start(configuration.profile)
9+
::SimpleCov.start(configuration.profile) do
10+
skip_token CodeClimate::TestReporter.configuration.skip_token
11+
end
1012
end
1113
end
1214

lib/code_climate/test_reporter/configuration.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def profile
3333
@profile ||= "test_frameworks"
3434
end
3535

36+
def skip_token
37+
@skip_token ||= "nocov"
38+
end
39+
3640
private
3741

3842
def default_logger

lib/code_climate/test_reporter/formatter.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Formatter
1313
def format(result)
1414
return true unless CodeClimate::TestReporter.run?
1515

16-
print "Coverage = #{round(result.covered_percent, 2)}%. "
16+
print "Coverage = #{result.source_files.covered_percent.round(2)}%. "
1717

1818
payload = to_payload(result)
1919
PayloadValidator.validate(payload)
@@ -63,8 +63,8 @@ def to_payload(result)
6363
repo_token: ENV["CODECLIMATE_REPO_TOKEN"],
6464
source_files: source_files,
6565
run_at: result.created_at.to_i,
66-
covered_percent: round(result.covered_percent, 2),
67-
covered_strength: round(result.covered_strength, 2),
66+
covered_percent: result.source_files.covered_percent.round(2),
67+
covered_strength: result.source_files.covered_strength.round(2),
6868
line_counts: totals,
6969
partial: partial?,
7070
git: Git.info,

spec/lib/configuration_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module CodeClimate::TestReporter
1414
expect(CodeClimate::TestReporter.configuration.logger.level).to eq Logger::INFO
1515
expect(CodeClimate::TestReporter.configuration.profile).to eq('test_frameworks')
1616
expect(CodeClimate::TestReporter.configuration.path_prefix).to be_nil
17+
expect(CodeClimate::TestReporter.configuration.skip_token).to eq('nocov')
1718
end
1819
end
1920

spec/lib/formatter_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ module CodeClimate::TestReporter
66
let(:project_path) { "spec/tmp" }
77
let(:project_file) { "fake_project.rb" }
88
let(:formatter) { Formatter.new }
9+
let(:source_files) {
10+
double(
11+
:covered_percent => 24.3,
12+
:covered_strength => 33.2,
13+
)
14+
}
915
let(:files) {
1016
[
1117
double(
@@ -25,6 +31,7 @@ module CodeClimate::TestReporter
2531
:covered_percent => 24.3,
2632
:covered_strength => 33.2,
2733
:files => files,
34+
:source_files => source_files,
2835
:created_at => Time.at(1379704336),
2936
:command_name => "rspec"
3037
)

0 commit comments

Comments
 (0)