Class: Rubycritic::AnalysedFile
- Inherits:
-
Object
- Object
- Rubycritic::AnalysedFile
- Defined in:
- lib/rubycritic/core/analysed_file.rb
Instance Method Summary collapse
- #complexity_per_method ⇒ Object
- #cost ⇒ Object
- #has_smells? ⇒ Boolean
- #name ⇒ Object
- #path ⇒ Object
- #rating ⇒ Object
- #smells_at_location(location) ⇒ Object
Instance Method Details
#complexity_per_method ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rubycritic/core/analysed_file.rb', line 33 def complexity_per_method if methods_count == 0 "N/A" else complexity.fdiv(methods_count).round(1) end end |
#cost ⇒ Object
25 26 27 |
# File 'lib/rubycritic/core/analysed_file.rb', line 25 def cost @cost ||= smells.map(&:cost).inject(0, :+) + (complexity / 25) end |
#has_smells? ⇒ Boolean
41 42 43 |
# File 'lib/rubycritic/core/analysed_file.rb', line 41 def has_smells? !smells.empty? end |
#name ⇒ Object
17 18 19 |
# File 'lib/rubycritic/core/analysed_file.rb', line 17 def name @name ||= pathname.basename.sub_ext("").to_s end |
#path ⇒ Object
21 22 23 |
# File 'lib/rubycritic/core/analysed_file.rb', line 21 def path @path ||= pathname.to_s end |
#rating ⇒ Object
29 30 31 |
# File 'lib/rubycritic/core/analysed_file.rb', line 29 def @rating ||= Rating.from_cost(cost) end |
#smells_at_location(location) ⇒ Object
45 46 47 |
# File 'lib/rubycritic/core/analysed_file.rb', line 45 def smells_at_location(location) smells.select { |smell| smell.at_location?(location) } end |