yardstick 0.9.2 → 0.9.3
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/.travis.yml +9 -3
- data/Gemfile +19 -13
- data/Rakefile +3 -1
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/roodi.yml +16 -0
- data/config/site.reek +91 -0
- data/config/yardstick.yml +2 -0
- data/lib/yardstick/cli.rb +2 -0
- data/lib/yardstick/measurable.rb +2 -0
- data/lib/yardstick/measurement.rb +17 -7
- data/lib/yardstick/measurement_set.rb +2 -0
- data/lib/yardstick/method.rb +2 -0
- data/lib/yardstick/ordered_set.rb +2 -0
- data/lib/yardstick/processor.rb +2 -0
- data/lib/yardstick/rake/measurement.rb +2 -0
- data/lib/yardstick/rake/verify.rb +2 -0
- data/lib/yardstick/rule.rb +2 -0
- data/lib/yardstick/rule_set.rb +2 -0
- data/lib/yardstick/version.rb +3 -1
- data/lib/yardstick/yard_ext.rb +2 -0
- data/lib/yardstick.rb +2 -0
- data/spec/spec_helper.rb +25 -1
- data/spec/support/config_alias.rb +2 -0
- data/spec/{public → unit}/yardstick/cli_spec.rb +2 -0
- data/spec/{public → unit}/yardstick/measurement_set_spec.rb +2 -0
- data/spec/{public → unit}/yardstick/measurement_spec.rb +2 -0
- data/spec/{public → unit}/yardstick/method_spec.rb +2 -0
- data/spec/{public → unit}/yardstick/rake/measurement_spec.rb +2 -0
- data/spec/{public → unit}/yardstick/rake/verify_spec.rb +2 -0
- data/spec/{semipublic → unit}/yardstick/rule_spec.rb +2 -0
- data/spec/{public → unit}/yardstick_spec.rb +2 -0
- data/tasks/metrics/ci.rake +9 -0
- data/tasks/metrics/flay.rake +53 -0
- data/tasks/metrics/flog.rake +44 -0
- data/tasks/{heckle.rake → metrics/heckle.rake} +2 -2
- data/tasks/metrics/metric_fu.rake +31 -0
- data/tasks/metrics/reek.rake +21 -0
- data/tasks/metrics/roodi.rake +19 -0
- data/tasks/metrics/yardstick.rake +27 -0
- data/tasks/spec.rake +53 -11
- data/tasks/yard.rake +3 -1
- data/yardstick.gemspec +9 -6
- metadata +85 -110
- data/tasks/ci.rake +0 -1
- data/tasks/metrics.rake +0 -37
- data/tasks/yardstick.rake +0 -12
data/.travis.yml
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
|
4
|
-
script: "bundle exec rake spec"
|
2
|
+
bundler_args: --without yard guard benchmarks
|
3
|
+
script: "bundle exec rake ci"
|
5
4
|
rvm:
|
6
5
|
- ree
|
7
6
|
- 1.8.7
|
@@ -14,6 +13,13 @@ rvm:
|
|
14
13
|
- jruby-head
|
15
14
|
- rbx-18mode
|
16
15
|
- rbx-19mode
|
16
|
+
matrix:
|
17
|
+
allow_failures:
|
18
|
+
- rvm: ree
|
19
|
+
- rvm: 1.8.7
|
20
|
+
- rvm: jruby-19mode
|
21
|
+
- rvm: jruby-head
|
17
22
|
notifications:
|
23
|
+
irc: "irc.freenode.org#datamapper"
|
18
24
|
email:
|
19
25
|
- dan.kubb@gmail.com
|
data/Gemfile
CHANGED
@@ -4,8 +4,13 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
group :
|
8
|
-
gem '
|
7
|
+
group :development do
|
8
|
+
gem 'rake', '~> 10.0.3'
|
9
|
+
gem 'rspec', '~> 1.3.2'
|
10
|
+
end
|
11
|
+
|
12
|
+
group :benchmarks do
|
13
|
+
gem 'rbench', '~> 0.2.3'
|
9
14
|
end
|
10
15
|
|
11
16
|
group :guard do
|
@@ -24,6 +29,12 @@ group :guard do
|
|
24
29
|
gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
|
25
30
|
end
|
26
31
|
|
32
|
+
platform :jruby do
|
33
|
+
group :jruby do
|
34
|
+
gem 'jruby-openssl', '~> 0.8.2'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
27
38
|
group :metrics do
|
28
39
|
gem 'flay', '~> 1.4.3'
|
29
40
|
gem 'flog', '~> 2.5.3'
|
@@ -42,13 +53,9 @@ group :metrics do
|
|
42
53
|
gem 'map', '~> 6.3.0' # for metric_fu
|
43
54
|
gem 'metric_fu', '~> 2.1.1'
|
44
55
|
gem 'mspec', '~> 1.5.17'
|
56
|
+
gem 'rails_best_practices', '= 1.13.3' # for metric_fu
|
45
57
|
gem 'rcov', '~> 1.0.0'
|
46
58
|
gem 'ruby2ruby', '= 1.2.2' # for heckle
|
47
|
-
gem 'rails_best_practices', '= 1.13.3' # for metric_fu
|
48
|
-
end
|
49
|
-
|
50
|
-
platforms :mri_19 do
|
51
|
-
gem 'simplecov', '~> 0.7.1'
|
52
59
|
end
|
53
60
|
|
54
61
|
platforms :rbx do
|
@@ -56,12 +63,11 @@ group :metrics do
|
|
56
63
|
end
|
57
64
|
end
|
58
65
|
|
59
|
-
group :
|
60
|
-
gem '
|
66
|
+
group :test do
|
67
|
+
gem 'coveralls', '~> 0.5.6'
|
68
|
+
gem 'simplecov', '~> 0.7.1'
|
61
69
|
end
|
62
70
|
|
63
|
-
|
64
|
-
|
65
|
-
gem 'jruby-openssl', '~> 0.8.2'
|
66
|
-
end
|
71
|
+
group :yard do
|
72
|
+
gem 'kramdown', '~> 0.14.2'
|
67
73
|
end
|
data/Rakefile
CHANGED
data/config/flay.yml
ADDED
data/config/flog.yml
ADDED
data/config/roodi.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
AbcMetricMethodCheck: { score: 8.0 }
|
3
|
+
AssignmentInConditionalCheck: { }
|
4
|
+
CaseMissingElseCheck: { }
|
5
|
+
ClassLineCountCheck: { line_count: 221 }
|
6
|
+
ClassNameCheck: { pattern: !ruby/regexp '/\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/' }
|
7
|
+
ClassVariableCheck: { }
|
8
|
+
CyclomaticComplexityBlockCheck: { complexity: 3 }
|
9
|
+
CyclomaticComplexityMethodCheck: { complexity: 3 }
|
10
|
+
EmptyRescueBodyCheck: { }
|
11
|
+
ForLoopCheck: { }
|
12
|
+
MethodLineCountCheck: { line_count: 9 }
|
13
|
+
MethodNameCheck: { pattern: !ruby/regexp '/\A(?:[a-z\d](?:_?[a-z\d])+[?!=]?|\[\]=?|==|<=>|<<|[+*&|-])\z/' }
|
14
|
+
ModuleLineCountCheck: { line_count: 225 }
|
15
|
+
ModuleNameCheck: { pattern: !ruby/regexp '/\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/' }
|
16
|
+
ParameterNumberCheck: { parameter_count: 3 }
|
data/config/site.reek
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
---
|
2
|
+
UncommunicativeParameterName:
|
3
|
+
accept: []
|
4
|
+
exclude: []
|
5
|
+
enabled: true
|
6
|
+
reject:
|
7
|
+
- !ruby/regexp /^.$/
|
8
|
+
- !ruby/regexp /[0-9]$/
|
9
|
+
- !ruby/regexp /[A-Z]/
|
10
|
+
LargeClass:
|
11
|
+
max_methods: 0
|
12
|
+
exclude: []
|
13
|
+
enabled: true
|
14
|
+
max_instance_variables: 0
|
15
|
+
UncommunicativeMethodName:
|
16
|
+
accept: []
|
17
|
+
exclude: []
|
18
|
+
enabled: true
|
19
|
+
reject:
|
20
|
+
- !ruby/regexp /^[a-z]$/
|
21
|
+
- !ruby/regexp /[0-9]$/
|
22
|
+
- !ruby/regexp /[A-Z]/
|
23
|
+
LongParameterList:
|
24
|
+
max_params: 0
|
25
|
+
exclude: []
|
26
|
+
enabled: true
|
27
|
+
overrides: {}
|
28
|
+
FeatureEnvy:
|
29
|
+
exclude: []
|
30
|
+
enabled: true
|
31
|
+
ClassVariable:
|
32
|
+
exclude: []
|
33
|
+
enabled: true
|
34
|
+
BooleanParameter:
|
35
|
+
exclude: []
|
36
|
+
enabled: true
|
37
|
+
IrresponsibleModule:
|
38
|
+
exclude: []
|
39
|
+
enabled: false
|
40
|
+
UncommunicativeModuleName:
|
41
|
+
accept: []
|
42
|
+
exclude: []
|
43
|
+
enabled: true
|
44
|
+
reject:
|
45
|
+
- !ruby/regexp /^.$/
|
46
|
+
- !ruby/regexp /[0-9]$/
|
47
|
+
NestedIterators:
|
48
|
+
ignore_iterators: []
|
49
|
+
exclude: []
|
50
|
+
enabled: true
|
51
|
+
max_allowed_nesting: 0
|
52
|
+
LongMethod:
|
53
|
+
max_statements: 1
|
54
|
+
exclude: []
|
55
|
+
enabled: true
|
56
|
+
Duplication:
|
57
|
+
allow_calls: []
|
58
|
+
exclude: []
|
59
|
+
enabled: true
|
60
|
+
max_calls: 1
|
61
|
+
UtilityFunction:
|
62
|
+
max_helper_calls: 1
|
63
|
+
exclude: []
|
64
|
+
enabled: true
|
65
|
+
Attribute:
|
66
|
+
exclude: []
|
67
|
+
enabled: false
|
68
|
+
UncommunicativeVariableName:
|
69
|
+
accept: []
|
70
|
+
exclude: []
|
71
|
+
enabled: true
|
72
|
+
reject:
|
73
|
+
- !ruby/regexp /^.$/
|
74
|
+
- !ruby/regexp /[0-9]$/
|
75
|
+
- !ruby/regexp /[A-Z]/
|
76
|
+
SimulatedPolymorphism:
|
77
|
+
exclude: []
|
78
|
+
enabled: true
|
79
|
+
max_ifs: 1
|
80
|
+
DataClump:
|
81
|
+
exclude: []
|
82
|
+
enabled: true
|
83
|
+
max_copies: 1
|
84
|
+
min_clump_size: 1
|
85
|
+
ControlCouple:
|
86
|
+
exclude: []
|
87
|
+
enabled: true
|
88
|
+
LongYieldList:
|
89
|
+
max_params: 1
|
90
|
+
exclude: []
|
91
|
+
enabled: true
|
data/lib/yardstick/cli.rb
CHANGED
data/lib/yardstick/measurable.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Yardstick
|
2
4
|
|
3
5
|
# A measurement given a constraint on the docs
|
@@ -14,6 +16,14 @@ module Yardstick
|
|
14
16
|
# @api public
|
15
17
|
attr_reader :description
|
16
18
|
|
19
|
+
# Return the method docstring
|
20
|
+
#
|
21
|
+
# @return [YARD::Docstring]
|
22
|
+
#
|
23
|
+
# @api private
|
24
|
+
attr_reader :docstring
|
25
|
+
protected :docstring
|
26
|
+
|
17
27
|
# Return a Measurement instance
|
18
28
|
#
|
19
29
|
# @example
|
@@ -99,7 +109,7 @@ module Yardstick
|
|
99
109
|
# @api public
|
100
110
|
def puts(io = $stdout)
|
101
111
|
unless ok?
|
102
|
-
io.puts("#{file}:#{line}: #{path}: #{
|
112
|
+
io.puts("#{file}:#{line}: #{path}: #{description}")
|
103
113
|
end
|
104
114
|
end
|
105
115
|
|
@@ -116,8 +126,9 @@ module Yardstick
|
|
116
126
|
#
|
117
127
|
# @api semipublic
|
118
128
|
def eql?(other)
|
119
|
-
|
120
|
-
|
129
|
+
other.kind_of?(self.class) &&
|
130
|
+
description.eql?(other.description) &&
|
131
|
+
docstring.eql?(other.docstring)
|
121
132
|
end
|
122
133
|
|
123
134
|
# Return hash identifier for the Measurement
|
@@ -127,7 +138,7 @@ module Yardstick
|
|
127
138
|
#
|
128
139
|
# @api private
|
129
140
|
def hash
|
130
|
-
|
141
|
+
description.hash ^ docstring.hash
|
131
142
|
end
|
132
143
|
|
133
144
|
private
|
@@ -142,7 +153,7 @@ module Yardstick
|
|
142
153
|
# @api private
|
143
154
|
def measure
|
144
155
|
catch :measurement do
|
145
|
-
|
156
|
+
docstring.instance_eval(&@block)
|
146
157
|
end
|
147
158
|
end
|
148
159
|
|
@@ -153,7 +164,7 @@ module Yardstick
|
|
153
164
|
#
|
154
165
|
# @api private
|
155
166
|
def object
|
156
|
-
|
167
|
+
docstring.object
|
157
168
|
end
|
158
169
|
|
159
170
|
# The filename for the code
|
@@ -214,6 +225,5 @@ module Yardstick
|
|
214
225
|
end
|
215
226
|
|
216
227
|
end # module UtilityMethods
|
217
|
-
|
218
228
|
end # class Measurement
|
219
229
|
end # module Yardstick
|
data/lib/yardstick/method.rb
CHANGED
data/lib/yardstick/processor.rb
CHANGED
data/lib/yardstick/rule.rb
CHANGED
data/lib/yardstick/rule_set.rb
CHANGED
data/lib/yardstick/version.rb
CHANGED
data/lib/yardstick/yard_ext.rb
CHANGED
data/lib/yardstick.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if ENV['COVERAGE'] == 'true'
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
11
|
+
|
12
|
+
SimpleCov.start do
|
13
|
+
command_name 'spec:unit'
|
14
|
+
add_filter 'config'
|
15
|
+
add_filter 'spec'
|
16
|
+
minimum_coverage 100
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
1
20
|
require 'yardstick'
|
2
21
|
require 'spec'
|
3
|
-
require 'spec/autorun'
|
22
|
+
require 'spec/autorun' if RUBY_VERSION < '1.9'
|
23
|
+
|
24
|
+
# require spec support files and shared behavior
|
25
|
+
Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each do |file|
|
26
|
+
require file
|
27
|
+
end
|
4
28
|
|
5
29
|
Spec::Runner.configure do |config|
|
6
30
|
clear_tasks = proc { Rake::Task.clear }
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
desc 'Run metrics with Heckle'
|
4
|
+
task :ci => %w[ ci:metrics metrics:heckle ]
|
5
|
+
|
6
|
+
namespace :ci do
|
7
|
+
desc 'Run metrics (except heckle) and spec'
|
8
|
+
task :metrics => %w[ spec metrics:verify_measurements metrics:flog metrics:flay metrics:reek metrics:roodi metrics:all ]
|
9
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
PLATFORM = defined?(RUBY_ENGINE) && RUBY_ENGINE || 'ruby'
|
4
|
+
|
5
|
+
namespace :metrics do
|
6
|
+
if RUBY_VERSION >= '1.9.3' && PLATFORM == 'ruby'
|
7
|
+
begin
|
8
|
+
require 'flay'
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
config = YAML.load_file(File.expand_path('../../../config/flay.yml', __FILE__)).freeze
|
12
|
+
threshold = config.fetch('threshold').to_i
|
13
|
+
total_score = config.fetch('total_score').to_f
|
14
|
+
files = Flay.expand_dirs_to_files(config.fetch('path', 'lib')).sort
|
15
|
+
|
16
|
+
# original code by Marty Andrews:
|
17
|
+
# http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
|
18
|
+
desc 'Analyze for code duplication'
|
19
|
+
task :flay do
|
20
|
+
# run flay once without a threshold to ensure the max mass matches the threshold
|
21
|
+
flay = Flay.new(:fuzzy => false, :verbose => false, :mass => 0)
|
22
|
+
flay.process(*files)
|
23
|
+
|
24
|
+
max = (flay.masses.map { |hash, mass| mass.to_f / flay.hashes[hash].size }.max) || 0
|
25
|
+
unless max >= threshold
|
26
|
+
raise "Adjust flay threshold down to #{max}"
|
27
|
+
end
|
28
|
+
|
29
|
+
total = flay.masses.reduce(0.0) { |total, (hash, mass)| total + (mass.to_f / flay.hashes[hash].size) }
|
30
|
+
unless total == total_score
|
31
|
+
raise "Flay total is now #{total}, but expected #{total_score}"
|
32
|
+
end
|
33
|
+
|
34
|
+
# run flay a second time with the threshold set
|
35
|
+
flay = Flay.new(:fuzzy => false, :verbose => false, :mass => threshold.succ)
|
36
|
+
flay.process(*files)
|
37
|
+
|
38
|
+
if flay.masses.any?
|
39
|
+
flay.report
|
40
|
+
raise "#{flay.masses.size} chunks of code have a duplicate mass > #{threshold}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
rescue LoadError
|
44
|
+
task :flay do
|
45
|
+
$stderr.puts 'Flay is not available. In order to run flay, you must: gem install flay'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
else
|
49
|
+
task :flay do
|
50
|
+
$stderr.puts "Flay is disabled under #{PLATFORM}-#{RUBY_VERSION} since it is not score compatible with other implementations"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :metrics do
|
4
|
+
begin
|
5
|
+
require 'backports'
|
6
|
+
require 'flog'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
config = YAML.load_file(File.expand_path('../../../config/flog.yml', __FILE__)).freeze
|
10
|
+
threshold = config.fetch('threshold').to_f.round(1)
|
11
|
+
|
12
|
+
# original code by Marty Andrews:
|
13
|
+
# http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
|
14
|
+
desc 'Analyze for code complexity'
|
15
|
+
task :flog do
|
16
|
+
flog = Flog.new
|
17
|
+
flog.flog Array(config.fetch('path', 'lib'))
|
18
|
+
|
19
|
+
totals = flog.totals.select { |name, score| name[-5, 5] != '#none' }.
|
20
|
+
map { |name, score| [ name, score.round(1) ] }.
|
21
|
+
sort_by { |name, score| score }
|
22
|
+
|
23
|
+
if totals.any?
|
24
|
+
max = totals.last[1]
|
25
|
+
unless max >= threshold
|
26
|
+
raise "Adjust flog score down to #{max}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
bad_methods = totals.select { |name, score| score > threshold }
|
31
|
+
if bad_methods.any?
|
32
|
+
bad_methods.reverse_each do |name, score|
|
33
|
+
puts '%8.1f: %s' % [ score, name ]
|
34
|
+
end
|
35
|
+
|
36
|
+
raise "#{bad_methods.size} methods have a flog complexity > #{threshold}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
rescue LoadError
|
40
|
+
task :flog do
|
41
|
+
$stderr.puts 'Flog is not available. In order to run flog, you must: gem install flog'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# original code by Ashley Moran:
|
2
2
|
# http://aviewfromafar.net/2007/11/1/rake-task-for-heckling-your-specs
|
3
3
|
desc 'Heckle each module and class'
|
4
|
-
task :heckle => :
|
4
|
+
task 'metrics:heckle' => 'metrics:coverage' do
|
5
5
|
root_module = 'Yardstick'
|
6
|
-
spec_files = FileList['spec/**/*_spec.rb']
|
6
|
+
spec_files = FileList['spec/uni/**/*_spec.rb']
|
7
7
|
|
8
8
|
current_module = nil
|
9
9
|
current_method = nil
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'metric_fu'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
# XXX: temporary hack until metric_fu is fixed
|
8
|
+
MetricFu::Saikuro.class_eval { include FileUtils }
|
9
|
+
|
10
|
+
MetricFu::Configuration.run do |config|
|
11
|
+
config.rcov = {
|
12
|
+
:environment => 'test',
|
13
|
+
:test_files => %w[ spec/**/*_spec.rb ],
|
14
|
+
:rcov_opts => %w[
|
15
|
+
--sort coverage
|
16
|
+
--no-html
|
17
|
+
--text-coverage
|
18
|
+
--no-color
|
19
|
+
--profile
|
20
|
+
--exclude spec/,^/
|
21
|
+
--include lib:spec
|
22
|
+
],
|
23
|
+
}
|
24
|
+
end
|
25
|
+
rescue LoadError
|
26
|
+
namespace :metrics do
|
27
|
+
task :all do
|
28
|
+
$stderr.puts 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :metrics do
|
4
|
+
begin
|
5
|
+
require 'reek/rake/task'
|
6
|
+
|
7
|
+
RBX_18_MODE = RUBY_VERSION < '1.9' && defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
8
|
+
|
9
|
+
Reek::Rake::Task.new do |t|
|
10
|
+
# reek has some problems under rbx in 1.8 mode that cause the underlying
|
11
|
+
# script to raise an exception. Rather than halt the "rake ci" process due
|
12
|
+
# to one bug, we choose to ignore it in this specific case until reek can be
|
13
|
+
# fixed.
|
14
|
+
t.fail_on_error = ! RBX_18_MODE # always true, except under rbx 18 mode
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
task :reek do
|
18
|
+
$stderr.puts 'Reek is not available. In order to run reek, you must: gem install reek'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :metrics do
|
4
|
+
begin
|
5
|
+
require 'roodi'
|
6
|
+
require 'rake/tasklib'
|
7
|
+
require 'roodi_task'
|
8
|
+
|
9
|
+
RoodiTask.new do |t|
|
10
|
+
t.verbose = false
|
11
|
+
t.config = File.expand_path('../../../config/roodi.yml', __FILE__)
|
12
|
+
t.patterns = %w[ lib/**/*.rb ]
|
13
|
+
end
|
14
|
+
rescue LoadError
|
15
|
+
task :roodi do
|
16
|
+
$stderr.puts 'Roodi is not available. In order to run roodi, you must: gem install roodi'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :metrics do
|
4
|
+
begin
|
5
|
+
$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
|
6
|
+
|
7
|
+
require 'yardstick/rake/measurement'
|
8
|
+
require 'yardstick/rake/verify'
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
config = YAML.load_file(File.expand_path('../../../config/yardstick.yml', __FILE__))
|
12
|
+
|
13
|
+
# yardstick_measure task
|
14
|
+
Yardstick::Rake::Measurement.new
|
15
|
+
|
16
|
+
# verify_measurements task
|
17
|
+
Yardstick::Rake::Verify.new do |verify|
|
18
|
+
verify.threshold = config.fetch('threshold')
|
19
|
+
end
|
20
|
+
rescue LoadError
|
21
|
+
%w[ yardstick_measure verify_measurements ].each do |name|
|
22
|
+
task name.to_s do
|
23
|
+
$stderr.puts "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/tasks/spec.rake
CHANGED
@@ -1,22 +1,64 @@
|
|
1
|
-
|
2
|
-
require 'spec/rake/verify_rcov'
|
1
|
+
# encoding: utf-8
|
3
2
|
|
4
3
|
spec_defaults = lambda do |spec|
|
5
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
6
4
|
spec.ruby_opts = %w[ -r./spec/support/config_alias ]
|
7
5
|
spec.spec_opts << '--options' << 'spec/spec.opts'
|
8
6
|
end
|
9
7
|
|
10
|
-
|
8
|
+
begin
|
9
|
+
require 'spec/rake/spectask'
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
desc 'Run all specs'
|
12
|
+
task :spec => %w[ spec:unit spec:integration ]
|
13
|
+
|
14
|
+
namespace :spec do
|
15
|
+
desc 'Run unit specs'
|
16
|
+
Spec::Rake::SpecTask.new(:unit) do |unit|
|
17
|
+
spec_defaults.call(unit)
|
18
|
+
unit.pattern = 'spec/unit/**/*_spec.rb'
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Run integration specs'
|
22
|
+
Spec::Rake::SpecTask.new(:integration) do |integration|
|
23
|
+
spec_defaults.call(integration)
|
24
|
+
integration.pattern = 'spec/integration/**/*_spec.rb'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
rescue LoadError
|
28
|
+
%w[ spec spec:unit spec:integration ].each do |name|
|
29
|
+
task name do
|
30
|
+
$stderr.puts "rspec is not available. In order to run #{name}, you must: gem install rspec"
|
31
|
+
end
|
32
|
+
end
|
16
33
|
end
|
17
34
|
|
18
|
-
|
19
|
-
|
35
|
+
namespace :metrics do
|
36
|
+
lib = RUBY_VERSION < '1.9' ? 'rcov' : 'simplecov'
|
37
|
+
begin
|
38
|
+
require lib
|
39
|
+
|
40
|
+
if lib == 'rcov'
|
41
|
+
require 'spec/rake/spectask'
|
42
|
+
|
43
|
+
desc 'Generate code coverage'
|
44
|
+
Spec::Rake::SpecTask.new(:coverage) do |rcov|
|
45
|
+
spec_defaults.call(rcov)
|
46
|
+
rcov.rcov = true
|
47
|
+
rcov.pattern = 'spec/unit/**/*_spec.rb'
|
48
|
+
rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
|
49
|
+
end
|
50
|
+
else
|
51
|
+
desc 'Generate code coverage'
|
52
|
+
task :coverage do
|
53
|
+
ENV['COVERAGE'] = 'true'
|
54
|
+
Rake::Task['spec:unit'].execute
|
55
|
+
end
|
56
|
+
end
|
57
|
+
rescue LoadError
|
58
|
+
task :coverage do
|
59
|
+
$stderr.puts "coverage is not available. In order to run #{lib}, you must: gem install #{lib}"
|
60
|
+
end
|
61
|
+
end
|
20
62
|
end
|
21
63
|
|
22
|
-
task :
|
64
|
+
task :test => :spec
|
data/tasks/yard.rake
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
begin
|
2
4
|
require 'yard'
|
3
5
|
|
4
6
|
YARD::Rake::YardocTask.new
|
5
7
|
rescue LoadError
|
6
8
|
task :yard do
|
7
|
-
|
9
|
+
$stderr.puts 'YARD is not available. In order to run yard, you must: gem install yard'
|
8
10
|
end
|
9
11
|
end
|
data/yardstick.gemspec
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'yardstick/version'
|
4
7
|
|
5
8
|
Gem::Specification.new do |gem|
|
6
9
|
gem.name = 'yardstick'
|
7
|
-
gem.version = Yardstick::VERSION
|
10
|
+
gem.version = Yardstick::VERSION
|
8
11
|
gem.authors = ['Dan Kubb']
|
9
12
|
gem.email = %w[dan.kubb@gmail.com]
|
10
13
|
gem.description = 'Measure YARD documentation coverage'
|
11
14
|
gem.summary = 'A tool for verifying YARD documentation coverage'
|
12
15
|
gem.homepage = 'https://github.com/dkubb/yardstick'
|
16
|
+
gem.licenses = ['MIT']
|
13
17
|
|
14
18
|
gem.require_paths = %w[lib]
|
15
19
|
gem.files = `git ls-files`.split($/)
|
@@ -17,9 +21,8 @@ Gem::Specification.new do |gem|
|
|
17
21
|
gem.extra_rdoc_files = %w[LICENSE README.rdoc]
|
18
22
|
gem.executables = %w[yardstick]
|
19
23
|
|
20
|
-
gem.
|
21
|
-
gem.
|
24
|
+
gem.add_dependency 'backports', ['~> 3.0', '>= 3.0.3']
|
25
|
+
gem.add_dependency 'yard', '~> 0.8.5'
|
22
26
|
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.add_development_dependency('rspec', '~> 1.3.2')
|
27
|
+
gem.add_development_dependency 'bundler', '~> 1.0'
|
25
28
|
end
|
metadata
CHANGED
@@ -1,98 +1,80 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: yardstick
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.3
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 9
|
9
|
-
- 2
|
10
|
-
version: 0.9.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Dan Kubb
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: backports
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
- 2
|
33
|
-
version: 2.8.2
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.0.3
|
34
25
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: yard
|
38
26
|
prerelease: false
|
39
|
-
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.0.3
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: yard
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
|
-
requirements:
|
40
|
+
requirements:
|
42
41
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
- 8
|
48
|
-
- 4
|
49
|
-
- 1
|
50
|
-
version: 0.8.4.1
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.8.5
|
51
44
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: rake
|
55
45
|
prerelease: false
|
56
|
-
|
46
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ~>
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 0.8.5
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: bundler
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
57
55
|
none: false
|
58
|
-
requirements:
|
56
|
+
requirements:
|
59
57
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
segments:
|
63
|
-
- 10
|
64
|
-
- 0
|
65
|
-
- 3
|
66
|
-
version: 10.0.3
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.0'
|
67
60
|
type: :development
|
68
|
-
version_requirements: *id003
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
61
|
prerelease: false
|
72
|
-
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
63
|
none: false
|
74
|
-
requirements:
|
64
|
+
requirements:
|
75
65
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
segments:
|
79
|
-
- 1
|
80
|
-
- 3
|
81
|
-
- 2
|
82
|
-
version: 1.3.2
|
83
|
-
type: :development
|
84
|
-
version_requirements: *id004
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.0'
|
85
68
|
description: Measure YARD documentation coverage
|
86
|
-
email:
|
69
|
+
email:
|
87
70
|
- dan.kubb@gmail.com
|
88
|
-
executables:
|
71
|
+
executables:
|
89
72
|
- yardstick
|
90
73
|
extensions: []
|
91
|
-
|
92
|
-
extra_rdoc_files:
|
74
|
+
extra_rdoc_files:
|
93
75
|
- LICENSE
|
94
76
|
- README.rdoc
|
95
|
-
files:
|
77
|
+
files:
|
96
78
|
- .document
|
97
79
|
- .gitignore
|
98
80
|
- .rvmrc
|
@@ -102,6 +84,11 @@ files:
|
|
102
84
|
- README.rdoc
|
103
85
|
- Rakefile
|
104
86
|
- bin/yardstick
|
87
|
+
- config/flay.yml
|
88
|
+
- config/flog.yml
|
89
|
+
- config/roodi.yml
|
90
|
+
- config/site.reek
|
91
|
+
- config/yardstick.yml
|
105
92
|
- lib/yardstick.rb
|
106
93
|
- lib/yardstick/cli.rb
|
107
94
|
- lib/yardstick/measurable.rb
|
@@ -116,65 +103,53 @@ files:
|
|
116
103
|
- lib/yardstick/rule_set.rb
|
117
104
|
- lib/yardstick/version.rb
|
118
105
|
- lib/yardstick/yard_ext.rb
|
119
|
-
- spec/public/yardstick/cli_spec.rb
|
120
|
-
- spec/public/yardstick/measurement_set_spec.rb
|
121
|
-
- spec/public/yardstick/measurement_spec.rb
|
122
|
-
- spec/public/yardstick/method_spec.rb
|
123
|
-
- spec/public/yardstick/rake/measurement_spec.rb
|
124
|
-
- spec/public/yardstick/rake/verify_spec.rb
|
125
|
-
- spec/public/yardstick_spec.rb
|
126
106
|
- spec/rcov.opts
|
127
|
-
- spec/semipublic/yardstick/rule_spec.rb
|
128
107
|
- spec/spec.opts
|
129
108
|
- spec/spec_helper.rb
|
130
109
|
- spec/support/config_alias.rb
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
110
|
+
- spec/unit/yardstick/cli_spec.rb
|
111
|
+
- spec/unit/yardstick/measurement_set_spec.rb
|
112
|
+
- spec/unit/yardstick/measurement_spec.rb
|
113
|
+
- spec/unit/yardstick/method_spec.rb
|
114
|
+
- spec/unit/yardstick/rake/measurement_spec.rb
|
115
|
+
- spec/unit/yardstick/rake/verify_spec.rb
|
116
|
+
- spec/unit/yardstick/rule_spec.rb
|
117
|
+
- spec/unit/yardstick_spec.rb
|
118
|
+
- tasks/metrics/ci.rake
|
119
|
+
- tasks/metrics/flay.rake
|
120
|
+
- tasks/metrics/flog.rake
|
121
|
+
- tasks/metrics/heckle.rake
|
122
|
+
- tasks/metrics/metric_fu.rake
|
123
|
+
- tasks/metrics/reek.rake
|
124
|
+
- tasks/metrics/roodi.rake
|
125
|
+
- tasks/metrics/yardstick.rake
|
134
126
|
- tasks/spec.rake
|
135
127
|
- tasks/yard.rake
|
136
|
-
- tasks/yardstick.rake
|
137
128
|
- yardstick.gemspec
|
138
129
|
homepage: https://github.com/dkubb/yardstick
|
139
|
-
licenses:
|
140
|
-
|
130
|
+
licenses:
|
131
|
+
- MIT
|
141
132
|
post_install_message:
|
142
133
|
rdoc_options: []
|
143
|
-
|
144
|
-
require_paths:
|
134
|
+
require_paths:
|
145
135
|
- lib
|
146
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
137
|
none: false
|
148
|
-
requirements:
|
149
|
-
- -
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
|
152
|
-
|
153
|
-
- 0
|
154
|
-
version: "0"
|
155
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
143
|
none: false
|
157
|
-
requirements:
|
158
|
-
- -
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
|
161
|
-
segments:
|
162
|
-
- 0
|
163
|
-
version: "0"
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
164
148
|
requirements: []
|
165
|
-
|
166
149
|
rubyforge_project:
|
167
|
-
rubygems_version: 1.8.
|
150
|
+
rubygems_version: 1.8.23
|
168
151
|
signing_key:
|
169
152
|
specification_version: 3
|
170
153
|
summary: A tool for verifying YARD documentation coverage
|
171
|
-
test_files:
|
172
|
-
- spec/public/yardstick/cli_spec.rb
|
173
|
-
- spec/public/yardstick/measurement_set_spec.rb
|
174
|
-
- spec/public/yardstick/measurement_spec.rb
|
175
|
-
- spec/public/yardstick/method_spec.rb
|
176
|
-
- spec/public/yardstick/rake/measurement_spec.rb
|
177
|
-
- spec/public/yardstick/rake/verify_spec.rb
|
178
|
-
- spec/public/yardstick_spec.rb
|
179
|
-
- spec/semipublic/yardstick/rule_spec.rb
|
154
|
+
test_files: []
|
180
155
|
has_rdoc:
|
data/tasks/ci.rake
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
task :ci => [ :verify_measurements, :heckle, 'metrics:all' ]
|
data/tasks/metrics.rake
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'metric_fu'
|
3
|
-
rescue LoadError
|
4
|
-
namespace :metrics do
|
5
|
-
task :all do
|
6
|
-
abort 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
begin
|
12
|
-
require 'reek/adapters/rake_task'
|
13
|
-
|
14
|
-
Reek::RakeTask.new do |t|
|
15
|
-
t.fail_on_error = true
|
16
|
-
t.verbose = false
|
17
|
-
t.source_files = 'lib/**/*.rb'
|
18
|
-
end
|
19
|
-
rescue LoadError
|
20
|
-
task :reek do
|
21
|
-
abort 'Reek is not available. In order to run reek, you must: gem install reek'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
begin
|
26
|
-
require 'roodi'
|
27
|
-
require 'rake/tasklib'
|
28
|
-
require 'roodi_task'
|
29
|
-
|
30
|
-
RoodiTask.new do |t|
|
31
|
-
t.verbose = false
|
32
|
-
end
|
33
|
-
rescue LoadError
|
34
|
-
task :roodi do
|
35
|
-
abort 'Roodi is not available. In order to run roodi, you must: gem install roodi'
|
36
|
-
end
|
37
|
-
end
|
data/tasks/yardstick.rake
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
2
|
-
|
3
|
-
require 'yardstick/rake/measurement'
|
4
|
-
require 'yardstick/rake/verify'
|
5
|
-
|
6
|
-
# yardstick_measure task
|
7
|
-
Yardstick::Rake::Measurement.new
|
8
|
-
|
9
|
-
# verify_measurements task
|
10
|
-
Yardstick::Rake::Verify.new do |verify|
|
11
|
-
verify.threshold = 100
|
12
|
-
end
|