Permalink
Browse files

simplified complexity computations

  • Loading branch information...
1 parent 17f0eb0 commit 2826c2b56b1bd48c8da2fe255bbd99358855473c @michaelfeathers michaelfeathers committed May 14, 2011
Showing with 7 additions and 4 deletions.
  1. +1 −2 class.rb
  2. +5 −0 codehistory.rb
  3. +1 −2 repository.rb
View
@@ -13,8 +13,7 @@ def initialize name, events
end
def complexity
- return 0.0 if declared_methods.empty?
- declared_methods.map(&:complexity).reduce(:+)
+ complexity_of(@declared_methods)
end
end
View
@@ -14,6 +14,11 @@ def build_collection symbol, class_object
events.group_by(&symbol).map { |args| class_object.new(*args) }
end
+ def complexity_of collection
+ return 0.0 if collection.empty?
+ collection.map(&:complexity).reduce(:+)
+ end
+
end
end
View
@@ -14,8 +14,7 @@ def initialize name, events
end
def complexity
- return 0.0 if @classes.empty?
- @classes.map(&:complexity).reduce(:+)
+ complexity_of(@classes)
end
end

0 comments on commit 2826c2b

Please sign in to comment.