metric_fu 4.7.3 → 4.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.metrics +19 -20
- data/.travis.yml +5 -5
- data/CONTRIBUTORS +13 -11
- data/DEV.md +56 -0
- data/HISTORY.md +9 -1
- data/README.md +6 -3
- data/checksum/metric_fu-4.7.3.gem.sha512 +1 -0
- data/gemfiles/Gemfile.travis +1 -7
- data/lib/metric_fu/configuration.rb +6 -10
- data/lib/metric_fu/loader.rb +1 -0
- data/lib/metric_fu/metrics/rcov/init.rb +24 -6
- data/lib/metric_fu/metrics/rcov/rcov.rb +7 -8
- data/lib/metric_fu/metrics/reek/reek.rb +4 -0
- data/lib/metric_fu/metrics/roodi/roodi.rb +1 -1
- data/lib/metric_fu/run.rb +4 -7
- data/lib/metric_fu/version.rb +1 -1
- data/spec/metric_fu/configuration_spec.rb +2 -1
- data/spec/metric_fu/metrics/rcov/rcov_grapher_spec.rb +1 -0
- data/spec/metric_fu/metrics/reek/reek_spec.rb +52 -32
- data/spec/metric_fu/metrics/roodi/roodi_spec.rb +61 -0
- metadata +4 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGM5Njc5OTJhMzVlNzcwMTEzODAwM2I4MDdlNmQzYWVkMmFiNzI4NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2NhZjJmMmMyN2RhZGQxYWNjYmE3MzI1OGUzNWNmNjFlNDVkOGE5ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODhhMmQ5ZDg2MWVlNjY0YjNlM2M4MTU4NjM5YzE3ZWZhYTgwNDQ5YjIyMjU0
|
10
|
+
ZjNlYjk5MTY0NzY3MzFiZTI1MTU2YzA2OGI1YTVjMGFmYTkyYjcxMTMyMTQ0
|
11
|
+
NTQyZmVlMWNlMjA4OGE5OWM2OWE0Yzc3ZjNiZmIwYzgyZmU2OWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjkzNzhkMDFmNjMyYzRmODA4NzNmOTE0NGViZTVjZTgzM2QxZGJiYjQ5Yzlk
|
14
|
+
MmMwYjU3ZGZhYmJhNTRmNzgwMjg4MzJhMTg4ZDBiZDMyNWViZDFiMDRlMzAx
|
15
|
+
ODk0MGVmMzA5N2EwODI3MTVlODdjOWM1MDEwNGYwNjg1MjQ2ZmU=
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.metrics
CHANGED
@@ -4,14 +4,13 @@
|
|
4
4
|
#
|
5
5
|
# MetricFu::Configuration.run do |config|
|
6
6
|
#
|
7
|
-
# Configure Metrics
|
7
|
+
# # Configure Metrics
|
8
8
|
#
|
9
|
-
# To configure individual metrics...
|
9
|
+
# # To configure individual metrics...
|
10
10
|
#
|
11
11
|
# config.configure_metric(:rcov) do |rcov|
|
12
|
-
# rcov.
|
13
|
-
#
|
14
|
-
# rcov.external = coverage_file
|
12
|
+
# rcov.coverage_file = MetricFu.run_path.join("coverage/rcov/rcov.txt")
|
13
|
+
# rcov.enable
|
15
14
|
# rcov.activate
|
16
15
|
# end
|
17
16
|
#
|
@@ -29,7 +28,7 @@
|
|
29
28
|
# churn.start_date = '6 months ago'
|
30
29
|
# end
|
31
30
|
#
|
32
|
-
# Or, to configure a group of metrics...
|
31
|
+
# # Or, to configure a group of metrics...
|
33
32
|
# config.configure_metrics.each do |metric|
|
34
33
|
# if [:churn, :flay, :flog].include?(metric.name)
|
35
34
|
# metric.enabled = true
|
@@ -39,31 +38,31 @@
|
|
39
38
|
# end
|
40
39
|
#
|
41
40
|
#
|
42
|
-
# Configure Formatters
|
41
|
+
# # Configure Formatters
|
43
42
|
#
|
44
|
-
# By default, metric_fu will use the built-in html formatter
|
45
|
-
# to generate HTML reports for each metric with pretty graphs.
|
43
|
+
# # By default, metric_fu will use the built-in html formatter
|
44
|
+
# # to generate HTML reports for each metric with pretty graphs.
|
46
45
|
|
47
|
-
# To configure different formatter(s) or output ...
|
46
|
+
# # To configure different formatter(s) or output ...
|
48
47
|
#
|
49
48
|
# config.configure_formatter(:html)
|
50
49
|
# config.configure_formatter(:yaml, "customreport.yml")
|
51
50
|
# config.configure_formatter(MyCustomFormatter)
|
52
51
|
#
|
53
|
-
# MetricFu will attempt to require a custom formatter by
|
54
|
-
# fully qualified name based on ruby search path,
|
55
|
-
# but you may find that you need to add a require above.
|
52
|
+
# # MetricFu will attempt to require a custom formatter by
|
53
|
+
# # fully qualified name based on ruby search path,
|
54
|
+
# # but you may find that you need to add a require above.
|
56
55
|
#
|
57
|
-
# For instance, to require a formatter in your app's lib directory, add the
|
58
|
-
# following line to the top of this file.
|
59
|
-
# require './lib/my_custom_formatter.rb'
|
56
|
+
# # For instance, to require a formatter in your app's lib directory, add the
|
57
|
+
# # following line to the top of this file.
|
58
|
+
# # require './lib/my_custom_formatter.rb'
|
60
59
|
#
|
61
60
|
#
|
62
|
-
# Configure Graph Engine
|
61
|
+
# # Configure Graph Engine
|
63
62
|
#
|
64
|
-
# By default, metric_fu uses the bluff graph engine.
|
65
|
-
# To configure a different graph engine...
|
63
|
+
# # By default, metric_fu uses the bluff graph engine.
|
64
|
+
# # To configure a different graph engine...
|
66
65
|
#
|
67
|
-
# config.configure_graph_engine(:gchart)
|
66
|
+
# # config.configure_graph_engine(:gchart)
|
68
67
|
#
|
69
68
|
# end
|
data/.travis.yml
CHANGED
@@ -5,16 +5,16 @@ cache: bundler
|
|
5
5
|
gemfile:
|
6
6
|
- gemfiles/Gemfile.travis
|
7
7
|
before_install:
|
8
|
-
- gem install bundler
|
8
|
+
- gem install bundler
|
9
9
|
# env:
|
10
10
|
# - "rack=1.3.4"
|
11
11
|
rvm:
|
12
12
|
- 2.1.0
|
13
13
|
- 2.0.0
|
14
14
|
- 1.9.3
|
15
|
-
|
16
|
-
- jruby
|
17
|
-
- rbx
|
15
|
+
- 1.9.2
|
16
|
+
- jruby
|
17
|
+
- rbx-2
|
18
18
|
matrix:
|
19
19
|
allow_failures:
|
20
|
-
- rvm: rbx
|
20
|
+
- rvm: rbx-2
|
data/CONTRIBUTORS
CHANGED
@@ -34,34 +34,36 @@ Extrovert
|
|
34
34
|
KAKUTANI Shintaro
|
35
35
|
Andrew Timberlake
|
36
36
|
Guilherme Souza
|
37
|
+
Przemysław Dąbek
|
37
38
|
carlost
|
38
39
|
David Barri
|
39
40
|
Beau Fabry
|
40
41
|
Chris Mason
|
41
42
|
Andrew Selder
|
42
|
-
Mark Wilden
|
43
43
|
iain
|
44
|
+
Mark Wilden
|
44
45
|
Lars E. Hoeg
|
45
46
|
Eric Wollesen
|
46
47
|
Adam Bair
|
47
48
|
Jinzhu
|
48
|
-
Diego Carrion
|
49
|
-
Martin Gotink
|
50
49
|
Matthew Van Horn
|
51
|
-
|
50
|
+
Martin Gotink
|
51
|
+
Diego Carrion
|
52
52
|
benlovell
|
53
|
-
|
53
|
+
saltracer
|
54
54
|
ff-cviradiya
|
55
|
-
|
55
|
+
khall
|
56
56
|
Stefan Huber
|
57
|
+
Todd A. Jacobs
|
58
|
+
jayzes
|
59
|
+
Scyllinice
|
57
60
|
Hans Hasselberg
|
58
61
|
Bitdeli Chef
|
59
|
-
Scyllinice
|
60
|
-
jayzes
|
61
62
|
Matthew Gordon
|
62
|
-
|
63
|
+
Chris Ian Fiel
|
63
64
|
factorylabs
|
65
|
+
Paul Elliott
|
64
66
|
Greg Allen
|
67
|
+
Joel Nimety
|
65
68
|
Mike Ball
|
66
|
-
|
67
|
-
Paul Elliott
|
69
|
+
Guilherme Simões
|
data/DEV.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
## Contracted Interfaces
|
2
|
+
|
3
|
+
```ruby
|
4
|
+
MetricFu.run_dir #=> Dir.pwd
|
5
|
+
MetricFu.run_dir = some_path
|
6
|
+
MetricFu.run_path #=> Pathname(Dir.pwd)
|
7
|
+
MetricFu.root_dir
|
8
|
+
MetricFu.load_user_configuration
|
9
|
+
MetricFu.loader.loaded_files
|
10
|
+
MetricFu.lib_require(base = '',&block)
|
11
|
+
MetricFu.lib_dir #=> metric_fu/lib
|
12
|
+
MetricFu.metrics_require(&block)
|
13
|
+
MetricFu.metrics_dir #=> metric_fu/lib/metrics
|
14
|
+
MetricFu.formatter_require(&block)
|
15
|
+
MetricFu.formatter_dir #=> metric_fu/lib/formatter
|
16
|
+
MetricFu.reporting_require(&block)
|
17
|
+
MetricFu.reporting_dir #=> metric_fu/lib/reporting
|
18
|
+
MetricFu.logging_require(&block)
|
19
|
+
MetricFu.logging_dir #=> metric_fu/lib/logging
|
20
|
+
MetricFu.errors_require(&block)
|
21
|
+
MetricFu.errors_dir #=> metric_fu/lib/errors
|
22
|
+
MetricFu.data_structures_require(&block)
|
23
|
+
MetricFu.data_structures_dir #=> metric_fu/lib/data_structures
|
24
|
+
MetricFu.tasks_require(&block)
|
25
|
+
MetricFu.tasks_dir #=> metric_fu/lib/tasks
|
26
|
+
|
27
|
+
MetricFu.configuration #=> MetricFu::Configuration.new
|
28
|
+
MetricFu.configuration.configure_metrics # for each metric, yield to block or runs enable, activate
|
29
|
+
metric = MetricFu.configuration.configure_metric(:flog)
|
30
|
+
metric.run_options #=> metric.default_run_options.merge(metric.configured_run_options)
|
31
|
+
metric.enable
|
32
|
+
metric.enabled = true
|
33
|
+
metric.activate
|
34
|
+
metric.activated = true
|
35
|
+
metric.name #=> :flog
|
36
|
+
```
|
37
|
+
|
38
|
+
## Testing
|
39
|
+
|
40
|
+
`bundle exec rspec`
|
41
|
+
|
42
|
+
## Forking
|
43
|
+
|
44
|
+
## Issues / Pull Requests
|
45
|
+
|
46
|
+
* see [CONTRIBUTING](CONTRIBUTING.md)
|
47
|
+
|
48
|
+
## Building
|
49
|
+
|
50
|
+
`rake build` or `rake install`
|
51
|
+
|
52
|
+
## Releasing
|
53
|
+
|
54
|
+
1. Update lib/metric_fu/version.rb
|
55
|
+
2. Update HISTORY.md
|
56
|
+
3. `rake release`
|
data/HISTORY.md
CHANGED
@@ -4,13 +4,21 @@ Each change should fall into categories that would affect whether the release is
|
|
4
4
|
|
5
5
|
As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch. And _misc_ is either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding tests would be patch level.
|
6
6
|
|
7
|
-
### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.7.
|
7
|
+
### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.7.4...master)
|
8
8
|
|
9
9
|
* Breaking Changes
|
10
10
|
* Features
|
11
11
|
* Fixes
|
12
12
|
* Misc
|
13
13
|
|
14
|
+
### [4.7.4 / 2014-02-16](https://github.com/metricfu/metric_fu/compare/v4.7.3...v4.7.4)
|
15
|
+
|
16
|
+
* Fixes
|
17
|
+
* Reek no longer crashes when reporting no warnings (Michael Stark, #199)
|
18
|
+
* Prevent Roodi non-metric output from ending up in the results (Martin Gotink #202)
|
19
|
+
* Coverage file is only read in when the specified external file exists. (Benjamin Fleischer, #156)
|
20
|
+
* Metrics are configured to default values before the user config is loaded (Benjamin Fleischer, #156, #78)
|
21
|
+
|
14
22
|
### [4.7.3 / 2014-02-09](https://github.com/metricfu/metric_fu/compare/v4.7.2...v4.7.3)
|
15
23
|
|
16
24
|
* Fixes
|
data/README.md
CHANGED
@@ -122,8 +122,8 @@ in your .metrics file add the below to run pre-generated metrics
|
|
122
122
|
```ruby
|
123
123
|
MetricFu::Configuration.run do |config|
|
124
124
|
config.configure_metric(:rcov) do |rcov|
|
125
|
-
rcov.
|
126
|
-
rcov.
|
125
|
+
rcov.coverage_file = MetricFu.run_path.join("coverage/rcov/rcov.txt")
|
126
|
+
rcov.enable
|
127
127
|
rcov.activate
|
128
128
|
end
|
129
129
|
end
|
@@ -164,13 +164,16 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
164
164
|
SimpleCov.start
|
165
165
|
```
|
166
166
|
|
167
|
+
Additionally, the `coverage_file` path must be specified as above
|
168
|
+
and must exist.
|
169
|
+
|
167
170
|
## Compatibility
|
168
171
|
|
169
172
|
* It is currently testing on MRI (>= 1.9.3), JRuby (19 mode), and Rubinius (19 mode). Ruby 1.8 is no longer supported.
|
170
173
|
|
171
174
|
* For 1.8.7 support, see version 3.0.0 for partial support, or 2.1.3.7.18.1 (where [Semantic Versioning](http://semver.org/) goes to die)
|
172
175
|
|
173
|
-
* MetricFu no longer runs any of the analyzed code. For code coverage, You may still use rcov metrics as documented
|
176
|
+
* MetricFu no longer runs any of the analyzed code. For code coverage, You may still use rcov metrics as documented above
|
174
177
|
|
175
178
|
* The Cane, Flog, and Rails Best Practices metrics are disabled when Ripper is not available
|
176
179
|
|
@@ -0,0 +1 @@
|
|
1
|
+
9a3c76074181ca4ec770f1a52f652268e44af10648cf82cb641672d2075d92133751ad275ad1ba417c473ba8095d872df762eb379e2e48fd38ce1db06b4ea1e7
|
data/gemfiles/Gemfile.travis
CHANGED
@@ -3,14 +3,8 @@ source 'https://rubygems.org'
|
|
3
3
|
#to use, from the app root run
|
4
4
|
# export BUNDLE_GEMFILE=$PWD/gemfiles/Gemfile.travis
|
5
5
|
# when done, unset BUNDLE_GEMFILE
|
6
|
-
# for 1.9.2 support because of https://github.com/railsbp/rails_best_practices/blob/master/rails_best_practices.gemspec
|
7
|
-
|
8
|
-
platforms :rbx do
|
9
|
-
gem 'racc'
|
10
|
-
gem 'rubysl', '~> 2.0'
|
11
|
-
gem 'psych'
|
12
|
-
end
|
13
6
|
|
7
|
+
# for 1.9.2 support because of https://github.com/railsbp/rails_best_practices/blob/master/rails_best_practices.gemspec
|
14
8
|
gem 'activesupport', '~> 3.2'
|
15
9
|
|
16
10
|
eval_gemfile File.expand_path('../../Gemfile', __FILE__)
|
@@ -96,16 +96,20 @@ module MetricFu
|
|
96
96
|
yield MetricFu.configuration
|
97
97
|
end
|
98
98
|
|
99
|
-
def configure_metric(name)
|
99
|
+
def self.configure_metric(name)
|
100
100
|
yield MetricFu::Metric.get_metric(name)
|
101
101
|
end
|
102
102
|
|
103
|
+
def configure_metric(name, &block)
|
104
|
+
self.class.configure_metric(name, &block)
|
105
|
+
end
|
106
|
+
|
103
107
|
def configure_metrics
|
104
108
|
MetricFu::Io::FileSystem.set_directories
|
105
109
|
MetricFu::Metric.metrics.each do |metric|
|
106
110
|
if block_given?
|
107
111
|
yield metric
|
108
|
-
|
112
|
+
else
|
109
113
|
metric.enabled = false
|
110
114
|
metric.enable
|
111
115
|
end
|
@@ -113,14 +117,6 @@ module MetricFu
|
|
113
117
|
end
|
114
118
|
end
|
115
119
|
|
116
|
-
# TODO: Remove this method. If we run configure_metrics
|
117
|
-
# and it disabled rcov, we shouldn't have to worry here
|
118
|
-
# that rcov is a special case that can only be enabled
|
119
|
-
# manually
|
120
|
-
def metric_manually_configured?(metric)
|
121
|
-
[:rcov].include?(metric.name)
|
122
|
-
end
|
123
|
-
|
124
120
|
# TODO: Reconsider method name/behavior, as it really adds a formatter
|
125
121
|
def configure_formatter(format, output = nil)
|
126
122
|
@formatters << MetricFu::Formatter.class_for(format).new(output: output)
|
data/lib/metric_fu/loader.rb
CHANGED
@@ -6,11 +6,16 @@ module MetricFu
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def default_run_options
|
9
|
-
{
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
{
|
10
|
+
:environment => 'test',
|
11
|
+
:test_files => Dir['{spec,test}/**/*_{spec,test}.rb'],
|
12
|
+
:rcov_opts => rcov_opts,
|
13
|
+
:external => nil,
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def coverage_file=(coverage_file)
|
18
|
+
configured_run_options.update(:external => coverage_file)
|
14
19
|
end
|
15
20
|
|
16
21
|
def has_graph?
|
@@ -18,13 +23,26 @@ module MetricFu
|
|
18
23
|
end
|
19
24
|
|
20
25
|
def enable
|
21
|
-
|
26
|
+
if external_coverage_file?
|
27
|
+
super
|
28
|
+
else
|
29
|
+
mf_debug("RCov is not available. See README")
|
30
|
+
end
|
22
31
|
end
|
23
32
|
|
24
33
|
def activate
|
25
34
|
super
|
26
35
|
end
|
27
36
|
|
37
|
+
def external_coverage_file?
|
38
|
+
if coverage_file = run_options[:external]
|
39
|
+
File.exist?(coverage_file) ||
|
40
|
+
mf_log("Configured RCov file #{coverage_file.inspect} does not exist")
|
41
|
+
else
|
42
|
+
false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
28
46
|
private
|
29
47
|
|
30
48
|
def rcov_opts
|
@@ -1,5 +1,6 @@
|
|
1
1
|
MetricFu.lib_require { 'utility' }
|
2
2
|
MetricFu.lib_require { 'calculate' }
|
3
|
+
MetricFu.data_structures_require { 'line_numbers' }
|
3
4
|
|
4
5
|
module MetricFu
|
5
6
|
|
@@ -45,6 +46,7 @@ module MetricFu
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def default_command
|
49
|
+
require 'rake'
|
48
50
|
reset_output_location
|
49
51
|
test_files = FileList[*options[:test_files]].join(' ')
|
50
52
|
rcov_opts = options[:rcov_opts].join(' ')
|
@@ -144,8 +146,9 @@ module MetricFu
|
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
149
|
+
# We never run rcov anymore
|
147
150
|
def run_rcov?
|
148
|
-
|
151
|
+
false
|
149
152
|
end
|
150
153
|
|
151
154
|
def load_output
|
@@ -153,17 +156,13 @@ module MetricFu
|
|
153
156
|
end
|
154
157
|
|
155
158
|
def output_file
|
156
|
-
|
157
|
-
default_output_file
|
158
|
-
else
|
159
|
-
options.fetch(:external)
|
160
|
-
end
|
159
|
+
options.fetch(:external)
|
161
160
|
end
|
162
161
|
|
162
|
+
# Only used if run_rcov? is true
|
163
163
|
def default_output_file
|
164
|
-
File.join(metric_directory, 'rcov.txt')
|
164
|
+
output_file || File.join(metric_directory, 'rcov.txt')
|
165
165
|
end
|
166
166
|
|
167
|
-
|
168
167
|
end
|
169
168
|
end
|
@@ -23,6 +23,7 @@ module MetricFu
|
|
23
23
|
def analyze
|
24
24
|
@matches = @output.chomp.split("\n\n").map{|m| m.split("\n") }
|
25
25
|
@matches = @matches.map do |match|
|
26
|
+
break {} if zero_warnings?(match)
|
26
27
|
file_path = match.shift.split(' -- ').first
|
27
28
|
file_path = file_path.gsub('"', ' ').strip
|
28
29
|
code_smells = match.map do |smell|
|
@@ -115,5 +116,8 @@ module MetricFu
|
|
115
116
|
'-n'
|
116
117
|
end
|
117
118
|
|
119
|
+
def zero_warnings?(match)
|
120
|
+
match.last == "0 total warnings"
|
121
|
+
end
|
118
122
|
end
|
119
123
|
end
|
@@ -17,7 +17,7 @@ module MetricFu
|
|
17
17
|
@output = MetricFu::Utility.strip_escape_codes(@output)
|
18
18
|
@matches = @output.chomp.split("\n").map{|m| m.split(" - ") }
|
19
19
|
total = @matches.pop
|
20
|
-
@matches.reject! {|array| array.
|
20
|
+
@matches.reject! {|array| array.size < 2 }
|
21
21
|
@matches.map! do |match|
|
22
22
|
file, line = match[0].split(':')
|
23
23
|
problem = match[1]
|
data/lib/metric_fu/run.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
MetricFu.configure
|
2
1
|
module MetricFu
|
3
2
|
class Run
|
4
3
|
def initialize
|
@@ -45,12 +44,10 @@ module MetricFu
|
|
45
44
|
end
|
46
45
|
end
|
47
46
|
def configure_metric(metric, metric_options)
|
48
|
-
MetricFu::Configuration.
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
metric.public_send("#{option}=", value)
|
53
|
-
end
|
47
|
+
MetricFu::Configuration.configure_metric(metric) do |metric|
|
48
|
+
metric_options.each do |option, value|
|
49
|
+
mf_log "Setting #{metric} option #{option} to #{value}"
|
50
|
+
metric.public_send("#{option}=", value)
|
54
51
|
end
|
55
52
|
end
|
56
53
|
end
|
data/lib/metric_fu/version.rb
CHANGED
@@ -212,6 +212,7 @@ describe MetricFu::Configuration do
|
|
212
212
|
load_metric 'rcov'
|
213
213
|
expect(MetricFu::Metric.get_metric(:rcov).run_options).to eq(
|
214
214
|
{ :environment => 'test',
|
215
|
+
:external => nil,
|
215
216
|
:test_files => Dir['{spec,test}/**/*_{spec,test}.rb'],
|
216
217
|
:rcov_opts => [
|
217
218
|
"--sort coverage",
|
@@ -223,7 +224,7 @@ describe MetricFu::Configuration do
|
|
223
224
|
'--include-file "\Aapp,\Alib"',
|
224
225
|
"-Ispec"
|
225
226
|
],
|
226
|
-
|
227
|
+
}
|
227
228
|
)
|
228
229
|
end
|
229
230
|
|
@@ -15,8 +15,16 @@ describe MetricFu::ReekGenerator do
|
|
15
15
|
|
16
16
|
#TODO review tested output
|
17
17
|
describe "analyze method" do
|
18
|
+
|
18
19
|
before :each do
|
19
|
-
|
20
|
+
MetricFu::Configuration.run {}
|
21
|
+
allow(File).to receive(:directory?).and_return(true)
|
22
|
+
@reek = MetricFu::ReekGenerator.new
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with reek warnings" do
|
26
|
+
before :each do
|
27
|
+
@lines = <<-HERE
|
20
28
|
"app/controllers/activity_reports_controller.rb" -- 4 warnings:
|
21
29
|
ActivityReportsController#authorize_user calls current_user.primary_site_ids multiple times (Duplication)
|
22
30
|
ActivityReportsController#authorize_user calls params[id] multiple times (Duplication)
|
@@ -32,43 +40,55 @@ LinkTargetsController#authorize_user calls current_user.role multiple times (Dup
|
|
32
40
|
"app/controllers/newline_controller.rb" -- 1 warnings:
|
33
41
|
NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
|
34
42
|
HERE
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
43
|
+
@reek.instance_variable_set(:@output, @lines)
|
44
|
+
@matches = @reek.analyze
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should find the code smell's method name" do
|
48
|
+
smell = @matches.first[:code_smells].first
|
49
|
+
expect(smell[:method]).to eq("ActivityReportsController#authorize_user")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should find the code smell's type" do
|
53
|
+
smell = @matches[1][:code_smells].first
|
54
|
+
expect(smell[:type]).to eq("Nested Iterators")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should find the code smell's message" do
|
58
|
+
smell = @matches[1][:code_smells].first
|
59
|
+
expect(smell[:message]).to eq("is nested")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should find the code smell's type" do
|
63
|
+
smell = @matches.first
|
64
|
+
expect(smell[:file_path]).to eq("app/controllers/activity_reports_controller.rb")
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should NOT insert nil smells into the array when there's a newline in the method call" do
|
68
|
+
expect(@matches.last[:code_smells]).to eq(@matches.last[:code_smells].compact)
|
69
|
+
expect(@matches.last).to eq({:file_path=>"app/controllers/newline_controller.rb",
|
70
|
+
:code_smells=>[{:type=>"Duplication",
|
71
|
+
:method=>"\"",
|
72
|
+
:message=>"multiple times"}]})
|
73
|
+
# Note: hopefully a temporary solution until I figure out how to deal with newlines in the method call more effectively -Jake 5/11/2009
|
74
|
+
end
|
40
75
|
end
|
41
76
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
77
|
+
context "without reek warnings" do
|
78
|
+
before :each do
|
79
|
+
@lines = <<-HERE
|
46
80
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
it "should find the code smell's message" do
|
53
|
-
smell = @matches[1][:code_smells].first
|
54
|
-
expect(smell[:message]).to eq("is nested")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should find the code smell's type" do
|
58
|
-
smell = @matches.first
|
59
|
-
expect(smell[:file_path]).to eq("app/controllers/activity_reports_controller.rb")
|
60
|
-
end
|
81
|
+
0 total warnings
|
82
|
+
HERE
|
83
|
+
@reek.instance_variable_set(:@output, @lines)
|
84
|
+
@matches = @reek.analyze
|
85
|
+
end
|
61
86
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
:code_smells=>[{:type=>"Duplication",
|
66
|
-
:method=>"\"",
|
67
|
-
:message=>"multiple times"}]})
|
68
|
-
# Note: hopefully a temporary solution until I figure out how to deal with newlines in the method call more effectively -Jake 5/11/2009
|
87
|
+
it "returns empty analysis" do
|
88
|
+
expect(@matches).to eq({})
|
89
|
+
end
|
69
90
|
end
|
70
91
|
end
|
71
|
-
|
72
92
|
end
|
73
93
|
|
74
94
|
describe MetricFu::ReekGenerator do
|
@@ -18,4 +18,65 @@ describe MetricFu::RoodiGenerator do
|
|
18
18
|
roodi.emit
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
describe "analyze" do
|
23
|
+
context "when it has multiple failures" do
|
24
|
+
before :each do
|
25
|
+
lines = <<-HERE
|
26
|
+
|
27
|
+
Running Roodi checks
|
28
|
+
./app/models/some_model.rb:14 - Found = in conditional. It should probably be an ==
|
29
|
+
lib/some_file.rb:53 - Rescue block should not be empty.
|
30
|
+
|
31
|
+
Checked 65 files
|
32
|
+
HERE
|
33
|
+
|
34
|
+
roodi = MetricFu::RoodiGenerator.new
|
35
|
+
roodi.instance_variable_set(:@output, lines)
|
36
|
+
@matches = roodi.analyze
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should find all problems" do
|
40
|
+
problem_count = @matches[:problems].size
|
41
|
+
expect(problem_count).to eq(2)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should find the file of the problem" do
|
45
|
+
problem = @matches[:problems].first
|
46
|
+
expect(problem[:file]).to eq("./app/models/some_model.rb")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should find the line of the problem" do
|
50
|
+
problem = @matches[:problems].first
|
51
|
+
expect(problem[:line]).to eq("14")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should find the description of the problem" do
|
55
|
+
problem = @matches[:problems].first
|
56
|
+
expect(problem[:problem]).to eq("Found = in conditional. It should probably be an ==")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "when it has no failures" do
|
62
|
+
before :each do
|
63
|
+
lines = <<-HERE
|
64
|
+
|
65
|
+
Running Roodi checks
|
66
|
+
|
67
|
+
Checked 42 files
|
68
|
+
Found 0 errors.
|
69
|
+
|
70
|
+
HERE
|
71
|
+
|
72
|
+
roodi = MetricFu::RoodiGenerator.new
|
73
|
+
roodi.instance_variable_set(:@output, lines)
|
74
|
+
@matches = roodi.analyze
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should have no problems" do
|
78
|
+
problem_count = @matches[:problems].size
|
79
|
+
expect(problem_count).to eq(0)
|
80
|
+
end
|
81
|
+
end
|
21
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metric_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.7.
|
4
|
+
version: 4.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Scruggs
|
@@ -49,7 +49,7 @@ cert_chain:
|
|
49
49
|
dWphdUtxcjhoS0RMdTRLK3F1Q0dqWC82TEw2CldPTno5dlQ2aDA1M2tIWllN
|
50
50
|
cmQ0R3MvTmRhQTR0SlN4cmhabFhkYWpBbS8wdkFPekxJcVVISFFrM1IwdGY3
|
51
51
|
YVkKZC93PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
52
|
-
date: 2014-02-
|
52
|
+
date: 2014-02-16 00:00:00.000000000 Z
|
53
53
|
dependencies:
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: flay
|
@@ -309,6 +309,7 @@ files:
|
|
309
309
|
- AUTHORS
|
310
310
|
- CONTRIBUTING.md
|
311
311
|
- CONTRIBUTORS
|
312
|
+
- DEV.md
|
312
313
|
- Gemfile
|
313
314
|
- Gemfile.devtools
|
314
315
|
- Guardfile
|
@@ -342,6 +343,7 @@ files:
|
|
342
343
|
- checksum/metric_fu-4.7.0.gem.sha512
|
343
344
|
- checksum/metric_fu-4.7.1.gem.sha512
|
344
345
|
- checksum/metric_fu-4.7.2.gem.sha512
|
346
|
+
- checksum/metric_fu-4.7.3.gem.sha512
|
345
347
|
- config/roodi_config.yml
|
346
348
|
- gem_tasks/build.rake
|
347
349
|
- gemfiles/Gemfile.travis
|
metadata.gz.sig
CHANGED
Binary file
|