Class: Audition::Static::Checks::DependencyClassState

Inherits:
Base
  • Object
show all
Defined in:
lib/audition/static/checks/dependency_class_state.rb

Overview

Class-level state owned by a dependency. A gem's own source is outside the scanned tree, so the graph audit never sees the ivar and the call site is the only place left to flag. Generated type stubs in the target's tree record it: an attribute reader on a singleton class is a class-level ivar read by definition, and the generator marks those methods apart from ones that compute their answer.

Constant Summary collapse

STUB_READER =

The generator documents a reader it generated from an attribute; a hand-written method of the same shape gets its own prose and stays quiet.

/Returns the value of attribute (\w+)/
STUB_SINGLETON =
/\A\s*class\s+<<\s+self\b/
STUB_SCOPE =
/\A\s*(?:class|module)\s+([A-Za-z0-9_:]+)/
STUB_DEF =
/\A\s*def ([a-z_][A-Za-z0-9_]*)[(;]/
STUB_COMMENT =
/\A\s*#/

Constants inherited from Base

Base::EMPTY_CATALOG, Base::WRAPPER

Class Attribute Summary collapse

Attributes inherited from Base

#file, #findings

Class Method Summary collapse

Methods inherited from Base

call, check_name, explain, explanations, handlers, #initialize, on

Constructor Details

This class inherits a constructor from Audition::Static::Checks::Base

Class Attribute Details

.attributes ⇒ Object

Returns the value of attribute attributes.



51
52
53
# File 'lib/audition/static/checks/dependency_class_state.rb', line 51

def attributes
  @attributes
end

Class Method Details

.learn(paths) ⇒ void

This method returns an undefined value.

Parameters:

  • paths (Array<String>) —

    scanned files; only generated type stubs carry this evidence



66
67
68
69
70
71
72
73
74
# File 'lib/audition/static/checks/dependency_class_state.rb', line 66

def learn(paths)
  pairs = []
  paths.each do |path|
    next unless path.end_with?(".rbi")

    read_stub(path, pairs)
  end
  self.attributes = pairs
end