Class: Rubycritic::AnalysedModule

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycritic/core/analysed_module.rb

Instance Method Summary collapse

Instance Method Details

#complexity_per_methodObject



30
31
32
33
34
35
36
# File 'lib/rubycritic/core/analysed_module.rb', line 30

def complexity_per_method
  if methods_count == 0
    "N/A"
  else
    complexity.fdiv(methods_count).round(1)
  end
end

#costObject



22
23
24
# File 'lib/rubycritic/core/analysed_module.rb', line 22

def cost
  @cost ||= smells.map(&:cost).inject(0, :+) + (complexity / 25)
end

#pathObject



18
19
20
# File 'lib/rubycritic/core/analysed_module.rb', line 18

def path
  @path ||= pathname.to_s
end

#ratingObject



26
27
28
# File 'lib/rubycritic/core/analysed_module.rb', line 26

def rating
  @rating ||= Rating.from_cost(cost)
end

#smells?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/rubycritic/core/analysed_module.rb', line 38

def smells?
  !smells.empty?
end

#smells_at_location(location) ⇒ Object



42
43
44
# File 'lib/rubycritic/core/analysed_module.rb', line 42

def smells_at_location(location)
  smells.select { |smell| smell.at_location?(location) }
end