indirect-metric_fu 0.8.2 → 0.9.0

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 (50) hide show
  1. data/HISTORY +19 -0
  2. data/MIT-LICENSE +1 -1
  3. data/Manifest.txt +25 -0
  4. data/README +74 -21
  5. data/Rakefile +4 -10
  6. data/lib/metric_fu/base.rb +116 -9
  7. data/lib/metric_fu/churn.rb +8 -7
  8. data/lib/metric_fu/flay.rb +17 -0
  9. data/lib/metric_fu/flog.rb +129 -0
  10. data/lib/metric_fu/reek.rb +17 -0
  11. data/lib/metric_fu/roodi.rb +17 -0
  12. data/lib/metric_fu.rb +17 -3
  13. data/lib/tasks/churn.rake +1 -3
  14. data/lib/tasks/coverage.rake +19 -10
  15. data/lib/tasks/flay.rake +1 -4
  16. data/lib/tasks/flog.rake +10 -10
  17. data/lib/tasks/metric_fu.rake +8 -4
  18. data/lib/tasks/metric_fu.rb +1 -1
  19. data/lib/tasks/railroad.rake +39 -0
  20. data/lib/tasks/reek.rake +6 -0
  21. data/lib/tasks/roodi.rake +7 -0
  22. data/lib/tasks/saikuro.rake +1 -1
  23. data/lib/tasks/stats.rake +2 -3
  24. data/lib/templates/churn.html.erb +7 -4
  25. data/lib/templates/default.css +45 -0
  26. data/lib/templates/flay.html.erb +17 -10
  27. data/lib/templates/flog.html.erb +27 -15
  28. data/lib/templates/flog_page.html.erb +15 -3
  29. data/lib/templates/reek.html.erb +30 -0
  30. data/lib/templates/roodi.html.erb +26 -0
  31. data/spec/base_spec.rb +31 -9
  32. data/spec/churn_spec.rb +11 -4
  33. data/spec/config_spec.rb +110 -0
  34. data/spec/{flay_reporter_spec.rb → flay_spec.rb} +10 -3
  35. data/spec/flog_spec.rb +208 -0
  36. data/spec/md5_tracker_spec.rb +1 -3
  37. data/spec/reek_spec.rb +26 -0
  38. data/spec/spec_helper.rb +7 -3
  39. metadata +42 -18
  40. data/lib/metric_fu/flay_reporter.rb +0 -17
  41. data/lib/metric_fu/flog_reporter/base.rb +0 -49
  42. data/lib/metric_fu/flog_reporter/generator.rb +0 -39
  43. data/lib/metric_fu/flog_reporter/operator.rb +0 -10
  44. data/lib/metric_fu/flog_reporter/page.rb +0 -33
  45. data/lib/metric_fu/flog_reporter/scanned_method.rb +0 -28
  46. data/lib/metric_fu/flog_reporter.rb +0 -5
  47. data/lib/templates/churn.css +0 -38
  48. data/lib/templates/flay.css +0 -38
  49. data/lib/templates/flog.css +0 -39
  50. data/spec/flog_reporter/base_spec.rb +0 -69
@@ -1,39 +0,0 @@
1
- module MetricFu::FlogReporter
2
- class Generator < MetricFu::Base::Generator
3
- def generate_report
4
- flog_hashes = []
5
- Dir.glob("#{@base_dir}/**/*.txt").each do |filename|
6
- begin
7
- page = Base.parse(open(filename, "r") { |f| f.read })
8
- rescue InvalidFlog
9
- puts "Invalid flog for #{filename}"
10
- next
11
- end
12
-
13
- next unless page
14
-
15
- unless MetricFu::MD5Tracker.file_already_counted?(filename)
16
- generate_page(filename, page)
17
- end
18
- flog_hashes << { :path => File.basename(filename, ".txt") + '.html',
19
- :page => page }
20
- end
21
-
22
- generate_index(flog_hashes)
23
- end
24
-
25
- def generate_page(filename, page)
26
- save_html(page.to_html, File.basename(filename, ".txt"))
27
- end
28
-
29
- # should be dynamically read from the class
30
- def template_name
31
- 'flog'
32
- end
33
-
34
- def generate_index(flog_hashes)
35
- html = ERB.new(File.read(template_file)).result(binding)
36
- save_html(html)
37
- end
38
- end
39
- end
@@ -1,10 +0,0 @@
1
- module MetricFu::FlogReporter
2
- class Operator
3
- attr_accessor :score, :operator
4
-
5
- def initialize(score, operator)
6
- @score = score.to_f
7
- @operator = operator
8
- end
9
- end
10
- end
@@ -1,33 +0,0 @@
1
- module MetricFu::FlogReporter
2
- class Page < MetricFu::Base::Generator
3
- attr_accessor :score, :scanned_methods
4
-
5
- def initialize(score, scanned_methods = [])
6
- @score = score.to_f
7
- @scanned_methods = scanned_methods
8
- end
9
-
10
- def to_html
11
- ERB.new(File.read(template_file)).result(binding)
12
- end
13
-
14
- def average_score
15
- sum = 0
16
- scanned_methods.each do |m|
17
- sum += m.score
18
- end
19
- sum / scanned_methods.length
20
- end
21
-
22
- def highest_score
23
- scanned_methods.inject(0) do |highest, m|
24
- m.score > highest ? m.score : highest
25
- end
26
- end
27
-
28
- # should be dynamically read from the class
29
- def template_name
30
- 'flog_page'
31
- end
32
- end
33
- end
@@ -1,28 +0,0 @@
1
- module MetricFu::FlogReporter
2
- class ScannedMethod
3
- attr_accessor :name, :score, :operators
4
-
5
- def initialize(name, score, operators = [])
6
- @name = name
7
- @score = score.to_f
8
- @operators = operators
9
- end
10
-
11
- def to_html
12
- output = "<p><strong>#{name} (#{score})</strong></p>\n"
13
- output << "<table>\n"
14
- output << "<tr><th>Score</th><th>Operator</th></tr>\n"
15
- count = 0
16
- operators.each do |operator|
17
- output << <<-EOF
18
- <tr class='#{Base.cycle("light", "dark", count)}'>
19
- <td class='score'>#{sprintf(SCORE_FORMAT, operator.score)}</td>
20
- <td class='score'>#{operator.operator}</td>
21
- </tr>
22
- EOF
23
- count += 1
24
- end
25
- output << "</table>\n\n"
26
- end
27
- end
28
- end
@@ -1,5 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'flog_reporter', 'base')
2
- require File.join(File.dirname(__FILE__), 'flog_reporter', 'page')
3
- require File.join(File.dirname(__FILE__), 'flog_reporter', 'scanned_method')
4
- require File.join(File.dirname(__FILE__), 'flog_reporter', 'operator')
5
- require File.join(File.dirname(__FILE__), 'flog_reporter', 'generator')
@@ -1,38 +0,0 @@
1
- body {
2
- margin: 20px;
3
- padding: 0;
4
- font-size: 12px;
5
- font-family: bitstream vera sans, verdana, arial, sans serif;
6
- background-color: #efefef;
7
- }
8
-
9
- table {
10
- border-collapse: collapse;
11
- /*border-spacing: 0;*/
12
- border: 1px solid #666;
13
- background-color: #fff;
14
- margin-bottom: 20px;
15
- }
16
-
17
- table, th, th+th, td, td+td {
18
- border: 1px solid #ccc;
19
- }
20
-
21
- table th {
22
- font-size: 12px;
23
- color: #fc0;
24
- padding: 4px 0;
25
- background-color: #336;
26
- }
27
-
28
- th, td {
29
- padding: 4px 10px;
30
- }
31
-
32
- td {
33
- font-size: 13px;
34
- }
35
-
36
- .warning {
37
- background-color: yellow;
38
- }
@@ -1,38 +0,0 @@
1
- body {
2
- margin: 20px;
3
- padding: 0;
4
- font-size: 12px;
5
- font-family: bitstream vera sans, verdana, arial, sans serif;
6
- background-color: #efefef;
7
- }
8
-
9
- table {
10
- border-collapse: collapse;
11
- /*border-spacing: 0;*/
12
- border: 1px solid #666;
13
- background-color: #fff;
14
- margin-bottom: 10px;
15
- }
16
-
17
- table, th, th+th, td, td+td {
18
- border: 1px solid #ccc;
19
- }
20
-
21
- table th {
22
- font-size: 14px;
23
- color: #fc0;
24
- background-color: #336;
25
- text-align: left;
26
- }
27
-
28
- th, td {
29
- padding: 4px 10px;
30
- }
31
-
32
- td {
33
- font-size: 13px;
34
- }
35
-
36
- .warning {
37
- background-color: yellow;
38
- }
@@ -1,39 +0,0 @@
1
- body {
2
- background-color: rgb(240, 240, 245);
3
- font-family: verdana, arial, helvetica;
4
- }
5
-
6
- table {
7
- border-collapse: collapse;
8
- }
9
-
10
- table.report {
11
- width: 100%;
12
- }
13
-
14
- table th {
15
- text-align: center;
16
- }
17
-
18
- table td.score {
19
- text-align: right;
20
- }
21
-
22
- table th {
23
- background: #dcecff;
24
- border: #d0d0d0 1px solid;
25
- font-weight: bold;
26
- }
27
-
28
- table td {
29
- border: #d0d0d0 1px solid;
30
- }
31
-
32
- table tr.light {
33
- background-color: rgb(240, 240, 245);
34
- }
35
-
36
- table tr.dark {
37
- background-color: rgb(230, 230, 235);
38
- }
39
-
@@ -1,69 +0,0 @@
1
- require 'spec'
2
- require File.dirname(__FILE__) + '/../../lib/metric_fu/flog_reporter'
3
- include MetricFu::FlogReporter
4
-
5
- describe "FlogReporter::Base" do
6
- before do
7
- @alpha_only_method = <<-AOM
8
- Total flog = 13.6283678106927
9
-
10
- ErrorMailer#errormail: (12.5)
11
- 12.0: assignment
12
- 1.2: []
13
- 1.2: now
14
- 1.2: content_type
15
- AOM
16
-
17
- @method_that_has_digits = <<-MTHD
18
- Total flog = 7.08378429936994
19
-
20
- NoImmunizationReason#to_c32: (7.1)
21
- 3.0: code
22
- 2.3: branch
23
- 1.4: templateId
24
- 1.2: act
25
- 1.1: entryRelationship
26
- MTHD
27
-
28
- @bang_method = <<-BM
29
- Total flog = 7.08378429936994
30
-
31
- NoImmunizationReason#to_c32!: (7.1)
32
- 3.0: code
33
- 2.3: branch
34
- 1.4: templateId
35
- 1.2: act
36
- 1.1: entryRelationship
37
- BM
38
- end
39
-
40
- it "should be able to parse an alpha only method" do
41
- page = Base.parse(@alpha_only_method)
42
- page.should_not be_nil
43
- page.score.should == 13.6283678106927
44
- page.scanned_methods.size.should == 1
45
- sm = page.scanned_methods.first
46
- sm.name.should == 'ErrorMailer#errormail'
47
- sm.score.should == 12.5
48
- end
49
-
50
- it "should be able to parse method that has digits" do
51
- page = Base.parse(@method_that_has_digits)
52
- page.should_not be_nil
53
- page.score.should == 7.08378429936994
54
- page.scanned_methods.size.should == 1
55
- sm = page.scanned_methods.first
56
- sm.name.should == 'NoImmunizationReason#to_c32'
57
- sm.score.should == 7.1
58
- end
59
-
60
- it "should be able to parse bang method" do
61
- page = Base.parse(@bang_method)
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
- end