jscruggs-metric_fu 0.7.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ === MetricFu 0.8.0 / 2008-10-06
2
+
3
+ * Source Control Churn now supports git (thanks to Erik St Martin)
4
+ * Flog Results are sorted by Highest Flog Score
5
+ * Fix for a bunch of 'already initialized constant' warnings that metric_fu caused
6
+ * Fixing bug so the flog reporter can handle methods with digits in the name (thanks to Andy Gregorowicz)
7
+ * Internal Rake task now allows metric_fu to flog/churn itself
8
+
1
9
  === MetricFu 0.7.6 / 2008-09-15
2
10
 
3
11
  * CHURN_OPTIONS has become MetricFu::CHURN_OPTIONS
data/README CHANGED
@@ -57,11 +57,11 @@ When creating a coverage report, metric_fu runs all the tests in the test folder
57
57
 
58
58
  Saikuro is bundled with metric_fu so you don't have to install it. Look at the SAIKURO_README (or the internet) for more documentation on Saikuro. If you wish to change the options Saikuro is run with, then set this constant in your Rakefile:
59
59
 
60
- SAIKURO_OPTIONS = { "--warn_cyclo" => "3", "--error_cyclo" => "4" }
60
+ MetricFu::SAIKURO_OPTIONS = { "--warn_cyclo" => "3", "--error_cyclo" => "4" }
61
61
 
62
- Like RCOV_OPTIONS, SAIKURO_OPTIONS is a hash that gets merged with the default options hash. The above example will set the warn_cyclo to 3 and the error_cyclo to 4 (which is way too low -- it's just an example) instructing Saikuro to flag methods with a higher cyclomatic complexity in it's report.
62
+ MetricFu::SAIKURO_OPTIONS is a hash that gets merged with the default options hash. The above example will set the warn_cyclo to 3 and the error_cyclo to 4 (which is way too low -- it's just an example) instructing Saikuro to flag methods with a higher cyclomatic complexity in it's report.
63
63
 
64
- If you want to have Saikuro look at multiple folders you can put something like this in you rakefile:
64
+ If you want to have Saikuro look at multiple folders you can put something like this in your rakefile:
65
65
  MetricFu::SAIKURO_OPTIONS = {"--input_directory" => '"cms/app | cms/lib"'}
66
66
 
67
67
 
data/TODO.txt CHANGED
@@ -1,7 +1,6 @@
1
1
  == TODO list
2
2
 
3
- * Sort Flog scores from worst to best
4
- * Get churn to work with git
3
+ * Color code flog results with scale from: http://jakescruggs.blogspot.com/2008/08/whats-good-flog-score.html
5
4
  * Extract functionality from rake files and put under test
6
5
  * Change churn start_date to not rely on Rails 1.day.ago functionality (so metric_fu can be used in non-Rails apps)
7
6
  * Make integration with RSpec better (use SpecTask?)
@@ -1,6 +1,5 @@
1
1
  module MetricFu::FlogReporter
2
2
 
3
- THRESHOLD = (ENV['FLOG_THRESHOLD'] || 120)
4
3
  SCORE_FORMAT = "%0.2f"
5
4
 
6
5
  class InvalidFlog < RuntimeError
@@ -8,7 +7,7 @@ module MetricFu::FlogReporter
8
7
 
9
8
  class Base
10
9
  MODULE_NAME = "([A-Z][a-z]+)+"
11
- METHOD_NAME = "#([a-z]+_?)+"
10
+ METHOD_NAME = "#([a-z0-9]+_?)+\\??\\!?"
12
11
  SCORE = "\\d+\\.\\d+"
13
12
 
14
13
  METHOD_NAME_RE = Regexp.new("#{MODULE_NAME}#{METHOD_NAME}")
@@ -48,7 +48,7 @@ module MetricFu::FlogReporter
48
48
  html << "<table class='report'>\n"
49
49
  html << "<tr><th>File</th><th>Total score</th><th>Methods</th><th>Average score</th><th>Highest score</th></tr>"
50
50
  count = 0
51
- flog_hashes.each do |flog_hash|
51
+ flog_hashes.sort {|x,y| y[:page].highest_score <=> x[:page].highest_score }.each do |flog_hash|
52
52
  html << <<-EOF
53
53
  <tr class='#{Base.cycle("light", "dark", count)}'>
54
54
  <td><a href='#{flog_hash[:path]}'>#{flog_hash[:path].sub('.html', '.rb')}</a></td>
data/lib/tasks/churn.rake CHANGED
@@ -3,13 +3,23 @@ namespace :metrics do
3
3
 
4
4
  desc "Which files change the most"
5
5
  task :churn do
6
- date_range, minimum_churn_count = churn_options()
7
- svn_logs = `svn log #{date_range} --verbose`.split(/\n/).select {|line| line.strip =~ /^[A,M]/}
8
-
6
+ date_range, minimum_churn_count, scm = churn_options()
7
+
9
8
  changes = {}
10
- svn_logs.each do |line|
11
- line.strip =~ /^[A,M] (.*)/
12
- changes[$1] ? changes[$1] += 1 : changes[$1] = 1
9
+ if scm == :git
10
+ git_logs = `git log #{date_range} --name-only --pretty=format:`.split(/\n/)
11
+ git_logs.reject!{|line| line == ""}
12
+
13
+ git_logs.each do |line|
14
+ changes[line] ? changes[line] += 1 : changes[line] = 1
15
+ end
16
+ else
17
+ svn_logs = `svn log #{date_range} --verbose`.split(/\n/).select {|line| line.strip =~ /^[A,M]/}
18
+
19
+ svn_logs.each do |line|
20
+ line.strip =~ /^[A,M] (.*)/
21
+ changes[$1] ? changes[$1] += 1 : changes[$1] = 1
22
+ end
13
23
  end
14
24
  write_churn_file(changes.reject {|file, change_count| change_count < minimum_churn_count})
15
25
  system("open #{CHURN_DIR}/index.html") if PLATFORM['darwin']
@@ -20,12 +30,17 @@ namespace :metrics do
20
30
  options = defined?(MetricFu::CHURN_OPTIONS) ? MetricFu::CHURN_OPTIONS : {}
21
31
  if options[:start_date]
22
32
  require RAILS_ROOT + '/config/environment'
23
- date_range = "--revision {#{options[:start_date].call.strftime('%Y-%m-%d')}}:{#{Time.now.strftime('%Y-%m-%d')}}"
33
+ if options[:scm] == :git
34
+ date_range = "--after=#{options[:start_date].call.strftime('%Y-%m-%d')}"
35
+ else
36
+ date_range = "--revision {#{options[:start_date].call.strftime('%Y-%m-%d')}}:{#{Time.now.strftime('%Y-%m-%d')}}"
37
+ end
24
38
  else
25
39
  date_range = ""
26
40
  end
27
41
  minimum_churn_count = options[:minimum_churn_count] ? options[:minimum_churn_count] : 5
28
- return date_range, minimum_churn_count
42
+ scm = options[:scm] == :git ? :git : :svn
43
+ return date_range, minimum_churn_count, scm
29
44
  end
30
45
 
31
46
  def write_churn_file changes
@@ -93,4 +108,4 @@ namespace :metrics do
93
108
  </body>
94
109
  </html>
95
110
  EOS
96
- end
111
+ end
data/lib/tasks/flog.rake CHANGED
@@ -1,6 +1,3 @@
1
- require File.join(File.dirname(__FILE__), '..', 'metric_fu', 'md5_tracker')
2
- require File.join(File.dirname(__FILE__), '..', 'metric_fu', 'flog_reporter')
3
-
4
1
  begin
5
2
  FLOG_DIR = File.join(MetricFu::BASE_DIRECTORY, 'flog')
6
3
 
data/metric_fu.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "metric_fu"
3
- s.version = "0.7.6"
3
+ s.version = "0.8.0"
4
4
  s.summary = "Generates project metrics using Flog, RCov, Saikuro and more"
5
5
  s.email = "jake.scruggs@gmail.com"
6
6
  s.homepage = "http://metric-fu.rubyforge.org/"
data/test/test_helper.rb CHANGED
@@ -2,5 +2,3 @@ require 'test/unit'
2
2
  require 'fileutils'
3
3
 
4
4
  ENV['CC_BUILD_ARTIFACTS'] = File.join(File.dirname(__FILE__), 'tmp')
5
-
6
- require File.join(File.dirname(__FILE__), '..', 'lib', 'metric_fu')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jscruggs-metric_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Scruggs