Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,8 @@ require "simplecov_json_formatter"
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
```

> _Note:_ In case you plan to report your coverage results to CodeClimate services, know that SimpleCov will automatically use the
> JSON formatter along with the HTML formatter when the `CC_TEST_REPORTER_ID` variable is present in the environment.
> _Note:_ In case you plan to report your coverage results to [Qlty Cloud](https://qlty.sh) services, know that SimpleCov will automatically use the
> JSON formatter along with the HTML formatter when the `QLTY_COVERAGE_TOKEN` variable is present in the environment.

## Available formatters, editor integrations and hosted services

Expand Down
10 changes: 5 additions & 5 deletions doc/commercial-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ these integrations with their respective owners.

Upload coverage reports to [codacy.com](https://www.codacy.com/), a hosted (or self-hosted) software quality analysis platform that also includes coverage reporting.

#### [codeclimate](https://github.com/codeclimate/ruby-test-reporter)
*by [Code Climate](https://codeclimate.com/)*

Upload coverage reports to [codeclimate.com](https://codeclimate.com/), a hosted software quality analysis and that also includes coverage reporting.

#### [codecov](https://github.com/codecov/codecov-ruby)
*by [Codecov](https://codecov.io/)*

Expand All @@ -23,3 +18,8 @@ Upload coverage reports to [codecov.io](https://codecov.io/), a hosted coverage
*by [Coveralls](https://coveralls.io/)*

Upload coverage reports to [coveralls.io](https://coveralls.io/), a hosted coverage reporting solution.

#### [Qlty Cloud](https://github.com/qltysh/qlty)
*by [Qlty Software](https://qlty.sh/)*

Upload coverage reports to [Qlty Cloud](https://qlty.sh/), a hosted software quality analysis and that also includes coverage reporting.
4 changes: 2 additions & 2 deletions features/config_json_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Feature:
Then a JSON coverage report should have been generated in "coverage"
And the output should contain "JSON Coverage report generated"

Scenario: When CC_TEST_REPORTER_ID is set in the environment
Scenario: When QLTY_COVERAGE_TOKEN is set in the environment
Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
Expand All @@ -39,7 +39,7 @@ Feature:
"""
And I set the environment variables to:
| variable | value |
| CC_TEST_REPORTER_ID | some-id |
| QLTY_COVERAGE_TOKEN | some-id |

When I successfully run `bundle exec rake test`

Expand Down
2 changes: 1 addition & 1 deletion features/test_unit_basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Feature:
Scenario:
Given SimpleCov for Test/Unit is configured with:
"""
ENV['CC_TEST_REPORTER_ID'] = "9719ac886877886b7e325d1e828373114f633683e429107d1221d25270baeabf"
ENV['QLTY_COVERAGE_TOKEN'] = "9719ac886877886b7e325d1e828373114f633683e429107d1221d25270baeabf"
require 'simplecov'
SimpleCov.start
"""
Expand Down
10 changes: 8 additions & 2 deletions lib/simplecov/default_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ class << self
def from_env(env)
formatters = [SimpleCov::Formatter::HTMLFormatter]

# When running under a CI that uses CodeClimate, JSON output is expected
if env.fetch("CC_TEST_REPORTER_ID", nil)
# When running under a CI that uses Qlty, JSON output is expected
#
# CC_TEST_REPORTER_ID is the previous environment variable which was used by
# Code Climate's test reporter. QLTY_COVERAGE_TOKEN is the new environment
# variable used by Qlty.
#
# We retain detection of CC_TEST_REPORTER_ID for backwards compatibility.
if env.fetch("CC_TEST_REPORTER_ID", nil) || env.fetch("QLTY_COVERAGE_TOKEN", nil)
require "simplecov_json_formatter"
formatters.push(SimpleCov::Formatter::JSONFormatter)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/default_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

describe SimpleCov::Formatter do
describe ".from_env" do
let(:env) { {"CC_TEST_REPORTER_ID" => "4c9f1de6193f30799e9a5d5c082692abecc1fd2c6aa62c621af7b2a910761970"} }
let(:env) { {"QLTY_COVERAGE_TOKEN" => "4c9f1de6193f30799e9a5d5c082692abecc1fd2c6aa62c621af7b2a910761970"} }

context "when CC_TEST_REPORTER_ID environment variable is set" do
context "when QLTY_COVERAGE_TOKEN environment variable is set" do
it "returns an array containing the HTML and JSON formatters" do
expect(described_class.from_env(env)).to eq([
SimpleCov::Formatter::HTMLFormatter,
Expand All @@ -16,7 +16,7 @@
end
end

context "when CC_TEST_REPORTER_ID environment variable isn't set" do
context "when QLTY_COVERAGE_TOKEN environment variable isn't set" do
let(:env) { {} }

it "returns an array containing only the HTML formatter" do
Expand Down
Loading