bf4-metric_fu 2.1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data/HISTORY +252 -0
  2. data/MIT-LICENSE +22 -0
  3. data/README.md +49 -0
  4. data/Rakefile +22 -0
  5. data/TODO +6 -0
  6. data/lib/base/base_template.rb +182 -0
  7. data/lib/base/churn_analyzer.rb +38 -0
  8. data/lib/base/code_issue.rb +100 -0
  9. data/lib/base/configuration.rb +219 -0
  10. data/lib/base/flay_analyzer.rb +50 -0
  11. data/lib/base/flog_analyzer.rb +43 -0
  12. data/lib/base/generator.rb +166 -0
  13. data/lib/base/graph.rb +44 -0
  14. data/lib/base/grouping.rb +42 -0
  15. data/lib/base/line_numbers.rb +79 -0
  16. data/lib/base/location.rb +87 -0
  17. data/lib/base/md5_tracker.rb +52 -0
  18. data/lib/base/metric_analyzer.rb +331 -0
  19. data/lib/base/ranking.rb +34 -0
  20. data/lib/base/rcov_analyzer.rb +43 -0
  21. data/lib/base/record.rb +43 -0
  22. data/lib/base/reek_analyzer.rb +164 -0
  23. data/lib/base/report.rb +110 -0
  24. data/lib/base/roodi_analyzer.rb +37 -0
  25. data/lib/base/saikuro_analyzer.rb +48 -0
  26. data/lib/base/scoring_strategies.rb +29 -0
  27. data/lib/base/stats_analyzer.rb +37 -0
  28. data/lib/base/table.rb +108 -0
  29. data/lib/generators/churn.rb +28 -0
  30. data/lib/generators/flay.rb +31 -0
  31. data/lib/generators/flog.rb +113 -0
  32. data/lib/generators/hotspots.rb +52 -0
  33. data/lib/generators/rails_best_practices.rb +53 -0
  34. data/lib/generators/rcov.rb +124 -0
  35. data/lib/generators/reek.rb +81 -0
  36. data/lib/generators/roodi.rb +35 -0
  37. data/lib/generators/saikuro.rb +259 -0
  38. data/lib/generators/stats.rb +58 -0
  39. data/lib/graphs/engines/bluff.rb +113 -0
  40. data/lib/graphs/engines/gchart.rb +157 -0
  41. data/lib/graphs/flay_grapher.rb +18 -0
  42. data/lib/graphs/flog_grapher.rb +57 -0
  43. data/lib/graphs/grapher.rb +11 -0
  44. data/lib/graphs/rails_best_practices_grapher.rb +19 -0
  45. data/lib/graphs/rcov_grapher.rb +18 -0
  46. data/lib/graphs/reek_grapher.rb +30 -0
  47. data/lib/graphs/roodi_grapher.rb +18 -0
  48. data/lib/graphs/stats_grapher.rb +20 -0
  49. data/lib/metric_fu.rb +80 -0
  50. data/lib/tasks/metric_fu.rake +36 -0
  51. data/lib/templates/awesome/awesome_template.rb +92 -0
  52. data/lib/templates/awesome/churn.html.erb +58 -0
  53. data/lib/templates/awesome/css/buttons.css +82 -0
  54. data/lib/templates/awesome/css/default.css +91 -0
  55. data/lib/templates/awesome/css/integrity.css +334 -0
  56. data/lib/templates/awesome/css/reset.css +7 -0
  57. data/lib/templates/awesome/css/syntax.css +19 -0
  58. data/lib/templates/awesome/flay.html.erb +34 -0
  59. data/lib/templates/awesome/flog.html.erb +55 -0
  60. data/lib/templates/awesome/hotspots.html.erb +62 -0
  61. data/lib/templates/awesome/index.html.erb +34 -0
  62. data/lib/templates/awesome/layout.html.erb +30 -0
  63. data/lib/templates/awesome/rails_best_practices.html.erb +27 -0
  64. data/lib/templates/awesome/rcov.html.erb +42 -0
  65. data/lib/templates/awesome/reek.html.erb +40 -0
  66. data/lib/templates/awesome/roodi.html.erb +27 -0
  67. data/lib/templates/awesome/saikuro.html.erb +71 -0
  68. data/lib/templates/awesome/stats.html.erb +51 -0
  69. data/lib/templates/javascripts/bluff-min.js +1 -0
  70. data/lib/templates/javascripts/excanvas.js +35 -0
  71. data/lib/templates/javascripts/js-class.js +1 -0
  72. data/lib/templates/standard/churn.html.erb +31 -0
  73. data/lib/templates/standard/default.css +64 -0
  74. data/lib/templates/standard/flay.html.erb +34 -0
  75. data/lib/templates/standard/flog.html.erb +57 -0
  76. data/lib/templates/standard/hotspots.html.erb +54 -0
  77. data/lib/templates/standard/index.html.erb +41 -0
  78. data/lib/templates/standard/rails_best_practices.html.erb +29 -0
  79. data/lib/templates/standard/rcov.html.erb +43 -0
  80. data/lib/templates/standard/reek.html.erb +42 -0
  81. data/lib/templates/standard/roodi.html.erb +29 -0
  82. data/lib/templates/standard/saikuro.html.erb +84 -0
  83. data/lib/templates/standard/standard_template.rb +27 -0
  84. data/lib/templates/standard/stats.html.erb +55 -0
  85. data/spec/base/base_template_spec.rb +194 -0
  86. data/spec/base/configuration_spec.rb +277 -0
  87. data/spec/base/generator_spec.rb +223 -0
  88. data/spec/base/graph_spec.rb +61 -0
  89. data/spec/base/line_numbers_spec.rb +62 -0
  90. data/spec/base/location_spec.rb +127 -0
  91. data/spec/base/md5_tracker_spec.rb +57 -0
  92. data/spec/base/metric_analyzer_spec.rb +452 -0
  93. data/spec/base/ranking_spec.rb +42 -0
  94. data/spec/base/report_spec.rb +146 -0
  95. data/spec/base/table_spec.rb +36 -0
  96. data/spec/generators/churn_spec.rb +41 -0
  97. data/spec/generators/flay_spec.rb +105 -0
  98. data/spec/generators/flog_spec.rb +70 -0
  99. data/spec/generators/hotspots_spec.rb +88 -0
  100. data/spec/generators/rails_best_practices_spec.rb +52 -0
  101. data/spec/generators/rcov_spec.rb +180 -0
  102. data/spec/generators/reek_spec.rb +134 -0
  103. data/spec/generators/roodi_spec.rb +24 -0
  104. data/spec/generators/saikuro_spec.rb +74 -0
  105. data/spec/generators/stats_spec.rb +74 -0
  106. data/spec/graphs/engines/bluff_spec.rb +19 -0
  107. data/spec/graphs/engines/gchart_spec.rb +156 -0
  108. data/spec/graphs/flay_grapher_spec.rb +56 -0
  109. data/spec/graphs/flog_grapher_spec.rb +108 -0
  110. data/spec/graphs/rails_best_practices_grapher_spec.rb +61 -0
  111. data/spec/graphs/rcov_grapher_spec.rb +56 -0
  112. data/spec/graphs/reek_grapher_spec.rb +65 -0
  113. data/spec/graphs/roodi_grapher_spec.rb +56 -0
  114. data/spec/graphs/stats_grapher_spec.rb +68 -0
  115. data/spec/resources/line_numbers/foo.rb +33 -0
  116. data/spec/resources/line_numbers/module.rb +11 -0
  117. data/spec/resources/line_numbers/module_surrounds_class.rb +15 -0
  118. data/spec/resources/line_numbers/two_classes.rb +11 -0
  119. data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
  120. data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
  121. data/spec/resources/saikuro/index_cyclo.html +155 -0
  122. data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +11 -0
  123. data/spec/resources/yml/20090630.yml +7922 -0
  124. data/spec/resources/yml/metric_missing.yml +1 -0
  125. data/spec/spec.opts +6 -0
  126. data/spec/spec_helper.rb +7 -0
  127. metadata +560 -0
data/HISTORY ADDED
@@ -0,0 +1,252 @@
1
+ === MetricFu 2.1.3 / 2012-10-25
2
+
3
+ * Added to rubygems.org as bf-metric_fu -Benjamin Fleischer
4
+ * Added to travis-ci -Benjamin Fleischer
5
+ * Re-enabling Saikuro for ruby 1.9 with jpgolly's gem jpgolly-Saikuro -Benjamin Fleischer
6
+ * Ensured files are only loaded once -Benjamin Fleischer
7
+ * Looked at moving to simplecov-rcov, but was unsuccessful -Benjamin Fleischer
8
+ * Fixed breaking tests, deprecation warnings -Benjamin Fleischer
9
+
10
+ === MetricFu 2.1.2 / 2012-09-05
11
+
12
+ * Getting it working on Rails 3, partly by going through the pull requests and setting gem dependencies to older, working versions - Benjamin Fleischer
13
+ * It mostly works on Ruby 1.9, though there is an unresolved sexp_parser issue - Benjamin Fleischer
14
+ * Added link_prefix to configuration to allow URIs specified in config instead of file or txmt - dan sinclair
15
+
16
+ === MetricFu 2.1.1 / 2011-03-2
17
+
18
+ * Making syntax highlighting optional (config.syntax_highlighting = false) so Ruby 1.9.2 users don't get "invalid byte sequence in UTF-8" errors.
19
+
20
+ === MetricFu 2.1.0 / 2011-03-1
21
+
22
+ * Flog gemspec version was >= 2.2.0, which was too early and didn't work. Changed to >= 2.3.0 - Chris Griego
23
+ * RCov generator now uses a regex with begin and end line anchor to avoid splitting on comments with equal signs in source files - Andrew Selder
24
+ * RCov generator now always strips the 3 leading characters from the lines when reconstruction source files so that heredocs and block comments parse successfully - Andrew Selder
25
+ * Dan Mayer ported some specs for the Hotspots code into MetricFu from Caliper's code.
26
+ * Stefan Huber fixed some problems with churn pretending not to support Svn.
27
+ * Kakutani Shintaro added the ability to opt out of opening files with TextMate (config.darwin_txmt_protocol_no_thanks = true).
28
+ * Joel Nimety and Andrew Selder fixed a problem where Saikuro was parsing a dir twice.
29
+ * Dan Sinclair added some awesome 'annotate' functionality to the Hotspots page. Click on it so see the file with problems in-line.
30
+ * Dan Sinclair added a verbose mode (config.verbose = true).
31
+
32
+ === MetricFu 2.0.1 / 2010-11-13
33
+
34
+ * Delete trailing whitespaces - Delwyn de Villiers
35
+ * Stop Ubuntu choking on invalid multibyte char (US-ASCII) - Delwyn de Villiers
36
+ * Fix invalid next in lib/base/metric_analyzer.rb - Delwyn de Villiers
37
+ * Don't load Saikuro for Ruby 1.9.2 - Delwyn de Villiers
38
+ * Fixed a bug reported by Andrew Davis on the mailing list where configuring the data directory causes dates to be 0/0 - Joshua Cronemeyer
39
+
40
+ === MetricFu 2.0.0 / 2010-11-10
41
+
42
+ * Hotspots - Dan Mayer, Ben Brinckerhoff, Jake Scruggs
43
+ * Rcov integration with Hotspots - Jake Scruggs, Tony Castiglione, Rob Meyer
44
+
45
+ === MetricFu 1.5.1 / 2010-7-28
46
+
47
+ * Patch that allows graphers to skip dates that didn't generate metrics for that graph (GitHub Issue #20). - Chris Griego
48
+ * Fixed bug where if you try and use the gchart grapher with the rails_best_practices metric, it blows up (GitHub Issue #23). - Chris Griego
49
+ * Fixed 'If coverage is 0% metric_fu will explode' bug (GitHub Issue #6). - Stew Welbourne
50
+
51
+ === MetricFu 1.5.0 / 2010-7-27
52
+
53
+ * Fixed bug where Flay results were not being reported. Had to remove the ability to remove selected files from flay processing (undocumented feature that may go away soon if it keeps causing problems).
54
+ * Rewrote Flog parsing/processing to use Flog programmatically. Note: the yaml output for Flog has changed significantly - Pages have now become MethodContainers. This probably doesn't matter to you if you are not consuming the metric_fu yaml output.
55
+ * Added support for using config files in Reek and Roodi (roodi support was already there but undocumented).
56
+ * Removed verify_dependencies! as it caused too much confusion to justify the limited set of problems it solved. In the post Bundler world it just didn't seem necessary to limit metric_fu dependencies.
57
+ * Deal with Rails 3 activesupport vs active_support problems. - jinzhu
58
+
59
+ === MetricFu 1.4.0 / 2010-06-19
60
+
61
+ * Added support for rails_best_practices gem - Richard Huang
62
+ * Added rails stats graphing -- Josh Cronemeyer
63
+ * Parameterize the filetypes for flay. By default flay supports haml as well as rb and has a plugin ability for other filetypes. - bfabry
64
+ * Support for Flog 2.4.0 line numbers - Dan Mayer
65
+ * Saikuro multi input directory patch - Spencer Dillard and Dan Mayer
66
+ * Can now parse rcov analysis file coming from multiple sources with an rcov :external option in the config. - Tarsoly András
67
+ * Fixed open file handles problem in the Saikuro analyzer - aselder, erebor
68
+ * Fix some problems with the google charts - Chris Griego
69
+ * Stop showing the googlecharts warning if you are not using google charts.
70
+
71
+ === MetricFu 1.3.0 / 2010-01-26
72
+
73
+ * Flay can be configured to ignore scores below a threshold (by default it ignores scores less than 100)
74
+ * When running Rcov you can configure the RAILS_ENV (defaults to 'test') so running metric_fu doesn't interfere with other environments
75
+ * Changed devver-construct (a gem hosted by GitHub) development dependency to test-construct dependency (on Gemcutter) - Dan Mayer
76
+ * Upgrade Bluff to 0.3.6 and added tooltips to graphs - Édouard Brière
77
+ * Removed Saikuro from vendor and added it as a gem dependency - Édouard Brière
78
+ * Churn has moved outside metric_fu and is now a gem and a dependency - Dan Mayer
79
+ * Fix 'activesupport' deprecation (it should be 'active_support') - Bryan Helmkamp
80
+ * Declared development dependencies
81
+ * Cleaned and sped up specs
82
+
83
+ === MetricFu 1.2.0 / 2010-01-09
84
+
85
+ * ftools isn't supported by 1.9 so moved to fileutils.
86
+ * Overhauled the graphing to use Gruff or Google Charts so we no longer depend on ImageMagick/rmagick -- thanks to Carl Youngblood.
87
+ * Stopped relying on Github gems as they will be going away.
88
+
89
+ === MetricFu 1.1.6 / 2009-12-14
90
+
91
+ * Now compatible with Reek 1.2x thanks to Kevin Rutherford
92
+ * Fixed problem with deleted files still showing up in Flog reports thanks to Dan Mayer
93
+
94
+ === MetricFu 1.1.5 / 2009-8-13
95
+
96
+ * Previous Ruby 1.9 fix was not quite fix-y enough
97
+
98
+ === MetricFu 1.1.4 / 2009-7-13
99
+
100
+ * Fixed another Ruby 1.9x bug
101
+
102
+ === MetricFu 1.1.3 / 2009-7-10
103
+
104
+ * MetricFu is now Ruby 1.9x compatible
105
+ * Removed the check for deprecated ways of configuring metric_fu as the tests were causing Ruby 1.9x problems and it's been forever since they were supported.
106
+ * Removed total flog score from graph (which will always go up and so doesn't mean much) and replacing it with top_five_percent_average which is an average of the worst 5 percent of your methods.
107
+ * Sort Flog by highest score in the class which I feel is more important than the total flog flog score.
108
+
109
+ === MetricFu 1.1.2 / 2009-7-09
110
+
111
+ * Removed dependency on gruff and rmagick (unless the user wants graphs, of course).
112
+ * New look for styling -- Edouard Brière
113
+ * Extra param in rcov call was causing problems -- Stewart Welbourne
114
+ * Preventing rake task from being run multiple times when other rake tasks switch the environment -- Matthew Van Horn
115
+ * Typo in Rcov dependency verification and fixing parsing Saikuro nested information -- Mark Wilden
116
+
117
+ === MetricFu 1.1.1 / 2009-6-29
118
+
119
+ * Fix for empty flog files
120
+
121
+ === MetricFu 1.1.0 / 2009-6-22
122
+
123
+ * Flog, flay, reek, roodi, and rcov reports now graph progress over time. Well done Nick Quaranto and Edouard Brière.
124
+ * 'Awesome' template has been brought in so that reports look 90% less 'ghetto.' Also done by Nick Quaranto and Edouard Brière.
125
+ * Added links to TextMate (which keep getting removed. Probably by me. Sorry.) -- David Chelimsky
126
+ * Fixed a bug for scratch files which have a size of 0 -- Kevin Hall
127
+ * Changed gem dependencies from install-time in gemspec to runtime when each of the generators is loaded. This allows use of github gems (i.e. relevance-rcov instead of rcov) and also allows you to install only the gems for the metrics you plan on using. -- Alex Rothenberg
128
+ * Empty Flog file fix -- Adam Bair
129
+ * Added a simple fix for cases where Saikuro results with nested information -- Randy Souza
130
+ * Fixed rcov configuration so it ignores library files on Linux -- Diego Carrion
131
+ * Changing churn so that it still works deeper than the git root directory -- Andrew Timberlake
132
+ * Andrew Timberlake also made some nice changes to the base template which kinda of got overshadowed by the 'awesome' template. Sorry about that Andrew.
133
+
134
+ === MetricFu 1.0.2 / 2009-5-11
135
+
136
+ * Fixing problems with Reek new line character (thanks to all who pointed this out)
137
+ * Flog now recognizes namespaces in method names thanks to Daniel Guettler
138
+ * Saikuro now looks at multiple directories, again.
139
+
140
+ === MetricFu 1.0.1 / 2009-5-3
141
+
142
+ * metrics:all task no longer requires a MetricFu::Configuration.run {} if you want to accept the defaults
143
+ * rcov task now reports total coverage percent
144
+
145
+ === MetricFu 1.0.0 / 2009-4-30
146
+
147
+ * Merged in Grant McInnes' work on creating yaml output for all metrics to aid harvesting by other tools
148
+ * Supporting Flog 2.1.0
149
+ * Supporting Reek 1.0.0
150
+ * Removed dependency on Rails Env for 3.months.ago (for churn report), now using chronic gem ("3 months ago").
151
+ * Almost all code is out of Rakefiles now and so is more easily testable
152
+ * Metrics inherit from a refactored Generator now. New metrics generators just have to implement "emit", "analyze", "to_h" and inherit from Generator. They also must have a template. See the flay generator and template for a simple implementation.
153
+ * You now define the metrics you wish to run in the configuration and then run "metrics:all". No other metrics task is exposed by default.
154
+
155
+ === MetricFu 0.9.0 / 2009-1-25
156
+
157
+ * Adding line numbers to the views so that people viewing it on cc.rb can figure out where the problems are
158
+ * Merging in changes from Jay Zeschin having to do with the railroad task -- I still have no idea how to use it (lemme know if you figure it out)
159
+ * Added totals to Flog results
160
+ * Moved rcov options to configuration
161
+
162
+ === MetricFu 0.8.9 / 2009-1-20
163
+
164
+ * Thanks to Andre Arko and Petrik de Heus for adding the following features:
165
+ * The source control type is auto-detected for Churn
166
+ * Moved all presentation to templates
167
+ * Wrote specs for all classes
168
+ * Added flay, Reek and Roodi metrics
169
+ * There's now a configuration class (see README for details)
170
+ * Unification of metrics reports
171
+ * Metrics can be generated using one command
172
+ * Adding new metrics reports has been standardized
173
+
174
+ === MetricFu 0.8.0 / 2008-10-06
175
+
176
+ * Source Control Churn now supports git (thanks to Erik St Martin)
177
+ * Flog Results are sorted by Highest Flog Score
178
+ * Fix for a bunch of 'already initialized constant' warnings that metric_fu caused
179
+ * Fixing bug so the flog reporter can handle methods with digits in the name (thanks to Andy Gregorowicz)
180
+ * Internal Rake task now allows metric_fu to flog/churn itself
181
+
182
+ === MetricFu 0.7.6 / 2008-09-15
183
+
184
+ * CHURN_OPTIONS has become MetricFu::CHURN_OPTIONS
185
+ * SAIKURO_OPTIONS has become MetricFu::SAIKURO_OPTIONS
186
+ * Rcov now looks at test and specs
187
+ * Exclude gems and Library ruby code from rcov
188
+ * Fixed bug with churn start_date functionality (bad path)
189
+
190
+ === MetricFu 0.7.5 / 2008-09-12
191
+
192
+ * Flog can now flog any set of directories you like (see README).
193
+ * Saikuro can now look at any set of directories you like (see README).
194
+
195
+ === MetricFu 0.7.1 / 2008-09-12
196
+
197
+ * Fixed filename bugs pointed out by Bastien
198
+
199
+ === MetricFu 0.7.0 / 2008-09-11
200
+
201
+ * Merged in Sean Soper's changes to metric_fu.
202
+ * Metric_fu is now a gem.
203
+ * Flogging now uses a MD5 hash to figure out if it should re-flog a file (if it's changed)
204
+ * Flogging also has a cool new output screen(s)
205
+ * Thanks Sean!
206
+
207
+ === Metricks 0.4.2 / 2008-07-01
208
+
209
+ * Changed rcov output directory so that it is no longer 'coverage/unit' but just 'coverage' for better integration with CC.rb
210
+
211
+ === Metricks 0.4.1 / 2008-06-13
212
+
213
+ * Rcov tests now extend beyond one level depth directory by using RcovTask instead of the shell
214
+
215
+ === Metricks 0.4.0 / 2008-06-13
216
+
217
+ * Implementing functionality for use as a gem
218
+ * Added Rakefile to facilitate testing
219
+
220
+ === Metricks 0.3.0 / 2008-06-11
221
+
222
+ * Generated reports now open on darwin automatically
223
+ * Generated reports reside under tmp/metricks unless otherwise specified by ENV['CC_BUILD_ARTIFACTS']
224
+ * MD5Tracker works with Flog reports for speed optimization
225
+
226
+ === Metricks 0.2.0 / 2008-06-11
227
+
228
+ * Integrated use of base directory constant
229
+ * Have all reports automatically open in a browser if platform is darwin
230
+ * Namespaced under Metricks
231
+ * Dropped use of shell md5 command in favor of Ruby's Digest::MD5 libraries
232
+
233
+ === Metricks 0.1.0 / 2008-06-10
234
+
235
+ * Initial integration of metric_fu and my enhancements to flog
236
+ * Metrics are generated but are all over the place
237
+
238
+ === MetricFu 0.6.0 / 2008-05-11
239
+
240
+ * Add source control churn report
241
+
242
+ === MetricFu 0.5.1 / 2008-04-25
243
+
244
+ * Fixed bug with Saikuro report generation - thanks Toby Tripp
245
+
246
+ === MetricFu 0.5.0 / 2008-04-25
247
+
248
+ * create MetricFu as a Rails Plugin
249
+ * Add Flog Report
250
+ * Add Coverage Report
251
+ * Add Saikuro Report
252
+ * Add Stats Report
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008,2009,2010,2011 Jake Scruggs
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
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
+ The japgolly-Saikuro fork is a part of an attempt to get metric_fu working in a modern
6
+ Ruby environment, specifically compatibility with Ruby 1.9 and Bundler.
7
+
8
+ __CI Build Status__
9
+
10
+ [![Build Status](https://secure.travis-ci.org/bf4/metric_fu.png)](http://travis-ci.org/bf4/metric_fu)
11
+
12
+ This project runs [travis-ci.org](http://travis-ci.org)
13
+
14
+ ===============================================================================
15
+
16
+ See http://metric-fu.rubyforge.org/ for documentation, or the HISTORY file for a change log.
17
+
18
+ How to contribute:
19
+
20
+ 1. Fork metric_fu on github.
21
+ 2. bundle install
22
+ 3. Run the tests ('rake')
23
+ 4. Run metric_fu on itself ('rake metrics:all')
24
+ 5. Make the changes you want and back them up with tests.
25
+ 6. Make sure two important rake tests still run ('rake' and 'rake metrics:all')
26
+ 7. Commit and send me a pull request with details as to what has been changed.
27
+
28
+ Extra Credit:
29
+
30
+ 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)
31
+ 2. Update the documentation (web page inside the 'home_page' folder)
32
+ 3. Update the History and give yourself credit.
33
+
34
+
35
+ 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.
36
+
37
+ Resources:
38
+
39
+ Github: http://github.com/bf4/metric_fu
40
+ Issue Tracker: http://github.com/bf4/metric_fu/issues
41
+ My Blog: http://benjaminfleischer.com
42
+
43
+ Original Resources:
44
+
45
+ Homepage: http://metric-fu.rubyforge.org/
46
+ Github: http://github.com/jscruggs/metric_fu
47
+ Google Group: http://groups.google.com/group/metric_fu
48
+ Issue Tracker: http://github.com/jscruggs/metric_fu/issues
49
+ My Blog: http://jakescruggs.blogspot.com/
@@ -0,0 +1,22 @@
1
+ $LOAD_PATH << '.'
2
+ begin
3
+ require 'spec/rake/spectask'
4
+ desc "Run all specs in spec directory"
5
+ Spec::Rake::SpecTask.new(:spec) do |t|
6
+ t.spec_files = FileList['spec/**/*_spec.rb']
7
+ end
8
+ rescue LoadError
9
+ require 'rspec/core/rake_task'
10
+ desc "Run all specs in spec directory"
11
+ RSpec::Core::RakeTask.new(:spec)
12
+ end
13
+
14
+ require File.expand_path File.join(File.dirname(__FILE__),'lib/metric_fu')
15
+
16
+ MetricFu::Configuration.run do |config|
17
+ config.roodi = config.roodi.merge(:roodi_config => 'config/roodi_config.yml')
18
+ config.churn = { :start_date => "1 year ago", :minimum_churn_count => 10}
19
+ config.hotspots = { :start_date => "1 year ago", :minimum_churn_count => 10}
20
+ end
21
+
22
+ task :default => :spec
data/TODO ADDED
@@ -0,0 +1,6 @@
1
+ == TODO list
2
+
3
+ * Color code flog results with scale from: http://jakescruggs.blogspot.com/2008/08/whats-good-flog-score.html
4
+ * Make running metric_fu on metric_fu less embarrassing
5
+ * Load all gems at config time so you fail fast if one is missing
6
+
@@ -0,0 +1,182 @@
1
+ module MetricFu
2
+
3
+ # The Template class is intended as an abstract class for concrete
4
+ # template classes to subclass. It provides a variety of utility
5
+ # methods to make templating a bit easier. However, classes do not
6
+ # have to inherit from here in order to provide a template. The only
7
+ # requirement for a template class is that it provides a #write method
8
+ # to actually write out the template. See StandardTemplate for an
9
+ # example.
10
+ class Template
11
+ attr_accessor :report, :per_file_data
12
+
13
+ private
14
+ # Creates a new erb evaluated result from the passed in section.
15
+ #
16
+ # @param section String
17
+ # The section name of
18
+ #
19
+ # @return String
20
+ # The erb evaluated string
21
+ def erbify(section)
22
+ require 'erb'
23
+ erb_doc = File.read(template(section))
24
+ ERB.new(erb_doc).result(binding)
25
+ end
26
+
27
+ # Determines whether a template file exists for a given section
28
+ # of the full template.
29
+ #
30
+ # @param section String
31
+ # The section of the template to check against
32
+ #
33
+ # @return Boolean
34
+ # Does a template file exist for this section or not?
35
+ def template_exists?(section)
36
+ File.exist?(template(section))
37
+ end
38
+
39
+ # Copies an instance variable mimicing the name of the section
40
+ # we are trying to render, with a value equal to the passed in
41
+ # constant. Allows the concrete template classes to refer to
42
+ # that instance variable from their ERB rendering
43
+ #
44
+ # @param section String
45
+ # The name of the instance variable to create
46
+ #
47
+ # @param contents Object
48
+ # The value to set as the value of the created instance
49
+ # variable
50
+ def create_instance_var(section, contents)
51
+ instance_variable_set("@#{section}", contents)
52
+ end
53
+
54
+ # Generates the filename of the template file to load and
55
+ # evaluate. In this case, the path to the template directory +
56
+ # the section name + .html.erb
57
+ #
58
+ # @param section String
59
+ # A section of the template to render
60
+ #
61
+ # @return String
62
+ # A file path
63
+ def template(section)
64
+ File.join(this_directory, section.to_s + ".html.erb")
65
+ end
66
+
67
+ # Returns the filename that the template will render into for
68
+ # a given section. In this case, the section name + '.html'
69
+ #
70
+ # @param section String
71
+ # A section of the template to render
72
+ #
73
+ # @return String
74
+ # The output filename
75
+ def output_filename(section)
76
+ section.to_s + ".html"
77
+ end
78
+
79
+ # Returns the contents of a given css file in order to
80
+ # render it inline into a template.
81
+ #
82
+ # @param css String
83
+ # The name of a css file to open
84
+ #
85
+ # @return String
86
+ # The contents of the css file
87
+ def inline_css(css)
88
+ open(File.join(this_directory, css)) { |f| f.read }
89
+ end
90
+
91
+ # Provides a link to open a file through the textmate protocol
92
+ # on Darwin, or otherwise, a simple file link.
93
+ #
94
+ # @param name String
95
+ #
96
+ # @param line Integer
97
+ # The line number to link to, if textmate is available. Defaults
98
+ # to nil
99
+ #
100
+ # @return String
101
+ # An anchor link to a textmate reference or a file reference
102
+ def link_to_filename(name, line = nil, link_content = nil)
103
+ "<a href='#{file_url(name, line)}'>#{link_content(name, line, link_content)}</a>"
104
+ end
105
+
106
+ def round_to_tenths(decimal)
107
+ decimal = 0.0 if decimal.to_s.eql?('NaN')
108
+ (decimal * 10).round / 10.0
109
+ end
110
+
111
+ def link_content(name, line=nil, link_content=nil) # :nodoc:
112
+ if link_content
113
+ link_content
114
+ elsif line
115
+ "#{name}:#{line}"
116
+ else
117
+ name
118
+ end
119
+ end
120
+
121
+ def display_location(location, stat)
122
+ file_path, class_name, method_name = location.file_path, location.class_name, location.method_name
123
+ str = ""
124
+ str += link_to_filename(file_path)
125
+ str += " : " if method_name || class_name
126
+ if(method_name)
127
+ str += "#{method_name}"
128
+ else
129
+ #TODO HOTSPOTS BUG ONLY exists on move over to metric_fu
130
+ if class_name.is_a?(String)
131
+ str+= "#{class_name}"
132
+ end
133
+ end
134
+ str
135
+ end
136
+
137
+ def file_url(name, line) # :nodoc:
138
+ return '' unless name
139
+ filename = File.expand_path(name.gsub(/^\//, ''))
140
+ link_prefix = MetricFu.configuration.link_prefix
141
+ if link_prefix
142
+ "#{link_prefix}/#{name.gsub(/:.*$/, '')}"
143
+ elsif render_as_txmt_protocol?
144
+ "txmt://open/?url=file://#{filename}" << (line ? "&line=#{line}" : "")
145
+ # elsif render_as_mvim_protocol?
146
+ # "mvim://open/?url=file://#{filename}" << (line ? "&line=#{line}" : "")
147
+ else
148
+ "file://#{filename}"
149
+ end
150
+ end
151
+
152
+ def render_as_txmt_protocol? # :nodoc:
153
+ config = MetricFu.configuration
154
+ return false unless config.platform.include?('darwin')
155
+ return !config.darwin_txmt_protocol_no_thanks
156
+ end
157
+ def render_as_mvim_protocol? # :nodoc:
158
+ config = MetricFu.configuration
159
+ return false unless config.platform.include?('darwin')
160
+ return !config.darwin_mvim_protocol_no_thanks
161
+ end
162
+
163
+ # Provides a brain dead way to cycle between two values during
164
+ # an iteration of some sort. Pass in the first_value, the second_value,
165
+ # and the cardinality of the iteration.
166
+ #
167
+ # @param first_value Object
168
+ #
169
+ # @param second_value Object
170
+ #
171
+ # @param iteration Integer
172
+ # The number of times through the iteration.
173
+ #
174
+ # @return Object
175
+ # The first_value if iteration is even. The second_value if
176
+ # iteration is odd.
177
+ def cycle(first_value, second_value, iteration)
178
+ return first_value if iteration % 2 == 0
179
+ return second_value
180
+ end
181
+ end
182
+ end