Class: Hashira::Complexity::Analyzer

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

Constant Summary collapse

THRESHOLD =
10

Instance Method Summary collapse

Constructor Details

#initialize(project, trees) ⇒ Analyzer

Returns a new instance of Analyzer.



6
7
8
9
# File 'lib/hashira/complexity/analyzer.rb', line 6

def initialize(project, trees)
  @project = project
  @scores = trees.flat_map { |path, tree| harvest(path, tree) }
end

Instance Method Details

#classesObject



13
# File 'lib/hashira/complexity/analyzer.rb', line 13

def classes = Hashira::Complexity::Rollup.new(@scores).classes.sort_by { -it.cognitive }

#findingsObject



15
# File 'lib/hashira/complexity/analyzer.rb', line 15

def findings = flagged.map { Hashira::Complexity::MethodFinding.new(it).to_finding }

#methodsObject



11
# File 'lib/hashira/complexity/analyzer.rb', line 11

def methods = @scores.sort_by { -it.cognitive }