Class: Hashira::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/hashira/pipeline.rb

Constant Summary collapse

ANALYZERS =
%i[coupling complexity duplication].freeze
RULES =
[Analysis::CycleFindings, Analysis::SdpViolationFindings].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, enabled: ANALYZERS) ⇒ Pipeline

Returns a new instance of Pipeline.



11
12
13
14
15
16
# File 'lib/hashira/pipeline.rb', line 11

def initialize(project, enabled: ANALYZERS)
  @project = project
  @enabled = enabled
  @trees = project.files.to_h { [it, parse(it)] }
  @graph = Analysis::Graph.new(project, @trees, Analysis::Census.new(project, @trees))
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



18
19
20
# File 'lib/hashira/pipeline.rb', line 18

def graph
  @graph
end

#projectObject (readonly)

Returns the value of attribute project.



18
19
20
# File 'lib/hashira/pipeline.rb', line 18

def project
  @project
end

Instance Method Details

#churnObject



32
# File 'lib/hashira/pipeline.rb', line 32

def churn = @churn ||= Churn.from_git

#complexityObject



20
21
22
# File 'lib/hashira/pipeline.rb', line 20

def complexity
  @complexity ||= Complexity::Analyzer.new(@project, @trees) if enabled?(:complexity)
end

#duplicationObject



24
25
26
# File 'lib/hashira/pipeline.rb', line 24

def duplication
  @duplication ||= Duplication::Analyzer.new(@project, @trees, churn) if enabled?(:duplication)
end

#enabled?(analyzer) ⇒ Boolean

Returns:

  • (Boolean)


34
# File 'lib/hashira/pipeline.rb', line 34

def enabled?(analyzer) = @enabled.include?(analyzer)

#findingsObject



36
# File 'lib/hashira/pipeline.rb', line 36

def findings = coupling_findings + listed(complexity) + listed(duplication)

#hotspotsObject



28
29
30
# File 'lib/hashira/pipeline.rb', line 28

def hotspots
  @hotspots ||= Hotspots::Rollup.new(complexity, duplication, churn) if complexity || duplication
end