Sha256: 7da8aea414ae4ced6c3d4a0daff56556fc1243215c067b66d0fedfb09d4c7bd8

Contents?: true

Size: 1.17 KB

Versions: 19

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module SimpleCov
  module Combine
    #
    # Combine different branch coverage results on single file.
    #
    # Should be called through `SimpleCov.combine`.
    module BranchesCombiner
    module_function

      #
      # Return merged branches or the existed brach if other is missing.
      #
      # Branches inside files are always same if they exist, the difference only in coverage count.
      # Branch coverage report for any conditional case is built from hash, it's key is a condition and
      # it's body is a hash << keys from condition and value is coverage rate >>.
      # ex: branches =>{ [:if, 3, 8, 6, 8, 36] => {[:then, 4, 8, 6, 8, 12] => 1, [:else, 5, 8, 6, 8, 36]=>2}, other conditions...}
      # We create copy of result and update it values depending on the combined branches coverage values.
      #
      # @return [Hash]
      #
      def combine(coverage_a, coverage_b)
        coverage_a.merge(coverage_b) do |_condition, branches_inside_a, branches_inside_b|
          branches_inside_a.merge(branches_inside_b) do |_branch, a_count, b_count|
            a_count + b_count
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 18 versions & 8 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/simplecov-0.22.0/lib/simplecov/combine/branches_combiner.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/simplecov-0.22.0/lib/simplecov/combine/branches_combiner.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/simplecov-0.22.0/lib/simplecov/combine/branches_combiner.rb
strongmind-simplecov-0.23.0 lib/simplecov/combine/branches_combiner.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/simplecov-0.22.0/lib/simplecov/combine/branches_combiner.rb
simplecov-0.22.0 lib/simplecov/combine/branches_combiner.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/simplecov-0.21.2/lib/simplecov/combine/branches_combiner.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/simplecov-0.21.2/lib/simplecov/combine/branches_combiner.rb
simplecov-0.21.2 lib/simplecov/combine/branches_combiner.rb
simplecov-0.21.1 lib/simplecov/combine/branches_combiner.rb
simplecov-0.21.0 lib/simplecov/combine/branches_combiner.rb
simplecov-0.20.0 lib/simplecov/combine/branches_combiner.rb
simplecov-0.19.1 lib/simplecov/combine/branches_combiner.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/simplecov-0.19.0/lib/simplecov/combine/branches_combiner.rb
simplecov-0.19.0 lib/simplecov/combine/branches_combiner.rb
simplecov-0.18.5 lib/simplecov/combine/branches_combiner.rb
simplecov-0.18.4 lib/simplecov/combine/branches_combiner.rb
simplecov-0.18.3 lib/simplecov/combine/branches_combiner.rb
simplecov-0.18.2 lib/simplecov/combine/branches_combiner.rb