Skip to main content

Using Knapsack Pro with CodeClimate

Check how to configure CodeClimate with knapsack_pro on our blog:

Troubleshooting

Using Knapsack Pro in Queue Mode with CodeClimate and SimpleCov

You need to generate a simplecov report in JSON format on CI in order to avoid the following error from CodeClimate:

Error: json: cannot unmarshal object into Go struct field resultSet.coverage of type []formatters.NullInt

RSpec

Apply the following code:

spec/spec_helper.rb
require 'knapsack_pro'
require 'simplecov'

if ENV['CI']
require 'simplecov_json_formatter'
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
end

SimpleCov.start

KnapsackPro::Hooks::Queue.before_queue do |queue_id|
SimpleCov.command_name("rspec_ci_node_#{KnapsackPro::Config::Env.ci_node_index}")
end

Minitest

Apply the following code:

test/test_helper.rb
require 'knapsack_pro'
require 'simplecov'

if ENV['CI']
require 'simplecov_json_formatter'
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
end

SimpleCov.start

KnapsackPro::Hooks::Queue.before_queue do |queue_id|
SimpleCov.command_name("minitest_ci_node_#{KnapsackPro::Config::Env.ci_node_index}")
end

KnapsackPro::Hooks::Queue.after_queue do
SimpleCov.result.format!
end