From 2274f59f73cbf44a69c3e3ae21bbf5096b3c38ae Mon Sep 17 00:00:00 2001 From: Jitesh Gosai Date: Fri, 11 Dec 2015 14:39:50 +0000 Subject: [PATCH] Update file_revision.rb Will now check to see if the report returned is empty or nil and stop the processing of that file with an error. It also now uses fetch to obtain values as you can then submit a default value. Ideally the nil and empty check will stop this from ever being used. Also prints '.' on screen to show that something is happening. --- lib/ruby/file_revision.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ruby/file_revision.rb b/lib/ruby/file_revision.rb index 9c264fd..fc9c0f1 100644 --- a/lib/ruby/file_revision.rb +++ b/lib/ruby/file_revision.rb @@ -32,12 +32,13 @@ def complexity_report end end - if report.nil? - puts "WARNING: Could not parse #{@path}" + if report.nil? | report.empty? + STDOUT.write "WARNING: Could not parse #{@path}" else - e = 1 + report[:num_dependencies] - b = 1 + report[:num_branches] - s = 1 + report[:num_superclasses] + print '.' # prints '.' to indicate something is happening + e = 1 + report.fetch(:num_dependencies, 1) + b = 1 + report.fetch(:num_branches, 1) + s = 1 + report.fetch(:num_superclasses, 1) report['weight'] = b * e * s report[:churn] = @repo.num_commits_involving(@path) report[:filename] = @path