Module: Coverband

Defined in:
lib/coverband/version.rb,
lib/coverband/at_exit.rb,
lib/coverband/utils/result.rb,
lib/coverband/adapters/base.rb,
lib/coverband/configuration.rb,
lib/coverband/reporters/web.rb,
lib/coverband/utils/railtie.rb,
lib/coverband/utils/results.rb,
lib/coverband/reporters/base.rb,
lib/coverband/utils/file_list.rb,
lib/coverband/collectors/delta.rb,
lib/alternative_coverband_patch.rb,
lib/coverband/utils/file_hasher.rb,
lib/coverband/utils/source_file.rb,
lib/coverband/utils/dead_methods.rb,
lib/coverband/adapters/file_store.rb,
lib/coverband/adapters/null_store.rb,
lib/coverband/collectors/coverage.rb,
lib/coverband/integrations/resque.rb,
lib/coverband/adapters/redis_store.rb,
lib/coverband/utils/html_formatter.rb,
lib/coverband/adapters/stdout_store.rb,
lib/coverband/reporters/html_report.rb,
lib/coverband/reporters/json_report.rb,
lib/coverband/utils/lines_classifier.rb,
lib/coverband/collectors/view_tracker.rb,
lib/coverband/integrations/background.rb,
lib/coverband/adapters/memcached_store.rb,
lib/coverband/collectors/route_tracker.rb,
lib/coverband/reporters/console_report.rb,
lib/coverband/adapters/hash_redis_store.rb,
lib/coverband/adapters/web_service_store.rb,
lib/coverband/collectors/abstract_tracker.rb,
lib/coverband/utils/absolute_file_converter.rb,
lib/coverband/utils/relative_file_converter.rb,
lib/coverband/collectors/translation_tracker.rb,
lib/coverband/integrations/rack_server_check.rb,
lib/coverband/integrations/report_middleware.rb,
lib/coverband/collectors/view_tracker_service.rb,
lib/coverband/utils/method_definition_scanner.rb,
lib/coverband/integrations/background_middleware.rb,
lib/coverband.rb

Overview

NOTE: with Ruby 2.6.0 and beyond we can replace this classifier with ::Coverage.line_stub ruby-doc.org/stdlib-2.6.1/libdoc/coverage/rdoc/Coverage.html#method-c-line_stub

Thanks for all the help SimpleCov github.com/colszowka/simplecov-html initial version pulled into Coverband from Simplecov 12/04/2018

Classifies whether lines are relevant for code coverage analysis. Comments & whitespace lines, and :nocov: token blocks, are considered not relevant.

Defined Under Namespace

Modules: Adapters, Collectors, RailsEagerLoad, Reporters, ResqueWorker, Utils Classes: AtExit, Background, BackgroundMiddleware, Configuration, RackServerCheck, Railtie, ReportMiddleware

Constant Summary collapse

VERSION =
"6.1.2"
COVERBAND_ALTERNATE_PATCH =
true
SERVICE_CONFIG =
"./config/coverband_service.rb"
CONFIG_FILE =
"./config/coverband.rb"
RUNTIME_TYPE =
:runtime
EAGER_TYPE =
:eager_loading
MERGED_TYPE =
:merged
TYPES =
[RUNTIME_TYPE, EAGER_TYPE]
ALL_TYPES =
TYPES + [:merged]
@@configured =
false

Class Method Summary collapse

Class Method Details

.configurationObject



72
73
74
# File 'lib/coverband.rb', line 72

def self.configuration
  @configuration ||= Configuration.new
end

.configure(file = nil) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/coverband.rb', line 42

def self.configure(file = nil)
  configuration_file = file || ENV["COVERBAND_CONFIG"]
  if configuration_file.nil?
    configuration_file = coverband_service? ? SERVICE_CONFIG : CONFIG_FILE
  end

  configuration
  if block_given?
    yield(configuration)
  elsif File.exist?(configuration_file)
    load configuration_file
  else
    configuration.logger.debug("using default configuration")
  end
  @@configured = true
  coverage_instance.reset_instance
end

.configured?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/coverband.rb', line 64

def self.configured?
  @@configured
end

.coverband_service?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/coverband.rb', line 60

def self.coverband_service?
  !!File.exist?(SERVICE_CONFIG)
end

.eager_loading_coverageObject



94
95
96
# File 'lib/coverband.rb', line 94

def self.eager_loading_coverage(...)
  coverage_instance.eager_loading(...)
end

.eager_loading_coverage!Object



90
91
92
# File 'lib/coverband.rb', line 90

def self.eager_loading_coverage!
  coverage_instance.eager_loading!
end

.report_coverageObject



68
69
70
# File 'lib/coverband.rb', line 68

def self.report_coverage
  coverage_instance.report_coverage
end

.runtime_coverage!Object



98
99
100
# File 'lib/coverband.rb', line 98

def self.runtime_coverage!
  coverage_instance.runtime!
end

.startObject



76
77
78
79
80
81
82
# File 'lib/coverband.rb', line 76

def self.start
  Coverband::Collectors::Coverage.instance
  # TODO: Railtie sets up at_exit after forks, via middleware, perhaps this should be
  # added if not rails or if rails but not rackserverrunning
  AtExit.register unless tasks_to_ignore?
  Background.start if configuration.background_reporting_enabled && !RackServerCheck.running? && !tasks_to_ignore?
end

.tasks_to_ignore?Boolean

Returns:

  • (Boolean)


84
85
86
87
88
# File 'lib/coverband.rb', line 84

def self.tasks_to_ignore?
  defined?(Rake) &&
    Rake.respond_to?(:application) &&
    (Rake&.application&.top_level_tasks || []).any? { |task| Coverband::Configuration::IGNORE_TASKS.include?(task) }
end