Class: Watchr::FileAnalyse
- Inherits:
-
Object
- Object
- Watchr::FileAnalyse
- Includes:
- Analysers::Flog, Analysers::Reek
- Defined in:
- lib/watchr/file_analyse.rb
Overview
Analyse for one given file. All the different metric analyse data are collected in order to output reasonable recommendations for a code improvements.
Constant Summary
Constants included from SmellTypes
Constants included from Analysers::Flog
Analysers::Flog::COMPLEX_METHOD_THRESHOLD, Analysers::Flog::COMPLEX_OBJECT_THRESHOLD, Analysers::Flog::VERY_COMPLEX_METHOD_THRESHOLD, Analysers::Flog::VERY_COMPLEX_OBJECT_THRESHOLD
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #add_smell(smell) ⇒ Object
- #code_loc ⇒ Object
-
#flay(report) ⇒ Object
Store the flay report, which was evaluated on global basis to check for duplications across multiple files.
-
#initialize(path) ⇒ FileAnalyse
constructor
Craete new file analyse.
- #loc ⇒ Object
- #smells ⇒ Object
- #smelly? ⇒ Boolean
Methods included from Analysers::Reek
Methods included from Analysers::Flog
Constructor Details
#initialize(path) ⇒ FileAnalyse
Craete new file analyse.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/watchr/file_analyse.rb', line 25 def initialize(path) @path = path @smells = SmellsCollector.new begin analyse_flog(FlogMetric::Report.new([path])) rescue Racc::ParseError => e puts e end analyse_reek(ReekMetric::Report.new([path])) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
18 19 20 |
# File 'lib/watchr/file_analyse.rb', line 18 def path @path end |
Instance Method Details
#add_smell(smell) ⇒ Object
65 66 67 |
# File 'lib/watchr/file_analyse.rb', line 65 def add_smell(smell) @smells.add(smell) end |
#code_loc ⇒ Object
46 47 48 |
# File 'lib/watchr/file_analyse.rb', line 46 def code_loc stats_report.code_loc end |
#flay(report) ⇒ Object
Store the flay report, which was evaluated on global basis to check for duplications across multiple files.
57 58 59 |
# File 'lib/watchr/file_analyse.rb', line 57 def flay(report) @flay_report = report end |
#loc ⇒ Object
42 43 44 |
# File 'lib/watchr/file_analyse.rb', line 42 def loc stats_report.loc end |
#smells ⇒ Object
61 62 63 |
# File 'lib/watchr/file_analyse.rb', line 61 def smells @smells.all end |
#smelly? ⇒ Boolean
38 39 40 |
# File 'lib/watchr/file_analyse.rb', line 38 def smelly? smells.any? end |