metric_fu 4.6.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/.metrics +6 -0
- data/.travis.yml +6 -5
- data/CONTRIBUTING.md +15 -3
- data/Gemfile +3 -8
- data/Gemfile.devtools +3 -3
- data/HISTORY.md +23 -2
- data/README.md +42 -38
- data/checksum/metric_fu-4.6.0.gem.sha512 +1 -0
- data/gemfiles/Gemfile.travis +7 -0
- data/lib/metric_fu/cli/helper.rb +2 -1
- data/lib/metric_fu/configuration.rb +0 -2
- data/lib/metric_fu/formatter/html.rb +2 -0
- data/lib/metric_fu/formatter/syntax.rb +47 -0
- data/lib/metric_fu/gem_version.rb +44 -11
- data/lib/metric_fu/io.rb +5 -5
- data/lib/metric_fu/loader.rb +12 -5
- data/lib/metric_fu/metric.rb +10 -0
- data/lib/metric_fu/metrics/base_template.rb +2 -2
- data/lib/metric_fu/metrics/cane/cane.rb +1 -0
- data/lib/metric_fu/metrics/churn/churn.rb +16 -42
- data/lib/metric_fu/metrics/churn/init.rb +7 -1
- data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -0
- data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +1 -0
- data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +2 -0
- data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +5 -0
- data/lib/metric_fu/metrics/hotspots/hotspot.rb +3 -0
- data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +8 -4
- data/lib/metric_fu/metrics/hotspots/hotspots.rb +11 -0
- data/lib/metric_fu/metrics/reek/reek.rb +1 -1
- data/lib/metric_fu/metrics/reek/reek_hotspot.rb +0 -1
- data/lib/metric_fu/metrics/saikuro/saikuro.rb +1 -0
- data/lib/metric_fu/reporting/graphs/grapher.rb +0 -1
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +8 -59
- data/lib/metric_fu/run.rb +1 -1
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/bluff.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/buttons.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/default.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/integrity.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/rcov.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/reset.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/syntax.css +0 -0
- data/lib/metric_fu/templates/report.html.erb +32 -0
- data/lib/metric_fu/templates/report.rb +36 -0
- data/lib/metric_fu/utility.rb +4 -0
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +11 -2
- data/spec/cli/helper_spec.rb +33 -33
- data/spec/metric_fu/configuration_spec.rb +20 -20
- data/spec/metric_fu/data_structures/line_numbers_spec.rb +12 -11
- data/spec/metric_fu/data_structures/location_spec.rb +27 -26
- data/spec/metric_fu/formatter/html_spec.rb +18 -8
- data/spec/metric_fu/formatter/yaml_spec.rb +14 -3
- data/spec/metric_fu/formatter_spec.rb +5 -5
- data/spec/metric_fu/loader_spec.rb +1 -1
- data/spec/metric_fu/metric_spec.rb +2 -2
- data/spec/metric_fu/metrics/base_template_spec.rb +50 -50
- data/spec/metric_fu/metrics/cane/cane_spec.rb +29 -28
- data/spec/metric_fu/metrics/churn/churn_spec.rb +10 -33
- data/spec/metric_fu/metrics/flay/flay_grapher_spec.rb +9 -8
- data/spec/metric_fu/metrics/flay/flay_spec.rb +14 -13
- data/spec/metric_fu/metrics/flog/flog_grapher_spec.rb +16 -15
- data/spec/metric_fu/metrics/flog/flog_spec.rb +10 -9
- data/spec/metric_fu/metrics/generator_spec.rb +19 -19
- data/spec/metric_fu/metrics/graph_spec.rb +11 -9
- data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +5 -0
- data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +11 -6
- data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +4 -3
- data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +16 -10
- data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +2 -1
- data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +2 -1
- data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +8 -2
- data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +4 -8
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher_spec.rb +10 -9
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +8 -7
- data/spec/metric_fu/metrics/rcov/rcov_grapher_spec.rb +8 -8
- data/spec/metric_fu/metrics/rcov/rcov_hotspot_spec.rb +7 -4
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +15 -14
- data/spec/metric_fu/metrics/reek/reek_grapher_spec.rb +10 -9
- data/spec/metric_fu/metrics/reek/reek_spec.rb +17 -15
- data/spec/metric_fu/metrics/roodi/roodi_grapher_spec.rb +9 -8
- data/spec/metric_fu/metrics/roodi/roodi_spec.rb +4 -3
- data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +13 -10
- data/spec/metric_fu/metrics/stats/stats_grapher_spec.rb +13 -12
- data/spec/metric_fu/metrics/stats/stats_spec.rb +16 -14
- data/spec/metric_fu/reporter_spec.rb +8 -7
- data/spec/metric_fu/reporting/graphs/grapher_spec.rb +1 -1
- data/spec/metric_fu/reporting/result_spec.rb +12 -11
- data/spec/metric_fu/run_spec.rb +24 -8
- data/spec/spec_helper.rb +1 -2
- data/spec/support/helper_methods.rb +14 -1
- metadata +124 -57
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
- data/lib/metric_fu/initial_requires.rb +0 -13
- data/lib/metric_fu/load_files.rb +0 -34
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
MetricFu.lib_require { 'formatter/syntax' }
|
|
2
|
+
|
|
3
|
+
module MetricFu
|
|
4
|
+
module Templates
|
|
5
|
+
class Report < MetricFu::Template
|
|
6
|
+
|
|
7
|
+
def initialize(file, lines)
|
|
8
|
+
@file = file
|
|
9
|
+
@lines = lines
|
|
10
|
+
@data = File.readlines(file)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def render(metrics)
|
|
14
|
+
@metrics = metrics
|
|
15
|
+
erbify('report')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def convert_ruby_to_html(ruby_text, line_number)
|
|
19
|
+
MetricFu::Formatter::Syntax.new.highlight(ruby_text, line_number)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def line_for_display(line, line_number)
|
|
23
|
+
if MetricFu::Formatter::Templates.option('syntax_highlighting')
|
|
24
|
+
line_for_display = convert_ruby_to_html(line, line_number)
|
|
25
|
+
else
|
|
26
|
+
"<a name='n#{line_number}' href='n#{line_number}'>#{line_number}</a>#{line}"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def template_directory
|
|
31
|
+
File.dirname(__FILE__)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/metric_fu/utility.rb
CHANGED
data/lib/metric_fu/version.rb
CHANGED
data/metric_fu.gemspec
CHANGED
|
@@ -9,11 +9,15 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.description = "Code metrics from Flog, Flay, Saikuro, Churn, Reek, Roodi, Code Statistics, and Rails Best Practices. (and optionally RCov)"
|
|
10
10
|
s.email = "github@benjaminfleischer.com"
|
|
11
11
|
author_file = File.expand_path('AUTHORS', File.dirname(__FILE__))
|
|
12
|
-
s.authors = File.readlines(author_file).map(&:strip)
|
|
12
|
+
s.authors = File.readlines(author_file, :encoding => Encoding::UTF_8).map(&:strip)
|
|
13
13
|
|
|
14
14
|
# used with gem i metric_fu -P HighSecurity
|
|
15
15
|
s.cert_chain = ['certs/bf4.pem']
|
|
16
|
-
|
|
16
|
+
# Sign gem when evaluating spec with `gem` command
|
|
17
|
+
# unless ENV has set a SKIP_GEM_SIGNING
|
|
18
|
+
if ($0 =~ /gem\z/) and not ENV.include?('SKIP_GEM_SIGNING')
|
|
19
|
+
s.signing_key = File.join(Gem.user_home, '.ssh', 'gem-private_key.pem')
|
|
20
|
+
end
|
|
17
21
|
|
|
18
22
|
s.rubyforge_project = 'metric_fu'
|
|
19
23
|
s.license = 'MIT'
|
|
@@ -56,4 +60,9 @@ Gem::Specification.new do |s|
|
|
|
56
60
|
# to_json support
|
|
57
61
|
s.add_runtime_dependency 'multi_json'
|
|
58
62
|
|
|
63
|
+
# temporary filesystem to act on
|
|
64
|
+
s.add_development_dependency 'test_construct'
|
|
65
|
+
# ensure we have a JSON parser
|
|
66
|
+
s.add_development_dependency 'json'
|
|
67
|
+
|
|
59
68
|
end
|
data/spec/cli/helper_spec.rb
CHANGED
|
@@ -15,52 +15,52 @@ describe MetricFu::Cli::Helper do
|
|
|
15
15
|
context "on every Ruby version" do
|
|
16
16
|
|
|
17
17
|
it "opens the report in a browser" do
|
|
18
|
-
defaults[:open].
|
|
18
|
+
expect(defaults[:open]).to be_truthy
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "enables Flay" do
|
|
22
|
-
defaults[:flay].
|
|
22
|
+
expect(defaults[:flay]).to be_truthy
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "enables Reek" do
|
|
26
|
-
defaults[:reek].
|
|
26
|
+
expect(defaults[:reek]).to be_truthy
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "enables Hotspots" do
|
|
30
|
-
defaults[:hotspots].
|
|
30
|
+
expect(defaults[:hotspots]).to be_truthy
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "enables Churn" do
|
|
34
|
-
defaults[:churn].
|
|
34
|
+
expect(defaults[:churn]).to be_truthy
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "enables Saikuro" do
|
|
38
|
-
defaults[:saikuro].
|
|
38
|
+
expect(defaults[:saikuro]).to be_truthy
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
if MetricFu.configuration.mri?
|
|
42
42
|
it "enables Flog" do
|
|
43
|
-
!defaults[:flog].
|
|
43
|
+
!expect(defaults[:flog]).to be_truthy
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "enables Cane" do
|
|
47
|
-
defaults[:cane].
|
|
47
|
+
expect(defaults[:cane]).to be_truthy
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "enables RCov" do
|
|
52
|
-
defaults[:rcov].
|
|
52
|
+
expect(defaults[:rcov]).to be_truthy
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "runs by default" do
|
|
56
|
-
defaults[:run].
|
|
56
|
+
expect(defaults[:run]).to be_truthy
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
if MetricFu.configuration.mri?
|
|
61
61
|
|
|
62
62
|
it "enables Rails Best Practices" do
|
|
63
|
-
defaults[:rails_best_practices].
|
|
63
|
+
expect(defaults[:rails_best_practices]).to be_truthy
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
end
|
|
@@ -71,99 +71,99 @@ describe MetricFu::Cli::Helper do
|
|
|
71
71
|
let(:helper) { MetricFu::Cli::Helper.new }
|
|
72
72
|
|
|
73
73
|
it "turns open in browser off" do
|
|
74
|
-
helper.process_options(["--no-open"])[:open].
|
|
74
|
+
expect(helper.process_options(["--no-open"])[:open]).to be_falsey
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
it "turns open in browser on" do
|
|
78
|
-
helper.process_options(["--open"])[:open].
|
|
78
|
+
expect(helper.process_options(["--open"])[:open]).to be_truthy
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it "turns saikuro off" do
|
|
82
|
-
helper.process_options(["--no-saikuro"])[:saikuro].
|
|
82
|
+
expect(helper.process_options(["--no-saikuro"])[:saikuro]).to be_falsey
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
it "turns saikuro on" do
|
|
86
|
-
helper.process_options(["--saikuro"])[:saikuro].
|
|
86
|
+
expect(helper.process_options(["--saikuro"])[:saikuro]).to be_truthy
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
it "turns churn off" do
|
|
90
|
-
helper.process_options(["--no-churn"])[:churn].
|
|
90
|
+
expect(helper.process_options(["--no-churn"])[:churn]).to be_falsey
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
it "turns churn on" do
|
|
94
|
-
helper.process_options(["--churn"])[:churn].
|
|
94
|
+
expect(helper.process_options(["--churn"])[:churn]).to be_truthy
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
it "turns flay off" do
|
|
98
|
-
helper.process_options(["--no-flay"])[:flay].
|
|
98
|
+
expect(helper.process_options(["--no-flay"])[:flay]).to be_falsey
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
it "turns flay on" do
|
|
102
|
-
helper.process_options(["--flay"])[:flay].
|
|
102
|
+
expect(helper.process_options(["--flay"])[:flay]).to be_truthy
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
if MetricFu.configuration.mri?
|
|
106
106
|
|
|
107
107
|
it "turns flog off" do
|
|
108
|
-
helper.process_options(["--no-flog"])[:flog].
|
|
108
|
+
expect(helper.process_options(["--no-flog"])[:flog]).to be_falsey
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it "turns flog on" do
|
|
112
|
-
helper.process_options(["--flog"])[:flog].
|
|
112
|
+
expect(helper.process_options(["--flog"])[:flog]).to be_truthy
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
it "turns cane off" do
|
|
116
|
-
helper.process_options(["--no-cane"])[:cane].
|
|
116
|
+
expect(helper.process_options(["--no-cane"])[:cane]).to be_falsey
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
it "turns cane on" do
|
|
120
|
-
helper.process_options(["--cane"])[:cane].
|
|
120
|
+
expect(helper.process_options(["--cane"])[:cane]).to be_truthy
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
it "turns hotspots off" do
|
|
127
|
-
helper.process_options(["--no-hotspots"])[:hotspots].
|
|
127
|
+
expect(helper.process_options(["--no-hotspots"])[:hotspots]).to be_falsey
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
it "turns hotspots on" do
|
|
131
|
-
helper.process_options(["--hotspots"])[:hotspots].
|
|
131
|
+
expect(helper.process_options(["--hotspots"])[:hotspots]).to be_truthy
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
it "turns rcov off" do
|
|
135
|
-
helper.process_options(["--no-rcov"])[:rcov].
|
|
135
|
+
expect(helper.process_options(["--no-rcov"])[:rcov]).to be_falsey
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it "turns rcov on" do
|
|
139
|
-
helper.process_options(["--rcov"])[:rcov].
|
|
139
|
+
expect(helper.process_options(["--rcov"])[:rcov]).to be_truthy
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
it "turns reek off" do
|
|
143
|
-
helper.process_options(["--no-reek"])[:reek].
|
|
143
|
+
expect(helper.process_options(["--no-reek"])[:reek]).to be_falsey
|
|
144
144
|
end
|
|
145
145
|
|
|
146
146
|
it "turns reek on" do
|
|
147
|
-
helper.process_options(["--reek"])[:reek].
|
|
147
|
+
expect(helper.process_options(["--reek"])[:reek]).to be_truthy
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
it "turns roodi off" do
|
|
151
|
-
helper.process_options(["--no-roodi"])[:roodi].
|
|
151
|
+
expect(helper.process_options(["--no-roodi"])[:roodi]).to be_falsey
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
it "turns roodi on" do
|
|
155
|
-
helper.process_options(["--roodi"])[:roodi].
|
|
155
|
+
expect(helper.process_options(["--roodi"])[:roodi]).to be_truthy
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
context 'given a single format' do
|
|
159
159
|
it "sets the format" do
|
|
160
|
-
helper.process_options(["--format", "json"])[:format].
|
|
160
|
+
expect(helper.process_options(["--format", "json"])[:format]).to eq([['json']])
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
context 'given multiple formats' do
|
|
165
165
|
it "sets multiple formats" do
|
|
166
|
-
helper.process_options(["--format", "json", "--format", "yaml"])[:format].
|
|
166
|
+
expect(helper.process_options(["--format", "json", "--format", "yaml"])[:format]).to eq([['json'], ['yaml']])
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
169
|
|
|
@@ -10,7 +10,7 @@ describe MetricFu::Configuration do
|
|
|
10
10
|
rcov.enabled = true
|
|
11
11
|
end
|
|
12
12
|
MetricFu.configure
|
|
13
|
-
MetricFu::Io::FileSystem.
|
|
13
|
+
allow(MetricFu::Io::FileSystem).to receive(:create_directories) # no need to create directories for the tests
|
|
14
14
|
@config
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -55,7 +55,7 @@ describe MetricFu::Configuration do
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it 'should return true' do
|
|
58
|
-
@config.is_cruise_control_rb
|
|
58
|
+
expect(@config.is_cruise_control_rb?).to be_truthy
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
after(:each) do
|
|
@@ -69,7 +69,7 @@ describe MetricFu::Configuration do
|
|
|
69
69
|
before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
|
|
70
70
|
|
|
71
71
|
it 'should return false' do
|
|
72
|
-
@config.is_cruise_control_rb
|
|
72
|
+
expect(@config.is_cruise_control_rb?).to be_falsey
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
end
|
|
@@ -100,7 +100,7 @@ describe MetricFu::Configuration do
|
|
|
100
100
|
get_new_config
|
|
101
101
|
end
|
|
102
102
|
it 'should return "tmp/metric_fu"' do
|
|
103
|
-
base_directory.
|
|
103
|
+
expect(base_directory).to eq(MetricFu.artifact_dir)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
it 'should set @metric_fu_root_directory to the base of the '+
|
|
@@ -108,7 +108,7 @@ describe MetricFu::Configuration do
|
|
|
108
108
|
app_root = File.join(File.dirname(__FILE__), '..', '..')
|
|
109
109
|
app_root_absolute_path = File.expand_path(app_root)
|
|
110
110
|
metric_fu_absolute_path = File.expand_path(metric_fu_root)
|
|
111
|
-
metric_fu_absolute_path.
|
|
111
|
+
expect(metric_fu_absolute_path).to eq(app_root_absolute_path)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
it 'should set @template_directory to the lib/templates relative '+
|
|
@@ -117,23 +117,23 @@ describe MetricFu::Configuration do
|
|
|
117
117
|
'..', '..', 'lib','templates')
|
|
118
118
|
template_dir_abs_path = File.expand_path(template_dir)
|
|
119
119
|
calc_template_dir_abs_path = File.expand_path(template_directory)
|
|
120
|
-
calc_template_dir_abs_path.
|
|
120
|
+
expect(calc_template_dir_abs_path).to eq(template_dir_abs_path)
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
it 'should set @scratch_directory to scratch relative '+
|
|
124
124
|
'to @base_directory' do
|
|
125
125
|
scratch_dir = MetricFu.scratch_dir
|
|
126
|
-
scratch_directory.
|
|
126
|
+
expect(scratch_directory).to eq(scratch_dir)
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
it 'should set @output_directory to output relative '+
|
|
130
130
|
'to @base_directory' do
|
|
131
131
|
output_dir = MetricFu.output_dir
|
|
132
|
-
output_directory.
|
|
132
|
+
expect(output_directory).to eq(output_dir)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
it 'should set @template_class to AwesomeTemplate by default' do
|
|
136
|
-
template_class.
|
|
136
|
+
expect(template_class).to eq(AwesomeTemplate)
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
describe 'when a templates configuration is given' do
|
|
@@ -158,11 +158,11 @@ describe MetricFu::Configuration do
|
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
it 'should set given darwin_txmt_protocol_no_thanks' do
|
|
161
|
-
expect(MetricFu::Formatter::Templates.option('darwin_txmt_protocol_no_thanks')).to
|
|
161
|
+
expect(MetricFu::Formatter::Templates.option('darwin_txmt_protocol_no_thanks')).to be_falsey
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
it 'should set given syntax_highlighting' do
|
|
165
|
-
expect(MetricFu::Formatter::Templates.option('syntax_highlighting')).to
|
|
165
|
+
expect(MetricFu::Formatter::Templates.option('syntax_highlighting')).to be_falsey
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
end
|
|
@@ -192,7 +192,7 @@ describe MetricFu::Configuration do
|
|
|
192
192
|
it 'should set @churn to {}' do
|
|
193
193
|
load_metric 'churn'
|
|
194
194
|
expect(MetricFu::Metric.get_metric(:churn).run_options).to eq(
|
|
195
|
-
{ :start_date => %q("1 year ago"), :minimum_churn_count => 10}
|
|
195
|
+
{ :start_date => %q("1 year ago"), :minimum_churn_count => 10, :ignore_files=>[], :data_directory=> MetricFu::Io::FileSystem.scratch_directory('churn')}
|
|
196
196
|
)
|
|
197
197
|
end
|
|
198
198
|
|
|
@@ -277,7 +277,7 @@ describe MetricFu::Configuration do
|
|
|
277
277
|
|
|
278
278
|
before(:each) do
|
|
279
279
|
@config = MetricFu.configuration
|
|
280
|
-
@config.
|
|
280
|
+
allow(@config).to receive(:rails?).and_return(true)
|
|
281
281
|
@config.reset
|
|
282
282
|
MetricFu.configure
|
|
283
283
|
%w(rails_best_practices).each do |metric|
|
|
@@ -287,7 +287,7 @@ describe MetricFu::Configuration do
|
|
|
287
287
|
|
|
288
288
|
describe '#set_graphs ' do
|
|
289
289
|
it 'should set the graphs to include rails_best_practices' do
|
|
290
|
-
expect(MetricFu::Metric.get_metric(:rails_best_practices).has_graph?).to
|
|
290
|
+
expect(MetricFu::Metric.get_metric(:rails_best_practices).has_graph?).to be_truthy
|
|
291
291
|
end
|
|
292
292
|
end
|
|
293
293
|
|
|
@@ -300,14 +300,14 @@ describe MetricFu::Configuration do
|
|
|
300
300
|
describe 'if #rails? is false ' do
|
|
301
301
|
before(:each) do
|
|
302
302
|
get_new_config
|
|
303
|
-
@config.
|
|
303
|
+
allow(@config).to receive(:rails?).and_return(false)
|
|
304
304
|
%w(rails_best_practices).each do |metric|
|
|
305
305
|
load_metric metric
|
|
306
306
|
end
|
|
307
307
|
end
|
|
308
308
|
|
|
309
309
|
it 'should set the registered code_dirs to ["lib"]' do
|
|
310
|
-
directory('code_dirs').
|
|
310
|
+
expect(directory('code_dirs')).to eq(['lib'])
|
|
311
311
|
end
|
|
312
312
|
end
|
|
313
313
|
end
|
|
@@ -318,7 +318,7 @@ describe MetricFu::Configuration do
|
|
|
318
318
|
|
|
319
319
|
it 'should return the value of the PLATFORM constant' do
|
|
320
320
|
this_platform = RUBY_PLATFORM
|
|
321
|
-
@config.platform.
|
|
321
|
+
expect(@config.platform).to eq(this_platform)
|
|
322
322
|
end
|
|
323
323
|
end
|
|
324
324
|
|
|
@@ -331,7 +331,7 @@ describe MetricFu::Configuration do
|
|
|
331
331
|
end
|
|
332
332
|
|
|
333
333
|
it 'adds to the list of formatters' do
|
|
334
|
-
@config.formatters.first.
|
|
334
|
+
expect(@config.formatters.first).to be_an_instance_of(MetricFu::Formatter::HTML)
|
|
335
335
|
end
|
|
336
336
|
end
|
|
337
337
|
|
|
@@ -342,7 +342,7 @@ describe MetricFu::Configuration do
|
|
|
342
342
|
end
|
|
343
343
|
|
|
344
344
|
it 'adds to the list of formatters' do
|
|
345
|
-
@config.formatters.first.
|
|
345
|
+
expect(@config.formatters.first).to be_an_instance_of(MyCustomFormatter)
|
|
346
346
|
end
|
|
347
347
|
end
|
|
348
348
|
|
|
@@ -355,7 +355,7 @@ describe MetricFu::Configuration do
|
|
|
355
355
|
end
|
|
356
356
|
|
|
357
357
|
it 'adds each to the list of formatters' do
|
|
358
|
-
@config.formatters.count.
|
|
358
|
+
expect(@config.formatters.count).to eq(3)
|
|
359
359
|
end
|
|
360
360
|
end
|
|
361
361
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
+
MetricFu.data_structures_require { 'line_numbers' }
|
|
2
3
|
|
|
3
4
|
describe MetricFu::LineNumbers do
|
|
4
5
|
FIXTURE_DATA = ->(paths) {
|
|
@@ -7,55 +8,55 @@ describe MetricFu::LineNumbers do
|
|
|
7
8
|
describe "in_method?" do
|
|
8
9
|
it "should know if a line is NOT in a method" do
|
|
9
10
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
|
|
10
|
-
ln.in_method?(2).
|
|
11
|
+
expect(ln.in_method?(2)).to eq(false)
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
it "should know if a line is in an instance method" do
|
|
14
15
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
|
|
15
|
-
ln.in_method?(8).
|
|
16
|
+
expect(ln.in_method?(8)).to eq(true)
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
it "should know if a line is in an class method" do
|
|
19
20
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
|
|
20
|
-
ln.in_method?(3).
|
|
21
|
+
expect(ln.in_method?(3)).to eq(true)
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
describe "method_at_line" do
|
|
25
26
|
it "should know the name of an instance method at a particular line" do
|
|
26
27
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
|
|
27
|
-
ln.method_at_line(8).
|
|
28
|
+
expect(ln.method_at_line(8)).to eq("Foo#what")
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
it "should know the name of a class method at a particular line" do
|
|
31
32
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
|
|
32
|
-
ln.method_at_line(3).
|
|
33
|
+
expect(ln.method_at_line(3)).to eq("Foo::awesome")
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
it "should know the name of a private method at a particular line" do
|
|
36
37
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
|
|
37
|
-
ln.method_at_line(28).
|
|
38
|
+
expect(ln.method_at_line(28)).to eq("Foo#whoop")
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
it "should know the name of a class method defined in a 'class << self block at a particular line" do
|
|
41
42
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
|
|
42
|
-
ln.method_at_line(22).
|
|
43
|
+
expect(ln.method_at_line(22)).to eq("Foo::neat")
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
it "should know the name of an instance method at a particular line in a file with two classes" do
|
|
46
47
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["two_classes.rb"])
|
|
47
|
-
ln.method_at_line(3).
|
|
48
|
-
ln.method_at_line(9).
|
|
48
|
+
expect(ln.method_at_line(3)).to eq("Foo#stuff")
|
|
49
|
+
expect(ln.method_at_line(9)).to eq("Bar#stuff")
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
it "should work with modules" do
|
|
52
53
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["module.rb"])
|
|
53
|
-
ln.method_at_line(4).
|
|
54
|
+
expect(ln.method_at_line(4)).to eq('KickAss#get_beat_up?')
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
it "should work with module surrounding class" do
|
|
57
58
|
ln = MetricFu::LineNumbers.new(FIXTURE_DATA["module_surrounds_class.rb"])
|
|
58
|
-
ln.method_at_line(5).
|
|
59
|
+
expect(ln.method_at_line(5)).to eq("StuffModule::ThingClass#do_it")
|
|
59
60
|
# ln.method_at_line(12).should == "StuffModule#blah" #why no work?
|
|
60
61
|
end
|
|
61
62
|
|