Skip to content

Commit 3551fd8

Browse files
committed
Remove CC_TEST_REPORTER_ID special case for JSON formatter
The default HTMLFormatter already writes coverage.json, so the env-var trigger that pushed JSONFormatter onto the formatter list is redundant, it just caused a duplicate write of the same file. With the special case gone, `SimpleCov::Formatter.from_env` has no reason to exist, so the default_formatter module and its spec are deleted and defaults.rb sets HTMLFormatter directly.
1 parent e1f0486 commit 3551fd8

8 files changed

Lines changed: 3 additions & 122 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Unreleased
77
* `StringFilter` now matches at path-segment boundaries. `"lib"` matches `/lib/` but no longer matches `/library/`. Use a `Regexp` filter for substring matching.
88
* `SourceFile#project_filename` now returns a truly relative path with no leading separator (e.g. `lib/foo.rb` instead of `/lib/foo.rb`). This also removes the leading `/` from file path keys in `coverage.json` and from the filename in `minimum_coverage_by_file` error messages. Anchored `RegexFilter`s that relied on a leading `/` (e.g. `%r{^/lib/}`) should be rewritten (e.g. `%r{\Alib/}`).
99
* Removed `docile` gem dependency. The `SimpleCov.configure` DSL block is now evaluated via `instance_exec` with instance variable proxying.
10+
* Removed automatic activation of `JSONFormatter` when the `CC_TEST_REPORTER_ID` environment variable is set. The default `HTMLFormatter` now always writes `coverage.json`, so the env-var special case is no longer needed.
1011

1112
## Enhancements
1213
* JSON formatter: `meta.timestamp` is now emitted with millisecond precision (`iso8601(3)`) so the concurrent-overwrite warning can distinguish writes within the same wall-clock second

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,9 +905,6 @@ SimpleCov includes a `SimpleCov::Formatter::JSONFormatter` that provides you wit
905905
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
906906
```
907907

908-
> _Note:_ In case you plan to report your coverage results to CodeClimate services, know that SimpleCov will automatically use the
909-
> JSON formatter along with the HTML formatter when the `CC_TEST_REPORTER_ID` variable is present in the environment.
910-
911908
> The JSON formatter was originally a separate gem called [simplecov_json_formatter](https://github.com/codeclimate-community/simplecov_json_formatter). It is now built in and loaded by default. Existing code that does `require "simplecov_json_formatter"` will continue to work.
912909
913910
## Available formatters, editor integrations and hosted services

features/config_json_formatter.feature

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,3 @@ Feature:
2424
When I successfully run `bundle exec rake test`
2525
Then a JSON coverage report should have been generated in "coverage"
2626
And the output should contain "JSON Coverage report generated"
27-
28-
Scenario: When CC_TEST_REPORTER_ID is set in the environment
29-
Given SimpleCov for Test/Unit is configured with:
30-
"""
31-
require 'simplecov'
32-
SimpleCov.at_exit do
33-
puts SimpleCov.result.format!
34-
end
35-
SimpleCov.start do
36-
add_group 'Libs', 'lib/faked_project/'
37-
end
38-
"""
39-
And I set the environment variables to:
40-
| variable | value |
41-
| CC_TEST_REPORTER_ID | some-id |
42-
43-
When I successfully run `bundle exec rake test`
44-
45-
Then a JSON coverage report should have been generated in "coverage"
46-
And the output should contain "JSON Coverage report generated"

features/step_definitions/json_steps.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

features/test_unit_basic.feature

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,3 @@ Feature:
3535

3636
And the report should be based upon:
3737
| Unit Tests |
38-
39-
Scenario:
40-
Given SimpleCov for Test/Unit is configured with:
41-
"""
42-
ENV['CC_TEST_REPORTER_ID'] = "9719ac886877886b7e325d1e828373114f633683e429107d1221d25270baeabf"
43-
require 'simplecov'
44-
SimpleCov.start
45-
"""
46-
47-
When I open the coverage report generated with `bundle exec rake test`
48-
Then I should see the groups:
49-
| name | coverage | files |
50-
| All Files | 91.37% | 6 |
51-
52-
And I should see the source files:
53-
| name | coverage |
54-
| lib/faked_project.rb | 100.00% |
55-
| lib/faked_project/some_class.rb | 80.00% |
56-
| lib/faked_project/framework_specific.rb | 75.00% |
57-
| lib/faked_project/meta_magic.rb | 100.00% |
58-
| test/meta_magic_test.rb | 100.00% |
59-
| test/some_class_test.rb | 100.00% |
60-
61-
# Note: faked_test.rb is not appearing here since that's the first unit test file
62-
# loaded by Rake, and only there test_helper is required, which then loads simplecov
63-
# and triggers tracking of all other loaded files! Solution for this would be to
64-
# configure simplecov in this first test instead of test_helper.
65-
66-
And the report should be based upon:
67-
| Unit Tests |
68-
69-
And a JSON coverage report should have been generated
70-
And the JSON coverage report should match the output for the basic case

lib/simplecov/default_formatter.rb

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/simplecov/defaults.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# frozen_string_literal: true
22

3-
# Load default formatter gem
43
require "pathname"
5-
require_relative "default_formatter"
4+
require_relative "formatter/html_formatter"
65
require_relative "profiles/root_filter"
76
require_relative "profiles/test_frameworks"
87
require_relative "profiles/bundler_filter"
@@ -11,9 +10,7 @@
1110

1211
# Default configuration
1312
SimpleCov.configure do
14-
formatter SimpleCov::Formatter::MultiFormatter.new(
15-
SimpleCov::Formatter.from_env(ENV)
16-
)
13+
formatter SimpleCov::Formatter::HTMLFormatter
1714

1815
load_profile "bundler_filter"
1916
load_profile "hidden_filter"

spec/default_formatter_spec.rb

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)