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,15 +1,18 @@
1
1
  # https://raw.githubusercontent.com/metric_fu/metric_fu/master/spec/capture_warnings.rb
2
- require 'rubygems' if RUBY_VERSION =~ /^1\.8/
3
- require 'bundler/setup'
4
- require 'rspec/core'
5
- require 'rspec/expectations'
6
- require 'tempfile'
7
-
8
- stderr_file = Tempfile.new("metric_fu.stderr")
9
- current_dir = Dir.pwd
2
+ require "rubygems" if RUBY_VERSION =~ /^1\.8/
3
+ require "bundler/setup"
4
+ require "rspec/core"
5
+ require "rspec/expectations"
6
+ require "tempfile"
7
+ require "fileutils"
8
+
9
+ stderr_file = Tempfile.new("app.stderr")
10
+ app_root ||= Dir.pwd
11
+ output_dir = File.join(app_root, "tmp")
12
+ FileUtils.mkdir_p(output_dir)
13
+ bundle_dir = File.join(app_root, "bundle")
10
14
 
11
15
  RSpec.configure do |config|
12
-
13
16
  config.before(:suite) do
14
17
  $stderr.reopen(stderr_file.path)
15
18
  $VERBOSE = true
@@ -22,27 +25,31 @@ RSpec.configure do |config|
22
25
 
23
26
  $stderr.reopen(STDERR)
24
27
 
25
- metric_fu_warnings, other_warnings = lines.partition { |line| line.include?(current_dir) }
28
+ app_warnings, other_warnings = lines.partition { |line|
29
+ line.include?(app_root) && !line.include?(bundle_dir)
30
+ }
26
31
 
27
- if metric_fu_warnings.any?
28
- puts
29
- puts "-" * 30 + " metric_fu warnings: " + "-" * 30
30
- puts
31
- puts metric_fu_warnings.join("\n")
32
- puts
33
- puts "-" * 75
34
- puts
32
+ if app_warnings.any?
33
+ puts <<-WARNINGS
34
+ #{'-' * 30} app warnings: #{'-' * 30}
35
+
36
+ #{app_warnings.join("\n")}
37
+
38
+ #{'-' * 75}
39
+ WARNINGS
35
40
  end
36
41
 
37
42
  if other_warnings.any?
38
- File.open('tmp/warnings.txt', 'w') { |f| f.write(other_warnings.join("\n")) }
43
+ output_file = File.join(output_dir, "warnings.txt")
44
+ File.write(output_file, other_warnings.join("\n") << "\n")
39
45
  puts
40
- puts "Non-metric_fu warnings written to tmp/warnings.txt"
46
+ puts "Non-app warnings written to tmp/warnings.txt"
41
47
  puts
42
48
  end
43
49
 
44
50
  # fail the build...
45
- raise "Failing build due to metric_fu warnings" if metric_fu_warnings.any?
51
+ if app_warnings.any?
52
+ abort "Failing build due to app warnings: #{app_warnings.inspect}"
53
+ end
46
54
  end
47
-
48
55
  end
@@ -1,19 +1,16 @@
1
- require 'spec_helper'
2
- require 'metric_fu/cli/helper'
1
+ require "spec_helper"
2
+ require "metric_fu/cli/helper"
3
3
  MetricFu.configuration.configure_metric(:rcov) do |rcov|
4
4
  rcov.enabled = true
5
5
  end
6
6
  MetricFu.configure
7
7
 
8
8
  describe MetricFu::Cli::Helper do
9
-
10
9
  describe "defaults" do
11
-
12
10
  let(:helper) { MetricFu::Cli::Helper.new }
13
11
  let(:defaults) { helper.process_options }
14
12
 
15
13
  context "on every Ruby version" do
16
-
17
14
  it "opens the report in a browser" do
18
15
  expect(defaults[:open]).to be_truthy
19
16
  end
@@ -59,12 +56,11 @@ describe MetricFu::Cli::Helper do
59
56
 
60
57
  if MetricFu.configuration.mri?
61
58
 
62
- it "enables Rails Best Practices" do
63
- expect(defaults[:rails_best_practices]).to be_truthy
64
- end
59
+ it "enables Rails Best Practices" do
60
+ expect(defaults[:rails_best_practices]).to be_truthy
61
+ end
65
62
 
66
63
  end
67
-
68
64
  end
69
65
 
70
66
  describe ".parse" do
@@ -122,7 +118,6 @@ describe MetricFu::Cli::Helper do
122
118
 
123
119
  end
124
120
 
125
-
126
121
  it "turns hotspots off" do
127
122
  expect(helper.process_options(["--no-hotspots"])[:hotspots]).to be_falsey
128
123
  end
@@ -155,18 +150,16 @@ describe MetricFu::Cli::Helper do
155
150
  expect(helper.process_options(["--roodi"])[:roodi]).to be_truthy
156
151
  end
157
152
 
158
- context 'given a single format' do
153
+ context "given a single format" do
159
154
  it "sets the format" do
160
- expect(helper.process_options(["--format", "json"])[:format]).to eq([['json']])
155
+ expect(helper.process_options(["--format", "json"])[:format]).to eq([["json"]])
161
156
  end
162
157
  end
163
158
 
164
- context 'given multiple formats' do
159
+ context "given multiple formats" do
165
160
  it "sets multiple formats" do
166
- expect(helper.process_options(["--format", "json", "--format", "yaml"])[:format]).to eq([['json'], ['yaml']])
161
+ expect(helper.process_options(["--format", "json", "--format", "yaml"])[:format]).to eq([["json"], ["yaml"]])
167
162
  end
168
163
  end
169
-
170
164
  end
171
-
172
165
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  class SomeClass
3
- def initialize(a,b,c)
3
+ def initialize(_a, _b, _c)
4
4
  "hey, invalid ASCII\xED"
5
5
  end
6
6
  end
@@ -3,9 +3,9 @@ class A
3
3
  def m(arg1)
4
4
  p "this is my method" # Assume that none of the line covered in this method
5
5
  if arg1 > 5
6
- p 'more than 5'
6
+ p "more than 5"
7
7
  else
8
- p 'not more than 5'
8
+ p "not more than 5"
9
9
  end
10
10
  end
11
11
  end
@@ -1,9 +1,9 @@
1
1
  class SomeClass
2
2
  def method_1
3
- 1+1
3
+ 1 + 1
4
4
  end
5
5
 
6
- def method_2 ( value )
6
+ def method_2(value)
7
7
  value * value
8
8
  end
9
9
 
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
2
- MetricFu.lib_require { 'calculate' }
1
+ require "spec_helper"
2
+ MetricFu.lib_require { "calculate" }
3
3
 
4
4
  describe MetricFu::Calculate do
5
5
  describe "returns a percent rounded to the nearest integer" do
@@ -15,7 +15,7 @@ describe MetricFu::Calculate do
15
15
  }.to raise_error(ArgumentError)
16
16
  end
17
17
  it "returns 0 when the denominator is 0" do
18
- expect(MetricFu::Calculate.integer_percent(3,0)).to eq(0)
18
+ expect(MetricFu::Calculate.integer_percent(3, 0)).to eq(0)
19
19
  end
20
20
  end
21
21
  end
@@ -1,102 +1,90 @@
1
1
  require "spec_helper"
2
- require 'shared/configured'
2
+ require "shared/configured"
3
3
 
4
4
  describe MetricFu::Configuration do
5
-
6
- it_behaves_like 'configured' do
7
-
8
- describe '#is_cruise_control_rb? ' do
9
-
10
- before(:each) { get_new_config }
11
- describe "when the CC_BUILD_ARTIFACTS env var is not nil" do
12
-
13
- before(:each) do
14
- ENV['CC_BUILD_ARTIFACTS'] = 'is set'
5
+ it_behaves_like "configured" do
6
+ describe "#is_cruise_control_rb?" do
7
+ before(:each) { get_new_config }
8
+ describe "when the CC_BUILD_ARTIFACTS env var is not nil" do
9
+ before(:each) do
10
+ ENV["CC_BUILD_ARTIFACTS"] = "is set"
11
+ end
12
+
13
+ it "should return true" do
14
+ expect(@config.is_cruise_control_rb?).to be_truthy
15
+ end
16
+
17
+ after(:each) do
18
+ ENV["CC_BUILD_ARTIFACTS"] = nil
19
+ FileUtils.rm_rf(File.join(MetricFu.root_dir, "is set"))
20
+ end
15
21
  end
16
22
 
17
- it 'should return true' do
18
- expect(@config.is_cruise_control_rb?).to be_truthy
19
- end
23
+ describe "when the CC_BUILD_ARTIFACTS env var is nil" do
24
+ before(:each) { ENV["CC_BUILD_ARTIFACTS"] = nil }
20
25
 
21
- after(:each) do
22
- ENV['CC_BUILD_ARTIFACTS'] = nil
23
- FileUtils.rm_rf(File.join(MetricFu.root_dir, 'is set'))
26
+ it "should return false" do
27
+ expect(@config.is_cruise_control_rb?).to be_falsey
28
+ end
24
29
  end
25
-
26
30
  end
27
31
 
28
- describe "when the CC_BUILD_ARTIFACTS env var is nil" do
29
- before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
30
-
31
- it 'should return false' do
32
- expect(@config.is_cruise_control_rb?).to be_falsey
32
+ describe "#reset" do
33
+ describe "when there is a CC_BUILD_ARTIFACTS environment variable" do
34
+ before do
35
+ ENV["CC_BUILD_ARTIFACTS"] = "foo"
36
+ @config = MetricFu.configuration
37
+ @config.reset
38
+ MetricFu.configure
39
+ end
40
+ it "should return the CC_BUILD_ARTIFACTS environment variable" do
41
+ compare_paths(base_directory, ENV["CC_BUILD_ARTIFACTS"])
42
+ end
43
+ after do
44
+ ENV["CC_BUILD_ARTIFACTS"] = nil
45
+ FileUtils.rm_rf(File.join(MetricFu.root_dir, "foo"))
46
+ end
33
47
  end
34
- end
35
- end
36
-
37
- describe "#reset" do
38
48
 
39
- describe 'when there is a CC_BUILD_ARTIFACTS environment variable' do
40
-
41
- before do
42
- ENV['CC_BUILD_ARTIFACTS'] = 'foo'
43
- @config = MetricFu.configuration
44
- @config.reset
45
- MetricFu.configure
46
- end
47
- it 'should return the CC_BUILD_ARTIFACTS environment variable' do
48
- compare_paths(base_directory, ENV['CC_BUILD_ARTIFACTS'])
49
- end
50
- after do
51
- ENV['CC_BUILD_ARTIFACTS'] = nil
52
- FileUtils.rm_rf(File.join(MetricFu.root_dir, 'foo'))
49
+ describe "when there is no CC_BUILD_ARTIFACTS environment variable" do
50
+ before(:each) do
51
+ ENV["CC_BUILD_ARTIFACTS"] = nil
52
+ get_new_config
53
+ end
54
+ it "should return 'tmp/metric_fu'" do
55
+ expect(base_directory).to eq(MetricFu.artifact_dir)
56
+ end
57
+
58
+ it "should set @metric_fu_root_directory to the base of the "\
59
+ "metric_fu application" do
60
+ app_root = File.join(File.dirname(__FILE__), "..", "..")
61
+ app_root_absolute_path = File.expand_path(app_root)
62
+ metric_fu_absolute_path = File.expand_path(metric_fu_root)
63
+ expect(metric_fu_absolute_path).to eq(app_root_absolute_path)
64
+ expect(MetricFu.root.to_s).to eq(app_root_absolute_path)
65
+ end
66
+
67
+ it "should set @scratch_directory to scratch relative "\
68
+ "to @base_directory" do
69
+ scratch_dir = MetricFu.scratch_dir
70
+ expect(scratch_directory).to eq(scratch_dir)
71
+ end
72
+
73
+ it "should set @output_directory to output relative "\
74
+ "to @base_directory" do
75
+ output_dir = MetricFu.output_dir
76
+ expect(output_directory).to eq(output_dir)
77
+ end
53
78
  end
54
79
  end
55
80
 
56
- describe 'when there is no CC_BUILD_ARTIFACTS environment variable' do
81
+ describe "#platform" do
82
+ before(:each) { get_new_config }
57
83
 
58
- before(:each) do
59
- ENV['CC_BUILD_ARTIFACTS'] = nil
60
- get_new_config
61
- end
62
- it 'should return "tmp/metric_fu"' do
63
- expect(base_directory).to eq(MetricFu.artifact_dir)
84
+ it "should return the value of the PLATFORM constant" do
85
+ this_platform = RUBY_PLATFORM
86
+ expect(@config.platform).to eq(this_platform)
64
87
  end
65
-
66
- it 'should set @metric_fu_root_directory to the base of the '+
67
- 'metric_fu application' do
68
- app_root = File.join(File.dirname(__FILE__), '..', '..')
69
- app_root_absolute_path = File.expand_path(app_root)
70
- metric_fu_absolute_path = File.expand_path(metric_fu_root)
71
- expect(metric_fu_absolute_path).to eq(app_root_absolute_path)
72
- expect(MetricFu.root.to_s).to eq(app_root_absolute_path)
73
- end
74
-
75
- it 'should set @scratch_directory to scratch relative '+
76
- 'to @base_directory' do
77
- scratch_dir = MetricFu.scratch_dir
78
- expect(scratch_directory).to eq(scratch_dir)
79
- end
80
-
81
- it 'should set @output_directory to output relative '+
82
- 'to @base_directory' do
83
- output_dir = MetricFu.output_dir
84
- expect(output_directory).to eq(output_dir)
85
- end
86
-
87
- end
88
-
89
- end
90
-
91
- describe '#platform' do
92
-
93
- before(:each) { get_new_config }
94
-
95
- it 'should return the value of the PLATFORM constant' do
96
- this_platform = RUBY_PLATFORM
97
- expect(@config.platform).to eq(this_platform)
98
88
  end
99
89
  end
100
-
101
- end
102
90
  end
@@ -1,9 +1,9 @@
1
1
  require "spec_helper"
2
- MetricFu.data_structures_require { 'line_numbers' }
2
+ MetricFu.data_structures_require { "line_numbers" }
3
3
 
4
4
  describe MetricFu::LineNumbers do
5
5
  FIXTURE_DATA = ->(paths) {
6
- FIXTURE.load_file( ['line_numbers'].concat(Array(paths)) )
6
+ FIXTURE.load_file(["line_numbers"].concat(Array(paths)))
7
7
  }
8
8
  describe "in_method?" do
9
9
  it "should know if a line is NOT in a method" do
@@ -51,7 +51,7 @@ describe MetricFu::LineNumbers do
51
51
 
52
52
  it "should work with modules" do
53
53
  ln = MetricFu::LineNumbers.new(FIXTURE_DATA["module.rb"])
54
- expect(ln.method_at_line(4)).to eq('KickAss#get_beat_up?')
54
+ expect(ln.method_at_line(4)).to eq("KickAss#get_beat_up?")
55
55
  end
56
56
 
57
57
  it "should work with module surrounding class" do
@@ -59,7 +59,5 @@ describe MetricFu::LineNumbers do
59
59
  expect(ln.method_at_line(5)).to eq("StuffModule::ThingClass#do_it")
60
60
  # ln.method_at_line(12).should == "StuffModule#blah" #why no work?
61
61
  end
62
-
63
62
  end
64
-
65
63
  end
@@ -1,8 +1,7 @@
1
1
  require "spec_helper"
2
- MetricFu.data_structures_require { 'location' }
2
+ MetricFu.data_structures_require { "location" }
3
3
 
4
4
  describe MetricFu::Location do
5
-
6
5
  context "with non-standard Reek method names" do
7
6
  # reek reports the method with :: not # on modules like
8
7
  # module ApplicationHelper \n def signed_in?, convert it so it records correctly
@@ -13,33 +12,29 @@ describe MetricFu::Location do
13
12
  end
14
13
 
15
14
  it "has method name" do
16
- expect(@location.method_name).to eq('ApplicationHelper#section_link')
15
+ expect(@location.method_name).to eq("ApplicationHelper#section_link")
17
16
  end
18
17
 
19
18
  it "has nil file path" do
20
- expect(@location.file_path).to eq(nil)
19
+ expect(@location.file_path).to eq(nil)
21
20
  end
22
21
 
23
22
  it "has class name" do
24
- expect(@location.class_name).to eq('ApplicationHelper')
23
+ expect(@location.class_name).to eq("ApplicationHelper")
25
24
  end
26
-
27
25
  end
28
26
 
29
27
  context "using new" do
30
-
31
28
  before do
32
29
  @location = Location.new("lib/foo.rb", "Foo", "Foo#some_method")
33
30
  end
34
31
 
35
32
  it "should return fully qualified method" do
36
- expect(@location.method_name).to eq('Foo#some_method')
33
+ expect(@location.method_name).to eq("Foo#some_method")
37
34
  end
38
-
39
35
  end
40
36
 
41
37
  context "using .for with class" do
42
-
43
38
  before do
44
39
  @location = Location.for("Module::Foo")
45
40
  end
@@ -53,58 +48,49 @@ describe MetricFu::Location do
53
48
  end
54
49
 
55
50
  it "has class_name" do
56
- expect(@location.class_name).to eq('Foo')
51
+ expect(@location.class_name).to eq("Foo")
57
52
  end
58
-
59
53
  end
60
54
 
61
55
  context "using .for with method" do
62
-
63
56
  before do
64
57
  @location = Location.for("Module::Foo#some_method")
65
58
  end
66
59
 
67
60
  it "strips module from class name" do
68
- expect(@location.class_name).to eq('Foo')
61
+ expect(@location.class_name).to eq("Foo")
69
62
  end
70
63
 
71
64
  it "strips module from method name" do
72
- expect(@location.method_name).to eq('Foo#some_method')
65
+ expect(@location.method_name).to eq("Foo#some_method")
73
66
  end
74
67
 
75
68
  it "has nil file_path" do
76
69
  expect(@location.file_path).to be nil
77
70
  end
78
-
79
71
  end
80
72
 
81
73
  context "with class method" do
82
-
83
74
  it "provides non-qualified name" do
84
75
  location = Location.for("Foo.some_class_method")
85
- expect(location.simple_method_name).to eq('.some_class_method')
76
+ expect(location.simple_method_name).to eq(".some_class_method")
86
77
  end
87
-
88
78
  end
89
79
 
90
80
  context "with instance method" do
91
-
92
81
  it "provides non-qualified name" do
93
82
  location = Location.for("Foo#some_class_method")
94
- expect(location.simple_method_name).to eq('#some_class_method')
83
+ expect(location.simple_method_name).to eq("#some_class_method")
95
84
  end
96
-
97
85
  end
98
- context "testing equality" do
86
+ context "testing equality" do
99
87
  before :each do
100
-
101
- @location1 = MetricFu::Location.get('/some/path','some_class','some_method')
88
+ @location1 = MetricFu::Location.get("/some/path", "some_class", "some_method")
102
89
 
103
90
  # ensure that we get a new object
104
- @location2 = MetricFu::Location.new('/some/path','some_class','some_method')
91
+ @location2 = MetricFu::Location.new("/some/path", "some_class", "some_method")
105
92
  end
106
93
  it "should match two locations with the same paths as equal" do
107
-
108
94
  hsh1 = {}
109
95
  hsh1[@location1] = 1
110
96
 
@@ -117,12 +103,8 @@ describe MetricFu::Location do
117
103
  expect(@location1.eql?(@location2)).to be_truthy
118
104
  end
119
105
 
120
-
121
106
  it "should produce the same hash value given the same paths" do
122
-
123
107
  expect(@location1.hash).to eq(@location2.hash)
124
108
  end
125
-
126
109
  end
127
-
128
110
  end