rubycritic icon indicating copy to clipboard operation
rubycritic copied to clipboard

Coverage page ignores .resultset.json

Open eprislac opened this issue 3 years ago • 1 comments

I run specs on Travis CI for pull-requests, but I use Jenkins to generate docs on deployment. I host these directly from Jenkins. So far, I'm able to generate all Rubycritic pages except coverage. Coverage recognizes all my files, but fails to utilize the .resultset.json file I have committed to the repo. All files show up with 0% coverage, even though SimpleCov reports 77% coverage when I look at the results after running my specs.

eprislac avatar Mar 21 '22 16:03 eprislac

any news on this issue? @eprislac were you able to get coverage results in the rubycritic report?

radomirz avatar Jun 03 '22 10:06 radomirz

I have a similar issue on CircleCI.

      - run:
          name: RubyCritic
          command:  bundle exec rubycritic --no-browser --path artifacts/rubycritic
      - store_artifacts:
          path: artifacts

and

  SimpleCov.start 'rails' do
    add_filter 'vendor'
  end
  SimpleCov.coverage_dir('artifacts/coverage')

in spec_helper.rb.

Then, CircleCI stores .resultset.json and rubycritic~ files like this: image

However, the RubyCritic coverage page ignores the coverage JSON. It looks like RubyCritic assumes the default coverage directory is always used. https://github.com/whitesmith/rubycritic/blob/3bc857d2ca399341f4cfff19519cb32cbf29ad78/lib/rubycritic/analysers/coverage.rb#L51

I think it should support different coverage dir, something like this:

SimpleCov.coverage_dir(ENV['RUBYCRITIC_COVERAGE_PATH`]) if ENV['RUBYCRITIC_COVERAGE_PATH`]

exoego avatar Dec 05 '22 13:12 exoego

The below worked for me. Both coverage and rubycritic results are successfully stored in CircleCI, and RubyCritic coverage page shows coverage successfully.

      - run:    
          name: RSpec
          command: COVERAGE=1 bundle exec rspec
      - store_artifacts:
          path: coverage

      - run:
          name: RubyCritic
          command:  bundle exec rubycritic --no-browser --path rubycritic
      - store_artifacts:
          path: rubycritic

and

  SimpleCov.start 'rails' do
    add_filter 'vendor'
  end
  # SimpleCov.coverage_dir('artifacts/coverage')
  # Do not customize since the current implementation of RubyCritic expects
  # the result set file in the default directory.

exoego avatar Dec 06 '22 00:12 exoego

This was fixed by https://github.com/whitesmith/rubycritic/pull/481 (based on #364)

@eprislac @exoego Thanks for reporting and thanks for your PR!

etagwerker avatar Mar 02 '24 21:03 etagwerker