p8-metric_fu 0.8.0.16 → 0.8.2

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 (47) hide show
  1. data/README +17 -63
  2. data/Rakefile +1 -1
  3. data/lib/metric_fu/base.rb +8 -114
  4. data/lib/metric_fu/churn.rb +7 -8
  5. data/lib/metric_fu/flay_reporter.rb +17 -0
  6. data/lib/metric_fu/flog_reporter/base.rb +49 -0
  7. data/lib/metric_fu/flog_reporter/generator.rb +39 -0
  8. data/lib/metric_fu/flog_reporter/operator.rb +10 -0
  9. data/lib/metric_fu/flog_reporter/page.rb +33 -0
  10. data/lib/metric_fu/flog_reporter/scanned_method.rb +28 -0
  11. data/lib/metric_fu/flog_reporter.rb +5 -0
  12. data/lib/tasks/churn.rake +3 -1
  13. data/lib/tasks/coverage.rake +35 -49
  14. data/lib/tasks/flay.rake +4 -1
  15. data/lib/tasks/flog.rake +10 -10
  16. data/lib/tasks/metric_fu.rake +4 -8
  17. data/lib/tasks/metric_fu.rb +1 -1
  18. data/lib/tasks/saikuro.rake +1 -1
  19. data/lib/tasks/stats.rake +1 -1
  20. data/lib/templates/churn.css +38 -0
  21. data/lib/templates/churn.html.erb +3 -6
  22. data/lib/templates/flay.css +38 -0
  23. data/lib/templates/flay.html.erb +10 -17
  24. data/lib/templates/flog.css +39 -0
  25. data/lib/templates/flog.html.erb +14 -19
  26. data/lib/templates/flog_page.html.erb +3 -15
  27. data/spec/base_spec.rb +8 -30
  28. data/spec/churn_spec.rb +3 -10
  29. data/spec/{flay_spec.rb → flay_reporter_spec.rb} +2 -9
  30. data/spec/flog_reporter/base_spec.rb +69 -0
  31. data/spec/md5_tracker_spec.rb +3 -1
  32. data/spec/spec_helper.rb +3 -7
  33. metadata +17 -41
  34. data/Manifest.txt +0 -25
  35. data/lib/metric_fu/flay.rb +0 -17
  36. data/lib/metric_fu/flog.rb +0 -139
  37. data/lib/metric_fu/reek.rb +0 -17
  38. data/lib/metric_fu/roodi.rb +0 -17
  39. data/lib/tasks/railroad.rake +0 -36
  40. data/lib/tasks/reek.rake +0 -6
  41. data/lib/tasks/roodi.rake +0 -7
  42. data/lib/templates/default.css +0 -45
  43. data/lib/templates/reek.html.erb +0 -30
  44. data/lib/templates/roodi.html.erb +0 -26
  45. data/spec/config_spec.rb +0 -110
  46. data/spec/flog_spec.rb +0 -147
  47. data/spec/reek_spec.rb +0 -26
data/spec/flog_spec.rb DELETED
@@ -1,147 +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
- end
49
-
50
- it "should be able to parse an alpha only method" do
51
- page = Base.parse(@alpha_only_method)
52
- page.should_not be_nil
53
- page.score.should == 13.6283678106927
54
- page.scanned_methods.size.should == 1
55
- sm = page.scanned_methods.first
56
- sm.name.should == 'ErrorMailer#errormail'
57
- sm.score.should == 12.5
58
- end
59
-
60
- it "should be able to parse method that has digits" do
61
- page = Base.parse(@method_that_has_digits)
62
- page.should_not be_nil
63
- page.score.should == 7.08378429936994
64
- page.scanned_methods.size.should == 1
65
- sm = page.scanned_methods.first
66
- sm.name.should == 'NoImmunizationReason#to_c32'
67
- sm.score.should == 7.1
68
- end
69
-
70
- it "should be able to parse bang method" do
71
- page = Base.parse(@bang_method)
72
- page.should_not be_nil
73
- page.score.should == 7.08378429936994
74
- page.scanned_methods.size.should == 1
75
- sm = page.scanned_methods.first
76
- sm.name.should == 'NoImmunizationReason#to_c32!'
77
- sm.score.should == 7.1
78
- end
79
-
80
- it "should return nil when parsing invalid method" do
81
- page = Base.parse(@invalid_method)
82
- page.should be_nil
83
- end
84
- end
85
-
86
- IM = <<-IM
87
- Total flog = 7.08378429936994
88
-
89
- 3.0: code
90
- 2.3: branch
91
- 1.4: templateId
92
- 1.2: act
93
- 1.1: entryRelationship
94
- IM
95
- describe MetricFu::Flog do
96
-
97
- describe "generate_report" do
98
- it "should generate reports" do
99
- generator = Flog::Generator.new('other_dir')
100
- generator.should_receive(:flog_results).and_return(['A', 'B'])
101
- generator.should_receive(:save_html).at_least(3).times.and_return('')
102
- 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"))
103
- generator.generate_report
104
- end
105
-
106
- it "should be able to handle InvalidFlogs" do
107
- generator = Flog::Generator.new('other_dir')
108
- generator.should_receive(:flog_results).and_return(['A', 'B'])
109
- generator.should_receive(:inline_css).any_number_of_times.and_return('')
110
- generator.should_receive(:save_html).once
111
- generator.should_receive(:open).any_number_of_times.and_return(IM)
112
- generator.generate_report
113
- end
114
- end
115
-
116
- describe "template_name" do
117
- it "should return the class name in lowercase" do
118
- flog = Flog::Generator.new('base_dir')
119
- flog.template_name.should == 'flog'
120
- end
121
- end
122
- end
123
-
124
- describe MetricFu::Flog::Page do
125
-
126
- describe "average_score" do
127
- it "should calculate the average score" do
128
- page = Page.new(10)
129
- page.should_receive(:scanned_methods).any_number_of_times.and_return([ScannedMethod.new(:test, 10), ScannedMethod.new(:test, 20)])
130
- page.average_score.should == 15
131
- end
132
-
133
- it "should be able to handle divide by zero" do
134
- page = Page.new(10)
135
- page.should_receive(:scanned_methods).any_number_of_times.and_return([])
136
- page.average_score.should == 0
137
- end
138
- end
139
-
140
- describe "highest_score" do
141
- it "should calculate the average score" do
142
- page = Page.new(10)
143
- page.should_receive(:scanned_methods).any_number_of_times.and_return([ScannedMethod.new(:test, 10), ScannedMethod.new(:test, 20)])
144
- page.highest_score.should == 20
145
- end
146
- end
147
- 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