Class: Rubycritic::AnalysedModule
- Inherits:
-
Object
- Object
- Rubycritic::AnalysedModule
- Defined in:
- lib/rubycritic/core/analysed_module.rb
Instance Method Summary collapse
- #complexity_per_method ⇒ Object
- #cost ⇒ Object
- #path ⇒ Object
- #rating ⇒ Object
- #smells? ⇒ Boolean
- #smells_at_location(location) ⇒ Object
- #to_h ⇒ Object
- #to_json(*a) ⇒ Object
Instance Method Details
#complexity_per_method ⇒ Object
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 |
#cost ⇒ Object
22 23 24 |
# File 'lib/rubycritic/core/analysed_module.rb', line 22 def cost @cost ||= smells.map(&:cost).inject(0, :+) + (complexity / 25) end |
#path ⇒ Object
18 19 20 |
# File 'lib/rubycritic/core/analysed_module.rb', line 18 def path @path ||= pathname.to_s end |
#rating ⇒ Object
26 27 28 |
# File 'lib/rubycritic/core/analysed_module.rb', line 26 def @rating ||= Rating.from_cost(cost) end |
#smells? ⇒ 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 |
#to_h ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubycritic/core/analysed_module.rb', line 46 def to_h { :name => name, :path => path, :smells => smells, :churn => churn, :committed_at => committed_at, :complexity => complexity, :duplication => duplication, :methods_count => methods_count, :cost => cost, :rating => } end |
#to_json(*a) ⇒ Object
61 62 63 |
# File 'lib/rubycritic/core/analysed_module.rb', line 61 def to_json(*a) to_h.to_json(*a) end |