Class: SimpleCov::Formatter::AIFormatter::MarkdownBuilder::MethodDeficit

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/simplecov-ai/markdown_builder/deficit_group.rb

Overview

A method SimpleCov >= 1.0 reported as never invoked, captured in the formatter's own shape so that no SimpleCov::SourceFile::Method constant (absent before 1.0) is ever referenced at runtime.

Constant Summary collapse

SINGLETON_OWNER_PATTERN =

The class name Ruby reports for the owner of a singleton method.

T.let(/\A#<Class:(.+)>\z/.freeze, Regexp)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_file(file) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/simplecov-ai/markdown_builder/deficit_group.rb', line 44

def self.from_file(file)
  missed_methods = (file.respond_to?(:missed_methods) && file.missed_methods) || []
  missed_methods.map do |missed_method|
    method_name = missed_method.method_name.to_s
    new(name: qualified_name(missed_method.class_name.to_s, method_name), method_name: method_name,
        start_line: missed_method.start_line, end_line: missed_method.end_line)
  end
end

.measured?(coverage_metrics) ⇒ Boolean

Returns:



34
35
36
# File 'lib/simplecov-ai/markdown_builder/deficit_group.rb', line 34

def self.measured?(coverage_metrics)
  coverage_metrics.respond_to?(:total_methods) && !coverage_metrics.total_methods.nil?
end

.qualified_name(class_name, method_name) ⇒ Object



60
61
62
63
# File 'lib/simplecov-ai/markdown_builder/deficit_group.rb', line 60

def self.qualified_name(class_name, method_name)
  singleton_owner = class_name[SINGLETON_OWNER_PATTERN, 1]
  singleton_owner ? "#{singleton_owner}.#{method_name}" : "#{class_name}##{method_name}"
end

Instance Method Details

#end_lineInteger

Returns The last line of the definition.

Returns:

  • The last line of the definition.



24
# File 'lib/simplecov-ai/markdown_builder/deficit_group.rb', line 24

const :end_line, Integer

#method_nameString

Returns The bare method name, without its owner.

Returns:

  • The bare method name, without its owner.



20
# File 'lib/simplecov-ai/markdown_builder/deficit_group.rb', line 20

const :method_name, String

#nameString

Returns The method's semantic name (Klass#name or Klass.name).

Returns:

  • The method's semantic name (Klass#name or Klass.name).



18
# File 'lib/simplecov-ai/markdown_builder/deficit_group.rb', line 18

const :name, String

#start_lineInteger

Returns The first line of the definition.

Returns:

  • The first line of the definition.



22
# File 'lib/simplecov-ai/markdown_builder/deficit_group.rb', line 22

const :start_line, Integer