Class: FlogTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- FlogTask
- Defined in:
- lib/flog_task.rb
Instance Attribute Summary collapse
-
#dirs ⇒ Object
Returns the value of attribute dirs.
-
#method ⇒ Object
Returns the value of attribute method.
-
#name ⇒ Object
Returns the value of attribute name.
-
#threshold ⇒ Object
Returns the value of attribute threshold.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :flog, threshold = 200, dirs = nil, method = nil) {|_self| ... } ⇒ FlogTask
constructor
A new instance of FlogTask.
Constructor Details
#initialize(name = :flog, threshold = 200, dirs = nil, method = nil) {|_self| ... } ⇒ FlogTask
Returns a new instance of FlogTask.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/flog_task.rb', line 10 def initialize name = :flog, threshold = 200, dirs = nil, method = nil @name = name @dirs = dirs || %w(app bin lib spec test) @threshold = threshold @method = method || :total @verbose = Rake.application..trace yield self if block_given? @dirs.reject! { |f| ! File.directory? f } define end |
Instance Attribute Details
#dirs ⇒ Object
Returns the value of attribute dirs.
5 6 7 |
# File 'lib/flog_task.rb', line 5 def dirs @dirs end |
#method ⇒ Object
Returns the value of attribute method.
8 9 10 |
# File 'lib/flog_task.rb', line 8 def method @method end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/flog_task.rb', line 4 def name @name end |
#threshold ⇒ Object
Returns the value of attribute threshold.
6 7 8 |
# File 'lib/flog_task.rb', line 6 def threshold @threshold end |
#verbose ⇒ Object
Returns the value of attribute verbose.
7 8 9 |
# File 'lib/flog_task.rb', line 7 def verbose @verbose end |
Instance Method Details
#define ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/flog_task.rb', line 24 def define desc "Analyze for code complexity in: #{dirs.join(', ')}" task name do require "flog" flog = Flog.new :continue => true, :quiet => true flog.flog(*dirs) desc, score = flog.send method desc, score = "total", desc unless score # total only returns a number flog.report if verbose raise "Flog score for #{desc} is too high! #{score} > #{threshold}" if score > threshold end self end |