goldstar-metric_fu 1.5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/HISTORY +208 -0
  2. data/MIT-LICENSE +22 -0
  3. data/README +28 -0
  4. data/Rakefile +16 -0
  5. data/TODO +9 -0
  6. data/lib/base/base_template.rb +151 -0
  7. data/lib/base/configuration.rb +190 -0
  8. data/lib/base/generator.rb +162 -0
  9. data/lib/base/graph.rb +39 -0
  10. data/lib/base/md5_tracker.rb +52 -0
  11. data/lib/base/report.rb +100 -0
  12. data/lib/generators/churn.rb +28 -0
  13. data/lib/generators/flay.rb +31 -0
  14. data/lib/generators/flog.rb +98 -0
  15. data/lib/generators/rails_best_practices.rb +25 -0
  16. data/lib/generators/rcov.rb +85 -0
  17. data/lib/generators/reek.rb +60 -0
  18. data/lib/generators/roodi.rb +27 -0
  19. data/lib/generators/saikuro.rb +224 -0
  20. data/lib/generators/stats.rb +59 -0
  21. data/lib/graphs/engines/bluff.rb +113 -0
  22. data/lib/graphs/engines/gchart.rb +157 -0
  23. data/lib/graphs/flay_grapher.rb +18 -0
  24. data/lib/graphs/flog_grapher.rb +57 -0
  25. data/lib/graphs/grapher.rb +11 -0
  26. data/lib/graphs/rails_best_practices_grapher.rb +19 -0
  27. data/lib/graphs/rcov_grapher.rb +18 -0
  28. data/lib/graphs/reek_grapher.rb +30 -0
  29. data/lib/graphs/roodi_grapher.rb +18 -0
  30. data/lib/graphs/stats_grapher.rb +20 -0
  31. data/lib/metric_fu.rb +37 -0
  32. data/lib/templates/awesome/awesome_template.rb +37 -0
  33. data/lib/templates/awesome/churn.html.erb +58 -0
  34. data/lib/templates/awesome/css/buttons.css +82 -0
  35. data/lib/templates/awesome/css/default.css +91 -0
  36. data/lib/templates/awesome/css/integrity.css +335 -0
  37. data/lib/templates/awesome/css/reset.css +7 -0
  38. data/lib/templates/awesome/flay.html.erb +34 -0
  39. data/lib/templates/awesome/flog.html.erb +55 -0
  40. data/lib/templates/awesome/index.html.erb +31 -0
  41. data/lib/templates/awesome/layout.html.erb +30 -0
  42. data/lib/templates/awesome/rails_best_practices.html.erb +27 -0
  43. data/lib/templates/awesome/rcov.html.erb +42 -0
  44. data/lib/templates/awesome/reek.html.erb +40 -0
  45. data/lib/templates/awesome/roodi.html.erb +27 -0
  46. data/lib/templates/awesome/saikuro.html.erb +71 -0
  47. data/lib/templates/awesome/stats.html.erb +51 -0
  48. data/lib/templates/javascripts/bluff-min.js +1 -0
  49. data/lib/templates/javascripts/excanvas.js +35 -0
  50. data/lib/templates/javascripts/js-class.js +1 -0
  51. data/lib/templates/standard/churn.html.erb +31 -0
  52. data/lib/templates/standard/default.css +64 -0
  53. data/lib/templates/standard/flay.html.erb +34 -0
  54. data/lib/templates/standard/flog.html.erb +57 -0
  55. data/lib/templates/standard/index.html.erb +41 -0
  56. data/lib/templates/standard/rails_best_practices.html.erb +29 -0
  57. data/lib/templates/standard/rcov.html.erb +43 -0
  58. data/lib/templates/standard/reek.html.erb +42 -0
  59. data/lib/templates/standard/roodi.html.erb +29 -0
  60. data/lib/templates/standard/saikuro.html.erb +84 -0
  61. data/lib/templates/standard/standard_template.rb +26 -0
  62. data/lib/templates/standard/stats.html.erb +55 -0
  63. data/spec/base/base_template_spec.rb +161 -0
  64. data/spec/base/configuration_spec.rb +276 -0
  65. data/spec/base/generator_spec.rb +223 -0
  66. data/spec/base/graph_spec.rb +24 -0
  67. data/spec/base/md5_tracker_spec.rb +57 -0
  68. data/spec/base/report_spec.rb +139 -0
  69. data/spec/generators/churn_spec.rb +41 -0
  70. data/spec/generators/flay_spec.rb +105 -0
  71. data/spec/generators/flog_spec.rb +70 -0
  72. data/spec/generators/reek_spec.rb +134 -0
  73. data/spec/generators/saikuro_spec.rb +58 -0
  74. data/spec/generators/stats_spec.rb +74 -0
  75. data/spec/graphs/engines/bluff_spec.rb +19 -0
  76. data/spec/graphs/engines/gchart_spec.rb +156 -0
  77. data/spec/graphs/flay_grapher_spec.rb +56 -0
  78. data/spec/graphs/flog_grapher_spec.rb +108 -0
  79. data/spec/graphs/rcov_grapher_spec.rb +56 -0
  80. data/spec/graphs/reek_grapher_spec.rb +65 -0
  81. data/spec/graphs/roodi_grapher_spec.rb +56 -0
  82. data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
  83. data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
  84. data/spec/resources/saikuro/index_cyclo.html +155 -0
  85. data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +11 -0
  86. data/spec/resources/yml/20090630.yml +7922 -0
  87. data/spec/spec.opts +6 -0
  88. data/spec/spec_helper.rb +7 -0
  89. data/tasks/metric_fu.rake +22 -0
  90. metadata +396 -0
@@ -0,0 +1,18 @@
1
+ module MetricFu
2
+ class RcovGrapher < Grapher
3
+ attr_accessor :rcov_percent, :labels
4
+
5
+ def initialize
6
+ super
7
+ self.rcov_percent = []
8
+ self.labels = {}
9
+ end
10
+
11
+ def get_metrics(metrics, date)
12
+ if metrics && metrics[:rcov]
13
+ self.rcov_percent.push(metrics[:rcov][:global_percent_run])
14
+ self.labels.update( { self.labels.size => date })
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ module MetricFu
2
+ class ReekGrapher < Grapher
3
+ attr_accessor :reek_count, :labels
4
+
5
+ def initialize
6
+ super
7
+ @reek_count = {}
8
+ @labels = {}
9
+ end
10
+
11
+ def get_metrics(metrics, date)
12
+ if metrics && metrics[:reek]
13
+ counter = @labels.size
14
+ @labels.update( { @labels.size => date })
15
+
16
+ metrics[:reek][:matches].each do |reek_chunk|
17
+ reek_chunk[:code_smells].each do |code_smell|
18
+ # speaking of code smell...
19
+ @reek_count[code_smell[:type]] = [] if @reek_count[code_smell[:type]].nil?
20
+ if @reek_count[code_smell[:type]][counter].nil?
21
+ @reek_count[code_smell[:type]][counter] = 1
22
+ else
23
+ @reek_count[code_smell[:type]][counter] += 1
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ module MetricFu
2
+ class RoodiGrapher < Grapher
3
+ attr_accessor :roodi_count, :labels
4
+
5
+ def initialize
6
+ super
7
+ @roodi_count = []
8
+ @labels = {}
9
+ end
10
+
11
+ def get_metrics(metrics, date)
12
+ if metrics && metrics[:roodi]
13
+ @roodi_count.push(metrics[:roodi][:problems].size)
14
+ @labels.update( { @labels.size => date })
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ module MetricFu
2
+ class StatsGrapher < Grapher
3
+ attr_accessor :loc_counts, :lot_counts, :labels
4
+
5
+ def initialize
6
+ super
7
+ self.loc_counts = []
8
+ self.lot_counts = []
9
+ self.labels = {}
10
+ end
11
+
12
+ def get_metrics(metrics, date)
13
+ if metrics && metrics[:stats]
14
+ self.loc_counts.push(metrics[:stats][:codeLOC].to_i)
15
+ self.lot_counts.push(metrics[:stats][:testLOC].to_i)
16
+ self.labels.update( { self.labels.size => date })
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/metric_fu.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'rake'
2
+ require 'yaml'
3
+ begin
4
+ require 'active_support'
5
+ rescue LoadError
6
+ require 'activesupport'
7
+ end
8
+
9
+ # Load a few things to make our lives easier elsewhere.
10
+ module MetricFu
11
+ LIB_ROOT = File.dirname(__FILE__)
12
+ end
13
+ base_dir = File.join(MetricFu::LIB_ROOT, 'base')
14
+ generator_dir = File.join(MetricFu::LIB_ROOT, 'generators')
15
+ template_dir = File.join(MetricFu::LIB_ROOT, 'templates')
16
+ graph_dir = File.join(MetricFu::LIB_ROOT, 'graphs')
17
+
18
+ # We need to require these two things first because our other classes
19
+ # depend on them.
20
+ require File.join(base_dir, 'report')
21
+ require File.join(base_dir, 'generator')
22
+ require File.join(base_dir, 'graph')
23
+
24
+ # prevent the task from being run multiple times.
25
+ unless Rake::Task.task_defined? "metrics:all"
26
+ # Load the rakefile so users of the gem get the default metric_fu task
27
+ load File.join(MetricFu::LIB_ROOT, '..', 'tasks', 'metric_fu.rake')
28
+ end
29
+
30
+ # Now load everything else that's in the directory
31
+ Dir[File.join(base_dir, '*.rb')].each{|l| require l }
32
+ Dir[File.join(generator_dir, '*.rb')].each {|l| require l }
33
+ Dir[File.join(template_dir, 'standard/*.rb')].each {|l| require l}
34
+ Dir[File.join(template_dir, 'awesome/*.rb')].each {|l| require l}
35
+ require graph_dir + "/grapher"
36
+ Dir[File.join(graph_dir, '*.rb')].each {|l| require l}
37
+ Dir[File.join(graph_dir, 'engines', '*.rb')].each {|l| require l}
@@ -0,0 +1,37 @@
1
+ require 'fileutils'
2
+
3
+ class AwesomeTemplate < MetricFu::Template
4
+
5
+ def write
6
+ # Getting rid of the crap before and after the project name from integrity
7
+ @name = File.basename(Dir.pwd).gsub(/^\w+-|-\w+$/, "")
8
+
9
+ # Copy Bluff javascripts to output directory
10
+ Dir[File.join(this_directory, '..', 'javascripts', '*')].each do |f|
11
+ FileUtils.copy(f, File.join(MetricFu.output_directory, File.basename(f)))
12
+ end
13
+
14
+ report.each_pair do |section, contents|
15
+ if template_exists?(section)
16
+ create_instance_var(section, contents)
17
+ @html = erbify(section)
18
+ html = erbify('layout')
19
+ fn = output_filename(section)
20
+ MetricFu.report.save_output(html, MetricFu.output_directory, fn)
21
+ end
22
+ end
23
+
24
+ # Instance variables we need should already be created from above
25
+ if template_exists?('index')
26
+ @html = erbify('index')
27
+ html = erbify('layout')
28
+ fn = output_filename('index')
29
+ MetricFu.report.save_output(html, MetricFu.output_directory, fn)
30
+ end
31
+ end
32
+
33
+ def this_directory
34
+ File.dirname(__FILE__)
35
+ end
36
+ end
37
+
@@ -0,0 +1,58 @@
1
+ <h3>Source Control Churn Results</h3>
2
+ <p>Files that change a lot in your project may be bad a sign.
3
+ This task uses your source control log to identify those files.
4
+ </p>
5
+ <table>
6
+ <tr>
7
+ <th>File Path</th>
8
+ <th>Times Changed</th>
9
+ </tr>
10
+ <% count = 0 %>
11
+ <% @churn[:changes].each do |change| %>
12
+ <tr>
13
+ <td><%= link_to_filename(change[:file_path]) %></td>
14
+ <td><%= change[:times_changed] %></td>
15
+ </tr>
16
+ <% count += 1 %>
17
+ <% end %>
18
+ </table>
19
+
20
+ <% if @churn[:class_churn] %>
21
+ <p>Classes that change a lot in your project may be bad a sign.</p>
22
+ <table>
23
+ <tr>
24
+ <th>File Path</th>
25
+ <th>Times Changed</th>
26
+ </tr>
27
+ <% count = 0 %>
28
+ <% @churn[:class_churn].each do |change| %>
29
+ <tr>
30
+ <td><%= link_to_filename(change['klass']['file']) %> <%= change['klass']['klass'] %></td>
31
+ <td><%= change['times_changed'] %></td>
32
+ </tr>
33
+ <% count += 1 %>
34
+ <% end %>
35
+ </table>
36
+ <% end %>
37
+
38
+ <% if @churn[:method_churn] %>
39
+ <p>Methods that change a lot in your project may be bad a sign.</p>
40
+ <table>
41
+ <tr>
42
+ <th>File Path</th>
43
+ <th>Times Changed</th>
44
+ </tr>
45
+ <% count = 0 %>
46
+ <% @churn[:method_churn].each do |change| %>
47
+ <tr>
48
+ <td><%= link_to_filename(change['method']['file']) %> <%= change['method']['method'] %></td>
49
+ <td><%= change['times_changed'] %></td>
50
+ </tr>
51
+ <% count += 1 %>
52
+ <% end %>
53
+ </table>
54
+ <% end %>
55
+
56
+
57
+
58
+ <p>Generated on <%= Time.now.localtime %></p>
@@ -0,0 +1,82 @@
1
+ /* --------------------------------------------------------------
2
+
3
+ buttons.css
4
+ * Gives you some great CSS-only buttons.
5
+
6
+ Created by Kevin Hale [particletree.com]
7
+ * particletree.com/features/rediscovering-the-button-element
8
+
9
+ See Readme.txt in this folder for instructions.
10
+
11
+ -------------------------------------------------------------- */
12
+
13
+ button {
14
+ display:block;
15
+ float:left;
16
+ margin:0 0.583em 0.667em 0;
17
+ padding:5px 10px 5px 7px; /* Links */
18
+
19
+ border:1px solid #dedede;
20
+ border-top:1px solid #eee;
21
+ border-left:1px solid #eee;
22
+
23
+ background-color:#f5f5f5;
24
+ font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
25
+ font-size:100%;
26
+ line-height:130%;
27
+ text-decoration:none;
28
+ font-weight:bold;
29
+ color:#565656;
30
+ cursor:pointer;
31
+ }
32
+ button {
33
+ width:auto;
34
+ overflow:visible;
35
+ padding:4px 10px 3px 7px; /* IE6 */
36
+ }
37
+ button[type] {
38
+ padding:4px 10px 4px 7px; /* Firefox */
39
+ line-height:17px; /* Safari */
40
+ }
41
+ *:first-child+html button[type] {
42
+ padding:4px 10px 3px 7px; /* IE7 */
43
+ }
44
+ button img {
45
+ margin:0 3px -3px 0 !important;
46
+ padding:0;
47
+ border:none;
48
+ width:16px;
49
+ height:16px;
50
+ float:none;
51
+ }
52
+
53
+
54
+ /* Button colors
55
+ -------------------------------------------------------------- */
56
+
57
+ /* Standard */
58
+ button:hover {
59
+ background-color:#dff4ff;
60
+ border:1px solid #c2e1ef;
61
+ color:#336699;
62
+ }
63
+
64
+ /* Positive */
65
+ body .positive {
66
+ color:#529214;
67
+ }
68
+ button.positive:hover {
69
+ background-color:#E6EFC2;
70
+ border:1px solid #C6D880;
71
+ color:#529214;
72
+ }
73
+
74
+ /* Negative */
75
+ body .negative {
76
+ color:#d12f19;
77
+ }
78
+ button.negative:hover {
79
+ background:#fbe3e4;
80
+ border:1px solid #fbc2c4;
81
+ color:#d12f19;
82
+ }
@@ -0,0 +1,91 @@
1
+ table {
2
+ margin-top: 20px;
3
+ border-collapse: collapse;
4
+ border: 1px solid #666;
5
+ background: #fff;
6
+ margin-bottom: 20px;
7
+ }
8
+
9
+ table tr.light {
10
+ background: #fff;
11
+ }
12
+
13
+ table tr.dark {
14
+ background: #f9f9f9;
15
+ }
16
+
17
+ table tr:hover {
18
+ background: #FFFFC0;
19
+ }
20
+
21
+ table td, table th {
22
+ padding: 4px;
23
+ font-size: 11px;
24
+ }
25
+ table th {
26
+ text-align: center;
27
+ color: #337022;
28
+ background: #DDFFCC;
29
+ font-weight: bold;
30
+ border: #99D688 1px solid;
31
+ }
32
+
33
+ table td {
34
+ border: #d0d0d0 1px solid;
35
+ }
36
+
37
+ table td.score {
38
+ text-align: right;
39
+ }
40
+
41
+ .warning {
42
+ background: yellow;
43
+ }
44
+ .rcov_code td {
45
+ border-bottom: 1px solid #ddd ;
46
+ padding: 0;
47
+ margin: 0;
48
+ }
49
+ .rcov_code tr {
50
+ border: 0px;
51
+ padding:0px;
52
+ margin: 0px;
53
+ }
54
+ .rcov_code pre {
55
+ border: 0px;
56
+ padding: 0px;
57
+ margin: 0px;
58
+ }
59
+ .rcov_run {}
60
+ .rcov_not_run {
61
+ background-color: #d88;
62
+ }
63
+ .rcov_run a, .rcov_not_run a {
64
+ text-decoration: none;
65
+ }
66
+ .rcov_run a {
67
+ color: #333;
68
+ }
69
+ .rcov_not_run a {
70
+ color: #000;
71
+ }
72
+ .rcov_overflow {
73
+ overflow: auto;
74
+ font-size: 50%;
75
+ }
76
+
77
+ .bluff-tooltip {
78
+ background: #fff;
79
+ border: 1px solid #d1edf5;
80
+ padding: 8px 8px 6px;
81
+ }
82
+ .bluff-tooltip .color {
83
+ display: block;
84
+ height: 4px;
85
+ width: 30px;
86
+ margin: 0 0 4px;
87
+ overflow: hidden;
88
+ }
89
+ .bluff-tooltip .data {
90
+ font-weight: bold;
91
+ }