metric_fu 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. data/HISTORY +13 -5
  2. data/README +2 -2
  3. data/Rakefile +1 -1
  4. data/TODO +3 -1
  5. data/lib/base/base_template.rb +16 -16
  6. data/lib/base/churn_analyzer.rb +3 -3
  7. data/lib/base/code_issue.rb +8 -8
  8. data/lib/base/configuration.rb +24 -22
  9. data/lib/base/flay_analyzer.rb +2 -2
  10. data/lib/base/flog_analyzer.rb +4 -4
  11. data/lib/base/generator.rb +21 -21
  12. data/lib/base/graph.rb +15 -10
  13. data/lib/base/line_numbers.rb +56 -55
  14. data/lib/base/location.rb +68 -66
  15. data/lib/base/metric_analyzer.rb +21 -21
  16. data/lib/base/ranking.rb +23 -22
  17. data/lib/base/rcov_analyzer.rb +3 -3
  18. data/lib/base/reek_analyzer.rb +12 -10
  19. data/lib/base/report.rb +9 -9
  20. data/lib/base/roodi_analyzer.rb +2 -2
  21. data/lib/base/saikuro_analyzer.rb +4 -4
  22. data/lib/base/scoring_strategies.rb +5 -5
  23. data/lib/base/stats_analyzer.rb +2 -2
  24. data/lib/base/table.rb +4 -4
  25. data/lib/generators/churn.rb +1 -1
  26. data/lib/generators/flay.rb +1 -1
  27. data/lib/generators/hotspots.rb +4 -4
  28. data/lib/generators/rails_best_practices.rb +1 -1
  29. data/lib/generators/rcov.rb +17 -17
  30. data/lib/generators/reek.rb +2 -2
  31. data/lib/generators/saikuro.rb +42 -42
  32. data/lib/generators/stats.rb +6 -6
  33. data/lib/graphs/engines/bluff.rb +1 -1
  34. data/lib/graphs/engines/gchart.rb +7 -7
  35. data/lib/graphs/flog_grapher.rb +3 -3
  36. data/lib/graphs/grapher.rb +1 -1
  37. data/lib/metric_fu.rb +2 -2
  38. data/lib/templates/awesome/churn.html.erb +1 -1
  39. data/lib/templates/awesome/css/integrity.css +0 -1
  40. data/lib/templates/awesome/flay.html.erb +2 -2
  41. data/lib/templates/awesome/flog.html.erb +2 -2
  42. data/lib/templates/awesome/hotspots.html.erb +4 -4
  43. data/lib/templates/awesome/index.html.erb +2 -2
  44. data/lib/templates/awesome/rails_best_practices.html.erb +1 -1
  45. data/lib/templates/awesome/rcov.html.erb +1 -1
  46. data/lib/templates/awesome/roodi.html.erb +1 -1
  47. data/lib/templates/awesome/saikuro.html.erb +3 -3
  48. data/lib/templates/awesome/stats.html.erb +1 -1
  49. data/lib/templates/standard/churn.html.erb +2 -2
  50. data/lib/templates/standard/default.css +4 -4
  51. data/lib/templates/standard/flay.html.erb +4 -4
  52. data/lib/templates/standard/flog.html.erb +1 -1
  53. data/lib/templates/standard/hotspots.html.erb +4 -4
  54. data/lib/templates/standard/index.html.erb +2 -2
  55. data/lib/templates/standard/rails_best_practices.html.erb +2 -2
  56. data/lib/templates/standard/rcov.html.erb +2 -2
  57. data/lib/templates/standard/reek.html.erb +1 -1
  58. data/lib/templates/standard/roodi.html.erb +2 -2
  59. data/lib/templates/standard/saikuro.html.erb +4 -4
  60. data/lib/templates/standard/stats.html.erb +2 -2
  61. data/spec/base/base_template_spec.rb +1 -1
  62. data/spec/base/configuration_spec.rb +36 -36
  63. data/spec/base/generator_spec.rb +10 -10
  64. data/spec/base/graph_spec.rb +41 -4
  65. data/spec/base/line_numbers_spec.rb +22 -22
  66. data/spec/base/report_spec.rb +9 -9
  67. data/spec/generators/churn_spec.rb +4 -4
  68. data/spec/generators/flay_spec.rb +31 -31
  69. data/spec/generators/flog_spec.rb +18 -18
  70. data/spec/generators/rails_best_practices_spec.rb +6 -6
  71. data/spec/generators/rcov_spec.rb +18 -18
  72. data/spec/generators/reek_spec.rb +10 -10
  73. data/spec/generators/roodi_spec.rb +2 -2
  74. data/spec/generators/saikuro_spec.rb +7 -7
  75. data/spec/generators/stats_spec.rb +6 -6
  76. data/spec/graphs/engines/gchart_spec.rb +8 -8
  77. data/spec/graphs/flog_grapher_spec.rb +8 -8
  78. data/spec/resources/line_numbers/foo.rb +7 -7
  79. data/spec/resources/line_numbers/module.rb +2 -2
  80. data/spec/resources/line_numbers/module_surrounds_class.rb +6 -6
  81. data/spec/resources/saikuro/index_cyclo.html +2 -2
  82. data/spec/resources/yml/20090630.yml +349 -349
  83. data/spec/resources/yml/metric_missing.yml +1 -1
  84. data/tasks/metric_fu.rake +4 -4
  85. metadata +4 -4
@@ -24,4 +24,4 @@
24
24
  <% count += 1 %>
25
25
  <% end %>
26
26
  </table>
27
- <p>Generated on <%= Time.now.localtime %></p>
27
+ <p>Generated on <%= Time.now.localtime %></p>
@@ -39,4 +39,4 @@
39
39
  </table>
40
40
  </div>
41
41
  <% end %>
42
- <p>Generated on <%= Time.now.localtime %></p>
42
+ <p>Generated on <%= Time.now.localtime %></p>
@@ -24,4 +24,4 @@
24
24
  <% count += 1 %>
25
25
  <% end %>
26
26
  </table>
27
- <p>Generated on <%= Time.now.localtime %></p>
27
+ <p>Generated on <%= Time.now.localtime %></p>
@@ -56,16 +56,16 @@
56
56
  <%= method[:name] %>
57
57
  </td>
58
58
  <td>
59
- <%= method[:complexity] %>
59
+ <%= method[:complexity] %>
60
60
  </td>
61
61
  <td>
62
62
  <%= method[:lines] %>
63
63
  </td>
64
64
  </tr>
65
65
  <% end %>
66
- </table>
66
+ </table>
67
67
  <% end %>
68
68
  <% end %>
69
69
  <% end %>
70
70
 
71
- <p>Generated on <%= Time.now.localtime %></p>
71
+ <p>Generated on <%= Time.now.localtime %></p>
@@ -48,4 +48,4 @@
48
48
  <% end %>
49
49
  </table>
50
50
 
51
- <p>Generated on <%= Time.now.localtime %></p>
51
+ <p>Generated on <%= Time.now.localtime %></p>
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Source Control Churn Results</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
 
@@ -26,6 +26,6 @@
26
26
  <% count += 1 %>
27
27
  <% end %>
28
28
  </table>
29
- <p>Generated on <%= Time.now.localtime %></p>
29
+ <p>Generated on <%= Time.now.localtime %></p>
30
30
  </body>
31
31
  </html>
@@ -9,7 +9,7 @@ table {
9
9
  border-collapse: collapse;
10
10
  border: 1px solid #666;
11
11
  background: #fff;
12
- margin-bottom: 20px;
12
+ margin-bottom: 20px;
13
13
  }
14
14
 
15
15
  table tr.light {
@@ -27,7 +27,7 @@ table {
27
27
  table th {
28
28
  text-align: center;
29
29
  color: #fc0;
30
- background: #336;
30
+ background: #336;
31
31
  font-weight: bold;
32
32
  border: #d0d0d0 1px solid;
33
33
  }
@@ -35,10 +35,10 @@ table {
35
35
  table td {
36
36
  border: #d0d0d0 1px solid;
37
37
  }
38
-
38
+
39
39
  table td.score {
40
40
  text-align: right;
41
- }
41
+ }
42
42
 
43
43
  .warning {
44
44
  background: yellow;
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Flay Results</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
 
@@ -10,11 +10,11 @@
10
10
  <h1>Flay Results</h1>
11
11
  <a href="index.html">back to menu</a>
12
12
  <h2>Total Score (lower is better): <%= @flay[:total_score] %></h2>
13
- <p><a href='http://ruby.sadi.st/Flay.html'>Flay</a> analyzes ruby code for structural similarities.</p>
13
+ <p><a href='http://ruby.sadi.st/Flay.html'>Flay</a> analyzes ruby code for structural similarities.</p>
14
14
  <table>
15
15
  <tr>
16
16
  <th>Files</th>
17
- <th>Matches</th>
17
+ <th>Matches</th>
18
18
  </tr>
19
19
  <% count = 0 %>
20
20
  <% @flay[:matches].each do |match| %>
@@ -29,6 +29,6 @@
29
29
  <% count += 1 %>
30
30
  <% end %>
31
31
  </table>
32
- <p>Generated on <%= Time.now.localtime %></p>
32
+ <p>Generated on <%= Time.now.localtime %></p>
33
33
  </body>
34
34
  </html>
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Flog Reporter</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
  <body>
@@ -9,8 +9,8 @@ No Hotspots were found.
9
9
  <% granularities = [:files, :classes, :methods] %>
10
10
  <table>
11
11
  <tr valign="top">
12
- <% granularities.each do |granularity| %>
13
- <th width='33%'>
12
+ <% granularities.each do |granularity| %>
13
+ <th width='33%'>
14
14
  <%= granularity.to_s.capitalize %></th>
15
15
  <% end %>
16
16
  </tr>
@@ -24,7 +24,7 @@ No Hotspots were found.
24
24
  <% items_length = 0 %>
25
25
  <% columns = [0, 1, 2] %>
26
26
  <% while (items_length < items[0].length || items_length < items[1].length || items_length < items[2].length) do %>
27
- <tr valign="top">
27
+ <tr valign="top">
28
28
  <% columns.each do |column| %>
29
29
  <% item = items[column].length >= items_length ? items[column][items_length] : nil %>
30
30
  <% if item %>
@@ -51,4 +51,4 @@ No Hotspots were found.
51
51
  <% end %>
52
52
 
53
53
 
54
- <p>Generated on <%= Time.now.localtime %></p>
54
+ <p>Generated on <%= Time.now.localtime %></p>
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Metric Fu Results</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
 
@@ -35,7 +35,7 @@
35
35
  <% if @rails_best_practices %>
36
36
  <p><a href="rails_best_practices.html">Rails Best Practices report</a></p>
37
37
  <% end %>
38
- <p>Generated on <%= Time.now.localtime %></p>
38
+ <p>Generated on <%= Time.now.localtime %></p>
39
39
  </body>
40
40
  </html>
41
41
 
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Rails Best Practices Results</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
 
@@ -24,6 +24,6 @@
24
24
  <% count += 1 %>
25
25
  <% end %>
26
26
  </table>
27
- <p>Generated on <%= Time.now.localtime %></p>
27
+ <p>Generated on <%= Time.now.localtime %></p>
28
28
  </body>
29
29
  </html>
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Rcov Code Coverage Results</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
 
@@ -37,7 +37,7 @@
37
37
  <% end %>
38
38
  </table>
39
39
  <% end %>
40
- <p>Generated on <%= Time.now.localtime %></p>
40
+ <p>Generated on <%= Time.now.localtime %></p>
41
41
  </body>
42
42
  </html>
43
43
 
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Reek Results</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
 
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Roodi Results</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
 
@@ -24,6 +24,6 @@
24
24
  <% count += 1 %>
25
25
  <% end %>
26
26
  </table>
27
- <p>Generated on <%= Time.now.localtime %></p>
27
+ <p>Generated on <%= Time.now.localtime %></p>
28
28
  </body>
29
29
  </html>
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Saikuro Results</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
 
@@ -66,19 +66,19 @@
66
66
  <%= method[:name] %>
67
67
  </td>
68
68
  <td>
69
- <%= method[:complexity] %>
69
+ <%= method[:complexity] %>
70
70
  </td>
71
71
  <td>
72
72
  <%= method[:lines] %>
73
73
  </td>
74
74
  </tr>
75
75
  <% end %>
76
- </table>
76
+ </table>
77
77
  <% end %>
78
78
  <% end %>
79
79
  <% end %>
80
80
 
81
- <p>Generated on <%= Time.now.localtime %></p>
81
+ <p>Generated on <%= Time.now.localtime %></p>
82
82
  </body>
83
83
  </html>
84
84
 
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Rake Stats Results</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= inline_css("default.css") %>
6
6
  </style>
7
7
  </head>
8
8
 
@@ -48,7 +48,7 @@
48
48
  <% end %>
49
49
  </table>
50
50
 
51
- <p>Generated on <%= Time.now.localtime %></p>
51
+ <p>Generated on <%= Time.now.localtime %></p>
52
52
  </body>
53
53
  </html>
54
54
 
@@ -82,7 +82,7 @@ describe MetricFu::Template do
82
82
  result.should == 'css contents'
83
83
  end
84
84
  end
85
-
85
+
86
86
  describe "#link_to_filename " do
87
87
  describe "when on OS X" do
88
88
  before(:each) do
@@ -1,11 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
3
  describe MetricFu::Configuration do
4
-
4
+
5
5
  def get_new_config
6
6
  @config = Configuration.new
7
7
  end
8
-
8
+
9
9
  def base_directory
10
10
  @config.instance_variable_get(:@base_directory)
11
11
  end
@@ -31,12 +31,12 @@ describe MetricFu::Configuration do
31
31
  end
32
32
 
33
33
  describe "#reset" do
34
-
35
- before(:each) { get_new_config }
36
-
34
+
35
+ before(:each) { get_new_config }
36
+
37
37
  describe 'when there is a CC_BUILD_ARTIFACTS environment variable' do
38
- before(:each) { ENV['CC_BUILD_ARTIFACTS'] = 'foo' }
39
-
38
+ before(:each) { ENV['CC_BUILD_ARTIFACTS'] = 'foo' }
39
+
40
40
  it 'should return the CC_BUILD_ARTIFACTS environment variable' do
41
41
  get_new_config
42
42
  base_directory.should == ENV['CC_BUILD_ARTIFACTS']
@@ -45,30 +45,30 @@ describe MetricFu::Configuration do
45
45
 
46
46
  describe 'when there is no CC_BUILD_ARTIFACTS environment variable' do
47
47
  before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
48
-
48
+
49
49
  it 'should return "tmp/metric_fu"' do
50
50
  get_new_config
51
51
  base_directory.should == "tmp/metric_fu"
52
52
  end
53
53
  end
54
-
54
+
55
55
  it 'should set @metric_fu_root_directory to the base of the '+
56
56
  'metric_fu application' do
57
57
  app_root = File.join(File.dirname(__FILE__), '..', '..')
58
58
  app_root_absolute_path = File.expand_path(app_root)
59
59
  metric_fu_absolute_path = File.expand_path(metric_fu_root)
60
- metric_fu_absolute_path.should == app_root_absolute_path
60
+ metric_fu_absolute_path.should == app_root_absolute_path
61
61
  end
62
62
 
63
63
  it 'should set @template_directory to the lib/templates relative '+
64
64
  'to @metric_fu_root_directory' do
65
- template_dir = File.join(File.dirname(__FILE__),
65
+ template_dir = File.join(File.dirname(__FILE__),
66
66
  '..', '..', 'lib','templates')
67
67
  template_dir_abs_path = File.expand_path(template_dir)
68
68
  calc_template_dir_abs_path = File.expand_path(template_directory)
69
69
  calc_template_dir_abs_path.should == template_dir_abs_path
70
70
  end
71
-
71
+
72
72
  it 'should set @scratch_directory to scratch relative '+
73
73
  'to @base_directory' do
74
74
  scratch_dir = File.join(base_directory, 'scratch')
@@ -80,7 +80,7 @@ describe MetricFu::Configuration do
80
80
  output_dir = File.join(base_directory, 'output')
81
81
  output_directory.should == output_dir
82
82
  end
83
-
83
+
84
84
  it 'should set @template_class to AwesomeTemplate' do
85
85
  template_class.should == AwesomeTemplate
86
86
  end
@@ -89,12 +89,12 @@ describe MetricFu::Configuration do
89
89
  @config.instance_variable_get(:@flay).
90
90
  should == {:dirs_to_flay => ['lib'], :filetypes=>["rb"], :minimum_score => 100}
91
91
  end
92
-
92
+
93
93
  it 'should set @flog to {:dirs_to_flog => @code_dirs}' do
94
94
  @config.instance_variable_get(:@flog).
95
95
  should == {:dirs_to_flog => ['lib']}
96
96
  end
97
-
97
+
98
98
  it 'should set @reek to {:dirs_to_reek => @code_dirs}' do
99
99
  @config.instance_variable_get(:@reek).
100
100
  should == {:config_file_pattern=>nil, :dirs_to_reek => ['lib']}
@@ -104,7 +104,7 @@ describe MetricFu::Configuration do
104
104
  @config.instance_variable_get(:@roodi).
105
105
  should == {:roodi_config=>nil, :dirs_to_roodi => ['lib']}
106
106
  end
107
-
107
+
108
108
  it 'should set @churn to {}' do
109
109
  @config.instance_variable_get(:@churn).
110
110
  should == {}
@@ -120,21 +120,21 @@ describe MetricFu::Configuration do
120
120
  should == {}
121
121
  end
122
122
 
123
- it 'should set @rcov to { :test_files => ["test/**/*_test.rb",
124
- "spec/**/*_spec.rb"]
125
- :rcov_opts => ["--sort coverage",
126
- "--no-html",
127
- "--text-coverage",
128
- "--no-color",
129
- "--profile",
130
- "--rails",
123
+ it 'should set @rcov to { :test_files => ["test/**/*_test.rb",
124
+ "spec/**/*_spec.rb"]
125
+ :rcov_opts => ["--sort coverage",
126
+ "--no-html",
127
+ "--text-coverage",
128
+ "--no-color",
129
+ "--profile",
130
+ "--rails",
131
131
  "--exclude /gems/,/Library/,/usr/,spec"]}' do
132
132
  @config.instance_variable_get(:@rcov).
133
133
  should == { :environment => 'test',
134
- :test_files => ['test/**/*_test.rb',
134
+ :test_files => ['test/**/*_test.rb',
135
135
  'spec/**/*_spec.rb'],
136
- :rcov_opts => ["--sort coverage",
137
- "--no-html",
136
+ :rcov_opts => ["--sort coverage",
137
+ "--no-html",
138
138
  "--text-coverage",
139
139
  "--no-color",
140
140
  "--profile",
@@ -151,7 +151,7 @@ describe MetricFu::Configuration do
151
151
  :error_cyclo => "7",
152
152
  :formater => "text" }' do
153
153
  @config.instance_variable_get(:@saikuro).
154
- should == { :output_directory => "#{scratch_directory}/saikuro",
154
+ should == { :output_directory => "#{scratch_directory}/saikuro",
155
155
  :input_directory => ['lib'],
156
156
  :cyclo => "",
157
157
  :filter_cyclo => "0",
@@ -159,7 +159,7 @@ describe MetricFu::Configuration do
159
159
  :error_cyclo => "7",
160
160
  :formater => "text"}
161
161
  end
162
-
162
+
163
163
  describe 'if #rails? is true ' do
164
164
  before(:each) do
165
165
  @config.stub!(:rails?).and_return(true)
@@ -194,7 +194,7 @@ describe MetricFu::Configuration do
194
194
  before(:each) do
195
195
  @config.stub!(:rails?).and_return(false)
196
196
  end
197
-
197
+
198
198
  describe '#set_metrics ' do
199
199
  it 'should set the @metrics instance var to AVAILABLE_METRICS' do
200
200
  @config.instance_variable_get(:@metrics).
@@ -211,9 +211,9 @@ describe MetricFu::Configuration do
211
211
  end
212
212
 
213
213
  describe '#add_attr_accessors_to_self' do
214
-
215
- before(:each) { get_new_config }
216
-
214
+
215
+ before(:each) { get_new_config }
216
+
217
217
  MetricFu::AVAILABLE_METRICS.each do |metric|
218
218
  it "should have a reader for #{metric}" do
219
219
  @config.respond_to?(metric).should be_true
@@ -226,7 +226,7 @@ describe MetricFu::Configuration do
226
226
  end
227
227
 
228
228
  describe '#add_class_methods_to_metric_fu' do
229
-
229
+
230
230
  before(:each) { get_new_config }
231
231
 
232
232
  MetricFu::AVAILABLE_METRICS.each do |metric|
@@ -234,7 +234,7 @@ describe MetricFu::Configuration do
234
234
  MetricFu.should respond_to(metric)
235
235
  end
236
236
  end
237
-
237
+
238
238
  MetricFu::AVAILABLE_GRAPHS.each do |graph|
239
239
  it "should add a #{graph} class metrhod to the MetricFu module" do
240
240
  MetricFu.should respond_to(graph)
@@ -267,7 +267,7 @@ describe MetricFu::Configuration do
267
267
 
268
268
  describe "when the CC_BUILD_ARTIFACTS env var is nil" do
269
269
  before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
270
-
270
+
271
271
  it 'should return false' do
272
272
  @config.is_cruise_control_rb?.should be_false
273
273
  end