metric_fu 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.metrics CHANGED
@@ -8,7 +8,7 @@ mf_debug "Metrics config loaded"
8
8
  # config.add_metric(:rcov)
9
9
  # config.add_graph(:rcov)
10
10
  # config.configure_metric(:rcov, {:external => coverage_file})
11
- # config.cane = {:abc_max => 15, :line_length => 80, :no_doc => 'y'}
11
+ # config.cane = {:abc_max => 15, :line_length => 80, :no_doc => 'y', :no_readme => 'y'}
12
12
  # end
13
13
  # or
14
14
  # MetricFu::Configuration.run do |config|
data/HISTORY.md CHANGED
@@ -1,17 +1,24 @@
1
- === master ===
1
+ ### Master
2
2
 
3
- == MetricFu 3.0.2 / 2013-03-02
3
+ ### MetricFu 4.1.0 / 2013-03-06
4
+
5
+ * Fix crash in cane when missing readme (Sathish, pull request #51)
6
+ * Prevent future cane failures on unexpected violations (Sathish, pull request #51)
7
+
8
+ ### MetricFu 4.0.0 / 2013-03-05
4
9
 
5
10
  * Adding cane metrics (Sathish, pull request #49)
6
11
  * Not yet included in hotspots
12
+ * *Removed ruby 1.9 support*
7
13
 
8
- == MetricFu 3.0.1 / 2013-03-01
14
+ ### MetricFu 3.0.1 / 2013-03-01
9
15
 
10
16
  * Fixed typo in Flay generator (Sathish, pull request #47)
11
17
 
12
- === MetricFu 3.0.0 / 2013-02-07
18
+ ### MetricFu 3.0.0 / 2013-02-07
19
+
20
+ #### Features
13
21
 
14
- Features
15
22
  * Included metrics: churn, flay, flog, roodi, saikuro, reek, 'coverage', rails stats, rails_best_practices, hotspots.
16
23
  * Works with ruby 1.9 syntax.
17
24
  * Can be configured just like metrical, with a .metrics file.
@@ -22,13 +29,15 @@ Features
22
29
  * Installation and running it have less dependency issues.
23
30
  * Can either load external coverage metrics (rcov or simplecov) or run rcov directly.
24
31
 
25
- Notes:
32
+ #### Notes:
33
+
26
34
  * Rcov is not included in the gem, and is off by default.
27
35
  * Rails best practices is not available in ruby 1.8.
28
36
  * Version 2.1.3.7.18.1 is currently the last version fully compatible with 1.8.
29
37
  * Metrical is no longer necessary. Its functionality has been merged into metric_fu.
30
38
 
31
- Other work
39
+ #### Other work
40
+
32
41
  * Re-organized test files - Michael Stark
33
42
  * Rspec2 - Michael Stark
34
43
  * Unify verbose logging with the MF_DEBUG=true commandline flag
@@ -37,16 +46,16 @@ Other work
37
46
  * Thanks to Dan Mayer for helping with churn compatibility
38
47
  * Thanks to Timo Rößner and Matijs van Zuijlen for their work on maintaining reek
39
48
 
40
- === MetricFu 2.1.3.7.18.1 / 2013-01-09
49
+ ### MetricFu 2.1.3.7.18.1 / 2013-01-09
41
50
 
42
51
  * Same as 2.1.3.7.18.1 but gem packaged using ruby 1.8 dependencies, including ripper
43
52
 
44
- === MetricFu 2.1.3.7.19 / 2013-01-08
53
+ ### MetricFu 2.1.3.7.19 / 2013-01-08
45
54
 
46
55
  * Bug fix, ensure Configuration is loaded before Run, https://github.com/metricfu/metric_fu/issues/36
47
56
  * Gem packaged using ruby 1.9 dependencies. Learned that we cannot dynamically change dependencies for a packaged gem.
48
57
 
49
- === MetricFu 2.1.3.6 / 2013-01-02
58
+ ### MetricFu 2.1.3.6 / 2013-01-02
50
59
 
51
60
  * Fixed bug that wasn't show stats or rails_best_practices graphs
52
61
  * Updated churn and rails_best_practices gems
@@ -54,7 +63,7 @@ Other work
54
63
  * Remove executable metric_fu dependency on rake
55
64
  * TODO: some unclear dependency issues may make metrics in 1.9 crash, esp Flog, Flay, Stats
56
65
 
57
- === MetricFu 2.1.3.5 / 2013-01-01
66
+ ### MetricFu 2.1.3.5 / 2013-01-01
58
67
 
59
68
  * Issue #35, Namespace MetricFu::Table. -Benjamin Fleischer
60
69
  * Additionally namespace
@@ -64,18 +73,18 @@ Other work
64
73
  * MetricFu::HotspotScoringStrategies
65
74
  * Rename MetricAnalyzer to HotspotAnalyzer, and rename all <metric>Analzyer classes to <metric>Hotspot to signify that they are part of the Hotspot code -Benjamin Fleischer
66
75
 
67
- === MetricFu 2.1.3.4 / 2012-12-28
76
+ ### MetricFu 2.1.3.4 / 2012-12-28
68
77
 
69
78
  * Restructuring of the project layout
70
79
  * Project is now at https://github.com/metricfu/metric_fu and gem is again metric_fu
71
80
  * Can run tasks as `metric_fu` command
72
81
 
73
- === MetricFu 2.1.3.2 / 2012-11-14
82
+ ### MetricFu 2.1.3.2 / 2012-11-14
74
83
 
75
84
  * Don't raise an exception in the LineNumbers rescue block. Issue https://github.com/bf4/metric_fu/issues/6 by joonty -Benjamin Fleischer
76
85
  tmp/metric_fu/output/flog.js
77
86
 
78
- === MetricFu 2.1.3 / 2012-10-25
87
+ ### MetricFu 2.1.3 / 2012-10-25
79
88
 
80
89
  * Added to rubygems.org as bf-metric_fu -Benjamin Fleischer
81
90
  * Added to travis-ci -Benjamin Fleischer
@@ -84,17 +93,17 @@ Other work
84
93
  * Looked at moving to simplecov-rcov, but was unsuccessful -Benjamin Fleischer
85
94
  * Fixed breaking tests, deprecation warnings -Benjamin Fleischer
86
95
 
87
- === MetricFu 2.1.2 / 2012-09-05
96
+ ### MetricFu 2.1.2 / 2012-09-05
88
97
 
89
98
  * Getting it working on Rails 3, partly by going through the pull requests and setting gem dependencies to older, working versions - Benjamin Fleischer
90
99
  * It mostly works on Ruby 1.9, though there is an unresolved sexp_parser issue - Benjamin Fleischer
91
100
  * Added link_prefix to configuration to allow URIs specified in config instead of file or txmt - dan sinclair
92
101
 
93
- === MetricFu 2.1.1 / 2011-03-2
102
+ ### MetricFu 2.1.1 / 2011-03-2
94
103
 
95
104
  * Making syntax highlighting optional (config.syntax_highlighting = false) so Ruby 1.9.2 users don't get "invalid byte sequence in UTF-8" errors.
96
105
 
97
- === MetricFu 2.1.0 / 2011-03-1
106
+ ### MetricFu 2.1.0 / 2011-03-1
98
107
 
99
108
  In 2.1.0 there are a lot of bug fixes. 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).
100
109
 
@@ -108,7 +117,7 @@ Other work
108
117
  * Dan Sinclair added some awesome 'annotate' functionality to the Hotspots page. Click on it so see the file with problems in-line.
109
118
  * Dan Sinclair added a verbose mode (config.verbose = true).
110
119
 
111
- === MetricFu 2.0.1 / 2010-11-13
120
+ ### MetricFu 2.0.1 / 2010-11-13
112
121
 
113
122
  * Delete trailing whitespaces - Delwyn de Villiers
114
123
  * Stop Ubuntu choking on invalid multibyte char (US-ASCII) - Delwyn de Villiers
@@ -116,7 +125,7 @@ Other work
116
125
  * Don't load Saikuro for Ruby 1.9.2 - Delwyn de Villiers
117
126
  * Fixed a bug reported by Andrew Davis on the mailing list where configuring the data directory causes dates to be 0/0 - Joshua Cronemeyer
118
127
 
119
- === MetricFu 2.0.0 / 2010-11-10
128
+ ### MetricFu 2.0.0 / 2010-11-10
120
129
 
121
130
  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:
122
131
 
@@ -127,13 +136,13 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
127
136
  * Hotspots - Dan Mayer, Ben Brinckerhoff, Jake Scruggs
128
137
  * Rcov integration with Hotspots - Jake Scruggs, Tony Castiglione, Rob Meyer
129
138
 
130
- === MetricFu 1.5.1 / 2010-7-28
139
+ ### MetricFu 1.5.1 / 2010-7-28
131
140
 
132
141
  * Patch that allows graphers to skip dates that didn't generate metrics for that graph (GitHub Issue #20). - Chris Griego
133
142
  * 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
134
143
  * Fixed 'If coverage is 0% metric_fu will explode' bug (GitHub Issue #6). - Stew Welbourne
135
144
 
136
- === MetricFu 1.5.0 / 2010-7-27
145
+ ### MetricFu 1.5.0 / 2010-7-27
137
146
 
138
147
  * 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).
139
148
  * 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.
@@ -141,7 +150,7 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
141
150
  * 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.
142
151
  * Deal with Rails 3 activesupport vs active_support problems. - jinzhu
143
152
 
144
- === MetricFu 1.4.0 / 2010-06-19
153
+ ### MetricFu 1.4.0 / 2010-06-19
145
154
 
146
155
  * Added support for rails_best_practices gem - Richard Huang
147
156
  * Added rails stats graphing -- Josh Cronemeyer
@@ -153,7 +162,7 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
153
162
  * Fix some problems with the google charts - Chris Griego
154
163
  * Stop showing the googlecharts warning if you are not using google charts.
155
164
 
156
- === MetricFu 1.3.0 / 2010-01-26
165
+ ### MetricFu 1.3.0 / 2010-01-26
157
166
 
158
167
  * Flay can be configured to ignore scores below a threshold (by default it ignores scores less than 100)
159
168
  * When running Rcov you can configure the RAILS_ENV (defaults to 'test') so running metric_fu doesn't interfere with other environments
@@ -165,33 +174,33 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
165
174
  * Declared development dependencies
166
175
  * Cleaned and sped up specs
167
176
 
168
- === MetricFu 1.2.0 / 2010-01-09
177
+ ### MetricFu 1.2.0 / 2010-01-09
169
178
 
170
179
  * ftools isn't supported by 1.9 so moved to fileutils.
171
180
  * Overhauled the graphing to use Gruff or Google Charts so we no longer depend on ImageMagick/rmagick -- thanks to Carl Youngblood.
172
181
  * Stopped relying on Github gems as they will be going away.
173
182
 
174
- === MetricFu 1.1.6 / 2009-12-14
183
+ ### MetricFu 1.1.6 / 2009-12-14
175
184
 
176
185
  * Now compatible with Reek 1.2x thanks to Kevin Rutherford
177
186
  * Fixed problem with deleted files still showing up in Flog reports thanks to Dan Mayer
178
187
 
179
- === MetricFu 1.1.5 / 2009-8-13
188
+ ### MetricFu 1.1.5 / 2009-8-13
180
189
 
181
190
  * Previous Ruby 1.9 fix was not quite fix-y enough
182
191
 
183
- === MetricFu 1.1.4 / 2009-7-13
192
+ ### MetricFu 1.1.4 / 2009-7-13
184
193
 
185
194
  * Fixed another Ruby 1.9x bug
186
195
 
187
- === MetricFu 1.1.3 / 2009-7-10
196
+ ### MetricFu 1.1.3 / 2009-7-10
188
197
 
189
198
  * MetricFu is now Ruby 1.9x compatible
190
199
  * 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.
191
200
  * 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.
192
201
  * Sort Flog by highest score in the class which I feel is more important than the total flog flog score.
193
202
 
194
- === MetricFu 1.1.2 / 2009-7-09
203
+ ### MetricFu 1.1.2 / 2009-7-09
195
204
 
196
205
  * Removed dependency on gruff and rmagick (unless the user wants graphs, of course).
197
206
  * New look for styling -- Edouard Brière
@@ -199,11 +208,11 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
199
208
  * Preventing rake task from being run multiple times when other rake tasks switch the environment -- Matthew Van Horn
200
209
  * Typo in Rcov dependency verification and fixing parsing Saikuro nested information -- Mark Wilden
201
210
 
202
- === MetricFu 1.1.1 / 2009-6-29
211
+ ### MetricFu 1.1.1 / 2009-6-29
203
212
 
204
213
  * Fix for empty flog files
205
214
 
206
- === MetricFu 1.1.0 / 2009-6-22
215
+ ### MetricFu 1.1.0 / 2009-6-22
207
216
 
208
217
  * Flog, flay, reek, roodi, and rcov reports now graph progress over time. Well done Nick Quaranto and Edouard Brière.
209
218
  * 'Awesome' template has been brought in so that reports look 90% less 'ghetto.' Also done by Nick Quaranto and Edouard Brière.
@@ -216,18 +225,18 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
216
225
  * Changing churn so that it still works deeper than the git root directory -- Andrew Timberlake
217
226
  * Andrew Timberlake also made some nice changes to the base template which kinda of got overshadowed by the 'awesome' template. Sorry about that Andrew.
218
227
 
219
- === MetricFu 1.0.2 / 2009-5-11
228
+ ### MetricFu 1.0.2 / 2009-5-11
220
229
 
221
230
  * Fixing problems with Reek new line character (thanks to all who pointed this out)
222
231
  * Flog now recognizes namespaces in method names thanks to Daniel Guettler
223
232
  * Saikuro now looks at multiple directories, again.
224
233
 
225
- === MetricFu 1.0.1 / 2009-5-3
234
+ ### MetricFu 1.0.1 / 2009-5-3
226
235
 
227
236
  * metrics:all task no longer requires a MetricFu::Configuration.run {} if you want to accept the defaults
228
237
  * rcov task now reports total coverage percent
229
238
 
230
- === MetricFu 1.0.0 / 2009-4-30
239
+ ### MetricFu 1.0.0 / 2009-4-30
231
240
 
232
241
  * Merged in Grant McInnes' work on creating yaml output for all metrics to aid harvesting by other tools
233
242
  * Supporting Flog 2.1.0
@@ -237,14 +246,14 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
237
246
  * 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.
238
247
  * 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.
239
248
 
240
- === MetricFu 0.9.0 / 2009-1-25
249
+ ### MetricFu 0.9.0 / 2009-1-25
241
250
 
242
251
  * Adding line numbers to the views so that people viewing it on cc.rb can figure out where the problems are
243
252
  * 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)
244
253
  * Added totals to Flog results
245
254
  * Moved rcov options to configuration
246
255
 
247
- === MetricFu 0.8.9 / 2009-1-20
256
+ ### MetricFu 0.8.9 / 2009-1-20
248
257
 
249
258
  * Thanks to Andre Arko and Petrik de Heus for adding the following features:
250
259
  * The source control type is auto-detected for Churn
@@ -256,7 +265,7 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
256
265
  * Metrics can be generated using one command
257
266
  * Adding new metrics reports has been standardized
258
267
 
259
- === MetricFu 0.8.0 / 2008-10-06
268
+ ### MetricFu 0.8.0 / 2008-10-06
260
269
 
261
270
  * Source Control Churn now supports git (thanks to Erik St Martin)
262
271
  * Flog Results are sorted by Highest Flog Score
@@ -264,7 +273,7 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
264
273
  * Fixing bug so the flog reporter can handle methods with digits in the name (thanks to Andy Gregorowicz)
265
274
  * Internal Rake task now allows metric_fu to flog/churn itself
266
275
 
267
- === MetricFu 0.7.6 / 2008-09-15
276
+ ### MetricFu 0.7.6 / 2008-09-15
268
277
 
269
278
  * CHURN_OPTIONS has become MetricFu::CHURN_OPTIONS
270
279
  * SAIKURO_OPTIONS has become MetricFu::SAIKURO_OPTIONS
@@ -272,16 +281,16 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
272
281
  * Exclude gems and Library ruby code from rcov
273
282
  * Fixed bug with churn start_date functionality (bad path)
274
283
 
275
- === MetricFu 0.7.5 / 2008-09-12
284
+ ### MetricFu 0.7.5 / 2008-09-12
276
285
 
277
286
  * Flog can now flog any set of directories you like (see README).
278
287
  * Saikuro can now look at any set of directories you like (see README).
279
288
 
280
- === MetricFu 0.7.1 / 2008-09-12
289
+ ### MetricFu 0.7.1 / 2008-09-12
281
290
 
282
291
  * Fixed filename bugs pointed out by Bastien
283
292
 
284
- === MetricFu 0.7.0 / 2008-09-11
293
+ ### MetricFu 0.7.0 / 2008-09-11
285
294
 
286
295
  * Merged in Sean Soper's changes to metric_fu.
287
296
  * Metric_fu is now a gem.
@@ -289,46 +298,46 @@ Big thanks to Dan Mayer and Ben Brinckerhoff for the Hotspots code and for helpi
289
298
  * Flogging also has a cool new output screen(s)
290
299
  * Thanks Sean!
291
300
 
292
- === Metricks 0.4.2 / 2008-07-01
301
+ ### Metricks 0.4.2 / 2008-07-01
293
302
 
294
303
  * Changed rcov output directory so that it is no longer 'coverage/unit' but just 'coverage' for better integration with CC.rb
295
304
 
296
- === Metricks 0.4.1 / 2008-06-13
305
+ ### Metricks 0.4.1 / 2008-06-13
297
306
 
298
307
  * Rcov tests now extend beyond one level depth directory by using RcovTask instead of the shell
299
308
 
300
- === Metricks 0.4.0 / 2008-06-13
309
+ ### Metricks 0.4.0 / 2008-06-13
301
310
 
302
311
  * Implementing functionality for use as a gem
303
312
  * Added Rakefile to facilitate testing
304
313
 
305
- === Metricks 0.3.0 / 2008-06-11
314
+ ### Metricks 0.3.0 / 2008-06-11
306
315
 
307
316
  * Generated reports now open on darwin automatically
308
317
  * Generated reports reside under tmp/metricks unless otherwise specified by ENV['CC_BUILD_ARTIFACTS']
309
318
  * MD5Tracker works with Flog reports for speed optimization
310
319
 
311
- === Metricks 0.2.0 / 2008-06-11
320
+ ### Metricks 0.2.0 / 2008-06-11
312
321
 
313
322
  * Integrated use of base directory constant
314
323
  * Have all reports automatically open in a browser if platform is darwin
315
324
  * Namespaced under Metricks
316
325
  * Dropped use of shell md5 command in favor of Ruby's Digest::MD5 libraries
317
326
 
318
- === Metricks 0.1.0 / 2008-06-10
327
+ ### Metricks 0.1.0 / 2008-06-10
319
328
 
320
329
  * Initial integration of metric_fu and my enhancements to flog
321
330
  * Metrics are generated but are all over the place
322
331
 
323
- === MetricFu 0.6.0 / 2008-05-11
332
+ ### MetricFu 0.6.0 / 2008-05-11
324
333
 
325
334
  * Add source control churn report
326
335
 
327
- === MetricFu 0.5.1 / 2008-04-25
336
+ ### MetricFu 0.5.1 / 2008-04-25
328
337
 
329
338
  * Fixed bug with Saikuro report generation - thanks Toby Tripp
330
339
 
331
- === MetricFu 0.5.0 / 2008-04-25
340
+ ### MetricFu 0.5.0 / 2008-04-25
332
341
 
333
342
  * create MetricFu as a Rails Plugin
334
343
  * Add Flog Report
@@ -16,6 +16,10 @@ module MetricFu
16
16
  process_module(file_sexp)
17
17
  when :block
18
18
  file_sexp.each_of_type(:class) { |sexp| process_class(sexp) }
19
+ when :iter
20
+ mf_debug "SEXP: Not parsing line number for #{file_sexp.inspect}"
21
+ when :cdecl
22
+ mf_debug "SEXP: Not parsing line number for #{file_sexp.inspect}"
19
23
  else
20
24
  puts "Unexpected sexp_type #{file_sexp[0].inspect}"
21
25
  end
@@ -5,7 +5,7 @@ module MetricFu
5
5
  attr_reader :violations, :total_violations
6
6
 
7
7
  def emit
8
- command = %Q{mf-cane#{abc_max_param}#{style_measure_param}#{no_doc_param}}
8
+ command = %Q{mf-cane#{abc_max_param}#{style_measure_param}#{no_doc_param}#{no_readme_param}}
9
9
  mf_debug = "** #{command}"
10
10
  @output = `#{command}`
11
11
  end
@@ -32,11 +32,16 @@ module MetricFu
32
32
  MetricFu.cane[:no_doc] == 'y' ? " --no-doc" : ""
33
33
  end
34
34
 
35
+ def no_readme_param
36
+ MetricFu.cane[:no_readme] == 'y' ? " --no-readme" : ""
37
+ end
38
+
35
39
  def violations_by_category
36
40
  violations_output = @output.scan(/(.*?)\n\n(.*?)\n\n/m)
37
41
  violations_output.each_with_object({}) do |(category_desc, violation_list), violations|
38
- category = category_from(category_desc)
39
- violations[category] = violations_for(category, violation_list)
42
+ category = category_from(category_desc) || :others
43
+ violations[category] ||= []
44
+ violations[category] += violations_for(category, violation_list)
40
45
  end
41
46
  end
42
47
 
@@ -44,9 +49,11 @@ module MetricFu
44
49
  category_descriptions = {
45
50
  :abc_complexity => /ABC complexity/,
46
51
  :line_style => /style requirements/,
47
- :comment => /comment/
52
+ :comment => /comment/,
53
+ :documentation => /documentation/
48
54
  }
49
- category_descriptions.find {|k,v| description =~ v}[0]
55
+ category, desc_matcher = category_descriptions.find {|k,v| description =~ v}
56
+ category
50
57
  end
51
58
 
52
59
  def violations_for(category, violation_list)
@@ -61,6 +68,10 @@ module MetricFu
61
68
  CaneViolations::LineStyle
62
69
  when :comment
63
70
  CaneViolations::Comment
71
+ when :documentation
72
+ CaneViolations::Documentation
73
+ else
74
+ CaneViolations::Others
64
75
  end
65
76
  end
66
77
 
@@ -6,6 +6,7 @@ MetricFu::Configuration.run do |config|
6
6
  :abc_max => 15,
7
7
  :line_length => 80,
8
8
  :no_doc => 'n',
9
+ :no_readme => 'n',
9
10
  :filetypes => ['rb']
10
11
  })
11
12
  end
@@ -56,6 +56,19 @@
56
56
  <% end %>
57
57
  </table>
58
58
  <% end %>
59
+ <% if @cane[:violations][:documentation] && @cane[:violations][:documentation].size > 0 %>
60
+ <h3>Missing documentation (<%= @cane[:violations][:documentation].size %>)</h3>
61
+ <table>
62
+ <tr>
63
+ <th>Description</th>
64
+ </tr>
65
+ <% @cane[:violations][:documentation].each do |violation| %>
66
+ <tr>
67
+ <td><%=violation[:description]%></td>
68
+ </tr>
69
+ <% end %>
70
+ </table>
71
+ <% end %>
59
72
  <% if @cane[:violations][:comment] && @cane[:violations][:comment].size > 0 %>
60
73
  <h3>Class definitions requiring comments (<%= @cane[:violations][:comment].size %>)</h3>
61
74
  <table>
@@ -72,6 +85,19 @@
72
85
  <% count += 1 %>
73
86
  <% end %>
74
87
  </table>
88
+ <% end %>
89
+ <% if @cane[:violations][:others] && @cane[:violations][:others].size > 0 %>
90
+ <h3>Others (<%= @cane[:violations][:others].size %>)</h3>
91
+ <table>
92
+ <tr>
93
+ <th>Description</th>
94
+ </tr>
95
+ <% @cane[:violations][:others].each do |violation| %>
96
+ <tr>
97
+ <td><%=violation[:description]%></td>
98
+ </tr>
99
+ <% end %>
100
+ </table>
75
101
  <% end %>
76
102
  <p>Generated on <%= Time.now.localtime %></p>
77
103
  </body>
@@ -47,6 +47,19 @@
47
47
  <% end %>
48
48
  </table>
49
49
  <% end %>
50
+ <% if @cane[:violations][:documentation] && @cane[:violations][:documentation].size > 0 %>
51
+ <h3>Missing documentation (<%= @cane[:violations][:documentation].size %>)</h3>
52
+ <table>
53
+ <tr>
54
+ <th>Description</th>
55
+ </tr>
56
+ <% @cane[:violations][:documentation].each do |violation| %>
57
+ <tr>
58
+ <td><%=violation[:description]%></td>
59
+ </tr>
60
+ <% end %>
61
+ </table>
62
+ <% end %>
50
63
  <% if @cane[:violations][:comment] && @cane[:violations][:comment].size > 0 %>
51
64
  <h3>Class definitions requiring comments (<%= @cane[:violations][:comment].size %>)</h3>
52
65
  <table>
@@ -63,6 +76,19 @@
63
76
  <% count += 1 %>
64
77
  <% end %>
65
78
  </table>
79
+ <% end %>
80
+ <% if @cane[:violations][:others] && @cane[:violations][:others].size > 0 %>
81
+ <h3>Others (<%= @cane[:violations][:others].size %>)</h3>
82
+ <table>
83
+ <tr>
84
+ <th>Description</th>
85
+ </tr>
86
+ <% @cane[:violations][:others].each do |violation| %>
87
+ <tr>
88
+ <td><%=violation[:description]%></td>
89
+ </tr>
90
+ <% end %>
91
+ </table>
66
92
  <% end %>
67
93
  <p>Generated on <%= Time.now.localtime %></p>
68
94
  </body>
@@ -26,5 +26,21 @@ module MetricFu
26
26
  end
27
27
  end
28
28
  end
29
+
30
+ class Documentation
31
+ def self.parse(violation_list)
32
+ violation_list.split(/\n/).map do |violation|
33
+ {:description => violation.strip}
34
+ end
35
+ end
36
+ end
37
+
38
+ class Others
39
+ def self.parse(violation_list)
40
+ violation_list.split(/\n/).map do |violation|
41
+ {:description => violation.strip}
42
+ end
43
+ end
44
+ end
29
45
  end
30
46
  end
@@ -1,3 +1,3 @@
1
1
  module MetricFu
2
- VERSION = "4.0.0"
2
+ VERSION = "4.1.0"
3
3
  end
@@ -127,7 +127,7 @@ describe MetricFu::Configuration do
127
127
  end
128
128
 
129
129
  it 'should set @cane to ' +
130
- %q(:dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => 'n') do
130
+ %q(:dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => 'n', :no_readme => 'y') do
131
131
  load_metric 'cane'
132
132
  @config.send(:cane).
133
133
  should == {
@@ -135,7 +135,8 @@ describe MetricFu::Configuration do
135
135
  :filetypes => ["rb"],
136
136
  :abc_max => 15,
137
137
  :line_length => 80,
138
- :no_doc => "n"}
138
+ :no_doc => "n",
139
+ :no_readme => "n"}
139
140
  end
140
141
 
141
142
  it 'should set @rcov to ' +
@@ -43,6 +43,20 @@ describe Cane do
43
43
  @cane.should_receive(:`).with("mf-cane")
44
44
  output = @cane.emit
45
45
  end
46
+
47
+ it "should use no-readme if specified" do
48
+ configure_cane_with({no_readme: 'y'})
49
+ @cane = MetricFu::Cane.new('base_dir')
50
+ @cane.should_receive(:`).with("mf-cane --no-readme")
51
+ output = @cane.emit
52
+ end
53
+
54
+ it "should include README violations if no_readme != 'y'" do
55
+ configure_cane_with({no_readme: 'n'})
56
+ @cane = MetricFu::Cane.new('base_dir')
57
+ @cane.should_receive(:`).with("mf-cane")
58
+ output = @cane.emit
59
+ end
46
60
  end
47
61
 
48
62
  describe "parse cane output" do
@@ -84,6 +98,21 @@ describe Cane do
84
98
  {line: 'lib/comments/bar.rb:2', class_name: 'Bar'}
85
99
  ]
86
100
  end
101
+
102
+ it "should extract no readme violations if present" do
103
+ @cane.analyze
104
+ @cane.violations[:documentation].should == [
105
+ {description: 'No README found'},
106
+ ]
107
+ end
108
+
109
+ it "should extract unknown violations in others category" do
110
+ @cane.analyze
111
+ @cane.violations[:others].should == [
112
+ {description: 'Misc issue 1'},
113
+ {description: 'Misc issue 2'}
114
+ ]
115
+ end
87
116
  end
88
117
 
89
118
  describe "to_h method" do
@@ -122,11 +151,23 @@ Lines violated style requirements (340):
122
151
  lib/line/foo.rb:1 Line is >80 characters (135)
123
152
  lib/line/bar.rb:2 Line contains trailing whitespace
124
153
 
154
+ Missing documentation (1):
155
+
156
+ No README found
157
+
125
158
  Class definitions require explanatory comments on preceding line (2):
126
159
 
127
160
  lib/comments/foo.rb:1 Foo
128
161
  lib/comments/bar.rb:2 Bar
129
162
 
163
+ Unknown violation (1):
164
+
165
+ Misc issue 1
166
+
167
+ Another Unknown violation (1):
168
+
169
+ Misc issue 2
170
+
130
171
  Total Violations: 6
131
172
  OUTPUT
132
173
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metric_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -19,7 +19,7 @@ authors:
19
19
  autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
- date: 2013-03-05 00:00:00.000000000 Z
22
+ date: 2013-03-06 00:00:00.000000000 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: rails_best_practices