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.
- checksums.yaml +5 -13
- data/.gitignore +6 -0
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +69 -0
- data/.simplecov +35 -3
- data/.travis.yml +6 -10
- data/CONTRIBUTORS +12 -11
- data/Gemfile +48 -29
- data/Guardfile +9 -9
- data/HISTORY.md +47 -1
- data/README.md +70 -57
- data/Rakefile +1 -15
- data/appveyor.yml +34 -0
- data/certs/bf4.pem +20 -20
- data/checksum/metric_fu-4.11.1.gem.sha512 +1 -0
- data/checksum/metric_fu-4.11.2.gem.sha512 +1 -0
- data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
- data/checksum/metric_fu-4.11.4.gem.sha512 +1 -0
- data/checksum/metric_fu-4.12.0.gem.sha512 +1 -0
- data/checksum/metric_fu-4.13.0.gem.sha512 +1 -0
- data/config/rubocop.yml +269 -0
- data/gem_tasks/build.rake +1 -0
- data/gem_tasks/rubocop.rake +10 -0
- data/gem_tasks/yard.rake +24 -0
- data/lib/metric_fu.rb +20 -9
- data/lib/metric_fu/calculate.rb +0 -1
- data/lib/metric_fu/cli/client.rb +6 -6
- data/lib/metric_fu/cli/helper.rb +22 -13
- data/lib/metric_fu/cli/parser.rb +14 -18
- data/lib/metric_fu/configuration.rb +7 -11
- data/lib/metric_fu/constantize.rb +4 -4
- data/lib/metric_fu/data_structures/line_numbers.rb +10 -11
- data/lib/metric_fu/data_structures/location.rb +12 -14
- data/lib/metric_fu/data_structures/sexp_node.rb +31 -13
- data/lib/metric_fu/environment.rb +29 -31
- data/lib/metric_fu/formatter.rb +4 -6
- data/lib/metric_fu/formatter/html.rb +13 -13
- data/lib/metric_fu/formatter/syntax.rb +5 -7
- data/lib/metric_fu/formatter/yaml.rb +1 -1
- data/lib/metric_fu/gem_run.rb +13 -15
- data/lib/metric_fu/gem_version.rb +10 -12
- data/lib/metric_fu/generator.rb +6 -9
- data/lib/metric_fu/io.rb +13 -15
- data/lib/metric_fu/loader.rb +17 -18
- data/lib/metric_fu/logger.rb +15 -18
- data/lib/metric_fu/logging/mf_debugger.rb +4 -4
- data/lib/metric_fu/metric.rb +11 -12
- data/lib/metric_fu/metrics/cane/generator.rb +10 -9
- data/lib/metric_fu/metrics/cane/grapher.rb +5 -7
- data/lib/metric_fu/metrics/cane/metric.rb +6 -8
- data/lib/metric_fu/metrics/cane/report.html.erb +3 -3
- data/lib/metric_fu/metrics/cane/violations.rb +6 -6
- data/lib/metric_fu/metrics/churn/generator.rb +2 -6
- data/lib/metric_fu/metrics/churn/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/churn/metric.rb +5 -7
- data/lib/metric_fu/metrics/flay/generator.rb +7 -11
- data/lib/metric_fu/metrics/flay/grapher.rb +5 -6
- data/lib/metric_fu/metrics/flay/hotspot.rb +5 -7
- data/lib/metric_fu/metrics/flay/metric.rb +5 -7
- data/lib/metric_fu/metrics/flog/generator.rb +35 -24
- data/lib/metric_fu/metrics/flog/grapher.rb +11 -11
- data/lib/metric_fu/metrics/flog/hotspot.rb +3 -5
- data/lib/metric_fu/metrics/flog/metric.rb +3 -5
- data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +0 -1
- data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +19 -18
- data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +0 -2
- data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -3
- data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +4 -6
- data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +14 -17
- data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +4 -5
- data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +1 -3
- data/lib/metric_fu/metrics/hotspots/analysis/record.rb +3 -5
- data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +0 -2
- data/lib/metric_fu/metrics/hotspots/analysis/table.rb +3 -4
- data/lib/metric_fu/metrics/hotspots/generator.rb +3 -6
- data/lib/metric_fu/metrics/hotspots/hotspot.rb +13 -13
- data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +5 -8
- data/lib/metric_fu/metrics/hotspots/metric.rb +1 -3
- data/lib/metric_fu/metrics/hotspots/report.html.erb +1 -1
- data/lib/metric_fu/metrics/rails_best_practices/generator.rb +14 -12
- data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +5 -6
- data/lib/metric_fu/metrics/rails_best_practices/metric.rb +5 -4
- data/lib/metric_fu/metrics/rcov/external_client.rb +1 -3
- data/lib/metric_fu/metrics/rcov/generator.rb +13 -15
- data/lib/metric_fu/metrics/rcov/grapher.rb +6 -7
- data/lib/metric_fu/metrics/rcov/hotspot.rb +5 -7
- data/lib/metric_fu/metrics/rcov/metric.rb +5 -7
- data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +16 -55
- data/lib/metric_fu/metrics/rcov/rcov_line.rb +48 -0
- data/lib/metric_fu/metrics/rcov/report.html.erb +2 -2
- data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +10 -11
- data/lib/metric_fu/metrics/reek/generator.rb +36 -82
- data/lib/metric_fu/metrics/reek/grapher.rb +5 -6
- data/lib/metric_fu/metrics/reek/hotspot.rb +5 -7
- data/lib/metric_fu/metrics/reek/metric.rb +2 -4
- data/lib/metric_fu/metrics/roodi/generator.rb +9 -10
- data/lib/metric_fu/metrics/roodi/grapher.rb +5 -6
- data/lib/metric_fu/metrics/roodi/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/roodi/metric.rb +2 -4
- data/lib/metric_fu/metrics/saikuro/generator.rb +23 -27
- data/lib/metric_fu/metrics/saikuro/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/saikuro/metric.rb +7 -8
- data/lib/metric_fu/metrics/saikuro/parsing_element.rb +6 -8
- data/lib/metric_fu/metrics/saikuro/report.html.erb +1 -1
- data/lib/metric_fu/metrics/saikuro/scratch_file.rb +24 -29
- data/lib/metric_fu/metrics/stats/generator.rb +9 -12
- data/lib/metric_fu/metrics/stats/grapher.rb +8 -9
- data/lib/metric_fu/metrics/stats/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/stats/metric.rb +3 -5
- data/lib/metric_fu/reporter.rb +1 -1
- data/lib/metric_fu/reporting/graphs/graph.rb +8 -12
- data/lib/metric_fu/reporting/graphs/grapher.rb +7 -9
- data/lib/metric_fu/reporting/result.rb +0 -3
- data/lib/metric_fu/run.rb +12 -3
- data/lib/metric_fu/tasks/metric_fu.rake +8 -8
- data/lib/metric_fu/templates/configuration.rb +2 -5
- data/lib/metric_fu/templates/metrics_template.rb +45 -32
- data/lib/metric_fu/templates/report.rb +5 -8
- data/lib/metric_fu/templates/template.rb +20 -24
- data/lib/metric_fu/utility.rb +15 -8
- data/lib/metric_fu/version.rb +7 -1
- data/metric_fu.gemspec +29 -32
- data/spec/capture_warnings.rb +29 -22
- data/spec/cli/helper_spec.rb +9 -16
- data/spec/dummy/lib/bad_encoding.rb +1 -1
- data/spec/fixtures/coverage-153.rb +2 -2
- data/spec/fixtures/coverage.rb +2 -2
- data/spec/metric_fu/calculate_spec.rb +3 -3
- data/spec/metric_fu/configuration_spec.rb +71 -83
- data/spec/metric_fu/data_structures/line_numbers_spec.rb +3 -5
- data/spec/metric_fu/data_structures/location_spec.rb +13 -31
- data/spec/metric_fu/formatter/configuration_spec.rb +18 -20
- data/spec/metric_fu/formatter/html_spec.rb +21 -28
- data/spec/metric_fu/formatter/yaml_spec.rb +9 -17
- data/spec/metric_fu/formatter_spec.rb +16 -16
- data/spec/metric_fu/gem_version_spec.rb +4 -6
- data/spec/metric_fu/generator_spec.rb +33 -43
- data/spec/metric_fu/loader_spec.rb +5 -4
- data/spec/metric_fu/metric_spec.rb +21 -25
- data/spec/metric_fu/metrics/cane/configuration_spec.rb +14 -14
- data/spec/metric_fu/metrics/cane/generator_spec.rb +26 -29
- data/spec/metric_fu/metrics/churn/configuration_spec.rb +7 -9
- data/spec/metric_fu/metrics/churn/generator_spec.rb +6 -11
- data/spec/metric_fu/metrics/flay/configuration_spec.rb +7 -9
- data/spec/metric_fu/metrics/flay/generator_spec.rb +36 -37
- data/spec/metric_fu/metrics/flay/grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/flog/configuration_spec.rb +12 -14
- data/spec/metric_fu/metrics/flog/generator_spec.rb +31 -32
- data/spec/metric_fu/metrics/flog/grapher_spec.rb +8 -10
- data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +18 -24
- data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +12 -17
- data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +2 -6
- data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -14
- data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +1 -3
- data/spec/metric_fu/metrics/hotspots/generator_spec.rb +6 -8
- data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +1 -3
- data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +4 -5
- data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +25 -17
- data/spec/metric_fu/metrics/rails_best_practices/generator_spec.rb +2 -3
- data/spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb +3 -3
- data/spec/metric_fu/metrics/rcov/configuration_spec.rb +21 -23
- data/spec/metric_fu/metrics/rcov/generator_spec.rb +6 -10
- data/spec/metric_fu/metrics/rcov/grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/rcov/hotspot_spec.rb +8 -8
- data/spec/metric_fu/metrics/rcov/rcov_line_spec.rb +89 -0
- data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +31 -33
- data/spec/metric_fu/metrics/reek/configuration_spec.rb +7 -7
- data/spec/metric_fu/metrics/reek/generator_spec.rb +131 -111
- data/spec/metric_fu/metrics/reek/grapher_spec.rb +4 -4
- data/spec/metric_fu/metrics/roodi/configuration_spec.rb +8 -10
- data/spec/metric_fu/metrics/roodi/generator_spec.rb +3 -3
- data/spec/metric_fu/metrics/roodi/grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +22 -23
- data/spec/metric_fu/metrics/saikuro/generator_spec.rb +7 -7
- data/spec/metric_fu/metrics/stats/generator_spec.rb +10 -10
- data/spec/metric_fu/metrics/stats/grapher_spec.rb +2 -2
- data/spec/metric_fu/reporter_spec.rb +8 -9
- data/spec/metric_fu/reporting/graphs/graph_spec.rb +1 -4
- data/spec/metric_fu/reporting/graphs/grapher_spec.rb +5 -5
- data/spec/metric_fu/reporting/result_spec.rb +12 -14
- data/spec/metric_fu/run_spec.rb +19 -33
- data/spec/metric_fu/templates/configuration_spec.rb +34 -40
- data/spec/metric_fu/templates/metrics_template_spec.rb +11 -0
- data/spec/metric_fu/templates/report_spec.rb +4 -4
- data/spec/metric_fu/templates/template_spec.rb +78 -64
- data/spec/metric_fu/utility_spec.rb +3 -3
- data/spec/metric_fu_spec.rb +23 -6
- data/spec/quality_spec.rb +43 -15
- data/spec/shared/configured.rb +9 -11
- data/spec/shared/test_coverage.rb +5 -9
- data/spec/spec_helper.rb +13 -31
- data/spec/{dummy → support}/.metrics +0 -0
- data/spec/support/deferred_garbaged_collection.rb +1 -2
- data/spec/support/matcher_create_file.rb +6 -4
- data/spec/support/matcher_create_files.rb +6 -4
- data/spec/support/samples/reek/alfa.rb +1 -0
- data/spec/support/suite.rb +3 -3
- data/spec/support/test_fixtures.rb +5 -7
- data/spec/support/timeout.rb +1 -1
- data/spec/support/usage_test.rb +24 -25
- data/spec/usage_test_spec.rb +30 -32
- metadata +104 -103
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/gemfiles/Gemfile.travis +0 -10
- metadata.gz.sig +0 -0
data/spec/capture_warnings.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
# https://raw.githubusercontent.com/metric_fu/metric_fu/master/spec/capture_warnings.rb
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
28
|
+
app_warnings, other_warnings = lines.partition { |line|
|
29
|
+
line.include?(app_root) && !line.include?(bundle_dir)
|
30
|
+
}
|
26
31
|
|
27
|
-
if
|
28
|
-
puts
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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.
|
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-
|
46
|
+
puts "Non-app warnings written to tmp/warnings.txt"
|
41
47
|
puts
|
42
48
|
end
|
43
49
|
|
44
50
|
# fail the build...
|
45
|
-
|
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
|
data/spec/cli/helper_spec.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
|
-
require
|
2
|
-
require
|
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
|
-
|
63
|
-
|
64
|
-
|
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
|
153
|
+
context "given a single format" do
|
159
154
|
it "sets the format" do
|
160
|
-
expect(helper.process_options(["--format", "json"])[:format]).to eq([[
|
155
|
+
expect(helper.process_options(["--format", "json"])[:format]).to eq([["json"]])
|
161
156
|
end
|
162
157
|
end
|
163
158
|
|
164
|
-
context
|
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([[
|
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
|
data/spec/fixtures/coverage.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
MetricFu.lib_require {
|
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
|
2
|
+
require "shared/configured"
|
3
3
|
|
4
4
|
describe MetricFu::Configuration do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
18
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
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 "
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
81
|
+
describe "#platform" do
|
82
|
+
before(:each) { get_new_config }
|
57
83
|
|
58
|
-
|
59
|
-
|
60
|
-
|
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 {
|
2
|
+
MetricFu.data_structures_require { "line_numbers" }
|
3
3
|
|
4
4
|
describe MetricFu::LineNumbers do
|
5
5
|
FIXTURE_DATA = ->(paths) {
|
6
|
-
FIXTURE.load_file(
|
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(
|
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 {
|
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(
|
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
|
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
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
83
|
+
expect(location.simple_method_name).to eq("#some_class_method")
|
95
84
|
end
|
96
|
-
|
97
85
|
end
|
98
|
-
|
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(
|
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
|