metric_fu 4.11.1 → 4.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +6 -0
  3. data/.rubocop.yml +15 -0
  4. data/.rubocop_todo.yml +69 -0
  5. data/.simplecov +35 -3
  6. data/.travis.yml +6 -10
  7. data/CONTRIBUTORS +12 -11
  8. data/Gemfile +48 -29
  9. data/Guardfile +9 -9
  10. data/HISTORY.md +47 -1
  11. data/README.md +70 -57
  12. data/Rakefile +1 -15
  13. data/appveyor.yml +34 -0
  14. data/certs/bf4.pem +20 -20
  15. data/checksum/metric_fu-4.11.1.gem.sha512 +1 -0
  16. data/checksum/metric_fu-4.11.2.gem.sha512 +1 -0
  17. data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
  18. data/checksum/metric_fu-4.11.4.gem.sha512 +1 -0
  19. data/checksum/metric_fu-4.12.0.gem.sha512 +1 -0
  20. data/checksum/metric_fu-4.13.0.gem.sha512 +1 -0
  21. data/config/rubocop.yml +269 -0
  22. data/gem_tasks/build.rake +1 -0
  23. data/gem_tasks/rubocop.rake +10 -0
  24. data/gem_tasks/yard.rake +24 -0
  25. data/lib/metric_fu.rb +20 -9
  26. data/lib/metric_fu/calculate.rb +0 -1
  27. data/lib/metric_fu/cli/client.rb +6 -6
  28. data/lib/metric_fu/cli/helper.rb +22 -13
  29. data/lib/metric_fu/cli/parser.rb +14 -18
  30. data/lib/metric_fu/configuration.rb +7 -11
  31. data/lib/metric_fu/constantize.rb +4 -4
  32. data/lib/metric_fu/data_structures/line_numbers.rb +10 -11
  33. data/lib/metric_fu/data_structures/location.rb +12 -14
  34. data/lib/metric_fu/data_structures/sexp_node.rb +31 -13
  35. data/lib/metric_fu/environment.rb +29 -31
  36. data/lib/metric_fu/formatter.rb +4 -6
  37. data/lib/metric_fu/formatter/html.rb +13 -13
  38. data/lib/metric_fu/formatter/syntax.rb +5 -7
  39. data/lib/metric_fu/formatter/yaml.rb +1 -1
  40. data/lib/metric_fu/gem_run.rb +13 -15
  41. data/lib/metric_fu/gem_version.rb +10 -12
  42. data/lib/metric_fu/generator.rb +6 -9
  43. data/lib/metric_fu/io.rb +13 -15
  44. data/lib/metric_fu/loader.rb +17 -18
  45. data/lib/metric_fu/logger.rb +15 -18
  46. data/lib/metric_fu/logging/mf_debugger.rb +4 -4
  47. data/lib/metric_fu/metric.rb +11 -12
  48. data/lib/metric_fu/metrics/cane/generator.rb +10 -9
  49. data/lib/metric_fu/metrics/cane/grapher.rb +5 -7
  50. data/lib/metric_fu/metrics/cane/metric.rb +6 -8
  51. data/lib/metric_fu/metrics/cane/report.html.erb +3 -3
  52. data/lib/metric_fu/metrics/cane/violations.rb +6 -6
  53. data/lib/metric_fu/metrics/churn/generator.rb +2 -6
  54. data/lib/metric_fu/metrics/churn/hotspot.rb +1 -3
  55. data/lib/metric_fu/metrics/churn/metric.rb +5 -7
  56. data/lib/metric_fu/metrics/flay/generator.rb +7 -11
  57. data/lib/metric_fu/metrics/flay/grapher.rb +5 -6
  58. data/lib/metric_fu/metrics/flay/hotspot.rb +5 -7
  59. data/lib/metric_fu/metrics/flay/metric.rb +5 -7
  60. data/lib/metric_fu/metrics/flog/generator.rb +35 -24
  61. data/lib/metric_fu/metrics/flog/grapher.rb +11 -11
  62. data/lib/metric_fu/metrics/flog/hotspot.rb +3 -5
  63. data/lib/metric_fu/metrics/flog/metric.rb +3 -5
  64. data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +0 -1
  65. data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +19 -18
  66. data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +0 -2
  67. data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -3
  68. data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +4 -6
  69. data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +14 -17
  70. data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +4 -5
  71. data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +1 -3
  72. data/lib/metric_fu/metrics/hotspots/analysis/record.rb +3 -5
  73. data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +0 -2
  74. data/lib/metric_fu/metrics/hotspots/analysis/table.rb +3 -4
  75. data/lib/metric_fu/metrics/hotspots/generator.rb +3 -6
  76. data/lib/metric_fu/metrics/hotspots/hotspot.rb +13 -13
  77. data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +5 -8
  78. data/lib/metric_fu/metrics/hotspots/metric.rb +1 -3
  79. data/lib/metric_fu/metrics/hotspots/report.html.erb +1 -1
  80. data/lib/metric_fu/metrics/rails_best_practices/generator.rb +14 -12
  81. data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +5 -6
  82. data/lib/metric_fu/metrics/rails_best_practices/metric.rb +5 -4
  83. data/lib/metric_fu/metrics/rcov/external_client.rb +1 -3
  84. data/lib/metric_fu/metrics/rcov/generator.rb +13 -15
  85. data/lib/metric_fu/metrics/rcov/grapher.rb +6 -7
  86. data/lib/metric_fu/metrics/rcov/hotspot.rb +5 -7
  87. data/lib/metric_fu/metrics/rcov/metric.rb +5 -7
  88. data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +16 -55
  89. data/lib/metric_fu/metrics/rcov/rcov_line.rb +48 -0
  90. data/lib/metric_fu/metrics/rcov/report.html.erb +2 -2
  91. data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +10 -11
  92. data/lib/metric_fu/metrics/reek/generator.rb +36 -82
  93. data/lib/metric_fu/metrics/reek/grapher.rb +5 -6
  94. data/lib/metric_fu/metrics/reek/hotspot.rb +5 -7
  95. data/lib/metric_fu/metrics/reek/metric.rb +2 -4
  96. data/lib/metric_fu/metrics/roodi/generator.rb +9 -10
  97. data/lib/metric_fu/metrics/roodi/grapher.rb +5 -6
  98. data/lib/metric_fu/metrics/roodi/hotspot.rb +1 -3
  99. data/lib/metric_fu/metrics/roodi/metric.rb +2 -4
  100. data/lib/metric_fu/metrics/saikuro/generator.rb +23 -27
  101. data/lib/metric_fu/metrics/saikuro/hotspot.rb +1 -3
  102. data/lib/metric_fu/metrics/saikuro/metric.rb +7 -8
  103. data/lib/metric_fu/metrics/saikuro/parsing_element.rb +6 -8
  104. data/lib/metric_fu/metrics/saikuro/report.html.erb +1 -1
  105. data/lib/metric_fu/metrics/saikuro/scratch_file.rb +24 -29
  106. data/lib/metric_fu/metrics/stats/generator.rb +9 -12
  107. data/lib/metric_fu/metrics/stats/grapher.rb +8 -9
  108. data/lib/metric_fu/metrics/stats/hotspot.rb +1 -3
  109. data/lib/metric_fu/metrics/stats/metric.rb +3 -5
  110. data/lib/metric_fu/reporter.rb +1 -1
  111. data/lib/metric_fu/reporting/graphs/graph.rb +8 -12
  112. data/lib/metric_fu/reporting/graphs/grapher.rb +7 -9
  113. data/lib/metric_fu/reporting/result.rb +0 -3
  114. data/lib/metric_fu/run.rb +12 -3
  115. data/lib/metric_fu/tasks/metric_fu.rake +8 -8
  116. data/lib/metric_fu/templates/configuration.rb +2 -5
  117. data/lib/metric_fu/templates/metrics_template.rb +45 -32
  118. data/lib/metric_fu/templates/report.rb +5 -8
  119. data/lib/metric_fu/templates/template.rb +20 -24
  120. data/lib/metric_fu/utility.rb +15 -8
  121. data/lib/metric_fu/version.rb +7 -1
  122. data/metric_fu.gemspec +29 -32
  123. data/spec/capture_warnings.rb +29 -22
  124. data/spec/cli/helper_spec.rb +9 -16
  125. data/spec/dummy/lib/bad_encoding.rb +1 -1
  126. data/spec/fixtures/coverage-153.rb +2 -2
  127. data/spec/fixtures/coverage.rb +2 -2
  128. data/spec/metric_fu/calculate_spec.rb +3 -3
  129. data/spec/metric_fu/configuration_spec.rb +71 -83
  130. data/spec/metric_fu/data_structures/line_numbers_spec.rb +3 -5
  131. data/spec/metric_fu/data_structures/location_spec.rb +13 -31
  132. data/spec/metric_fu/formatter/configuration_spec.rb +18 -20
  133. data/spec/metric_fu/formatter/html_spec.rb +21 -28
  134. data/spec/metric_fu/formatter/yaml_spec.rb +9 -17
  135. data/spec/metric_fu/formatter_spec.rb +16 -16
  136. data/spec/metric_fu/gem_version_spec.rb +4 -6
  137. data/spec/metric_fu/generator_spec.rb +33 -43
  138. data/spec/metric_fu/loader_spec.rb +5 -4
  139. data/spec/metric_fu/metric_spec.rb +21 -25
  140. data/spec/metric_fu/metrics/cane/configuration_spec.rb +14 -14
  141. data/spec/metric_fu/metrics/cane/generator_spec.rb +26 -29
  142. data/spec/metric_fu/metrics/churn/configuration_spec.rb +7 -9
  143. data/spec/metric_fu/metrics/churn/generator_spec.rb +6 -11
  144. data/spec/metric_fu/metrics/flay/configuration_spec.rb +7 -9
  145. data/spec/metric_fu/metrics/flay/generator_spec.rb +36 -37
  146. data/spec/metric_fu/metrics/flay/grapher_spec.rb +2 -2
  147. data/spec/metric_fu/metrics/flog/configuration_spec.rb +12 -14
  148. data/spec/metric_fu/metrics/flog/generator_spec.rb +31 -32
  149. data/spec/metric_fu/metrics/flog/grapher_spec.rb +8 -10
  150. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +18 -24
  151. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +12 -17
  152. data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +2 -6
  153. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -14
  154. data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +1 -3
  155. data/spec/metric_fu/metrics/hotspots/generator_spec.rb +6 -8
  156. data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +1 -3
  157. data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +4 -5
  158. data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +25 -17
  159. data/spec/metric_fu/metrics/rails_best_practices/generator_spec.rb +2 -3
  160. data/spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb +3 -3
  161. data/spec/metric_fu/metrics/rcov/configuration_spec.rb +21 -23
  162. data/spec/metric_fu/metrics/rcov/generator_spec.rb +6 -10
  163. data/spec/metric_fu/metrics/rcov/grapher_spec.rb +2 -2
  164. data/spec/metric_fu/metrics/rcov/hotspot_spec.rb +8 -8
  165. data/spec/metric_fu/metrics/rcov/rcov_line_spec.rb +89 -0
  166. data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +31 -33
  167. data/spec/metric_fu/metrics/reek/configuration_spec.rb +7 -7
  168. data/spec/metric_fu/metrics/reek/generator_spec.rb +131 -111
  169. data/spec/metric_fu/metrics/reek/grapher_spec.rb +4 -4
  170. data/spec/metric_fu/metrics/roodi/configuration_spec.rb +8 -10
  171. data/spec/metric_fu/metrics/roodi/generator_spec.rb +3 -3
  172. data/spec/metric_fu/metrics/roodi/grapher_spec.rb +2 -2
  173. data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +22 -23
  174. data/spec/metric_fu/metrics/saikuro/generator_spec.rb +7 -7
  175. data/spec/metric_fu/metrics/stats/generator_spec.rb +10 -10
  176. data/spec/metric_fu/metrics/stats/grapher_spec.rb +2 -2
  177. data/spec/metric_fu/reporter_spec.rb +8 -9
  178. data/spec/metric_fu/reporting/graphs/graph_spec.rb +1 -4
  179. data/spec/metric_fu/reporting/graphs/grapher_spec.rb +5 -5
  180. data/spec/metric_fu/reporting/result_spec.rb +12 -14
  181. data/spec/metric_fu/run_spec.rb +19 -33
  182. data/spec/metric_fu/templates/configuration_spec.rb +34 -40
  183. data/spec/metric_fu/templates/metrics_template_spec.rb +11 -0
  184. data/spec/metric_fu/templates/report_spec.rb +4 -4
  185. data/spec/metric_fu/templates/template_spec.rb +78 -64
  186. data/spec/metric_fu/utility_spec.rb +3 -3
  187. data/spec/metric_fu_spec.rb +23 -6
  188. data/spec/quality_spec.rb +43 -15
  189. data/spec/shared/configured.rb +9 -11
  190. data/spec/shared/test_coverage.rb +5 -9
  191. data/spec/spec_helper.rb +13 -31
  192. data/spec/{dummy → support}/.metrics +0 -0
  193. data/spec/support/deferred_garbaged_collection.rb +1 -2
  194. data/spec/support/matcher_create_file.rb +6 -4
  195. data/spec/support/matcher_create_files.rb +6 -4
  196. data/spec/support/samples/reek/alfa.rb +1 -0
  197. data/spec/support/suite.rb +3 -3
  198. data/spec/support/test_fixtures.rb +5 -7
  199. data/spec/support/timeout.rb +1 -1
  200. data/spec/support/usage_test.rb +24 -25
  201. data/spec/usage_test_spec.rb +30 -32
  202. metadata +104 -103
  203. checksums.yaml.gz.sig +0 -0
  204. data.tar.gz.sig +0 -0
  205. data/gemfiles/Gemfile.travis +0 -10
  206. metadata.gz.sig +0 -0
@@ -1,5 +1,5 @@
1
1
  require "spec_helper"
2
- MetricFu.metrics_require { 'flay/grapher' }
2
+ MetricFu.metrics_require { "flay/grapher" }
3
3
 
4
4
  describe FlayGrapher do
5
5
  before :each do
@@ -49,7 +49,7 @@ describe FlayGrapher do
49
49
  end
50
50
 
51
51
  it "should update labels with the date" do
52
- expect(@flay_grapher.labels).to receive(:update).with({ 0 => "1/2" })
52
+ expect(@flay_grapher.labels).to receive(:update).with(0 => "1/2")
53
53
  @flay_grapher.get_metrics(@metrics, @date)
54
54
  end
55
55
  end
@@ -1,20 +1,18 @@
1
- require 'spec_helper'
2
- require 'shared/configured'
3
-
4
- describe MetricFu::Configuration, 'for flog' do
5
- it_behaves_like 'configured' do
1
+ require "spec_helper"
2
+ require "shared/configured"
6
3
 
4
+ describe MetricFu::Configuration, "for flog" do
5
+ it_behaves_like "configured" do
7
6
  if MetricFu.configuration.mri?
8
- it 'should set @flog to {:dirs_to_flog => @code_dirs}' do
9
- load_metric 'flog'
10
- expect(MetricFu::Metric.get_metric(:flog).run_options).to eq({
11
- :all => true,
12
- :continue => true,
13
- :dirs_to_flog => ["lib"],
14
- :quiet => true
15
- })
7
+ it "should set @flog to {:dirs_to_flog => @code_dirs}" do
8
+ load_metric "flog"
9
+ expect(MetricFu::Metric.get_metric(:flog).run_options).to eq(
10
+ all: true,
11
+ continue: true,
12
+ dirs_to_flog: ["lib"],
13
+ quiet: true
14
+ )
16
15
  end
17
16
  end
18
-
19
17
  end
20
18
  end
@@ -1,8 +1,7 @@
1
1
  require "spec_helper"
2
- MetricFu.metrics_require { 'flog/generator' }
2
+ MetricFu.metrics_require { "flog/generator" }
3
3
 
4
4
  describe MetricFu::FlogGenerator do
5
-
6
5
  break if metric_not_activated?(:flog)
7
6
 
8
7
  before :each do
@@ -13,9 +12,10 @@ describe MetricFu::FlogGenerator do
13
12
 
14
13
  describe "emit method" do
15
14
  it "should look for files and flog them" do
16
- expect(FlogCLI).to receive(:parse_options).with(["--all","--continue"]).and_return("options")
17
- expect(FlogCLI).to receive(:new).with("options").and_return(flogger = double('flogger'))
18
- expect(flogger).to receive(:flog).with("lib")
15
+ expect(FlogCLI).to receive(:parse_options).with(["--all", "--continue"]).and_return("options")
16
+ expect(FlogCLI).to receive(:new).with("options").and_return(flogger = double("flogger"))
17
+ files_to_flog = Dir[File.join('lib', '**/*.{rb,rake}')]
18
+ expect(flogger).to receive(:flog).with(*files_to_flog)
19
19
  @flog.emit
20
20
  end
21
21
  end
@@ -25,34 +25,34 @@ describe MetricFu::FlogGenerator do
25
25
  first_full_method_name = "ClassName#first_method_name"
26
26
  second_full_method_name = "ClassName#second_method_name"
27
27
 
28
- flogger = double('flogger', :method_locations => {first_full_method_name => '/file/location.rb:11',
29
- second_full_method_name => '/file/location.rb:22'},
30
- :totals => {first_full_method_name => 11.11,
31
- second_full_method_name => 22.22})
28
+ flogger = double("flogger", method_locations: { first_full_method_name => "/file/location.rb:11",
29
+ second_full_method_name => "/file/location.rb:22" },
30
+ totals: { first_full_method_name => 11.11,
31
+ second_full_method_name => 22.22 })
32
32
  expect(flogger).to receive(:calculate)
33
33
  expect(flogger).to receive(:each_by_score).and_yield(
34
- first_full_method_name, 11.11, {:branch => 11.1, :puts => 1.1}
34
+ first_full_method_name, 11.11, branch: 11.1, puts: 1.1
35
35
  ).and_yield(
36
- second_full_method_name, 22.22, {:branch => 22.2, :puts => 2.2}
36
+ second_full_method_name, 22.22, branch: 22.2, puts: 2.2
37
37
  )
38
38
  @flog.instance_variable_set(:@flogger, flogger)
39
39
  @flog.analyze
40
40
  method_containers = @flog.instance_variable_get(:@method_containers)
41
41
  expect(method_containers.size).to eq(1)
42
42
 
43
- expected={:methods=>{"ClassName#first_method_name" => { :path=>"/file/location.rb:11",
44
- :score=>11.11,
45
- :operators=>{ :branch=>11.1,
46
- :puts=>1.1}},
47
- "ClassName#second_method_name" => {:path=>"/file/location.rb:22",
48
- :score=>22.22,
49
- :operators=>{ :branch=>22.2,
50
- :puts=>2.2}}},
51
- :path=>"/file/location.rb",
52
- :average_score=>((11.11 + 22.22) / 2.0),
53
- :total_score=>33.33,
54
- :highest_score=>22.22,
55
- :name=>"ClassName"}
43
+ expected = { methods: { "ClassName#first_method_name" => { path: "/file/location.rb:11",
44
+ score: 11.11,
45
+ operators: { branch: 11.1,
46
+ puts: 1.1 } },
47
+ "ClassName#second_method_name" => { path: "/file/location.rb:22",
48
+ score: 22.22,
49
+ operators: { branch: 22.2,
50
+ puts: 2.2 } } },
51
+ path: "/file/location.rb",
52
+ average_score: ((11.11 + 22.22) / 2.0),
53
+ total_score: 33.33,
54
+ highest_score: 22.22,
55
+ name: "ClassName" }
56
56
 
57
57
  expect(method_containers["ClassName"].to_h).to eq(expected)
58
58
  end
@@ -60,19 +60,18 @@ describe MetricFu::FlogGenerator do
60
60
 
61
61
  describe "to_h method" do
62
62
  it "should make-a nice hash" do
63
- flogger = double('flogger', :total_score => 111.1, :average => 7.3)
63
+ flogger = double("flogger", total_score: 111.1, average: 7.3)
64
64
  @flog.instance_variable_set(:@flogger, flogger)
65
- method_containers = {:ignore_me_1 => double('container_1', :highest_score => 11.1, :to_h => 'container_1'),
66
- :ignore_me_2 => double('container_2', :highest_score => 33.3, :to_h => 'container_2'),
67
- :ignore_me_3 => double('container_3', :highest_score => 22.2, :to_h => 'container_3')}
65
+ method_containers = { ignore_me_1: double("container_1", highest_score: 11.1, to_h: "container_1"),
66
+ ignore_me_2: double("container_2", highest_score: 33.3, to_h: "container_2"),
67
+ ignore_me_3: double("container_3", highest_score: 22.2, to_h: "container_3") }
68
68
  @flog.instance_variable_set(:@method_containers, method_containers)
69
69
 
70
- expected = {:flog => { :total => 111.1,
71
- :average => 7.3,
72
- :method_containers => ['container_2', 'container_3', 'container_1']}}
70
+ expected = { flog: { total: 111.1,
71
+ average: 7.3,
72
+ method_containers: ["container_2", "container_3", "container_1"] } }
73
73
 
74
74
  expect(@flog.to_h).to eq(expected)
75
75
  end
76
-
77
76
  end
78
77
  end
@@ -1,11 +1,10 @@
1
1
  require "spec_helper"
2
- MetricFu.metrics_require { 'flog/grapher' }
2
+ MetricFu.metrics_require { "flog/grapher" }
3
3
 
4
4
  describe MetricFu::FlogGrapher do
5
5
  before :each do
6
6
  MetricFu.configuration
7
7
  @flog_grapher = MetricFu::FlogGrapher.new
8
-
9
8
  end
10
9
 
11
10
  it "should respond to flog_total, flog_average and labels" do
@@ -26,12 +25,12 @@ describe MetricFu::FlogGrapher do
26
25
  before(:each) do
27
26
  methods = {}
28
27
  100.times do |i|
29
- methods["method_name_#{i}"] = {:score => i.to_f}
28
+ methods["method_name_#{i}"] = { score: i.to_f }
30
29
  end
31
30
 
32
- @metrics = {:flog => {:total => 111.1,
33
- :average => 7.7,
34
- :method_containers => [ {:methods => methods } ] } }
31
+ @metrics = { flog: { total: 111.1,
32
+ average: 7.7,
33
+ method_containers: [{ methods: methods }] } }
35
34
  @date = "1/2"
36
35
  end
37
36
 
@@ -48,7 +47,7 @@ describe MetricFu::FlogGrapher do
48
47
 
49
48
  context "when metrics were not generated" do
50
49
  before(:each) do
51
- @metrics = FIXTURE.load_metric('metric_missing.yml')
50
+ @metrics = FIXTURE.load_metric("metric_missing.yml")
52
51
  @date = "1/2"
53
52
  end
54
53
 
@@ -70,7 +69,7 @@ describe MetricFu::FlogGrapher do
70
69
 
71
70
  context "when metrics have been generated" do
72
71
  before(:each) do
73
- @metrics = FIXTURE.load_metric('20090630.yml')
72
+ @metrics = FIXTURE.load_metric("20090630.yml")
74
73
  @date = "1/2"
75
74
  end
76
75
 
@@ -86,7 +85,7 @@ describe MetricFu::FlogGrapher do
86
85
  end
87
86
 
88
87
  it "should update labels with the date" do
89
- expect(@flog_grapher.labels).to receive(:update).with({ 0 => "1/2" })
88
+ expect(@flog_grapher.labels).to receive(:update).with(0 => "1/2")
90
89
  @flog_grapher.get_metrics(@metrics, @date)
91
90
  end
92
91
  end
@@ -105,5 +104,4 @@ describe MetricFu::FlogGrapher do
105
104
  @flog_grapher.get_metrics(@metrics, @date)
106
105
  end
107
106
  end
108
-
109
107
  end
@@ -1,8 +1,7 @@
1
- require 'spec_helper'
2
- MetricFu.metrics_require { 'hotspots/analysis/analyzed_problems' }
1
+ require "spec_helper"
2
+ MetricFu.metrics_require { "hotspots/analysis/analyzed_problems" }
3
3
 
4
4
  describe MetricFu::HotspotAnalyzedProblems do
5
-
6
5
  before do
7
6
  enable_hotspots
8
7
  end
@@ -13,7 +12,7 @@ describe MetricFu::HotspotAnalyzedProblems do
13
12
  common_columns = %w{metric}
14
13
  granularities = %w{file_path class_name method_name}
15
14
  tool_analyzers = MetricFu::Hotspot.analyzers
16
- analyzer_columns = common_columns + granularities + tool_analyzers.map{|analyzer| analyzer.columns}.flatten
15
+ analyzer_columns = common_columns + granularities + tool_analyzers.map(&:columns).flatten
17
16
 
18
17
  analyzer_tables = MetricFu::AnalyzerTables.new(analyzer_columns)
19
18
  tool_analyzers.each do |analyzer|
@@ -29,7 +28,6 @@ describe MetricFu::HotspotAnalyzedProblems do
29
28
  end
30
29
 
31
30
  context "with several types of data" do
32
-
33
31
  before do
34
32
  @result_hash = HOTSPOT_DATA["several_metrics.yml"]
35
33
  @analyzed_problems = analyzed_problems(@result_hash)
@@ -38,8 +36,8 @@ describe MetricFu::HotspotAnalyzedProblems do
38
36
 
39
37
  it "gives all issues for a class" do
40
38
  expected = {
41
- :reek => "found 2 code smells",
42
- :flog => "complexity is 37.9"
39
+ reek: "found 2 code smells",
40
+ flog: "complexity is 37.9"
43
41
  }
44
42
  # TODO Unsure if we want to make problems_with and location public or private at this point
45
43
  expect(@worst_items[:classes].first.problems).to eq(expected)
@@ -47,44 +45,42 @@ describe MetricFu::HotspotAnalyzedProblems do
47
45
 
48
46
  it "gives all issues for a method" do
49
47
  expected = {
50
- :reek => "found 1 code smells",
51
- :flog => "complexity is 37.9"}
48
+ reek: "found 1 code smells",
49
+ flog: "complexity is 37.9" }
52
50
  expect(@worst_items[:methods].first.problems).to eq(expected)
53
51
  end
54
52
 
55
53
  it "gives all issues for a file" do
56
54
  expected = {
57
- :reek => "found 2 code smells" ,
58
- :flog => "complexity is 37.9",
59
- :churn => "detected high level of churn (changed 54 times)"}
55
+ reek: "found 2 code smells",
56
+ flog: "complexity is 37.9",
57
+ churn: "detected high level of churn (changed 54 times)" }
60
58
  expect(@worst_items[:files].first.problems).to eq(expected)
61
59
  end
62
60
 
63
61
  it "provide location for a method" do
64
62
  expected = MetricFu::Location.new("lib/client/client.rb",
65
- "Client",
66
- "Client#client_requested_sync")
63
+ "Client",
64
+ "Client#client_requested_sync")
67
65
  expect(@worst_items[:methods].first.location).to eq(expected)
68
66
  end
69
67
 
70
68
  it "provides location for a class" do
71
69
  expected = MetricFu::Location.new("lib/client/client.rb",
72
- "Client",
73
- nil)
70
+ "Client",
71
+ nil)
74
72
  expect(@worst_items[:classes].first.location).to eq(expected)
75
73
  end
76
74
 
77
75
  it "provides location for a file" do
78
76
  expected = MetricFu::Location.new("lib/client/client.rb",
79
- nil,
80
- nil)
77
+ nil,
78
+ nil)
81
79
  expect(@worst_items[:files].first.location).to eq(expected)
82
80
  end
83
-
84
81
  end
85
82
 
86
83
  context "with Saikuro data" do
87
-
88
84
  before do
89
85
  @result_hash = HOTSPOT_DATA["saikuro.yml"]
90
86
  @analyzed_problems = analyzed_problems(@result_hash)
@@ -93,18 +89,16 @@ describe MetricFu::HotspotAnalyzedProblems do
93
89
 
94
90
  it "gives complexity for method" do
95
91
  expected = {
96
- :saikuro => "complexity is 1.0"
92
+ saikuro: "complexity is 1.0"
97
93
  }
98
94
  expect(@worst_items[:methods].last.problems).to eq(expected)
99
95
  end
100
96
 
101
97
  it "gives average complexity for class" do
102
98
  expected = {
103
- :saikuro => "average complexity is 5.0"
99
+ saikuro: "average complexity is 5.0"
104
100
  }
105
101
  expect(@worst_items[:classes].last.problems).to eq(expected)
106
102
  end
107
-
108
103
  end
109
-
110
104
  end
@@ -1,8 +1,7 @@
1
- require 'spec_helper'
2
- MetricFu.metrics_require { 'hotspots/analysis/analyzer_tables' }
1
+ require "spec_helper"
2
+ MetricFu.metrics_require { "hotspots/analysis/analyzer_tables" }
3
3
 
4
4
  describe MetricFu::AnalyzerTables do
5
-
6
5
  before do
7
6
  enable_hotspots
8
7
  end
@@ -13,7 +12,7 @@ describe MetricFu::AnalyzerTables do
13
12
  common_columns = %w{metric}
14
13
  granularities = %w{file_path class_name method_name}
15
14
  tool_analyzers = MetricFu::Hotspot.analyzers
16
- analyzer_columns = common_columns + granularities + tool_analyzers.map{|analyzer| analyzer.columns}.flatten
15
+ analyzer_columns = common_columns + granularities + tool_analyzers.map(&:columns).flatten
17
16
 
18
17
  analyzer_tables = MetricFu::AnalyzerTables.new(analyzer_columns)
19
18
  tool_analyzers.each do |analyzer|
@@ -28,31 +27,28 @@ describe MetricFu::AnalyzerTables do
28
27
  end
29
28
 
30
29
  context "with Stats data" do
31
-
32
30
  before do
33
31
  @result_hash = HOTSPOT_DATA["stats.yml"]
34
32
  @table = analyzer_table(@result_hash).table
35
33
  end
36
34
 
37
35
  it "should have codeLOC" do
38
- row = @table.find{|row| row['stat_name'] == :codeLOC}
39
- expect(row['stat_value']).to eq(4222)
36
+ row = @table.find { |row| row["stat_name"] == :codeLOC }
37
+ expect(row["stat_value"]).to eq(4222)
40
38
  end
41
39
 
42
40
  it "should have testLOC" do
43
- row = @table.find{|row| row['stat_name'] == :testLOC}
44
- expect(row['stat_value']).to eq(2111)
41
+ row = @table.find { |row| row["stat_name"] == :testLOC }
42
+ expect(row["stat_value"]).to eq(2111)
45
43
  end
46
44
 
47
45
  it "should have code_to_test_ratio" do
48
- row = @table.find{|row| row['stat_name'] == :code_to_test_ratio}
49
- expect(row['stat_value']).to eq(2)
46
+ row = @table.find { |row| row["stat_name"] == :code_to_test_ratio }
47
+ expect(row["stat_value"]).to eq(2)
50
48
  end
51
-
52
49
  end
53
50
 
54
51
  context "with three different path representations of file (from Saikuro, Flog, and Reek)" do
55
-
56
52
  before do
57
53
  @result_hash = HOTSPOT_DATA["three_metrics_on_same_file.yml"]
58
54
  @table = analyzer_table(@result_hash).table
@@ -60,17 +56,16 @@ describe MetricFu::AnalyzerTables do
60
56
 
61
57
  specify "all records should have full file_path" do
62
58
  @table.each do |row|
63
- expect(row['file_path']).to eq('lib/client/client.rb')
59
+ expect(row["file_path"]).to eq("lib/client/client.rb")
64
60
  end
65
61
  end
66
62
 
67
63
  specify "all records should have class name" do
68
- expect(@table.select{|rows| rows.fetch(:class_name, :no_key) == nil }.size).to eq(0)
64
+ expect(@table.select { |rows| rows.fetch(:class_name, :no_key) == nil }.size).to eq(0)
69
65
  end
70
66
 
71
67
  specify "one record should not have method name" do
72
- expect(@table.select{|rows| rows.fetch(:method_name, :no_key) == nil }.size).to eq(0)
68
+ expect(@table.select { |rows| rows.fetch(:method_name, :no_key) == nil }.size).to eq(0)
73
69
  end
74
-
75
70
  end
76
71
  end
@@ -1,16 +1,14 @@
1
1
  require "spec_helper"
2
- MetricFu.metrics_require { 'hotspots/analysis/ranking' }
2
+ MetricFu.metrics_require { "hotspots/analysis/ranking" }
3
3
 
4
4
  describe MetricFu::Ranking do
5
-
6
5
  context "with many items" do
7
-
8
6
  specify "#top" do
9
7
  ranking = Ranking.new
10
8
  ranking[:a] = 10
11
9
  ranking[:b] = 50
12
10
  ranking[:c] = 1
13
- expect(ranking.top).to eq([:b,:a, :c])
11
+ expect(ranking.top).to eq([:b, :a, :c])
14
12
  end
15
13
 
16
14
  specify "lowest item is at 0 percentile" do
@@ -28,7 +26,5 @@ describe MetricFu::Ranking do
28
26
  ranking[:d] = 5
29
27
  expect(ranking.percentile(:b)).to eq(0.75)
30
28
  end
31
-
32
29
  end
33
-
34
30
  end
@@ -1,8 +1,7 @@
1
- require 'spec_helper'
2
- MetricFu.metrics_require { 'hotspots/analysis/rankings' }
1
+ require "spec_helper"
2
+ MetricFu.metrics_require { "hotspots/analysis/rankings" }
3
3
 
4
4
  describe MetricFu::HotspotRankings do
5
-
6
5
  before do
7
6
  enable_hotspots
8
7
  end
@@ -14,7 +13,7 @@ describe MetricFu::HotspotRankings do
14
13
  common_columns = %w{metric}
15
14
  granularities = %w{file_path class_name method_name}
16
15
  tool_analyzers = MetricFu::Hotspot.analyzers
17
- analyzer_columns = common_columns + granularities + tool_analyzers.map{|analyzer| analyzer.columns}.flatten
16
+ analyzer_columns = common_columns + granularities + tool_analyzers.map(&:columns).flatten
18
17
 
19
18
  analyzer_tables = MetricFu::AnalyzerTables.new(analyzer_columns)
20
19
  tool_analyzers.each do |analyzer|
@@ -30,8 +29,8 @@ describe MetricFu::HotspotRankings do
30
29
  context "with several types of data" do
31
30
  it "gives all files, in order, from worst to best" do
32
31
  expected = [
33
- "lib/client/client.rb",
34
- "lib/client/foo.rb"]
32
+ "lib/client/client.rb",
33
+ "lib/client/foo.rb"]
35
34
  expect(rankings(result_hash).worst_files).to eq(expected)
36
35
  end
37
36
  def result_hash
@@ -39,7 +38,6 @@ describe MetricFu::HotspotRankings do
39
38
  end
40
39
  end
41
40
  context "with Reek data" do
42
-
43
41
  before do
44
42
  @result_hash = HOTSPOT_DATA["reek.yml"]
45
43
  end
@@ -55,10 +53,8 @@ describe MetricFu::HotspotRankings do
55
53
  it "gives worst file" do
56
54
  expect(rankings(@result_hash).worst_files[0]).to eq("lib/client/client.rb")
57
55
  end
58
-
59
56
  end
60
57
  context "with Saikuro data" do
61
-
62
58
  before do
63
59
  @result_hash = HOTSPOT_DATA["saikuro.yml"]
64
60
  end
@@ -70,10 +66,8 @@ describe MetricFu::HotspotRankings do
70
66
  it "gives worst class" do
71
67
  expect(rankings(@result_hash).worst_classes[0]).to eq("Bitly")
72
68
  end
73
-
74
69
  end
75
70
  context "with Flog data" do
76
-
77
71
  before do
78
72
  @result_hash = HOTSPOT_DATA["flog.yml"]
79
73
  end
@@ -89,11 +83,9 @@ describe MetricFu::HotspotRankings do
89
83
  it "gives worst file" do
90
84
  expect(rankings(@result_hash).worst_files[0]).to eq("lib/generators/rcov.rb:57")
91
85
  end
92
-
93
86
  end
94
87
 
95
88
  context "with Roodi data" do
96
-
97
89
  before do
98
90
  @result_hash = HOTSPOT_DATA["roodi.yml"]
99
91
  end
@@ -101,6 +93,5 @@ describe MetricFu::HotspotRankings do
101
93
  it "gives worst file" do
102
94
  expect(rankings(@result_hash).worst_files[0]).to eq("lib/client/client.rb")
103
95
  end
104
-
105
96
  end
106
97
  end