From 05200b73308c019d3b3867739707b845fc54cee5 Mon Sep 17 00:00:00 2001 From: rishijain Date: Thu, 19 Oct 2023 19:41:53 +0700 Subject: [PATCH] add coverage data to compare view --- .rubocop.yml | 4 ++++ CHANGELOG.md | 2 ++ lib/rubycritic/core/analysed_module.rb | 2 +- lib/rubycritic/core/analysed_modules_collection.rb | 3 ++- test/lib/rubycritic/core/analysed_modules_collection_test.rb | 3 ++- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 916bc579..ed13cf4a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -85,3 +85,7 @@ Lint/StructNewOverride: Metrics/AbcSize: Exclude: - 'lib/rubycritic/configuration.rb' + +Metrics/MethodLength: + Exclude: + - 'lib/rubycritic/core/analysed_modules_collection.rb' diff --git a/CHANGELOG.md b/CHANGELOG.md index af624507..47ac400f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # main [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.9.0...main) +* [BUGFIX] Pass coverage data for compare branch mode (by [@rishijain][]) + # v4.9.0 / 2023-10-18 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.8.1...v4.9.0) * [CHANGE] Bump aruba, cucumber, fakefs, flog, mdl, minitest, and rubocop dependencies (by [@faisal][]) diff --git a/lib/rubycritic/core/analysed_module.rb b/lib/rubycritic/core/analysed_module.rb index 441a091b..c4c14579 100644 --- a/lib/rubycritic/core/analysed_module.rb +++ b/lib/rubycritic/core/analysed_module.rb @@ -82,7 +82,7 @@ def to_h name: name, path: path, smells: smells, churn: churn, committed_at: committed_at, complexity: complexity, duplication: duplication, methods_count: methods_count, cost: cost, - rating: rating + rating: rating, coverage: coverage } end diff --git a/lib/rubycritic/core/analysed_modules_collection.rb b/lib/rubycritic/core/analysed_modules_collection.rb index 9f7064b0..53564a1e 100644 --- a/lib/rubycritic/core/analysed_modules_collection.rb +++ b/lib/rubycritic/core/analysed_modules_collection.rb @@ -88,7 +88,8 @@ def build_analysed_module(analysed_module) committed_at: analysed_module.committed_at, complexity: analysed_module.complexity, duplication: analysed_module.duplication, - methods_count: analysed_module.methods_count + methods_count: analysed_module.methods_count, + coverage: analysed_module.coverage ) end end diff --git a/test/lib/rubycritic/core/analysed_modules_collection_test.rb b/test/lib/rubycritic/core/analysed_modules_collection_test.rb index 77b6e5a9..66a0a7ac 100644 --- a/test/lib/rubycritic/core/analysed_modules_collection_test.rb +++ b/test/lib/rubycritic/core/analysed_modules_collection_test.rb @@ -49,7 +49,7 @@ let(:analysed_modules) do [RubyCritic::AnalysedModule.new(pathname: Pathname.new('test/samples/empty.rb'), name: 'Name', smells: [], churn: 2, committed_at: Time.now, complexity: 2, duplication: 0, - methods_count: 2)] + methods_count: 2, coverage: 70.0)] end it 'registers one AnalysedModule element per existent file' do @@ -61,6 +61,7 @@ _(analysed_module.complexity).must_equal 2 _(analysed_module.duplication).must_equal 0 _(analysed_module.methods_count).must_equal 2 + _(analysed_module.coverage).must_equal 70.0 end end end