Class: Hashira::Pipeline

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, enabled: ANALYZERS, packaging: :auto) ⇒ Pipeline

Returns a new instance of Pipeline.



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

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

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



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

def graph
  @graph
end

#projectObject (readonly)

Returns the value of attribute project.



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

def project
  @project
end

Instance Method Details

#churnObject



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

def churn = @churn ||= Hashira::Churn.scan

#complexityObject



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

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

#duplicationObject



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

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

#enabled?(analyzer) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#findingsObject



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

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

#hotspotsObject



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

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