metric_fu 2.1.1 → 2.1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. data/.gitignore +20 -0
  2. data/.travis.yml +5 -0
  3. data/Gemfile +5 -0
  4. data/HISTORY +21 -1
  5. data/Manifest.txt +25 -0
  6. data/README.md +61 -0
  7. data/Rakefile +15 -9
  8. data/TODO +2 -0
  9. data/bin/metric_fu +4 -0
  10. data/config/roodi_config.yml +22 -0
  11. data/home_page/back_all.jpg +0 -0
  12. data/home_page/churn.gif +0 -0
  13. data/home_page/flay.gif +0 -0
  14. data/home_page/flog.gif +0 -0
  15. data/home_page/footer.gif +0 -0
  16. data/home_page/header.jpg +0 -0
  17. data/home_page/hotspot.gif +0 -0
  18. data/home_page/img09.gif +0 -0
  19. data/home_page/index.html +305 -0
  20. data/home_page/rcov.gif +0 -0
  21. data/home_page/reek.gif +0 -0
  22. data/home_page/roodi.gif +0 -0
  23. data/home_page/saikuro.gif +0 -0
  24. data/home_page/stats.gif +0 -0
  25. data/home_page/styles.css +245 -0
  26. data/home_page/title.gif +0 -0
  27. data/home_page/title_back.gif +0 -0
  28. data/lib/{base/configuration.rb → configuration.rb} +45 -17
  29. data/lib/data_structures/careful_array.rb +9 -0
  30. data/lib/{base → data_structures}/code_issue.rb +17 -16
  31. data/lib/data_structures/grouping.rb +40 -0
  32. data/lib/{base → data_structures}/line_numbers.rb +23 -14
  33. data/lib/{base → data_structures}/location.rb +3 -1
  34. data/lib/{base → data_structures}/ranking.rb +0 -0
  35. data/lib/data_structures/record.rb +43 -0
  36. data/lib/{base → data_structures}/table.rb +6 -2
  37. data/lib/errors/analysis_error.rb +1 -0
  38. data/lib/initial_requires.rb +25 -0
  39. data/lib/load_files.rb +39 -0
  40. data/lib/logging/mf_debugger.rb +24 -0
  41. data/lib/{base/md5_tracker.rb → md5_tracker.rb} +0 -0
  42. data/lib/metric_fu.rb +55 -37
  43. data/lib/{base → metrics}/base_template.rb +47 -16
  44. data/lib/{generators → metrics/churn}/churn.rb +0 -0
  45. data/lib/{base → metrics/churn}/churn_analyzer.rb +0 -0
  46. data/lib/{templates/awesome → metrics/churn/template_awesome}/churn.html.erb +0 -0
  47. data/lib/{templates/standard → metrics/churn/template_standard}/churn.html.erb +0 -0
  48. data/lib/{generators → metrics/flay}/flay.rb +0 -0
  49. data/lib/{base → metrics/flay}/flay_analyzer.rb +0 -0
  50. data/lib/{graphs → metrics/flay}/flay_grapher.rb +0 -0
  51. data/lib/{templates/awesome → metrics/flay/template_awesome}/flay.html.erb +0 -0
  52. data/lib/{templates/standard → metrics/flay/template_standard}/flay.html.erb +0 -0
  53. data/lib/{generators → metrics/flog}/flog.rb +2 -0
  54. data/lib/{base → metrics/flog}/flog_analyzer.rb +0 -0
  55. data/lib/{graphs → metrics/flog}/flog_grapher.rb +0 -0
  56. data/lib/{templates/awesome → metrics/flog/template_awesome}/flog.html.erb +0 -0
  57. data/lib/{templates/standard → metrics/flog/template_standard}/flog.html.erb +0 -0
  58. data/lib/{base → metrics}/generator.rb +0 -0
  59. data/lib/{base → metrics}/graph.rb +0 -0
  60. data/lib/{generators → metrics/hotspots}/hotspots.rb +0 -0
  61. data/lib/{templates/awesome → metrics/hotspots/template_awesome}/hotspots.html.erb +0 -0
  62. data/lib/{templates/standard → metrics/hotspots/template_standard}/hotspots.html.erb +0 -0
  63. data/lib/{base → metrics}/metric_analyzer.rb +4 -80
  64. data/lib/{generators → metrics/rails_best_practices}/rails_best_practices.rb +0 -0
  65. data/lib/{graphs → metrics/rails_best_practices}/rails_best_practices_grapher.rb +0 -0
  66. data/lib/{templates/awesome → metrics/rails_best_practices/template_awesome}/rails_best_practices.html.erb +1 -1
  67. data/lib/{templates/standard → metrics/rails_best_practices/template_standard}/rails_best_practices.html.erb +1 -1
  68. data/lib/{generators → metrics/rcov}/rcov.rb +5 -3
  69. data/lib/{base → metrics/rcov}/rcov_analyzer.rb +1 -1
  70. data/lib/{graphs → metrics/rcov}/rcov_grapher.rb +0 -0
  71. data/lib/{templates/awesome → metrics/rcov/template_awesome}/rcov.html.erb +0 -0
  72. data/lib/{templates/standard → metrics/rcov/template_standard}/rcov.html.erb +0 -0
  73. data/lib/{generators → metrics/reek}/reek.rb +3 -2
  74. data/lib/{base → metrics/reek}/reek_analyzer.rb +1 -0
  75. data/lib/{graphs → metrics/reek}/reek_grapher.rb +0 -0
  76. data/lib/{templates/awesome → metrics/reek/template_awesome}/reek.html.erb +0 -0
  77. data/lib/{templates/standard → metrics/reek/template_standard}/reek.html.erb +0 -0
  78. data/lib/{generators → metrics/roodi}/roodi.rb +0 -0
  79. data/lib/{base → metrics/roodi}/roodi_analyzer.rb +0 -0
  80. data/lib/{graphs → metrics/roodi}/roodi_grapher.rb +0 -0
  81. data/lib/{templates/awesome → metrics/roodi/template_awesome}/roodi.html.erb +0 -0
  82. data/lib/{templates/standard → metrics/roodi/template_standard}/roodi.html.erb +0 -0
  83. data/lib/{generators → metrics/saikuro}/saikuro.rb +4 -2
  84. data/lib/{base → metrics/saikuro}/saikuro_analyzer.rb +0 -0
  85. data/lib/{templates/awesome → metrics/saikuro/template_awesome}/saikuro.html.erb +0 -0
  86. data/lib/{templates/standard → metrics/saikuro/template_standard}/saikuro.html.erb +0 -0
  87. data/lib/{generators → metrics/stats}/stats.rb +0 -0
  88. data/lib/{base → metrics/stats}/stats_analyzer.rb +0 -0
  89. data/lib/{graphs → metrics/stats}/stats_grapher.rb +0 -0
  90. data/lib/{templates/awesome → metrics/stats/template_awesome}/stats.html.erb +0 -0
  91. data/lib/{templates/standard → metrics/stats/template_standard}/stats.html.erb +0 -0
  92. data/lib/{graphs → reporting/graphs}/engines/bluff.rb +0 -0
  93. data/lib/{graphs → reporting/graphs}/engines/gchart.rb +0 -0
  94. data/lib/{graphs → reporting/graphs}/grapher.rb +0 -0
  95. data/lib/{base → reporting}/report.rb +2 -0
  96. data/lib/{templates → reporting/templates}/awesome/awesome_template.rb +28 -7
  97. data/lib/{templates → reporting/templates}/awesome/css/buttons.css +0 -0
  98. data/lib/{templates → reporting/templates}/awesome/css/default.css +0 -0
  99. data/lib/{templates → reporting/templates}/awesome/css/integrity.css +0 -0
  100. data/lib/{templates → reporting/templates}/awesome/css/reset.css +0 -0
  101. data/lib/{templates → reporting/templates}/awesome/css/syntax.css +0 -0
  102. data/lib/{templates → reporting/templates}/awesome/index.html.erb +0 -0
  103. data/lib/{templates → reporting/templates}/awesome/layout.html.erb +0 -0
  104. data/lib/{templates → reporting/templates}/javascripts/bluff-min.js +0 -0
  105. data/lib/{templates → reporting/templates}/javascripts/excanvas.js +0 -0
  106. data/lib/{templates → reporting/templates}/javascripts/js-class.js +0 -0
  107. data/lib/{templates → reporting/templates}/standard/default.css +0 -0
  108. data/lib/{templates → reporting/templates}/standard/index.html.erb +0 -0
  109. data/lib/{templates → reporting/templates}/standard/standard_template.rb +3 -3
  110. data/lib/{base/scoring_strategies.rb → scoring_strategies.rb} +0 -0
  111. data/lib/tasks/metric_fu.rake +36 -0
  112. data/lib/version.rb +3 -0
  113. data/metric_fu.gemspec +65 -0
  114. data/spec/base/base_template_spec.rb +19 -2
  115. data/spec/base/configuration_spec.rb +4 -3
  116. data/spec/base/generator_spec.rb +2 -2
  117. data/spec/base/line_numbers_spec.rb +2 -2
  118. data/spec/base/location_spec.rb +127 -0
  119. data/spec/base/metric_analyzer_spec.rb +452 -0
  120. data/spec/base/ranking_spec.rb +42 -0
  121. data/spec/base/report_spec.rb +1 -1
  122. data/spec/base/table_spec.rb +36 -0
  123. data/spec/generators/hotspots_spec.rb +88 -0
  124. data/spec/generators/rails_best_practices_spec.rb +1 -1
  125. data/spec/generators/rcov_spec.rb +3 -3
  126. data/spec/generators/stats_spec.rb +1 -1
  127. data/spec/spec_helper.rb +4 -1
  128. metadata +466 -309
  129. data/README +0 -29
  130. data/tasks/metric_fu.rake +0 -22
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ .DS_Store
2
+ .rvmrc*
3
+ *.gem
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - 1.8.7
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'rake', '<=0.9.2'
4
+
5
+ gemspec
data/HISTORY CHANGED
@@ -1,3 +1,23 @@
1
+ === MetricFu 2.1.3.2 / 2012-11-14
2
+
3
+ * Don't raise an exception in the LineNumbers rescue block. Issue https://github.com/bf4/metric_fu/issues/6 by joonty -Benjamin Fleischer
4
+ tmp/metric_fu/output/flog.js
5
+
6
+ === MetricFu 2.1.3 / 2012-10-25
7
+
8
+ * Added to rubygems.org as bf-metric_fu -Benjamin Fleischer
9
+ * Added to travis-ci -Benjamin Fleischer
10
+ * Re-enabling Saikuro for ruby 1.9 with jpgolly's gem jpgolly-Saikuro -Benjamin Fleischer
11
+ * Ensured files are only loaded once -Benjamin Fleischer
12
+ * Looked at moving to simplecov-rcov, but was unsuccessful -Benjamin Fleischer
13
+ * Fixed breaking tests, deprecation warnings -Benjamin Fleischer
14
+
15
+ === MetricFu 2.1.2 / 2012-09-05
16
+
17
+ * Getting it working on Rails 3, partly by going through the pull requests and setting gem dependencies to older, working versions - Benjamin Fleischer
18
+ * It mostly works on Ruby 1.9, though there is an unresolved sexp_parser issue - Benjamin Fleischer
19
+ * Added link_prefix to configuration to allow URIs specified in config instead of file or txmt - dan sinclair
20
+
1
21
  === MetricFu 2.1.1 / 2011-03-2
2
22
 
3
23
  * Making syntax highlighting optional (config.syntax_highlighting = false) so Ruby 1.9.2 users don't get "invalid byte sequence in UTF-8" errors.
@@ -234,4 +254,4 @@
234
254
  * Add Flog Report
235
255
  * Add Coverage Report
236
256
  * Add Saikuro Report
237
- * Add Stats Report
257
+ * Add Stats Report
data/Manifest.txt ADDED
@@ -0,0 +1,25 @@
1
+ History.txt
2
+ Manifest.txt
3
+ metric_fu-0.7.gem
4
+ metric_fu.gemspec
5
+ MIT-LICENSE
6
+ Rakefile
7
+ README
8
+ TODO.txt
9
+ lib/metric_fu.rb
10
+ lib/metric_fu/base.rb
11
+ lib/metric_fu/churn.rb
12
+ lib/metric_fu/flay_reporter.rb
13
+ lib/metric_fu/flog_reporter.rb
14
+ lib/metric_fu/md5_tracker.rb
15
+ lib/metric_fu/saikuro/saikuro.rb
16
+ lib/metric_fu/saikuro/SAIKURO_README
17
+ lib/tasks/churn.rake
18
+ lib/tasks/coverage.rake
19
+ lib/tasks/flog.rake
20
+ lib/tasks/metric_fu.rake
21
+ lib/tasks/metric_fu.rb
22
+ lib/tasks/saikuro.rake
23
+ lib/tasks/stats.rake
24
+ test/test_helper.rb
25
+ test/test_md5_tracker.rb
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ This fork is intended to be a maintained version of metric_fu, as [the original version by Jake Scruggs has been abandoned.](http://jakescruggs.blogspot.com/2012/08/why-i-abandoned-metricfu.html). It is currently testing on MRI 1.8.7 and 1.9.3
2
+
3
+ At this time, the gem is published on rubygems.org as bf4-metric_fu
4
+
5
+ There is also a related bf4-metrical gem published
6
+
7
+ The japgolly-Saikuro fork is a part of an attempt to get metric_fu working in a modern
8
+
9
+ Please note that rake version 10.0.2 cannot be used, whereas 0.8.7 and 0.9.2 do work.
10
+
11
+ Ruby environment, specifically compatibility with Ruby 1.9 and Bundler.
12
+
13
+ __CI Build Status__
14
+
15
+ [![Build Status](https://secure.travis-ci.org/bf4/metric_fu.png)](http://travis-ci.org/bf4/metric_fu)
16
+
17
+ This project runs [travis-ci.org](http://travis-ci.org)
18
+
19
+ __Code Quality__
20
+
21
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/bf4/metric_fu)
22
+
23
+ This project runs [https://codeclimate.com/](https://codeclimate.com/)
24
+
25
+
26
+ ===============================================================================
27
+
28
+ See http://metric-fu.rubyforge.org/ for documentation, or the HISTORY file for a change log.
29
+
30
+ How to contribute:
31
+
32
+ 1. Fork metric_fu on github.
33
+ 2. bundle install
34
+ 3. Run the tests ('rake')
35
+ 4. Run metric_fu on itself ('rake metrics:all')
36
+ 5. Make the changes you want and back them up with tests.
37
+ 6. Make sure two important rake tests still run ('rake' and 'rake metrics:all')
38
+ 7. Commit and send me a pull request with details as to what has been changed.
39
+
40
+ Extra Credit:
41
+
42
+ 1. Make sure your changes work in 1.8.7, Ruby Enterprise Edition, and 1.9.3 (Hint use 'rvm' to help install multiple rubies)
43
+ 2. Update the documentation (web page inside the 'home_page' folder)
44
+ 3. Update the History and give yourself credit.
45
+
46
+
47
+ The more of the above steps you do the easier it will be for me to merge in which will greatly increase you chances of getting your changes accepted.
48
+
49
+ Resources:
50
+
51
+ Github: http://github.com/bf4/metric_fu
52
+ Issue Tracker: http://github.com/bf4/metric_fu/issues
53
+ My Blog: http://benjaminfleischer.com
54
+
55
+ Original Resources:
56
+
57
+ Homepage: http://metric-fu.rubyforge.org/
58
+ Github: http://github.com/jscruggs/metric_fu
59
+ Google Group: http://groups.google.com/group/metric_fu
60
+ Issue Tracker: http://github.com/jscruggs/metric_fu/issues
61
+ My Blog: http://jakescruggs.blogspot.com/
data/Rakefile CHANGED
@@ -1,14 +1,20 @@
1
- $LOAD_PATH << '.'
2
- require 'rake'
3
- require 'rake/rdoctask'
4
- require 'spec/rake/spectask'
5
- require 'lib/metric_fu'
6
-
7
- desc "Run all specs in spec directory"
8
- Spec::Rake::SpecTask.new(:spec) do |t|
9
- t.spec_files = FileList['spec/**/*_spec.rb']
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ # $LOAD_PATH << '.'
4
+ begin
5
+ require 'spec/rake/spectask'
6
+ desc "Run all specs in spec directory"
7
+ Spec::Rake::SpecTask.new(:spec) do |t|
8
+ t.spec_files = FileList['spec/**/*_spec.rb']
9
+ end
10
+ rescue LoadError
11
+ require 'rspec/core/rake_task'
12
+ desc "Run all specs in spec directory"
13
+ RSpec::Core::RakeTask.new(:spec)
10
14
  end
11
15
 
16
+ require File.expand_path File.join(File.dirname(__FILE__),'lib/metric_fu')
17
+
12
18
  MetricFu::Configuration.run do |config|
13
19
  config.roodi = config.roodi.merge(:roodi_config => 'config/roodi_config.yml')
14
20
  config.churn = { :start_date => "1 year ago", :minimum_churn_count => 10}
data/TODO CHANGED
@@ -1,5 +1,7 @@
1
1
  == TODO list
2
2
 
3
+ * Determine how to test metric_fu against codebases that are not metric_fu, to ensure it works on most applications
4
+ * Add configurable logger to all output streams
3
5
  * Color code flog results with scale from: http://jakescruggs.blogspot.com/2008/08/whats-good-flog-score.html
4
6
  * Make running metric_fu on metric_fu less embarrassing
5
7
  * Load all gems at config time so you fail fast if one is missing
data/bin/metric_fu ADDED
@@ -0,0 +1,4 @@
1
+ gem 'rake', '<= 0.9.2'
2
+ require 'rake'
3
+ require File.expand_path(File.join(File.dirname(__FILE__),'..','lib','metric_fu'))
4
+ Rake::Task['metrics:all'].invoke
@@ -0,0 +1,22 @@
1
+ ---
2
+ CaseMissingElseCheck: {}
3
+ ClassLineCountCheck:
4
+ line_count: 300
5
+ ClassNameCheck:
6
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
7
+ CyclomaticComplexityBlockCheck:
8
+ complexity: 4
9
+ CyclomaticComplexityMethodCheck:
10
+ complexity: 8
11
+ EmptyRescueBodyCheck: {}
12
+ ForLoopCheck: {}
13
+ MethodLineCountCheck:
14
+ line_count: 20
15
+ MethodNameCheck:
16
+ pattern: !ruby/regexp /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
17
+ ModuleLineCountCheck:
18
+ line_count: 300
19
+ ModuleNameCheck:
20
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
21
+ ParameterNumberCheck:
22
+ parameter_count: 5
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,305 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title>metric_fu: A Ruby Gem for Easy Metric Report Generation</title>
6
+ <meta name="keywords" content="metric_fu rails metrics saikuro flog flay roodi reek cyclomatic complexity rcov coverage gem" />
7
+ <meta name="description" content="Ruby Gem for Easy Metric Report Generation" />
8
+ <link href="styles.css" rel="stylesheet" type="text/css" />
9
+ </head>
10
+ <body>
11
+ <div id="main">
12
+ <!-- header begins -->
13
+ <div id="header">
14
+
15
+ <div id="logo"><a href="#">metric_fu</a></div>
16
+ <div id="buttons">
17
+ <ul><li>A Ruby Gem for Easy Metric Report Generation</li></ul>
18
+ </div>
19
+
20
+ </div>
21
+ <!-- header ends -->
22
+ <!-- content begins -->
23
+ <div id="content">
24
+ <div id="right">
25
+ <div id="sidebar">
26
+ <ul>
27
+ <li>
28
+ <h2>Links</h2>
29
+ <ul>
30
+ <li><a href="http://groups.google.com/group/metric_fu">
31
+ Google Group
32
+ </a>
33
+ </li>
34
+ <li><a href="http://github.com/jscruggs/metric_fu">
35
+ SCM
36
+ </a>
37
+ </li>
38
+ <li><a href="http://github.com/jscruggs/metric_fu/issues">
39
+ Issue Tracker
40
+ </a>
41
+ </li>
42
+ <li><a href="http://jakescruggs.blogspot.com/">
43
+ Jake Scruggs' Blog (lead developer)
44
+ </a>
45
+ </li>
46
+ </ul>
47
+ </li>
48
+ </ul>
49
+ </div>
50
+ <!-- end #sidebar -->
51
+ </div>
52
+ <div id="left">
53
+ <h1>About metric_fu 2.1.1</h1>
54
+ <div>
55
+ <p><br/>
56
+ Metric_fu is a set of rake tasks that make it easy to generate metrics reports. It uses
57
+ <a href="http://saikuro.rubyforge.org/">Saikuro</a>,
58
+ <a href="http://ruby.sadi.st/Flog.html">Flog</a>,
59
+ <a href="http://ruby.sadi.st/Flay.html">Flay</a>,
60
+ <a href="http://eigenclass.org/hiki.rb?rcov">Rcov</a>,
61
+ <a href="http://github.com/kevinrutherford/reek">Reek</a>,
62
+ <a href="http://github.com/martinjandrews/roodi">Roodi</a>,
63
+ <a href="http://github.com/danmayer/churn">Churn</a>,
64
+ <a href="http://rubygems.org/gems/rails_best_practices">RailsBestPractices</a>,
65
+ <a href="http://subversion.tigris.org/">Subversion</a>,
66
+ <a href="http://git.or.cz/">Git</a>, and
67
+ <a href="http://www.rubyonrails.org/">Rails</a>
68
+ built-in stats task to create a series of reports. It's designed to integrate easily with
69
+ <a href="http://cruisecontrolrb.thoughtworks.com/">CruiseControl.rb</a>
70
+ by placing files in the Custom Build Artifacts folder.
71
+ </p>
72
+ <br/>
73
+ <p>
74
+ In 2.1.0 there are a lot of bug fixes, Check the <a href="http://github.com/jscruggs/metric_fu/blob/master/HISTORY">HISTORY</a> file for complete details. There's a verbose mode (config.verbose = true) that's helpful for debugging (from Dan Sinclair), the ability to opt out of TextMate (from Kakutani Shintaro) opening your files (config.darwin_txmt_protocol_no_thanks = true), and super cool annotations on the Hotspots page so you can see your code problems in-line with the file contents (also from Dan Sinclair).
75
+ </p>
76
+ <br/>
77
+ <p>
78
+ In 2.0.0 the big new feature is Hotspots. The Hotspots report combines Flog, Flay, Rcov, Reek, Roodi, and Churn numbers into one report so you see parts of your code that have multiple problems like so:
79
+ </p>
80
+ <img src="hotspot.gif" width="359">
81
+ <p>
82
+ That is one terrible method.<br/>
83
+ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helping me integrate it with RCov.
84
+ </p>
85
+ <br/>
86
+
87
+ <p>
88
+ In 1.5.0 I re-wrote the Flog parsing engine to use Flog programmatically instead of parsing the command line output. This will hopefully stop minor changes in Flog's output from breaking metric_fu.
89
+ </p>
90
+
91
+ <h2>Installation:</h2>
92
+ <pre>gem install metric_fu</pre>
93
+ <br/>
94
+ <p>Then in your Rakefile:</p>
95
+ <br/>
96
+ <pre>require 'metric_fu'</pre>
97
+ <br/>
98
+
99
+ <h2>Output:</h2>
100
+ <table>
101
+ <tr>
102
+ <td><a href="flog.gif"><img src="flog.gif" width="250"></a></td>
103
+ <td><a href="flay.gif"><img src="flay.gif" width="250"></a></td>
104
+ <tr>
105
+ <td><a href="churn.gif"><img src="churn.gif" width="250"></a></td>
106
+ <td><a href="saikuro.gif"><img src="saikuro.gif" width="250"></a></td>
107
+ </tr>
108
+ <tr>
109
+ <td><a href="reek.gif"><img src="reek.gif" width="250"></a></td>
110
+ <td><a href="roodi.gif"><img src="roodi.gif" width="250"></a></td>
111
+ </tr>
112
+ <tr>
113
+ <td><a href="rcov.gif"><img src="rcov.gif" width="250"></a></td>
114
+ <td><a href="stats.gif"><img src="stats.gif" width="250"></a></td>
115
+ </tr>
116
+ </table>
117
+ <p><br/>
118
+ <h2>Usage:</h2>
119
+ Out of the box metric_fu provides this tasks:
120
+ <ul>
121
+ <li>rake metrics:all # Generate coverage, cyclomatic complexity, flog, flay, reek, roodi, stats... </li>
122
+ </ul>
123
+ <br/>
124
+ I recommend using CruiseControl.rb to set up a metrics build. See the CruiseControl.rb online docs for more info on how to set up cc.rb and, once you've got that figured out, change the cruise_config.rb file inside your project to have these lines:
125
+ <br/><br/>
126
+ <pre>project.rake_task = 'metrics:all'</pre>
127
+ <pre>project.scheduler.polling_interval = 24.hours</pre>
128
+ <br/>
129
+ Which will check for updates every 24 hours and run all the metric_fu rake tasks (migrating your test db first). The output will be visible from an individual build's detail page.
130
+ </p>
131
+ <br/>
132
+
133
+ <h2>Configuration:</h2>
134
+ <p>The definitive source for configuration is, of course, the source: <a href="http://github.com/jscruggs/metric_fu/blob/master/lib/base/configuration.rb#L99">lib/base/configuration.rb</a>
135
+ <p>Metric_fu can be customized to your liking by altering the defaults in your Rakefile:</p>
136
+ <pre>
137
+ MetricFu::Configuration.run do |config|
138
+ #define which metrics you want to use
139
+ config.metrics = [:churn, :saikuro, :stats, :flog, :flay]
140
+ config.graphs = [:flog, :flay, :stats]
141
+ # ...
142
+ end
143
+ </pre>
144
+ Note: if you don't want one of the metrics to run (like rcov), make sure you don't try to graph it (which will explode). Set config.graphs to exactly the graphs you want. Set config.graphs to an empty array (config.graphs = []) if you want no graphing at all.
145
+ </p>
146
+
147
+ <p><br/>
148
+ <h2>Graphing</h2>
149
+ MetricFu uses Bluff for graphing (a Javascript library) by default. If you'd rather use Google Charts you can set 'config.graph_engine = :gchart' in the config. You'll have to install the googlecharts gem, of course.
150
+ </p>
151
+
152
+ <p><br/>
153
+ <h2>Notes on Rails 3</h2>
154
+ If you use RSpec, you'll need to add this to one of your rake files:
155
+ <pre>
156
+ require 'metric_fu'
157
+ MetricFu::Configuration.run do |config|
158
+ config.rcov[:test_files] = ['spec/**/*_spec.rb']
159
+ config.rcov[:rcov_opts] &lt;&lt; "-Ispec" # Needed to find spec_helper
160
+ end
161
+ </pre>
162
+ If you're using default Rails testing, then you can do this:
163
+ <pre>
164
+ require 'metric_fu'
165
+ MetricFu::Configuration.run do |config|
166
+ config.rcov[:rcov_opts] &lt;&lt; "-Itest" # Needed to find test_helper
167
+ end
168
+ </pre>
169
+ <br/>
170
+
171
+ <p><br/>
172
+ <h2>Notes on metrics:coverage</h2>
173
+ When creating a coverage report, metric_fu runs all the tests in the test folder and specs in spec folder using Rcov. You can configure what files it should run and the RAILS_ENV (by setting 'environment') it runs under. Default config for rcov:
174
+ <pre>
175
+ config.rcov = { :environment => 'test',
176
+ :test_files => ['test/**/*_test.rb',
177
+ 'spec/**/*_spec.rb'],
178
+ :rcov_opts => ["--sort coverage",
179
+ "--no-html",
180
+ "--text-coverage",
181
+ "--no-color",
182
+ "--profile",
183
+ "--rails",
184
+ "--exclude /gems/,/Library/,/usr/,spec"],
185
+ :external => nil
186
+ }
187
+ </pre>
188
+ By far, Rcov is the most troublesome report in metric_fu. This is not because of Rcov itself, but because the Rcov report has to actually execute your tests and test suites can be very tricky things. MetricFu naively shells out to the command line, runs rcov on your tests/specs, and captures the output. This does not always work well. If you are having problems with metric_fu, try turning off Rcov (see the above Configuration section).
189
+ </p>
190
+ <p><br/>
191
+ <h2>Notes on metrics:saikuro</h2>
192
+ Saikuro measures cyclomatic complexity for Ruby. Default config for Saikuro:
193
+ <pre>
194
+ config.saikuro = { :output_directory => 'tmp/metirc_fu/saikuro',
195
+ :input_directory => ['app', 'lib'],
196
+ :cyclo => "",
197
+ :filter_cyclo => "0",
198
+ :warn_cyclo => "5",
199
+ :error_cyclo => "7",
200
+ :formater => "text"}
201
+ </pre>
202
+ <br/><br/>
203
+ </p>
204
+ <p><br/>
205
+ <h2>Notes on metrics:flay</h2>
206
+ Flay analyzes ruby code for structural similarities.
207
+ You can configure which directories need to be flayed.
208
+ The defaults are 'lib' for non Rails projects and ['app', 'lib'] for Rails projects.
209
+ By default, metric_fu ignores scores under 100. You can configure the minimum_score. Default config for Flay:
210
+ <pre>
211
+ config.flay ={:dirs_to_flay => ['app', 'lib'],
212
+ :minimum_score => 100,
213
+ :filetypes => ['rb'] }
214
+ </pre>
215
+ </p>
216
+
217
+ <p><br/>
218
+ <h2>Notes on metrics:flog</h2>
219
+ <br/>
220
+ Flog is another way of measuring complexity (or tortured code as the Flog authors like to put it). You should check out the awesome, and a little scary, <a href="http://ruby.sadi.st/Flog.html">Flog website</a> for more info. Default config for Flog:
221
+ <pre>
222
+ config.flog = { :dirs_to_flog => ['app', 'lib'] }
223
+ </pre>
224
+ </p>
225
+ <p><br/>
226
+ <h2>Notes on metrics:reek</h2>
227
+ Reek detects common code smells in ruby code.
228
+ You can configure which directories need to be checked.
229
+ The defaults are 'lib' for non Rails projects and ['app', 'lib'] for Rails projects. Default config for Reek:
230
+ <pre>
231
+ config.reek = { :dirs_to_reek => ['app', 'lib'] }
232
+ </pre>
233
+ </p>
234
+
235
+ <p><br/>
236
+ <h2>Notes on metrics:roodi</h2>
237
+ Roodi parses your Ruby code and warns you about design issues you have based on the checks that is has configured.
238
+ You can configure which directories need to be checked.
239
+ The defaults are 'lib' for non Rails projects and ['app', 'lib'] for Rails projects. Default config for Roodi:
240
+ <pre>
241
+ config.roodi = { :dirs_to_roodi => ['app', 'lib'] }
242
+ </pre>
243
+ </p>
244
+ <p><br/>
245
+ <h2>Notes on metrics:rails_best_practices</h2>
246
+ Rails Best Practices checks your rails files for violations of... Well the name says it all. The gem was inspired by ihower's presentation <a href="http://www.slideshare.net/ihower/rails-best-practices">Rails Best Practices</a>
247
+ </p>
248
+ <p><br/>
249
+ <h2>Notes on metrics:stats</h2>
250
+ This is just 'rake stats' put into a file. On my projects I like to be able to look at CruiseControl and get stats about the app at different points in time.
251
+ </p>
252
+ <p><br/>
253
+ <h2>Notes on metrics:churn</h2>
254
+ Files that change a lot in your project may be bad a sign. This task uses svn or git's log to identify those files and put them in a report.
255
+ <br/>
256
+ <br/>
257
+ </p>
258
+
259
+
260
+ <br/>
261
+ <p>Metric_fu began its life as a plugin for Rails that generated code metrics reports. As of version 0.7.0, metric_fu is a gem (owing to the excellent work done by Sean Soper) and is hosted on GitHub at <a href="http://github.com/jscruggs/metric_fu">http://github.com/jscruggs/metric_fu</a>. </p>
262
+ <p><br/>
263
+ <h2>Questions?</h2>
264
+ <p>Use the Google Group: <a href="http://groups.google.com/group/metric_fu">http://groups.google.com/group/metric_fu</a></p>
265
+ <br/>
266
+ <h2>Thanks</h2>
267
+ I'd like to thank the authors of Saikuro, Subversion, Flog, Rcov, CruiseControl.rb, and Rails for creating such excellent open source products. Also many thanks go to
268
+ <a href="http://arko.net/">Andre Arko</a>,
269
+ <a href="http://deheus.net/petrik">Petrik de Heus</a>,
270
+ <a href="http://seansoper.com/">Sean Soper</a>,
271
+ <a href="http://www.perilled.com/">Erik St Martin</a>,
272
+ <a href="http://gregorowicz.blogspot.com/">Andy Gregorowicz</a>,
273
+ <a href="http://github.com/bastien/">Bastien</a>,
274
+ <a href="http://schubert.cx/">Michael Schubert</a>,
275
+ <a href="http://kseebaldt.blogspot.com/">Kurtis Seebaldt</a>,
276
+ <a href="http://www.workingwithrails.com/person/11263-toby-tripp">Toby Tripp</a>,
277
+ <a href="http://www.aliaghareza.com">Ali Aghareza</a>,
278
+ <a href="http://www.pgrs.net/">Paul Gross</a>, and
279
+ <a href="http://chirdeepshetty.net/">Chirdeep Shetty</a>
280
+ for their contributions to metric_fu.
281
+ </p>
282
+ </div>
283
+
284
+ </div>
285
+
286
+ </div>
287
+ </div>
288
+ <!-- content ends -->
289
+ <!-- footer begins -->
290
+ <div id="metamorph2"><div id="footer">
291
+ <p>Copyright &copy; 2008. Designed by <a href="http://www.metamorphozis.com/" title="Free Web Templates">Free Web Templates</a></p>
292
+ </div></div>
293
+ <!-- footer ends -->
294
+
295
+ <script type="text/javascript">
296
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
297
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
298
+ </script>
299
+ <script type="text/javascript">
300
+ var pageTracker = _gat._getTracker("UA-1908573-3");
301
+ pageTracker._initData();
302
+ pageTracker._trackPageview();
303
+ </script>
304
+ </body>
305
+ </html>