metric_fu 4.11.3 → 4.11.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.rubocop.yml +15 -0
  5. data/.rubocop_todo.yml +69 -0
  6. data/.travis.yml +0 -1
  7. data/CONTRIBUTORS +1 -1
  8. data/Gemfile +23 -20
  9. data/Guardfile +9 -9
  10. data/HISTORY.md +10 -1
  11. data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
  12. data/config/rubocop.yml +269 -0
  13. data/gem_tasks/rubocop.rake +10 -0
  14. data/lib/metric_fu.rb +11 -9
  15. data/lib/metric_fu/calculate.rb +0 -1
  16. data/lib/metric_fu/cli/client.rb +6 -6
  17. data/lib/metric_fu/cli/helper.rb +22 -13
  18. data/lib/metric_fu/cli/parser.rb +14 -18
  19. data/lib/metric_fu/configuration.rb +7 -11
  20. data/lib/metric_fu/constantize.rb +4 -4
  21. data/lib/metric_fu/data_structures/line_numbers.rb +10 -11
  22. data/lib/metric_fu/data_structures/location.rb +12 -14
  23. data/lib/metric_fu/data_structures/sexp_node.rb +31 -13
  24. data/lib/metric_fu/environment.rb +29 -31
  25. data/lib/metric_fu/formatter.rb +4 -6
  26. data/lib/metric_fu/formatter/html.rb +13 -13
  27. data/lib/metric_fu/formatter/syntax.rb +5 -7
  28. data/lib/metric_fu/formatter/yaml.rb +1 -1
  29. data/lib/metric_fu/gem_run.rb +13 -15
  30. data/lib/metric_fu/gem_version.rb +9 -11
  31. data/lib/metric_fu/generator.rb +5 -8
  32. data/lib/metric_fu/io.rb +13 -15
  33. data/lib/metric_fu/loader.rb +17 -18
  34. data/lib/metric_fu/logger.rb +15 -18
  35. data/lib/metric_fu/logging/mf_debugger.rb +4 -4
  36. data/lib/metric_fu/metric.rb +11 -12
  37. data/lib/metric_fu/metrics/cane/generator.rb +10 -9
  38. data/lib/metric_fu/metrics/cane/grapher.rb +5 -7
  39. data/lib/metric_fu/metrics/cane/metric.rb +6 -8
  40. data/lib/metric_fu/metrics/cane/report.html.erb +3 -3
  41. data/lib/metric_fu/metrics/cane/violations.rb +6 -6
  42. data/lib/metric_fu/metrics/churn/generator.rb +2 -6
  43. data/lib/metric_fu/metrics/churn/hotspot.rb +1 -3
  44. data/lib/metric_fu/metrics/churn/metric.rb +5 -7
  45. data/lib/metric_fu/metrics/flay/generator.rb +7 -11
  46. data/lib/metric_fu/metrics/flay/grapher.rb +5 -6
  47. data/lib/metric_fu/metrics/flay/hotspot.rb +5 -7
  48. data/lib/metric_fu/metrics/flay/metric.rb +5 -7
  49. data/lib/metric_fu/metrics/flog/generator.rb +22 -23
  50. data/lib/metric_fu/metrics/flog/grapher.rb +11 -11
  51. data/lib/metric_fu/metrics/flog/hotspot.rb +3 -5
  52. data/lib/metric_fu/metrics/flog/metric.rb +3 -5
  53. data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +0 -1
  54. data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +19 -18
  55. data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +0 -2
  56. data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -3
  57. data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +4 -6
  58. data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +14 -9
  59. data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +4 -5
  60. data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +1 -3
  61. data/lib/metric_fu/metrics/hotspots/analysis/record.rb +3 -5
  62. data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +0 -2
  63. data/lib/metric_fu/metrics/hotspots/analysis/table.rb +3 -4
  64. data/lib/metric_fu/metrics/hotspots/generator.rb +3 -6
  65. data/lib/metric_fu/metrics/hotspots/hotspot.rb +13 -13
  66. data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +5 -8
  67. data/lib/metric_fu/metrics/hotspots/metric.rb +1 -3
  68. data/lib/metric_fu/metrics/hotspots/report.html.erb +1 -1
  69. data/lib/metric_fu/metrics/rails_best_practices/generator.rb +10 -12
  70. data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +5 -6
  71. data/lib/metric_fu/metrics/rails_best_practices/metric.rb +1 -3
  72. data/lib/metric_fu/metrics/rcov/external_client.rb +1 -3
  73. data/lib/metric_fu/metrics/rcov/generator.rb +13 -15
  74. data/lib/metric_fu/metrics/rcov/grapher.rb +6 -7
  75. data/lib/metric_fu/metrics/rcov/hotspot.rb +5 -7
  76. data/lib/metric_fu/metrics/rcov/metric.rb +5 -7
  77. data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +16 -55
  78. data/lib/metric_fu/metrics/rcov/rcov_line.rb +48 -0
  79. data/lib/metric_fu/metrics/rcov/report.html.erb +2 -2
  80. data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +10 -11
  81. data/lib/metric_fu/metrics/reek/generator.rb +22 -23
  82. data/lib/metric_fu/metrics/reek/grapher.rb +5 -6
  83. data/lib/metric_fu/metrics/reek/hotspot.rb +5 -7
  84. data/lib/metric_fu/metrics/reek/metric.rb +2 -4
  85. data/lib/metric_fu/metrics/roodi/generator.rb +9 -10
  86. data/lib/metric_fu/metrics/roodi/grapher.rb +5 -6
  87. data/lib/metric_fu/metrics/roodi/hotspot.rb +1 -3
  88. data/lib/metric_fu/metrics/roodi/metric.rb +2 -4
  89. data/lib/metric_fu/metrics/saikuro/generator.rb +23 -27
  90. data/lib/metric_fu/metrics/saikuro/hotspot.rb +1 -3
  91. data/lib/metric_fu/metrics/saikuro/metric.rb +7 -8
  92. data/lib/metric_fu/metrics/saikuro/parsing_element.rb +6 -8
  93. data/lib/metric_fu/metrics/saikuro/report.html.erb +1 -1
  94. data/lib/metric_fu/metrics/saikuro/scratch_file.rb +24 -29
  95. data/lib/metric_fu/metrics/stats/generator.rb +9 -12
  96. data/lib/metric_fu/metrics/stats/grapher.rb +8 -9
  97. data/lib/metric_fu/metrics/stats/hotspot.rb +1 -3
  98. data/lib/metric_fu/metrics/stats/metric.rb +3 -5
  99. data/lib/metric_fu/reporter.rb +1 -1
  100. data/lib/metric_fu/reporting/graphs/graph.rb +8 -12
  101. data/lib/metric_fu/reporting/graphs/grapher.rb +7 -9
  102. data/lib/metric_fu/reporting/result.rb +0 -3
  103. data/lib/metric_fu/run.rb +12 -3
  104. data/lib/metric_fu/tasks/metric_fu.rake +8 -8
  105. data/lib/metric_fu/templates/configuration.rb +2 -5
  106. data/lib/metric_fu/templates/metrics_template.rb +19 -19
  107. data/lib/metric_fu/templates/report.rb +5 -8
  108. data/lib/metric_fu/templates/template.rb +20 -24
  109. data/lib/metric_fu/utility.rb +7 -8
  110. data/lib/metric_fu/version.rb +1 -1
  111. data/metric_fu.gemspec +31 -32
  112. data/spec/cli/helper_spec.rb +7 -14
  113. data/spec/dummy/lib/bad_encoding.rb +1 -1
  114. data/spec/fixtures/coverage-153.rb +2 -2
  115. data/spec/fixtures/coverage.rb +2 -2
  116. data/spec/metric_fu/calculate_spec.rb +3 -3
  117. data/spec/metric_fu/configuration_spec.rb +70 -82
  118. data/spec/metric_fu/data_structures/line_numbers_spec.rb +3 -5
  119. data/spec/metric_fu/data_structures/location_spec.rb +13 -31
  120. data/spec/metric_fu/formatter/configuration_spec.rb +11 -13
  121. data/spec/metric_fu/formatter/html_spec.rb +21 -28
  122. data/spec/metric_fu/formatter/yaml_spec.rb +9 -17
  123. data/spec/metric_fu/formatter_spec.rb +6 -6
  124. data/spec/metric_fu/gem_version_spec.rb +3 -5
  125. data/spec/metric_fu/generator_spec.rb +28 -38
  126. data/spec/metric_fu/loader_spec.rb +1 -3
  127. data/spec/metric_fu/metric_spec.rb +17 -21
  128. data/spec/metric_fu/metrics/cane/configuration_spec.rb +8 -8
  129. data/spec/metric_fu/metrics/cane/generator_spec.rb +26 -29
  130. data/spec/metric_fu/metrics/churn/configuration_spec.rb +6 -8
  131. data/spec/metric_fu/metrics/churn/generator_spec.rb +6 -11
  132. data/spec/metric_fu/metrics/flay/configuration_spec.rb +6 -8
  133. data/spec/metric_fu/metrics/flay/generator_spec.rb +36 -37
  134. data/spec/metric_fu/metrics/flay/grapher_spec.rb +2 -2
  135. data/spec/metric_fu/metrics/flog/configuration_spec.rb +11 -13
  136. data/spec/metric_fu/metrics/flog/generator_spec.rb +29 -31
  137. data/spec/metric_fu/metrics/flog/grapher_spec.rb +8 -10
  138. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +18 -24
  139. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +12 -17
  140. data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +2 -6
  141. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -14
  142. data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +1 -3
  143. data/spec/metric_fu/metrics/hotspots/generator_spec.rb +6 -8
  144. data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +1 -3
  145. data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +4 -5
  146. data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +6 -10
  147. data/spec/metric_fu/metrics/rails_best_practices/generator_spec.rb +2 -3
  148. data/spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb +3 -3
  149. data/spec/metric_fu/metrics/rcov/configuration_spec.rb +20 -22
  150. data/spec/metric_fu/metrics/rcov/generator_spec.rb +6 -10
  151. data/spec/metric_fu/metrics/rcov/grapher_spec.rb +2 -2
  152. data/spec/metric_fu/metrics/rcov/hotspot_spec.rb +8 -8
  153. data/spec/metric_fu/metrics/rcov/rcov_line_spec.rb +89 -0
  154. data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +31 -33
  155. data/spec/metric_fu/metrics/reek/configuration_spec.rb +6 -6
  156. data/spec/metric_fu/metrics/reek/generator_spec.rb +19 -20
  157. data/spec/metric_fu/metrics/reek/grapher_spec.rb +4 -4
  158. data/spec/metric_fu/metrics/roodi/configuration_spec.rb +7 -9
  159. data/spec/metric_fu/metrics/roodi/generator_spec.rb +3 -3
  160. data/spec/metric_fu/metrics/roodi/grapher_spec.rb +2 -2
  161. data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +18 -19
  162. data/spec/metric_fu/metrics/saikuro/generator_spec.rb +7 -7
  163. data/spec/metric_fu/metrics/stats/generator_spec.rb +9 -9
  164. data/spec/metric_fu/metrics/stats/grapher_spec.rb +2 -2
  165. data/spec/metric_fu/reporter_spec.rb +3 -4
  166. data/spec/metric_fu/reporting/graphs/graph_spec.rb +1 -4
  167. data/spec/metric_fu/reporting/graphs/grapher_spec.rb +5 -5
  168. data/spec/metric_fu/reporting/result_spec.rb +9 -11
  169. data/spec/metric_fu/run_spec.rb +18 -32
  170. data/spec/metric_fu/templates/configuration_spec.rb +28 -34
  171. data/spec/metric_fu/templates/metrics_template_spec.rb +11 -0
  172. data/spec/metric_fu/templates/report_spec.rb +4 -4
  173. data/spec/metric_fu/templates/template_spec.rb +62 -48
  174. data/spec/metric_fu/utility_spec.rb +2 -2
  175. data/spec/metric_fu_spec.rb +5 -7
  176. data/spec/shared/configured.rb +9 -11
  177. data/spec/shared/test_coverage.rb +5 -9
  178. data/spec/spec_helper.rb +9 -9
  179. data/spec/support/deferred_garbaged_collection.rb +1 -2
  180. data/spec/support/matcher_create_file.rb +2 -4
  181. data/spec/support/matcher_create_files.rb +2 -4
  182. data/spec/support/suite.rb +3 -3
  183. data/spec/support/test_fixtures.rb +5 -7
  184. data/spec/support/timeout.rb +1 -1
  185. data/spec/support/usage_test.rb +23 -24
  186. data/spec/usage_test_spec.rb +18 -20
  187. metadata +12 -2
  188. metadata.gz.sig +0 -0
@@ -1,15 +1,13 @@
1
- require 'spec_helper'
2
- require 'shared/configured'
3
-
4
- describe MetricFu::Configuration, 'for churn' do
5
- it_behaves_like 'configured' do
1
+ require "spec_helper"
2
+ require "shared/configured"
6
3
 
4
+ describe MetricFu::Configuration, "for churn" do
5
+ it_behaves_like "configured" do
7
6
  it "should set @churn to {}" do
8
- load_metric 'churn'
7
+ load_metric "churn"
9
8
  expect(MetricFu::Metric.get_metric(:churn).run_options).to eq(
10
- { :start_date => %q("1 year ago"), :minimum_churn_count => 10, :ignore_files=>[], :data_directory=> MetricFu::Io::FileSystem.scratch_directory('churn')}
9
+ start_date: '"1 year ago"', minimum_churn_count: 10, ignore_files: [], data_directory: MetricFu::Io::FileSystem.scratch_directory("churn")
11
10
  )
12
11
  end
13
-
14
12
  end
15
13
  end
@@ -1,39 +1,36 @@
1
1
  require "spec_helper"
2
- MetricFu.metrics_require { 'churn/generator' }
2
+ MetricFu.metrics_require { "churn/generator" }
3
3
 
4
4
  describe MetricFu::ChurnGenerator do
5
-
6
5
  # TODO extract yaml
7
6
  let(:churn_hash) { YAML::load("--- \n:churn: \n :changed_files: \n - spec/graphs/flog_grapher_spec.rb\n - spec/base/graph_spec.rb\n - lib/templates/awesome/layout.html.erb\n - lib/graphs/rcov_grapher.rb\n - lib/base/base_template.rb\n - spec/graphs/grapher_spec.rb\n - lib/templates/awesome/flog.html.erb\n - lib/templates/awesome/flay.html.erb\n - lib/graphs/roodi_grapher.rb\n - lib/graphs/reek_grapher.rb\n - HISTORY\n - spec/graphs/roodi_grapher_spec.rb\n - lib/generators/rcov.rb\n - spec/graphs/engines/gchart_spec.rb\n - spec/graphs/rcov_grapher_spec.rb\n - lib/templates/javascripts/excanvas.js\n - lib/templates/javascripts/bluff-min.js\n - spec/graphs/reek_grapher_spec.rb\n") }
8
7
 
9
8
  let(:config_setup) {
10
- ENV['CC_BUILD_ARTIFACTS'] = nil
9
+ ENV["CC_BUILD_ARTIFACTS"] = nil
11
10
  MetricFu.configure.reset
12
11
  }
13
12
 
14
13
  describe "analyze method" do
15
14
  before :each do
16
15
  config_setup
17
- @changes = {"lib/generators/flog.rb" => 2, "lib/metric_fu.rb" => 3}
16
+ @changes = { "lib/generators/flog.rb" => 2, "lib/metric_fu.rb" => 3 }
18
17
  end
19
18
 
20
19
  it "should be empty on error no output captured" do
21
20
  churn = MetricFu::ChurnGenerator.new
22
21
  churn.instance_variable_set(:@output, nil)
23
22
  result = churn.analyze
24
- expect(result).to eq({:churn => {}})
23
+ expect(result).to eq(churn: {})
25
24
  end
26
25
 
27
26
  it "should return yaml results" do
28
27
  churn = MetricFu::ChurnGenerator.new
29
28
  churn.instance_variable_set(:@output, churn_hash)
30
29
  result = churn.analyze
31
- expect(result).to eq({:churn => {:changed_files => ["spec/graphs/flog_grapher_spec.rb", "spec/base/graph_spec.rb", "lib/templates/awesome/layout.html.erb", "lib/graphs/rcov_grapher.rb", "lib/base/base_template.rb", "spec/graphs/grapher_spec.rb", "lib/templates/awesome/flog.html.erb", "lib/templates/awesome/flay.html.erb", "lib/graphs/roodi_grapher.rb", "lib/graphs/reek_grapher.rb", "HISTORY", "spec/graphs/roodi_grapher_spec.rb", "lib/generators/rcov.rb", "spec/graphs/engines/gchart_spec.rb", "spec/graphs/rcov_grapher_spec.rb", "lib/templates/javascripts/excanvas.js", "lib/templates/javascripts/bluff-min.js", "spec/graphs/reek_grapher_spec.rb"]}})
30
+ expect(result).to eq(churn: { changed_files: ["spec/graphs/flog_grapher_spec.rb", "spec/base/graph_spec.rb", "lib/templates/awesome/layout.html.erb", "lib/graphs/rcov_grapher.rb", "lib/base/base_template.rb", "spec/graphs/grapher_spec.rb", "lib/templates/awesome/flog.html.erb", "lib/templates/awesome/flay.html.erb", "lib/graphs/roodi_grapher.rb", "lib/graphs/reek_grapher.rb", "HISTORY", "spec/graphs/roodi_grapher_spec.rb", "lib/generators/rcov.rb", "spec/graphs/engines/gchart_spec.rb", "spec/graphs/rcov_grapher_spec.rb", "lib/templates/javascripts/excanvas.js", "lib/templates/javascripts/bluff-min.js", "spec/graphs/reek_grapher_spec.rb"] })
32
31
  end
33
-
34
32
  end
35
33
 
36
-
37
34
  describe "to_h method" do
38
35
  before :each do
39
36
  config_setup
@@ -41,12 +38,11 @@ describe MetricFu::ChurnGenerator do
41
38
 
42
39
  it "should put the changes into a hash" do
43
40
  churn = MetricFu::ChurnGenerator.new
44
- churn.instance_variable_set(:@churn, {:churn => 'results'})
41
+ churn.instance_variable_set(:@churn, churn: "results")
45
42
  expect(churn.to_h[:churn]).to eq("results")
46
43
  end
47
44
  end
48
45
 
49
-
50
46
  describe "emit method" do
51
47
  before :each do
52
48
  config_setup
@@ -66,4 +62,3 @@ describe MetricFu::ChurnGenerator do
66
62
  end
67
63
  end
68
64
  end
69
-
@@ -1,15 +1,13 @@
1
- require 'spec_helper'
2
- require 'shared/configured'
3
-
4
- describe MetricFu::Configuration, 'for flay' do
5
- it_behaves_like 'configured' do
1
+ require "spec_helper"
2
+ require "shared/configured"
6
3
 
4
+ describe MetricFu::Configuration, "for flay" do
5
+ it_behaves_like "configured" do
7
6
  it "should set @flay to {:dirs_to_flay => @code_dirs}" do
8
- load_metric 'flay'
7
+ load_metric "flay"
9
8
  expect(MetricFu::Metric.get_metric(:flay).run_options).to eq(
10
- {:dirs_to_flay => ['lib'], :minimum_score=>nil}
9
+ dirs_to_flay: ["lib"], minimum_score: nil
11
10
  )
12
11
  end
13
-
14
12
  end
15
13
  end
@@ -1,10 +1,10 @@
1
1
  require "spec_helper"
2
- MetricFu.metrics_require { 'flay/generator' }
2
+ MetricFu.metrics_require { "flay/generator" }
3
3
 
4
4
  describe MetricFu::FlayGenerator do
5
5
  describe "emit method" do
6
6
  it "should look at the dirs" do
7
- options = { :dirs_to_flay => ['app', 'lib'] }
7
+ options = { dirs_to_flay: ["app", "lib"] }
8
8
  allow(File).to receive(:directory?).and_return(true)
9
9
  @flay = MetricFu::FlayGenerator.new(options)
10
10
 
@@ -13,7 +13,7 @@ describe MetricFu::FlayGenerator do
13
13
  end
14
14
 
15
15
  it "should limit flay scores by the minimum_score" do
16
- options = { :dirs_to_flay => [], :minimum_score => 99 }
16
+ options = { dirs_to_flay: [], minimum_score: 99 }
17
17
  allow(File).to receive(:directory?).and_return(true)
18
18
  @flay = MetricFu::FlayGenerator.new(options)
19
19
 
@@ -40,57 +40,56 @@ Total score (lower is better) = 246
40
40
  HERE
41
41
  MetricFu::Configuration.run {}
42
42
  allow(File).to receive(:directory?).and_return(true)
43
- @flay = MetricFu::FlayGenerator.new('base_dir')
43
+ @flay = MetricFu::FlayGenerator.new("base_dir")
44
44
  @flay.instance_variable_set(:@output, lines)
45
45
  end
46
46
 
47
47
  it "should analyze and return matches" do
48
- expect(@flay.analyze).to eq([ ["Total score (lower is better) = 246"],
49
- ["\n1) IDENTICAL code found in :or (mass*2 = 68)",
50
- "app/controllers/link_targets_controller.rb:57",
51
- "app/controllers/primary_sites_controller.rb:138"],
52
- ["2) Similar code found in :if (mass = 64)",
53
- "app/controllers/primary_sites_controller.rb:75",
54
- "app/controllers/primary_sites_controller.rb:76",
55
- "app/controllers/primary_sites_controller.rb:88",
56
- "app/controllers/primary_sites_controller.rb:89"] ])
48
+ expect(@flay.analyze).to eq([["Total score (lower is better) = 246"],
49
+ ["\n1) IDENTICAL code found in :or (mass*2 = 68)",
50
+ "app/controllers/link_targets_controller.rb:57",
51
+ "app/controllers/primary_sites_controller.rb:138"],
52
+ ["2) Similar code found in :if (mass = 64)",
53
+ "app/controllers/primary_sites_controller.rb:75",
54
+ "app/controllers/primary_sites_controller.rb:76",
55
+ "app/controllers/primary_sites_controller.rb:88",
56
+ "app/controllers/primary_sites_controller.rb:89"]])
57
57
  end
58
58
  end
59
59
 
60
60
  describe "to_h method" do
61
-
62
61
  before :each do
63
- lines = [ ["Total score (lower is better) = 284"],
64
- ["\n1) IDENTICAL code found in :or (mass*2 = 68)",
65
- "app/controllers/link_targets_controller.rb:57",
66
- "app/controllers/primary_sites_controller.rb:138"],
67
- ["2) Similar code found in :if (mass = 64)",
68
- "app/controllers/primary_sites_controller.rb:75",
69
- "app/controllers/primary_sites_controller.rb:76",
70
- "app/controllers/primary_sites_controller.rb:88",
71
- "app/controllers/primary_sites_controller.rb:89"],
72
- ["3) Similar code found in :defn (mass = 40)",
73
- "app/controllers/link_targets_controller.rb:40",
74
- "app/controllers/primary_sites_controller.rb:98"],
75
- ["4) Similar code found in :defn (mass = 38)",
76
- "app/controllers/link_targets_controller.rb:13",
77
- "app/controllers/primary_sites_controller.rb:50"],
78
- ["5) Similar code found in :defn (mass = 38)",
79
- "app/models/primary_site.rb:104",
80
- "app/models/primary_site.rb:109"],
81
- ["6) Similar code found in :call (mass = 36)",
82
- "app/controllers/bookmarklet_integration_controller.rb:6",
83
- "app/controllers/bookmarklet_integration_controller.rb:17"]]
62
+ lines = [["Total score (lower is better) = 284"],
63
+ ["\n1) IDENTICAL code found in :or (mass*2 = 68)",
64
+ "app/controllers/link_targets_controller.rb:57",
65
+ "app/controllers/primary_sites_controller.rb:138"],
66
+ ["2) Similar code found in :if (mass = 64)",
67
+ "app/controllers/primary_sites_controller.rb:75",
68
+ "app/controllers/primary_sites_controller.rb:76",
69
+ "app/controllers/primary_sites_controller.rb:88",
70
+ "app/controllers/primary_sites_controller.rb:89"],
71
+ ["3) Similar code found in :defn (mass = 40)",
72
+ "app/controllers/link_targets_controller.rb:40",
73
+ "app/controllers/primary_sites_controller.rb:98"],
74
+ ["4) Similar code found in :defn (mass = 38)",
75
+ "app/controllers/link_targets_controller.rb:13",
76
+ "app/controllers/primary_sites_controller.rb:50"],
77
+ ["5) Similar code found in :defn (mass = 38)",
78
+ "app/models/primary_site.rb:104",
79
+ "app/models/primary_site.rb:109"],
80
+ ["6) Similar code found in :call (mass = 36)",
81
+ "app/controllers/bookmarklet_integration_controller.rb:6",
82
+ "app/controllers/bookmarklet_integration_controller.rb:17"]]
84
83
 
85
84
  MetricFu::Configuration.run {}
86
85
  allow(File).to receive(:directory?).and_return(true)
87
- flay = MetricFu::FlayGenerator.new('base_dir')
86
+ flay = MetricFu::FlayGenerator.new("base_dir")
88
87
  flay.instance_variable_set(:@matches, lines)
89
88
  @results = flay.to_h
90
89
  end
91
90
 
92
91
  it "should find the total_score" do
93
- expect(@results[:flay][:total_score]).to eq('284')
92
+ expect(@results[:flay][:total_score]).to eq("284")
94
93
  end
95
94
 
96
95
  it "should have 6 matches" do
@@ -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
7
  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
- })
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,8 +12,8 @@ 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'))
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"))
18
17
  expect(flogger).to receive(:flog).with("lib")
19
18
  @flog.emit
20
19
  end
@@ -25,34 +24,34 @@ describe MetricFu::FlogGenerator do
25
24
  first_full_method_name = "ClassName#first_method_name"
26
25
  second_full_method_name = "ClassName#second_method_name"
27
26
 
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})
27
+ flogger = double("flogger", method_locations: { first_full_method_name => "/file/location.rb:11",
28
+ second_full_method_name => "/file/location.rb:22" },
29
+ totals: { first_full_method_name => 11.11,
30
+ second_full_method_name => 22.22 })
32
31
  expect(flogger).to receive(:calculate)
33
32
  expect(flogger).to receive(:each_by_score).and_yield(
34
- first_full_method_name, 11.11, {:branch => 11.1, :puts => 1.1}
33
+ first_full_method_name, 11.11, branch: 11.1, puts: 1.1
35
34
  ).and_yield(
36
- second_full_method_name, 22.22, {:branch => 22.2, :puts => 2.2}
35
+ second_full_method_name, 22.22, branch: 22.2, puts: 2.2
37
36
  )
38
37
  @flog.instance_variable_set(:@flogger, flogger)
39
38
  @flog.analyze
40
39
  method_containers = @flog.instance_variable_get(:@method_containers)
41
40
  expect(method_containers.size).to eq(1)
42
41
 
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"}
42
+ expected = { methods: { "ClassName#first_method_name" => { path: "/file/location.rb:11",
43
+ score: 11.11,
44
+ operators: { branch: 11.1,
45
+ puts: 1.1 } },
46
+ "ClassName#second_method_name" => { path: "/file/location.rb:22",
47
+ score: 22.22,
48
+ operators: { branch: 22.2,
49
+ puts: 2.2 } } },
50
+ path: "/file/location.rb",
51
+ average_score: ((11.11 + 22.22) / 2.0),
52
+ total_score: 33.33,
53
+ highest_score: 22.22,
54
+ name: "ClassName" }
56
55
 
57
56
  expect(method_containers["ClassName"].to_h).to eq(expected)
58
57
  end
@@ -60,19 +59,18 @@ describe MetricFu::FlogGenerator do
60
59
 
61
60
  describe "to_h method" do
62
61
  it "should make-a nice hash" do
63
- flogger = double('flogger', :total_score => 111.1, :average => 7.3)
62
+ flogger = double("flogger", total_score: 111.1, average: 7.3)
64
63
  @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')}
64
+ method_containers = { ignore_me_1: double("container_1", highest_score: 11.1, to_h: "container_1"),
65
+ ignore_me_2: double("container_2", highest_score: 33.3, to_h: "container_2"),
66
+ ignore_me_3: double("container_3", highest_score: 22.2, to_h: "container_3") }
68
67
  @flog.instance_variable_set(:@method_containers, method_containers)
69
68
 
70
- expected = {:flog => { :total => 111.1,
71
- :average => 7.3,
72
- :method_containers => ['container_2', 'container_3', 'container_1']}}
69
+ expected = { flog: { total: 111.1,
70
+ average: 7.3,
71
+ method_containers: ["container_2", "container_3", "container_1"] } }
73
72
 
74
73
  expect(@flog.to_h).to eq(expected)
75
74
  end
76
-
77
75
  end
78
76
  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