Class: Hashira::Pipeline

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

Constant Summary collapse

ANALYZERS =
%i[coupling complexity duplication smells].freeze
STRUCTURAL =
Hashira::Coupling::Report::RULES.map { it::KIND }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, enabled: ANALYZERS, packaging: :auto) ⇒ 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, packaging: :auto)
  @project = project
  @enabled = enabled
  @trees = project.files.to_h { [it, parse(it)] }
  @coupling = Hashira::Coupling::Report.new(project, @trees, packaging: settle(packaging))
end

Instance Attribute Details

#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



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

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

#complexityObject



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

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

#duplicationObject



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

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

#enabled?(analyzer) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#findingsObject



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

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

#graphObject



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

def graph = @coupling.graph

#hotspotsObject



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

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

#smellsObject



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

def smells
  @smells ||= Hashira::Smells::Report.new(@project, @trees) if enabled?(:smells)
end