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
-
#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.
- #smells ⇒ Object
- #smelly? ⇒ Boolean
Methods included from Analysers::Reek
Methods included from Analysers::Flog
Constructor Details
#initialize(path) ⇒ FileAnalyse
Craete new file analyse.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/watchr/file_analyse.rb', line 24 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.
17 18 19 |
# File 'lib/watchr/file_analyse.rb', line 17 def path @path end |
Instance Method Details
#add_smell(smell) ⇒ Object
56 57 58 |
# File 'lib/watchr/file_analyse.rb', line 56 def add_smell(smell) @smells.add(smell) end |
#flay(report) ⇒ Object
Store the flay report, which was evaluated on global basis to check for duplications across multiple files.
48 49 50 |
# File 'lib/watchr/file_analyse.rb', line 48 def flay(report) @flay_report = report end |
#smells ⇒ Object
52 53 54 |
# File 'lib/watchr/file_analyse.rb', line 52 def smells @smells.all end |
#smelly? ⇒ Boolean
37 38 39 |
# File 'lib/watchr/file_analyse.rb', line 37 def smelly? smells.any? end |