class SimpleCov::LinesClassifier
Classifies whether lines are relevant for code coverage analysis. Comments & whitespace lines, and :nocov: token blocks, are considered not relevant.
Constants
- COMMENT_LINE
- NOT_RELEVANT
- RELEVANT
- WHITESPACE_LINE
- WHITESPACE_OR_COMMENT_LINE
Public Class Methods
no_cov_line()
click to toggle source
# File lib/simplecov/lines_classifier.rb, line 14 def self.no_cov_line /^(\s*)#(\s*)(:#{SimpleCov.nocov_token}:)/o end
no_cov_line?(line)
click to toggle source
# File lib/simplecov/lines_classifier.rb, line 18 def self.no_cov_line?(line) no_cov_line.match?(line) rescue ArgumentError # E.g., line contains an invalid byte sequence in UTF-8 false end
whitespace_line?(line)
click to toggle source
# File lib/simplecov/lines_classifier.rb, line 25 def self.whitespace_line?(line) WHITESPACE_OR_COMMENT_LINE.match?(line) rescue ArgumentError # E.g., line contains an invalid byte sequence in UTF-8 false end
Public Instance Methods
classify(lines)
click to toggle source
# File lib/simplecov/lines_classifier.rb, line 32 def classify(lines) skipping = false lines.map do |line| if self.class.no_cov_line?(line) skipping = !skipping NOT_RELEVANT elsif skipping || self.class.whitespace_line?(line) NOT_RELEVANT else RELEVANT end end end