metric_fu 2.1.3.7.19 → 2.1.4.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/.rspec +2 -0
  2. data/.travis.yml +12 -0
  3. data/Gemfile +2 -2
  4. data/HISTORY.md +15 -2
  5. data/README.md +19 -12
  6. data/TODO.md +121 -7
  7. data/bin/metric_fu +134 -2
  8. data/lib/metric_fu.rb +8 -1
  9. data/lib/metric_fu/configuration.rb +192 -0
  10. data/lib/{data_structures → metric_fu/data_structures}/careful_array.rb +0 -0
  11. data/lib/{data_structures → metric_fu/data_structures}/line_numbers.rb +0 -0
  12. data/lib/{data_structures → metric_fu/data_structures}/location.rb +0 -0
  13. data/lib/{errors → metric_fu/errors}/analysis_error.rb +0 -0
  14. data/lib/{initial_requires.rb → metric_fu/initial_requires.rb} +1 -0
  15. data/lib/{load_files.rb → metric_fu/load_files.rb} +0 -8
  16. data/lib/{logging → metric_fu/logging}/mf_debugger.rb +0 -0
  17. data/lib/{metrics → metric_fu/metrics}/base_template.rb +0 -0
  18. data/lib/metric_fu/metrics/churn/churn.rb +64 -0
  19. data/lib/{metrics → metric_fu/metrics}/churn/churn_hotspot.rb +0 -0
  20. data/lib/metric_fu/metrics/churn/init.rb +5 -0
  21. data/lib/{metrics → metric_fu/metrics}/churn/template_awesome/churn.html.erb +0 -0
  22. data/lib/{metrics → metric_fu/metrics}/churn/template_standard/churn.html.erb +0 -0
  23. data/lib/{metrics → metric_fu/metrics}/flay/flay.rb +3 -1
  24. data/lib/{metrics → metric_fu/metrics}/flay/flay_grapher.rb +0 -0
  25. data/lib/{metrics → metric_fu/metrics}/flay/flay_hotspot.rb +0 -0
  26. data/lib/metric_fu/metrics/flay/init.rb +9 -0
  27. data/lib/{metrics → metric_fu/metrics}/flay/template_awesome/flay.html.erb +0 -0
  28. data/lib/{metrics → metric_fu/metrics}/flay/template_standard/flay.html.erb +0 -0
  29. data/lib/{metrics → metric_fu/metrics}/flog/flog.rb +0 -0
  30. data/lib/{metrics → metric_fu/metrics}/flog/flog_grapher.rb +0 -0
  31. data/lib/{metrics → metric_fu/metrics}/flog/flog_hotspot.rb +0 -0
  32. data/lib/metric_fu/metrics/flog/init.rb +7 -0
  33. data/lib/{metrics → metric_fu/metrics}/flog/template_awesome/flog.html.erb +0 -0
  34. data/lib/{metrics → metric_fu/metrics}/flog/template_standard/flog.html.erb +0 -0
  35. data/lib/{metrics → metric_fu/metrics}/generator.rb +3 -4
  36. data/lib/{metrics → metric_fu/metrics}/graph.rb +0 -0
  37. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/code_issue.rb +0 -0
  38. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/grouping.rb +0 -0
  39. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/ranking.rb +0 -0
  40. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/record.rb +0 -0
  41. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/scoring_strategies.rb +0 -0
  42. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/table.rb +0 -0
  43. data/lib/{metrics → metric_fu/metrics}/hotspots/hotspot_analyzer.rb +0 -0
  44. data/lib/{metrics → metric_fu/metrics}/hotspots/hotspots.rb +0 -0
  45. data/lib/metric_fu/metrics/hotspots/init.rb +5 -0
  46. data/lib/{metrics → metric_fu/metrics}/hotspots/template_awesome/hotspots.html.erb +0 -0
  47. data/lib/{metrics → metric_fu/metrics}/hotspots/template_standard/hotspots.html.erb +0 -0
  48. data/lib/metric_fu/metrics/rails_best_practices/init.rb +7 -0
  49. data/lib/{metrics → metric_fu/metrics}/rails_best_practices/rails_best_practices.rb +4 -2
  50. data/lib/{metrics → metric_fu/metrics}/rails_best_practices/rails_best_practices_grapher.rb +0 -0
  51. data/lib/{metrics → metric_fu/metrics}/rails_best_practices/template_awesome/rails_best_practices.html.erb +0 -0
  52. data/lib/{metrics → metric_fu/metrics}/rails_best_practices/template_standard/rails_best_practices.html.erb +0 -0
  53. data/lib/metric_fu/metrics/rcov/init.rb +18 -0
  54. data/lib/{metrics → metric_fu/metrics}/rcov/rcov.rb +22 -7
  55. data/lib/{metrics → metric_fu/metrics}/rcov/rcov_grapher.rb +0 -0
  56. data/lib/{metrics → metric_fu/metrics}/rcov/rcov_hotspot.rb +0 -0
  57. data/lib/{metrics → metric_fu/metrics}/rcov/template_awesome/rcov.html.erb +0 -0
  58. data/lib/{metrics → metric_fu/metrics}/rcov/template_standard/rcov.html.erb +0 -0
  59. data/lib/metric_fu/metrics/reek/init.rb +7 -0
  60. data/lib/{metrics → metric_fu/metrics}/reek/reek.rb +3 -1
  61. data/lib/{metrics → metric_fu/metrics}/reek/reek_grapher.rb +0 -0
  62. data/lib/{metrics → metric_fu/metrics}/reek/reek_hotspot.rb +0 -0
  63. data/lib/{metrics → metric_fu/metrics}/reek/template_awesome/reek.html.erb +0 -0
  64. data/lib/{metrics → metric_fu/metrics}/reek/template_standard/reek.html.erb +0 -0
  65. data/lib/metric_fu/metrics/roodi/init.rb +7 -0
  66. data/lib/{metrics → metric_fu/metrics}/roodi/roodi.rb +3 -1
  67. data/lib/{metrics → metric_fu/metrics}/roodi/roodi_grapher.rb +0 -0
  68. data/lib/{metrics → metric_fu/metrics}/roodi/roodi_hotspot.rb +0 -0
  69. data/lib/{metrics → metric_fu/metrics}/roodi/template_awesome/roodi.html.erb +0 -0
  70. data/lib/{metrics → metric_fu/metrics}/roodi/template_standard/roodi.html.erb +0 -0
  71. data/lib/metric_fu/metrics/saikuro/init.rb +11 -0
  72. data/lib/{metrics → metric_fu/metrics}/saikuro/saikuro.rb +0 -0
  73. data/lib/{metrics → metric_fu/metrics}/saikuro/saikuro_hotspot.rb +0 -0
  74. data/lib/{metrics → metric_fu/metrics}/saikuro/template_awesome/saikuro.html.erb +0 -0
  75. data/lib/{metrics → metric_fu/metrics}/saikuro/template_standard/saikuro.html.erb +0 -0
  76. data/lib/metric_fu/metrics/stats/init.rb +7 -0
  77. data/lib/{metrics → metric_fu/metrics}/stats/stats.rb +3 -1
  78. data/lib/{metrics → metric_fu/metrics}/stats/stats_grapher.rb +0 -0
  79. data/lib/{metrics → metric_fu/metrics}/stats/stats_hotspot.rb +0 -0
  80. data/lib/{metrics → metric_fu/metrics}/stats/template_awesome/stats.html.erb +0 -0
  81. data/lib/{metrics → metric_fu/metrics}/stats/template_standard/stats.html.erb +0 -0
  82. data/lib/{reporting → metric_fu/reporting}/graphs/engines/bluff.rb +0 -0
  83. data/lib/{reporting → metric_fu/reporting}/graphs/engines/gchart.rb +0 -0
  84. data/lib/metric_fu/reporting/graphs/engines/init.rb +5 -0
  85. data/lib/{reporting → metric_fu/reporting}/graphs/grapher.rb +0 -0
  86. data/lib/{reporting → metric_fu/reporting}/report.rb +3 -2
  87. data/lib/{reporting → metric_fu/reporting}/templates/awesome/awesome_template.rb +0 -0
  88. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/buttons.css +0 -0
  89. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/default.css +0 -0
  90. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/integrity.css +0 -0
  91. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/reset.css +0 -0
  92. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/syntax.css +0 -0
  93. data/lib/{reporting → metric_fu/reporting}/templates/awesome/index.html.erb +0 -0
  94. data/lib/{reporting → metric_fu/reporting}/templates/awesome/layout.html.erb +0 -0
  95. data/lib/{reporting → metric_fu/reporting}/templates/javascripts/bluff-min.js +0 -0
  96. data/lib/{reporting → metric_fu/reporting}/templates/javascripts/excanvas.js +0 -0
  97. data/lib/{reporting → metric_fu/reporting}/templates/javascripts/js-class.js +0 -0
  98. data/lib/{reporting → metric_fu/reporting}/templates/standard/default.css +0 -0
  99. data/lib/{reporting → metric_fu/reporting}/templates/standard/index.html.erb +0 -0
  100. data/lib/{reporting → metric_fu/reporting}/templates/standard/standard_template.rb +0 -0
  101. data/lib/{run.rb → metric_fu/run.rb} +12 -11
  102. data/lib/{tasks → metric_fu/tasks}/metric_fu.rake +0 -0
  103. data/lib/metric_fu/version.rb +3 -0
  104. data/metric_fu.gemspec +13 -21
  105. data/spec/metric_fu/configuration_spec.rb +298 -0
  106. data/spec/{base → metric_fu/data_structures}/line_numbers_spec.rb +11 -11
  107. data/spec/{base → metric_fu/data_structures}/location_spec.rb +1 -1
  108. data/spec/{base → metric_fu/metrics}/base_template_spec.rb +1 -1
  109. data/spec/metric_fu/metrics/churn/churn_spec.rb +85 -0
  110. data/spec/{graphs → metric_fu/metrics/flay}/flay_grapher_spec.rb +3 -3
  111. data/spec/{generators → metric_fu/metrics/flay}/flay_spec.rb +1 -1
  112. data/spec/{graphs → metric_fu/metrics/flog}/flog_grapher_spec.rb +4 -4
  113. data/spec/{generators → metric_fu/metrics/flog}/flog_spec.rb +1 -1
  114. data/spec/{base → metric_fu/metrics}/generator_spec.rb +4 -3
  115. data/spec/{base → metric_fu/metrics}/graph_spec.rb +1 -1
  116. data/spec/{base → metric_fu/metrics/hotspots/analysis}/ranking_spec.rb +1 -1
  117. data/spec/{base → metric_fu/metrics/hotspots/analysis}/table_spec.rb +1 -1
  118. data/spec/{base → metric_fu/metrics/hotspots}/hotspot_analyzer_spec.rb +1 -1
  119. data/spec/{generators → metric_fu/metrics/hotspots}/hotspots_spec.rb +1 -1
  120. data/spec/{graphs → metric_fu/metrics/rails_best_practices}/rails_best_practices_grapher_spec.rb +3 -3
  121. data/spec/{generators → metric_fu/metrics/rails_best_practices}/rails_best_practices_spec.rb +1 -1
  122. data/spec/{graphs → metric_fu/metrics/rcov}/rcov_grapher_spec.rb +3 -3
  123. data/spec/{generators → metric_fu/metrics/rcov}/rcov_spec.rb +1 -1
  124. data/spec/{graphs → metric_fu/metrics/reek}/reek_grapher_spec.rb +3 -3
  125. data/spec/{generators → metric_fu/metrics/reek}/reek_spec.rb +1 -1
  126. data/spec/{graphs → metric_fu/metrics/roodi}/roodi_grapher_spec.rb +3 -3
  127. data/spec/{generators → metric_fu/metrics/roodi}/roodi_spec.rb +1 -1
  128. data/spec/{generators → metric_fu/metrics/saikuro}/saikuro_spec.rb +4 -4
  129. data/spec/{graphs → metric_fu/metrics/stats}/stats_grapher_spec.rb +3 -3
  130. data/spec/{generators → metric_fu/metrics/stats}/stats_spec.rb +7 -4
  131. data/spec/{graphs → metric_fu/reporting/graphs}/engines/bluff_spec.rb +3 -3
  132. data/spec/{graphs → metric_fu/reporting/graphs}/engines/gchart_spec.rb +2 -1
  133. data/spec/{base → metric_fu/reporting}/report_spec.rb +5 -3
  134. data/spec/spec_helper.rb +17 -5
  135. data/spec/support/suite.rb +16 -0
  136. metadata +195 -183
  137. data/lib/configuration.rb +0 -227
  138. data/lib/metrics/churn/churn.rb +0 -28
  139. data/lib/version.rb +0 -3
  140. data/spec/base/configuration_spec.rb +0 -277
  141. data/spec/generators/churn_spec.rb +0 -41
  142. data/spec/spec.opts +0 -6
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --profile
data/.travis.yml CHANGED
@@ -3,3 +3,15 @@ rvm:
3
3
  - 1.9.3
4
4
  - 1.9.2
5
5
  - 1.8.7
6
+ - 1.8.6
7
+ - jruby-18mode # JRuby in 1.8 mode
8
+ - jruby-19mode # JRuby in 1.9 mode
9
+ - rbx-18mode
10
+ - rbx-19mode
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: 1.8.6
14
+ - rvm: jruby-18mode
15
+ - rvm: jruby-19mode
16
+ - rvm: rbx-18mode
17
+ - rvm: rbx-19mode
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source :rubygems
2
2
 
3
- gem 'rake', '<0.9.3'
3
+ gem 'rake'
4
4
  group :development, :test do
5
- gem "rspec", "= 1.3.0"
5
+ gem "rspec", '>2'
6
6
  gem "test-construct", ">= 1.2.0"
7
7
  gem "googlecharts"
8
8
  end
data/HISTORY.md CHANGED
@@ -1,6 +1,20 @@
1
- === MetricFu 2.1.3.7 / 2013-01-08
1
+ === master ===
2
+
3
+ * Add commandline behavior to `metric_fu`. Now there are options -v, -r, and -h
4
+ * Clean up global ivars a bit in Configuration
5
+ * Re-organized test files - Michael Stark
6
+ * Rspec2 - Michael Stark
7
+ * Unify verbose logging
8
+ * Modularize
9
+
10
+ === MetricFu 2.1.3.7.18.1 / 2013-01-09
11
+
12
+ * Same as 2.1.3.7.18.1 but gem packaged using ruby 1.8 dependencies, including ripper
13
+
14
+ === MetricFu 2.1.3.7.19 / 2013-01-08
2
15
 
3
16
  * Bug fix, ensure Configuration is loaded before Run, https://github.com/metricfu/metric_fu/issues/36
17
+ * Gem packaged using ruby 1.9 dependencies. Learned that we cannot dynamically change dependencies for a packaged gem.
4
18
 
5
19
  === MetricFu 2.1.3.6 / 2013-01-02
6
20
 
@@ -10,7 +24,6 @@
10
24
  * Remove executable metric_fu dependency on rake
11
25
  * TODO: some unclear dependency issues may make metrics in 1.9 crash, esp Flog, Flay, Stats
12
26
 
13
-
14
27
  === MetricFu 2.1.3.5 / 2013-01-01
15
28
 
16
29
  * Issue #35, Namespace MetricFu::Table. -Benjamin Fleischer
data/README.md CHANGED
@@ -3,22 +3,27 @@ This is the official repository for metric_fu. The original repository by Jake
3
3
  __Installation__
4
4
 
5
5
  gem install metric_fu
6
-
7
- See documentation on the rubyforge page for how to customize your metrics.
8
6
 
9
- By default, you can run all metrics from the root of an app with the command `metric_fu`
7
+ If you have trouble installing the gem, try adding metric_fu to your Gemfile. You may also want to file a ticket on the issues page.
8
+
9
+ See documentation on the rubyforge page for how to customize your metrics. Otherwise, all current information is either in this repo or on the wiki.
10
+
11
+ By default, you can run all metrics from the root of an app with the command `metric_fu -r`
10
12
 
11
13
  You may also wish to use the `metricfu-metrical` fork, which will probably be merged in at some point.
12
14
 
13
15
  __Compatibility__
14
16
 
15
- It is currently testing on MRI 1.8.7 and 1.9.3
17
+ It is currently testing on MRI 1.8.7, 1.9.2, and 1.9.3
16
18
 
17
19
  * The `japgolly-Saikuro` fork and `metric_fu-roodi` fork are a part of an attempt to get metric_fu working in a modern Ruby environment, specifically compatibility with Ruby 1.9 and Bundler.
18
20
 
19
21
  * Until we can upgrade to the latest RubyParser, metric_fu will fail on parsing some 1.9 code, e.g. the new hash syntax, and possibly have issues with encodings
20
22
 
21
- * Please note that rake version 10.0.2 cannot be used, whereas 0.8.7 and 0.9.2 do work.
23
+
24
+ _Gem Badge_
25
+
26
+ [![Gem Version](https://badge.fury.io/rb/metric_fu.png)](http://badge.fury.io/rb/metric_fu)
22
27
 
23
28
 
24
29
  __CI Build Status__
@@ -41,36 +46,38 @@ This project runs [https://gemnasium.com/metricfu](https://gemnasium.com/metricf
41
46
 
42
47
  ===============================================================================
43
48
 
44
- See http://metric-fu.rubyforge.org/ for documentation, or the HISTORY file for a change log.
49
+ For documentation, in addition to this file and the wiki, there is some useful-but-out-of-date documentation about configuring metric_fu at http://metric-fu.rubyforge.org/ and a change log in the the HISTORY file.
45
50
 
46
51
  How to contribute:
47
52
 
48
53
  1. Fork metric_fu on github.
49
54
  2. bundle install
50
- 3. Run the tests ('rake')
51
- 4. Run metric_fu on itself ('rake metrics:all')
55
+ 3. Run the tests ('bundle exec rake')
56
+ 4. Run metric_fu on itself ('bundle exec metric_fu -r')
52
57
  5. Make the changes you want and back them up with tests.
53
- 6. Make sure two important rake tests still run ('rake' and 'rake metrics:all')
58
+ 6. Make sure two important rake tests still run ('bundle exec rake' and 'bundle exec rake metrics:all')
54
59
  7. Commit and send me a pull request with details as to what has been changed.
55
60
 
56
61
  Extra Credit:
57
62
 
58
63
  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)
59
- 2. Update the documentation (web page inside the 'home_page' folder)
64
+ 2. Update the documentation here or the rubyforge web page inside the `'home_page'` folder
60
65
  3. Update the History and give yourself credit.
61
66
 
62
67
 
63
68
  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.
64
69
 
70
+ Also see [Quick guide to writing good bug reports](https://github.com/metricfu/metric_fu/wiki/Issues:-Quick-guide-to-writing-good-bug-reports)
71
+
65
72
  Resources:
66
73
 
67
74
  * Github: http://github.com/metricfu/metric_fu
68
75
  * Issue Tracker: http://github.com/metricfu/metric_fu/issues
69
76
  * Google Group: http://groups.google.com/group/metric_fu
70
- * Homepage: http://metric-fu.rubyforge.org/
77
+ * Historical Homepage: http://metric-fu.rubyforge.org/
71
78
 
72
79
  Original Resources:
73
80
 
74
81
  * Github: http://github.com/jscruggs/metric_fu
75
82
  * Issue Tracker: http://github.com/jscruggs/metric_fu/issues
76
- * My Blog: http://jakescruggs.blogspot.com/
83
+ * Jake's Blog: http://jakescruggs.blogspot.com/
data/TODO.md CHANGED
@@ -1,29 +1,131 @@
1
1
  # TODO list
2
2
 
3
+ * Keep HISTORY.md in master up to date
4
+
5
+ ## Before next release
6
+
7
+ * Move code that references rcov out of
8
+
9
+ lib/metrics/hotspots/hotspot_analyzer.rb
10
+ lib/reporting/graphs/engines/bluff.rb
11
+ lib/reporting/graphs/engines/gchart.rb
12
+ lib/reporting/templates/awesome/css/default.css
13
+ lib/reporting/templates/awesome/index.html.erb
14
+ lib/reporting/templates/standard/default.css
15
+ lib/reporting/templates/standard/index.html.erb
16
+
17
+ * Move code that references flog out of
18
+
19
+ lib/configuration.rb
20
+ lib/metrics/hotspots/analysis/code_issue.rb
21
+ lib/metrics/hotspots/analysis/scoring_strategies.rb
22
+ lib/metrics/hotspots/hotspot_analyzer.rb
23
+ lib/reporting/graphs/engines/bluff.rb
24
+ lib/reporting/graphs/engines/gchart.rb
25
+ lib/reporting/templates/awesome/index.html.erb
26
+ lib/reporting/templates/standard/index.html.erb
27
+
28
+ * Move code that references flay out of
29
+
30
+ lib/metrics/generator.rb
31
+ lib/metrics/hotspots/analysis/code_issue.rb
32
+ lib/metrics/hotspots/hotspot_analyzer.rb
33
+ lib/reporting/graphs/engines/bluff.rb
34
+ lib/reporting/graphs/engines/gchart.rb
35
+ lib/reporting/templates/awesome/index.html.erb
36
+ lib/reporting/templates/standard/index.html.erb
37
+
38
+ * Move code that references churn out of
39
+
40
+ lib/metrics/hotspots/analysis/code_issue.rb
41
+ lib/metrics/hotspots/hotspot_analyzer.rb
42
+ lib/metrics/hotspots/init.rb
43
+ lib/reporting/templates/awesome/index.html.erb
44
+ lib/reporting/templates/standard/index.html.erb
45
+
46
+ * Move code that references rails_best_practices out of
47
+
48
+ lib/metrics/hotspots/analysis/code_issue.rb
49
+ lib/metrics/hotspots/hotspot_analyzer.rb
50
+ lib/reporting/graphs/engines/bluff.rb
51
+ lib/reporting/graphs/engines/gchart.rb
52
+ lib/reporting/templates/awesome/index.html.erb
53
+ lib/reporting/templates/standard/index.html.erb
54
+
55
+
56
+ * Move code that references reek out of
57
+
58
+ lib/data_structures/location.rb
59
+ lib/metrics/hotspots/analysis/code_issue.rb
60
+ lib/metrics/hotspots/analysis/scoring_strategies.rb
61
+ lib/metrics/hotspots/hotspot_analyzer.rb
62
+ lib/reporting/graphs/engines/bluff.rb
63
+ lib/reporting/graphs/engines/gchart.rb
64
+ lib/reporting/templates/awesome/index.html.erb
65
+ lib/reporting/templates/standard/index.html.erb
66
+
67
+
68
+ * Move code that references roodi out of
69
+
70
+ lib/metrics/hotspots/analysis/code_issue.rb
71
+ lib/metrics/hotspots/hotspot_analyzer.rb
72
+ lib/reporting/graphs/engines/bluff.rb
73
+ lib/reporting/graphs/engines/gchart.rb
74
+ lib/reporting/templates/awesome/index.html.erb
75
+ lib/reporting/templates/standard/index.html.erb
76
+
77
+ * Move code that references saikuro out of
78
+
79
+ lib/metrics/hotspots/analysis/code_issue.rb
80
+ lib/metrics/hotspots/hotspot_analyzer.rb
81
+ lib/reporting/templates/awesome/index.html.erb
82
+ lib/reporting/templates/standard/index.html.erb
83
+
84
+ * Move code that references stats out of
85
+
86
+ lib/reporting/graphs/engines/bluff.rb
87
+ lib/reporting/graphs/engines/gchart.rb
88
+ lib/reporting/templates/awesome/index.html.erb
89
+ lib/reporting/templates/standard/index.html.erb
90
+
91
+ * Review how metric_fu uses each tools to generate metrics, e.g. by shelling out commands, rake task, modifying the output, etc.
92
+
93
+ * Change MetricFu.report.add(metric) to e.g. MetricFu.generate_report(metric) to make clear that this actually runs the tool
94
+
95
+ * Allow the coverage task to specify the command it runs plus any flags (see bundler/capistrano options)
96
+
97
+ * Test against a rails app
3
98
 
4
99
  ## Features
5
100
 
6
- * Look into removing rcov and churn, and adding
101
+ * Remove rcov by default
102
+ * Either allow user to define a command to run a coverage task or supply a directory with coverage results. We can't predict every test setup to run coverage correctly, but we can analyze results.
103
+ * Look into getting everything to run on RubyParser ~> 3
104
+ * Look into adding
7
105
  * https://github.com/metricfu/code_statistics
8
106
  * brakeman https://github.com/metricfu/brakeman
9
107
  * cane https://github.com/square/cane
10
108
  * laser https://github.com/metricfu/laser
11
109
  * Add configurable logger to all output streams
110
+ * Allow command-line metric_fu to accept parameters, and especially output its version
12
111
  * Color code flog results with scale from: http://jakescruggs.blogspot.com/2008/08/whats-good-flog-score.html
13
112
  * Make running metric_fu on metric_fu less embarrassing
14
113
  * Load all gems at config time so you fail fast if one is missing
114
+ * Refactor the hotspots code
115
+
15
116
 
16
117
  ## Testing
17
118
 
18
119
  * Determine how to test metric_fu against codebases that are not metric_fu, to ensure it works on most applications
19
- * Re-organize test files structure to align with changed structure of library files
120
+ * This is especially true for rails applications
121
+ * <strike>Re-organize test files structure to align with changed structure of library files</strike>
20
122
  * Remove / Modify Devver code from the generators/hotspots_spec and base/hotspot_analzyer_spec
21
- * Don't leave around test artifacts such as the folders './foo' and './is set'
123
+ * <strike>Don't leave around test artifacts such as the folders './foo' and './is set'</strike>
22
124
 
23
125
  ## Bugs / Fixes
24
126
 
25
127
  * Fix occasional gem install metric_fu failures such as with ripper in Ruby 1.9
26
- * Fork roodi and correct the yaml
128
+ * <strike>Fork roodi and correct the yaml</strike>
27
129
  * See https://github.com/metricfu/metric_fu/issues/2 about updating gems
28
130
 
29
131
  ## Ruby 1.9 compatibility
@@ -34,10 +136,22 @@
34
136
  ## Misc
35
137
 
36
138
  * Determine if CodeIssue is used, else remove it
37
- * Update the homepage http://metric-fu.rubyforge.org/
139
+ * Remove references to Ruport from the Devver / Caliper code
140
+ * Update or move the homepage http://metric-fu.rubyforge.org/
141
+ * Is there any reason not to remove the Manifest.txt?
142
+ * See other documentation code for examples to improve ours:
143
+ * https://github.com/charliesome/better_errors/blob/master/CONTRIBUTING.md
144
+ * https://github.com/charliesome/better_errors/blob/master/README.md
38
145
  * Other intersting libraries to consider:
146
+ * https://gist.github.com/4562865 for generating Flog on ERB templates by jamesmartin
147
+ * https://github.com/chad/turbulence churn and complexity (flog)
39
148
  * https://github.com/vinibaggio/discover-unused-partials
40
- * https://github.com/metricfu/heckle
149
+ * https://github.com/metricfu/heckle (test mutation)
150
+ * https://github.com/mbj/mutant (test mutation)
41
151
  * https://github.com/metricfu/gauntlet
42
- * https://github.com/metricfu/repodepot-ruby
152
+ * https://github.com/metricfu/repodepot-ruby https://twitter.com/jakescruggs/status/70521977303076865
43
153
  * https://github.com/eladmeidar/rails_indexes
154
+ * https://github.com/trptcolin/consistency_fail
155
+ * https://github.com/thoughtbot/appraisal
156
+ * https://github.com/jenkinsci/rubymetrics-plugin
157
+ * https://github.com/holman/hopper
data/bin/metric_fu CHANGED
@@ -1,2 +1,134 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),'..','lib','metric_fu'))
2
- MetricFu::Run.new.run
1
+ #!/usr/bin/env ruby
2
+ require 'metric_fu'
3
+ require 'optparse'
4
+
5
+ # see https://github.com/grosser/pru/blob/master/bin/pru
6
+ module MetricFu
7
+ class CLIHelper
8
+ def initialize
9
+ @metric_fu = MetricFu::Run.new
10
+ end
11
+ def run
12
+ @metric_fu.run
13
+ complete
14
+ end
15
+ def version
16
+ MetricFu::VERSION
17
+ end
18
+ def shutdown
19
+ out "\nShuting down. Bye"
20
+ exit(1)
21
+ end
22
+ def banner
23
+ "MetricFu: A Fistful of code metrics"
24
+ end
25
+ def usage
26
+ <<-EOS
27
+ #{banner}
28
+ Use --help for help
29
+ EOS
30
+
31
+ end
32
+ def executable_name
33
+ 'metric_fu'
34
+ end
35
+ private
36
+ def out(text)
37
+ STDOUT.puts text
38
+ end
39
+ def error(text)
40
+ STDERR.puts text
41
+ end
42
+ def complete
43
+ out "all done"
44
+ exit(0)
45
+ end
46
+ end
47
+ end
48
+ cli = MetricFu::CLIHelper.new
49
+ # see http://obtiva.com/blog/185-fun-with-ruby-it-s-a-trap
50
+ trap("INT") { cli.shutdown }
51
+
52
+ require 'optparse'
53
+ # see https://github.com/florianpilz/CLI-Option-Parser-Examples
54
+ # https://raw.github.com/florianpilz/micro-optparse/master/lib/micro-optparse/parser.rb
55
+ module MicroOptParse
56
+ class Parser
57
+ attr_accessor :banner, :version
58
+ def initialize
59
+ @options = []
60
+ @used_short = []
61
+ @default_values = nil
62
+ yield self if block_given?
63
+ end
64
+
65
+ def option(name, desc, settings = {})
66
+ @options << [name, desc, settings]
67
+ end
68
+
69
+ def short_from(name)
70
+ name.to_s.chars.each do |c|
71
+ next if @used_short.include?(c) || c == "_"
72
+ return c # returns from short_from method
73
+ end
74
+ end
75
+
76
+ def validate(options) # remove this method if you want fewer lines of code and don't need validations
77
+ options.each_pair do |key, value|
78
+ opt = @options.find_all{ |o| o[0] == key }.first
79
+ key = "--" << key.to_s.gsub("_", "-")
80
+ unless opt[2][:value_in_set].nil? || opt[2][:value_in_set].include?(value)
81
+ puts "Parameter for #{key} must be in [" << opt[2][:value_in_set].join(", ") << "]" ; exit(1)
82
+ end
83
+ unless opt[2][:value_matches].nil? || opt[2][:value_matches] =~ value
84
+ puts "Parameter for #{key} must match /" << opt[2][:value_matches].source << "/" ; exit(1)
85
+ end
86
+ unless opt[2][:value_satisfies].nil? || opt[2][:value_satisfies].call(value)
87
+ puts "Parameter for #{key} must satisfy given conditions (see description)" ; exit(1)
88
+ end
89
+ end
90
+ end
91
+
92
+ def process!(arguments = ARGV)
93
+ @result = (@default_values || {}).clone # reset or new
94
+ @optionparser ||= OptionParser.new do |p| # prepare only once
95
+ @options.each do |o|
96
+ @used_short << short = o[2][:short] || short_from(o[0])
97
+ @result[o[0]] = o[2][:default] || false # set default
98
+ klass = o[2][:default].class == Fixnum ? Integer : o[2][:default].class
99
+
100
+ if [TrueClass, FalseClass, NilClass].include?(klass) # boolean switch
101
+ p.on("-" << short, "--[no-]" << o[0].to_s.gsub("_", "-"), o[1]) {|x| @result[o[0]] = x}
102
+ else # argument with parameter
103
+ p.on("-" << short, "--" << o[0].to_s.gsub("_", "-") << " " << o[2][:default].to_s, klass, o[1]) {|x| @result[o[0]] = x}
104
+ end
105
+ end
106
+
107
+ p.banner = @banner unless @banner.nil?
108
+ p.on_tail("-h", "--help", "Show this message") {puts p ; exit}
109
+ short = @used_short.include?("v") ? "-V" : "-v"
110
+ p.on_tail(short, "--version", "Print version") {puts @version ; exit} unless @version.nil?
111
+ @default_values = @result.clone # save default values to reset @result in subsequent calls
112
+ end
113
+
114
+ begin
115
+ @optionparser.parse!(arguments)
116
+ rescue OptionParser::ParseError => e
117
+ puts e.message ; exit(1)
118
+ end
119
+
120
+ validate(@result) if self.respond_to?("validate")
121
+ @result
122
+ end
123
+ end
124
+ end
125
+ options = MicroOptParse::Parser.new do |p|
126
+ p.banner = cli.banner
127
+ p.version = cli.version
128
+ p.option :run, "Run all metrics with defaults"
129
+ end.process!
130
+ if options[:run]
131
+ cli.run
132
+ else
133
+ STDOUT.puts cli.usage
134
+ end
data/lib/metric_fu.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module MetricFu
2
2
  APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__),'..'))
3
- LIB_ROOT = File.join(APP_ROOT,'lib')
3
+ LIB_ROOT = File.join(APP_ROOT,'lib/metric_fu')
4
4
  @loaded_files = []
5
5
  class << self
6
6
  attr_reader :loaded_files
@@ -40,6 +40,13 @@ module MetricFu
40
40
  def self.artifact_dir
41
41
  (ENV['CC_BUILD_ARTIFACTS'] || 'tmp/metric_fu')
42
42
  end
43
+ def self.configure
44
+ MetricFu.lib_require { 'configuration' }
45
+ Dir.glob(File.join(MetricFu.metrics_dir, '**/init.rb')).each do |file|
46
+ load file
47
+ end
48
+ MetricFu.configuration
49
+ end
43
50
  class << self
44
51
  %w(scratch output _data).each do |dir|
45
52
  define_method("#{dir.gsub(/[^A-Za-z0-9]/,'')}_dir") do