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
SMELLS =
Hashira::Smells::Report::CHECKS.map(&:kind).sort.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Pipeline.



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

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.



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

def project
  @project
end

Instance Method Details

#churnObject



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

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

#complexityObject



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

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

#duplicationObject



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

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

#enabled?(analyzer) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#findingsObject



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

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

#graphObject



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

def graph = @coupling.graph

#hotspotsObject



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

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

#smellsObject



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

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