Sha256: 417e291d62d25dad9b0f91f20d311a42d103ec3afbdf896f3ab77582c13fe01e

Contents?: true

Size: 1.8 KB

Versions: 36

Compression:

Stored size: 1.8 KB

Contents

# An array of SimpleCov SourceFile instances with additional collection helper
# methods for calculating coverage across them etc.
module SimpleCov
  class FileList < Array
    # Returns the count of lines that have coverage
    def covered_lines
      return 0.0 if empty?
      map { |f| f.covered_lines.count }.inject(&:+)
    end

    # Returns the count of lines that have been missed
    def missed_lines
      return 0.0 if empty?
      map { |f| f.missed_lines.count }.inject(&:+)
    end

    # Returns the count of lines that are not relevant for coverage
    def never_lines
      return 0.0 if empty?
      map { |f| f.never_lines.count }.inject(&:+)
    end

    # Returns the count of skipped lines
    def skipped_lines
      return 0.0 if empty?
      map { |f| f.skipped_lines.count }.inject(&:+)
    end

    # Computes the coverage based upon lines covered and lines missed for each file
    # Returns an array with all coverage percentages
    def covered_percentages
      map(&:covered_percent)
    end

    # Finds the least covered file and returns that file's name
    def least_covered_file
      sort_by(&:covered_percent).first.filename
    end

    # Returns the overall amount of relevant lines of code across all files in this list
    def lines_of_code
      covered_lines + missed_lines
    end

    # Computes the coverage based upon lines covered and lines missed
    # @return [Float]
    def covered_percent
      return 100.0 if empty? || lines_of_code.zero?
      Float(covered_lines * 100.0 / lines_of_code)
    end

    # Computes the strength (hits / line) based upon lines covered and lines missed
    # @return [Float]
    def covered_strength
      return 0.0 if empty? || lines_of_code.zero?
      Float(map { |f| f.covered_strength * f.lines_of_code }.inject(&:+) / lines_of_code)
    end
  end
end

Version data entries

36 entries across 36 versions & 10 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/simplecov-0.13.0/lib/simplecov/file_list.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/simplecov-0.13.0/lib/simplecov/file_list.rb
tdiary-5.0.9 vendor/bundle/gems/simplecov-0.14.1/lib/simplecov/file_list.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/file_list.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/file_list.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/file_list.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/file_list.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/file_list.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/lib/simplecov/file_list.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/lib/simplecov/file_list.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/lib/simplecov/file_list.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/lib/simplecov/file_list.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simplecov-0.14.1/lib/simplecov/file_list.rb
simplecov-patched-0.14.3 lib/simplecov/file_list.rb
simplecov-patched-0.14.2 lib/simplecov/file_list.rb
simplecov-0.14.1 lib/simplecov/file_list.rb
simplecov-0.14.0 lib/simplecov/file_list.rb
simplecov-0.13.0 lib/simplecov/file_list.rb
abaci-0.3.0 vendor/bundle/gems/simplecov-0.12.0/lib/simplecov/file_list.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/simplecov-0.12.0/lib/simplecov/file_list.rb