nielsm-metric_fu 0.9.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/HISTORY +38 -0
  2. data/README +1 -154
  3. data/Rakefile +9 -2
  4. data/TODO +3 -3
  5. data/lib/base/base_template.rb +146 -0
  6. data/lib/base/configuration.rb +207 -0
  7. data/lib/base/generator.rb +160 -0
  8. data/lib/base/graph.rb +37 -0
  9. data/lib/{metric_fu → base}/md5_tracker.rb +0 -0
  10. data/lib/base/report.rb +100 -0
  11. data/lib/{metric_fu → generators}/churn.rb +26 -23
  12. data/lib/generators/flay.rb +34 -0
  13. data/lib/generators/flog.rb +140 -0
  14. data/lib/generators/rcov.rb +87 -0
  15. data/lib/generators/reek.rb +37 -0
  16. data/lib/generators/roodi.rb +31 -0
  17. data/lib/generators/saikuro.rb +208 -0
  18. data/lib/generators/stats.rb +43 -0
  19. data/lib/graphs/flay_grapher.rb +34 -0
  20. data/lib/graphs/flog_grapher.rb +37 -0
  21. data/lib/graphs/rcov_grapher.rb +34 -0
  22. data/lib/graphs/reek_grapher.rb +44 -0
  23. data/lib/graphs/roodi_grapher.rb +34 -0
  24. data/lib/metric_fu.rb +24 -3
  25. data/lib/templates/awesome/awesome_template.rb +30 -0
  26. data/lib/templates/awesome/churn.html.erb +19 -0
  27. data/lib/templates/awesome/default.css +75 -0
  28. data/lib/templates/awesome/flay.html.erb +27 -0
  29. data/lib/templates/awesome/flog.html.erb +46 -0
  30. data/lib/templates/awesome/index.html.erb +28 -0
  31. data/lib/templates/awesome/layout.html.erb +27 -0
  32. data/lib/templates/awesome/rcov.html.erb +36 -0
  33. data/lib/templates/awesome/reek.html.erb +34 -0
  34. data/lib/templates/awesome/roodi.html.erb +21 -0
  35. data/lib/templates/awesome/saikuro.html.erb +71 -0
  36. data/lib/templates/awesome/stats.html.erb +41 -0
  37. data/lib/templates/{churn.html.erb → standard/churn.html.erb} +13 -4
  38. data/lib/templates/{default.css → standard/default.css} +20 -1
  39. data/lib/templates/{flay.html.erb → standard/flay.html.erb} +13 -9
  40. data/lib/templates/standard/flog.html.erb +53 -0
  41. data/lib/templates/standard/index.html.erb +38 -0
  42. data/lib/templates/standard/rcov.html.erb +43 -0
  43. data/lib/templates/standard/reek.html.erb +42 -0
  44. data/lib/templates/{roodi.html.erb → standard/roodi.html.erb} +11 -8
  45. data/lib/templates/standard/saikuro.html.erb +84 -0
  46. data/lib/templates/standard/standard_template.rb +26 -0
  47. data/lib/templates/standard/stats.html.erb +55 -0
  48. data/spec/base/base_template_spec.rb +161 -0
  49. data/spec/base/configuration_spec.rb +303 -0
  50. data/spec/base/generator_spec.rb +181 -0
  51. data/spec/{md5_tracker_spec.rb → base/md5_tracker_spec.rb} +1 -1
  52. data/spec/base/report_spec.rb +139 -0
  53. data/spec/generators/churn_spec.rb +152 -0
  54. data/spec/generators/flay_spec.rb +104 -0
  55. data/spec/generators/flog_spec.rb +219 -0
  56. data/spec/generators/reek_spec.rb +60 -0
  57. data/spec/generators/saikuro_spec.rb +58 -0
  58. data/spec/generators/stats_spec.rb +74 -0
  59. data/spec/graphs/flog_grapher_spec.rb +15 -0
  60. data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
  61. data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
  62. data/spec/resources/saikuro/index_cyclo.html +155 -0
  63. data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +10 -0
  64. data/spec/spec.opts +8 -0
  65. data/spec/spec_helper.rb +24 -7
  66. data/tasks/metric_fu.rake +22 -0
  67. data/vendor/_fonts/monaco.ttf +0 -0
  68. data/{lib/metric_fu → vendor}/saikuro/saikuro.rb +0 -0
  69. metadata +84 -66
  70. data/lib/metric_fu/base.rb +0 -160
  71. data/lib/metric_fu/flay.rb +0 -17
  72. data/lib/metric_fu/flog.rb +0 -129
  73. data/lib/metric_fu/reek.rb +0 -17
  74. data/lib/metric_fu/roodi.rb +0 -17
  75. data/lib/tasks/churn.rake +0 -9
  76. data/lib/tasks/coverage.rake +0 -54
  77. data/lib/tasks/flay.rake +0 -6
  78. data/lib/tasks/flog.rake +0 -69
  79. data/lib/tasks/metric_fu.rake +0 -24
  80. data/lib/tasks/metric_fu.rb +0 -6
  81. data/lib/tasks/railroad.rake +0 -39
  82. data/lib/tasks/reek.rake +0 -6
  83. data/lib/tasks/roodi.rake +0 -7
  84. data/lib/tasks/saikuro.rake +0 -35
  85. data/lib/tasks/stats.rake +0 -14
  86. data/lib/templates/flog.html.erb +0 -38
  87. data/lib/templates/flog_page.html.erb +0 -25
  88. data/lib/templates/reek.html.erb +0 -30
  89. data/spec/base_spec.rb +0 -57
  90. data/spec/churn_spec.rb +0 -117
  91. data/spec/config_spec.rb +0 -110
  92. data/spec/flay_spec.rb +0 -19
  93. data/spec/flog_spec.rb +0 -208
  94. data/spec/reek_spec.rb +0 -26
data/spec/flay_spec.rb DELETED
@@ -1,19 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe MetricFu::Flay do
4
-
5
- describe "generate_html" do
6
- it "should create a new Generator and call generate_report on it" do
7
- @generator = MetricFu::Flay.new('other_dir')
8
- @generator.should_receive(:`).and_return("Matches found in :call (mass = 55)\n\tlib/metric_fu/flog_reporter.rb:2\n\tlib/metric_fu/flog_reporter.rb:3")
9
- @generator.generate_html
10
- end
11
- end
12
-
13
- describe "template_name" do
14
- it "should return the class name in lowercase" do
15
- flay = MetricFu::Flay.new('base_dir')
16
- flay.template_name.should == 'flay'
17
- end
18
- end
19
- end
data/spec/flog_spec.rb DELETED
@@ -1,208 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
- include MetricFu::Flog
3
-
4
- describe "Flog::Base" do
5
- before do
6
- @alpha_only_method = <<-AOM
7
- Total flog = 13.6283678106927
8
-
9
- ErrorMailer#errormail: (12.5)
10
- 12.0: assignment
11
- 1.2: []
12
- 1.2: now
13
- 1.2: content_type
14
- AOM
15
-
16
- @method_that_has_digits = <<-MTHD
17
- Total flog = 7.08378429936994
18
-
19
- NoImmunizationReason#to_c32: (7.1)
20
- 3.0: code
21
- 2.3: branch
22
- 1.4: templateId
23
- 1.2: act
24
- 1.1: entryRelationship
25
- MTHD
26
-
27
- @bang_method = <<-BM
28
- Total flog = 7.08378429936994
29
-
30
- NoImmunizationReason#to_c32!: (7.1)
31
- 3.0: code
32
- 2.3: branch
33
- 1.4: templateId
34
- 1.2: act
35
- 1.1: entryRelationship
36
- BM
37
-
38
- @invalid_method = <<-IM
39
- Total flog = 7.08378429936994
40
-
41
- 3.0: code
42
- 2.3: branch
43
- 1.4: templateId
44
- 1.2: act
45
- 1.1: entryRelationship
46
- IM
47
-
48
- @assignment_method = <<-MTHD
49
- Total Flog = 21.6 (5.4 +/- 3.3 flog / method)
50
-
51
- ActivityReport#existing_measure_attributes=: (8.5)
52
- 4.1: assignment
53
- 1.8: id
54
- 1.6: to_s
55
- 1.4: []
56
- 1.4: activity_report_measures
57
- 1.2: each
58
- 1.2: branch
59
- MTHD
60
-
61
- @class_methods_grouped_together = <<-MTHD
62
- Total Flog = 61.8 (7.7 +/- 95.3 flog / method)
63
-
64
- User#none: (32.8)
65
- 7.2: include
66
- 3.6: validates_length_of
67
- 3.6: validates_format_of
68
- 2.4: validates_presence_of
69
- 2.4: validates_uniqueness_of
70
- 1.4: bad_login_message
71
- 1.4: name_regex
72
- 1.4: bad_email_message
73
- 1.4: bad_name_message
74
- 1.4: login_regex
75
- 1.4: email_regex
76
- 1.2: private
77
- 1.2: has_and_belongs_to_many
78
- 1.2: before_create
79
- 1.2: attr_accessible
80
- 0.4: lit_fixnum
81
- MTHD
82
- end
83
-
84
- it "should be able to parse class_methods_grouped_together" do
85
- page = Base.parse(@class_methods_grouped_together)
86
- page.should_not be_nil
87
- page.score.should == 61.8
88
- page.scanned_methods.size.should == 1
89
- sm = page.scanned_methods.first
90
- sm.name.should == 'User#none'
91
- sm.score.should == 32.8
92
-
93
- sm.operators.size.should == 16
94
- sm.operators.first.score.should == 7.2
95
- sm.operators.first.operator.should == "include"
96
-
97
- sm.operators.last.score.should == 0.4
98
- sm.operators.last.operator.should == "lit_fixnum"
99
- end
100
-
101
- it "should be able to parse an assignment method" do
102
- page = Base.parse(@assignment_method)
103
- page.should_not be_nil
104
- page.score.should == 21.6
105
- page.scanned_methods.size.should == 1
106
- sm = page.scanned_methods.first
107
- sm.name.should == 'ActivityReport#existing_measure_attributes='
108
- sm.score.should == 8.5
109
- end
110
-
111
- it "should be able to parse an alpha only method" do
112
- page = Base.parse(@alpha_only_method)
113
- page.should_not be_nil
114
- page.score.should == 13.6283678106927
115
- page.scanned_methods.size.should == 1
116
- sm = page.scanned_methods.first
117
- sm.name.should == 'ErrorMailer#errormail'
118
- sm.score.should == 12.5
119
- end
120
-
121
- it "should be able to parse method that has digits" do
122
- page = Base.parse(@method_that_has_digits)
123
- page.should_not be_nil
124
- page.score.should == 7.08378429936994
125
- page.scanned_methods.size.should == 1
126
- sm = page.scanned_methods.first
127
- sm.name.should == 'NoImmunizationReason#to_c32'
128
- sm.score.should == 7.1
129
- end
130
-
131
- it "should be able to parse bang method" do
132
- page = Base.parse(@bang_method)
133
- page.should_not be_nil
134
- page.score.should == 7.08378429936994
135
- page.scanned_methods.size.should == 1
136
- sm = page.scanned_methods.first
137
- sm.name.should == 'NoImmunizationReason#to_c32!'
138
- sm.score.should == 7.1
139
- end
140
-
141
- it "should return nil when parsing invalid method" do
142
- page = Base.parse(@invalid_method)
143
- page.should be_nil
144
- end
145
- end
146
-
147
- IM = <<-IM
148
- Total flog = 7.08378429936994
149
-
150
- 3.0: code
151
- 2.3: branch
152
- 1.4: templateId
153
- 1.2: act
154
- 1.1: entryRelationship
155
- IM
156
- describe MetricFu::Flog do
157
-
158
- describe "generate_report" do
159
- it "should generate reports" do
160
- generator = Flog::Generator.new('other_dir')
161
- generator.should_receive(:flog_results).and_return(['A', 'B'])
162
- generator.should_receive(:save_html).at_least(3).times.and_return('')
163
- generator.should_receive(:open).any_number_of_times.and_return(['Total Flog = 1273.9 (9.3 +/- 259.2 flog / method)', 'TokenCounter#list_tokens_per_line: (15.2)', '9.0: assignment'].join("\n"))
164
- generator.generate_report
165
- end
166
-
167
- it "should be able to handle InvalidFlogs" do
168
- generator = Flog::Generator.new('other_dir')
169
- generator.should_receive(:flog_results).and_return(['A', 'B'])
170
- generator.should_receive(:inline_css).any_number_of_times.and_return('')
171
- generator.should_receive(:save_html).once
172
- generator.should_receive(:open).any_number_of_times.and_return(IM)
173
- generator.generate_report
174
- end
175
- end
176
-
177
- describe "template_name" do
178
- it "should return the class name in lowercase" do
179
- flog = Flog::Generator.new('base_dir')
180
- Flog::Generator.template_name.should == 'flog'
181
- end
182
- end
183
- end
184
-
185
- describe MetricFu::Flog::Page do
186
-
187
- describe "average_score" do
188
- it "should calculate the average score" do
189
- page = Page.new(10)
190
- page.should_receive(:scanned_methods).any_number_of_times.and_return([ScannedMethod.new(:test, 10), ScannedMethod.new(:test, 20)])
191
- page.average_score.should == 15
192
- end
193
-
194
- it "should be able to handle divide by zero" do
195
- page = Page.new(10)
196
- page.should_receive(:scanned_methods).any_number_of_times.and_return([])
197
- page.average_score.should == 0
198
- end
199
- end
200
-
201
- describe "highest_score" do
202
- it "should calculate the average score" do
203
- page = Page.new(10)
204
- page.should_receive(:scanned_methods).any_number_of_times.and_return([ScannedMethod.new(:test, 10), ScannedMethod.new(:test, 20)])
205
- page.highest_score.should == 20
206
- end
207
- end
208
- end
data/spec/reek_spec.rb DELETED
@@ -1,26 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- REEK_RESULT = %("lib/metric_fu/base.rb" -- 5 warnings:
4
- [Utility Function] #configuration doesn't depend on instance state
5
- [Utility Function] #open_in_browser? doesn't depend on instance state
6
- [Long Method] Configuration#reset has approx 6 statements
7
- [Utility Function] Generator#cycle doesn't depend on instance state
8
- [Utility Function] Generator#link_to_filename doesn't depend on instance state)
9
-
10
- describe MetricFu::Reek do
11
-
12
- describe "generate_html" do
13
- it "should create a new Generator and call generate_report on it" do
14
- @generator = MetricFu::Reek.new('other_dir')
15
- @generator.should_receive(:`).and_return(REEK_RESULT)
16
- @generator.generate_html
17
- end
18
- end
19
-
20
- describe "template_name" do
21
- it "should return the class name in lowercase" do
22
- flay = MetricFu::Reek.new('base_dir')
23
- flay.template_name.should == 'reek'
24
- end
25
- end
26
- end