metric_fu-Saikuro 1.1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README +52 -54
- data/lib/saikuro.rb +21 -1082
- data/lib/saikuro/base_formatter.rb +30 -0
- data/lib/saikuro/endable_parse_state.rb +12 -0
- data/lib/saikuro/filter.rb +22 -0
- data/lib/saikuro/html_stylesheet.rb +82 -0
- data/lib/saikuro/html_token_counter_formatter.rb +45 -0
- data/lib/saikuro/parse_block.rb +33 -0
- data/lib/saikuro/parse_class.rb +27 -0
- data/lib/saikuro/parse_comment.rb +15 -0
- data/lib/saikuro/parse_cond.rb +6 -0
- data/lib/saikuro/parse_def.rb +59 -0
- data/lib/saikuro/parse_do_cond.rb +24 -0
- data/lib/saikuro/parse_module.rb +6 -0
- data/lib/saikuro/parse_state.rb +286 -0
- data/lib/saikuro/parse_state_formatter.rb +27 -0
- data/lib/saikuro/parse_symbol.rb +13 -0
- data/lib/saikuro/result_index_generator.rb +87 -0
- data/lib/saikuro/saikuro_cmd_line_runner.rb +166 -0
- data/lib/saikuro/state_html_complexity_formatter.rb +38 -0
- data/lib/saikuro/token_counter.rb +51 -0
- data/lib/saikuro/token_counter_formatter.rb +35 -0
- data/lib/saikuro/usage.rb +0 -37
- data/lib/saikuro/version.rb +1 -1
- metadata +35 -24
- data/tests/large_example.rb +0 -70
- data/tests/samples.rb +0 -315
data/lib/saikuro/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metric_fu-Saikuro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Zev Blut
|
@@ -10,12 +9,14 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
|
-
description:
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
description: |-
|
15
|
+
When given Ruby
|
16
|
+
source code Saikuro will generate a report listing the cyclomatic
|
17
|
+
complexity of each method found. In addition, Saikuro counts the
|
18
|
+
number of lines per method and can generate a listing of the number of
|
19
|
+
tokens on each line of code.
|
19
20
|
email:
|
20
21
|
- zb@ubit.com
|
21
22
|
- japgolly@gmail.com
|
@@ -26,43 +27,53 @@ extra_rdoc_files:
|
|
26
27
|
- README
|
27
28
|
files:
|
28
29
|
- bin/saikuro
|
30
|
+
- lib/saikuro/base_formatter.rb
|
31
|
+
- lib/saikuro/endable_parse_state.rb
|
32
|
+
- lib/saikuro/filter.rb
|
33
|
+
- lib/saikuro/html_stylesheet.rb
|
34
|
+
- lib/saikuro/html_token_counter_formatter.rb
|
35
|
+
- lib/saikuro/parse_block.rb
|
36
|
+
- lib/saikuro/parse_class.rb
|
37
|
+
- lib/saikuro/parse_comment.rb
|
38
|
+
- lib/saikuro/parse_cond.rb
|
39
|
+
- lib/saikuro/parse_def.rb
|
40
|
+
- lib/saikuro/parse_do_cond.rb
|
41
|
+
- lib/saikuro/parse_module.rb
|
42
|
+
- lib/saikuro/parse_state.rb
|
43
|
+
- lib/saikuro/parse_state_formatter.rb
|
44
|
+
- lib/saikuro/parse_symbol.rb
|
45
|
+
- lib/saikuro/result_index_generator.rb
|
46
|
+
- lib/saikuro/saikuro_cmd_line_runner.rb
|
47
|
+
- lib/saikuro/state_html_complexity_formatter.rb
|
48
|
+
- lib/saikuro/token_counter.rb
|
49
|
+
- lib/saikuro/token_counter_formatter.rb
|
29
50
|
- lib/saikuro/usage.rb
|
30
51
|
- lib/saikuro/version.rb
|
31
52
|
- lib/saikuro.rb
|
32
53
|
- README
|
33
|
-
- tests/large_example.rb
|
34
|
-
- tests/samples.rb
|
35
54
|
homepage: https://github.com/metricfu/Saikuro
|
36
55
|
licenses:
|
37
56
|
- BSD
|
57
|
+
metadata: {}
|
38
58
|
post_install_message:
|
39
59
|
rdoc_options: []
|
40
60
|
require_paths:
|
41
61
|
- lib
|
42
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
63
|
requirements:
|
45
|
-
- -
|
64
|
+
- - '>='
|
46
65
|
- !ruby/object:Gem::Version
|
47
66
|
version: '0'
|
48
|
-
segments:
|
49
|
-
- 0
|
50
|
-
hash: -4041480192229165443
|
51
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
68
|
requirements:
|
54
|
-
- -
|
69
|
+
- - '>='
|
55
70
|
- !ruby/object:Gem::Version
|
56
71
|
version: '0'
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
hash: -4041480192229165443
|
60
72
|
requirements: []
|
61
73
|
rubyforge_project: Saikuro
|
62
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 2.1.11
|
63
75
|
signing_key:
|
64
|
-
specification_version:
|
76
|
+
specification_version: 4
|
65
77
|
summary: Saikuro is a Ruby cyclomatic complexity analyzer.
|
66
|
-
test_files:
|
67
|
-
|
68
|
-
- tests/samples.rb
|
78
|
+
test_files: []
|
79
|
+
has_rdoc: true
|
data/tests/large_example.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
# These are methods to show warning and errors
|
2
|
-
# The code is nonsense it is used to make large complexity values.
|
3
|
-
|
4
|
-
class ExtraTests
|
5
|
-
|
6
|
-
# CC 8
|
7
|
-
def warn_method_cc8(a, b, c)
|
8
|
-
q, r, s = nil
|
9
|
-
if a
|
10
|
-
q = a + c
|
11
|
-
end
|
12
|
-
if b
|
13
|
-
b = r - q
|
14
|
-
end
|
15
|
-
if !c
|
16
|
-
s = r + b
|
17
|
-
end
|
18
|
-
if b > q || c
|
19
|
-
a = c + q
|
20
|
-
end
|
21
|
-
if a
|
22
|
-
c = b
|
23
|
-
end
|
24
|
-
if c
|
25
|
-
b = a
|
26
|
-
end
|
27
|
-
if s
|
28
|
-
c = s + a
|
29
|
-
end
|
30
|
-
# large token count
|
31
|
-
a + b + c + q + r + s + a + b + c + q + r + s + a + b + c + q + r + s + a + b + c + q + r + s
|
32
|
-
end
|
33
|
-
|
34
|
-
# CC 11
|
35
|
-
def error_method_cc11(a, b, c)
|
36
|
-
q, r, s = nil
|
37
|
-
if a
|
38
|
-
q = a + c
|
39
|
-
end
|
40
|
-
if b
|
41
|
-
b = r - q
|
42
|
-
end
|
43
|
-
if !c
|
44
|
-
s = r + b
|
45
|
-
end
|
46
|
-
if b > q || c
|
47
|
-
a = c + q
|
48
|
-
end
|
49
|
-
if a
|
50
|
-
c = b
|
51
|
-
end
|
52
|
-
if c
|
53
|
-
b = a
|
54
|
-
end
|
55
|
-
if s
|
56
|
-
c = s + a
|
57
|
-
end
|
58
|
-
if q
|
59
|
-
r = s + q
|
60
|
-
end
|
61
|
-
if r
|
62
|
-
s = a + r
|
63
|
-
end
|
64
|
-
a + b + c + q + r + s + a + b + c + q + r + s
|
65
|
-
rescue => err
|
66
|
-
puts err
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
end
|
data/tests/samples.rb
DELETED
@@ -1,315 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# CC : 1
|
4
|
-
def cc1
|
5
|
-
"hello"
|
6
|
-
end
|
7
|
-
|
8
|
-
class CylcoIfTestClass
|
9
|
-
|
10
|
-
# CC 2
|
11
|
-
def cc2(arg)
|
12
|
-
# Comment inside method
|
13
|
-
if arg
|
14
|
-
"True Arg"
|
15
|
-
else
|
16
|
-
"False Arg"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# CC 3
|
21
|
-
def cc3(arg1 = true, arg2 = false)
|
22
|
-
if arg1
|
23
|
-
"ARG1"
|
24
|
-
elsif arg2
|
25
|
-
"ARG2"
|
26
|
-
else
|
27
|
-
"Neither ARG1 or ARG2"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Also CC 3
|
32
|
-
def cc3_2(arg1 = true, arg2 = false)
|
33
|
-
if arg1
|
34
|
-
if arg2
|
35
|
-
"ARG1 and ARG2"
|
36
|
-
else
|
37
|
-
"ARG1"
|
38
|
-
end
|
39
|
-
else
|
40
|
-
"No ARG1"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
def cc2_2(arg)
|
46
|
-
v = "not arg"
|
47
|
-
v = "arg" if arg
|
48
|
-
v
|
49
|
-
end
|
50
|
-
|
51
|
-
def cc2_2(arg)
|
52
|
-
if arg then
|
53
|
-
"True Arg"
|
54
|
-
else
|
55
|
-
"False Arg"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def cc2_ternary(arg)
|
60
|
-
arg ? "True" : "False"
|
61
|
-
end
|
62
|
-
|
63
|
-
def cc1?(arg)
|
64
|
-
cc2?
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
class CycloException < StandardError; end
|
70
|
-
|
71
|
-
class CycloUnlessTestClass
|
72
|
-
|
73
|
-
def cc2(arg = true)
|
74
|
-
v = "cc2"
|
75
|
-
unless arg
|
76
|
-
arg = false
|
77
|
-
v = "unless"
|
78
|
-
end
|
79
|
-
v
|
80
|
-
end
|
81
|
-
|
82
|
-
def cc2_2(arg)
|
83
|
-
unless arg
|
84
|
-
"not arg"
|
85
|
-
else
|
86
|
-
"arg"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def cc2_3(arg)
|
91
|
-
v = "arg"
|
92
|
-
v = "trail" unless arg
|
93
|
-
v
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
class CycloDefTestClass
|
99
|
-
|
100
|
-
def cc3
|
101
|
-
"p1"
|
102
|
-
rescue CycloException => ce
|
103
|
-
"ce"
|
104
|
-
rescue => err
|
105
|
-
"se"
|
106
|
-
end
|
107
|
-
|
108
|
-
def cc2
|
109
|
-
p = "p1"
|
110
|
-
rescue CycloException => ce
|
111
|
-
p = "CE"
|
112
|
-
else
|
113
|
-
p = "pelse"
|
114
|
-
ensure
|
115
|
-
p + "ensured"
|
116
|
-
end
|
117
|
-
|
118
|
-
def self.classm1_cc1
|
119
|
-
"c1"
|
120
|
-
end
|
121
|
-
|
122
|
-
def CycloDefTestClass.classm2_cc1
|
123
|
-
"c2"
|
124
|
-
end
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
module CycloTestModule
|
129
|
-
|
130
|
-
def cc4_case(arg)
|
131
|
-
v = "1"
|
132
|
-
case arg
|
133
|
-
when "1"
|
134
|
-
v += "c1"
|
135
|
-
when "2"
|
136
|
-
v << "c2"
|
137
|
-
when "3", "4"
|
138
|
-
v<< "c3/4"
|
139
|
-
else
|
140
|
-
v<< "else"
|
141
|
-
end
|
142
|
-
v
|
143
|
-
end
|
144
|
-
|
145
|
-
def while1_cc2(arg)
|
146
|
-
v = "no while"
|
147
|
-
while arg
|
148
|
-
v = "while"
|
149
|
-
arg = false
|
150
|
-
end
|
151
|
-
v
|
152
|
-
end
|
153
|
-
|
154
|
-
def while2_cc2(arg)
|
155
|
-
v = "no while"
|
156
|
-
arg = false while arg
|
157
|
-
v
|
158
|
-
end
|
159
|
-
|
160
|
-
def while3_cc2(arg)
|
161
|
-
v = "no while"
|
162
|
-
begin
|
163
|
-
v = "must while"
|
164
|
-
arg = false
|
165
|
-
end while arg
|
166
|
-
end
|
167
|
-
|
168
|
-
def while4_cc3(arg)
|
169
|
-
v = "no while"
|
170
|
-
while arg do
|
171
|
-
v = "while"
|
172
|
-
arg = false
|
173
|
-
end
|
174
|
-
v
|
175
|
-
end
|
176
|
-
|
177
|
-
def for_cc2(arg)
|
178
|
-
v = 0
|
179
|
-
for x in arg
|
180
|
-
v += x
|
181
|
-
end
|
182
|
-
v
|
183
|
-
end
|
184
|
-
|
185
|
-
# The do causes an error in the current implementation.
|
186
|
-
def for2_cc2(arg)
|
187
|
-
v = 0
|
188
|
-
for x in arg do
|
189
|
-
v += x
|
190
|
-
end
|
191
|
-
v
|
192
|
-
end
|
193
|
-
|
194
|
-
# def commented_out_method
|
195
|
-
# "Should not be seen"
|
196
|
-
# end
|
197
|
-
|
198
|
-
def block_cc2(arg)
|
199
|
-
v = 0
|
200
|
-
arg.each do |i|
|
201
|
-
v += x
|
202
|
-
end
|
203
|
-
v
|
204
|
-
end
|
205
|
-
|
206
|
-
def block2_cc2(arg)
|
207
|
-
v = 0
|
208
|
-
arg.each { |i| v += x }
|
209
|
-
v
|
210
|
-
end
|
211
|
-
|
212
|
-
def hash_cc1
|
213
|
-
{ :x => 1 }
|
214
|
-
end
|
215
|
-
|
216
|
-
end
|
217
|
-
|
218
|
-
# Just to make sure classes wrapped in module show.
|
219
|
-
module CycloTestModule2
|
220
|
-
|
221
|
-
class CycloUntilTestClass
|
222
|
-
|
223
|
-
def until_cc2(arg)
|
224
|
-
v = "until"
|
225
|
-
until arg
|
226
|
-
v = "no more until"
|
227
|
-
arg = true
|
228
|
-
end
|
229
|
-
v
|
230
|
-
end
|
231
|
-
|
232
|
-
|
233
|
-
def until2_cc2(arg)
|
234
|
-
v = "no until"
|
235
|
-
arg = true until arg
|
236
|
-
v
|
237
|
-
end
|
238
|
-
|
239
|
-
def until3_cc2(arg)
|
240
|
-
v = "no until"
|
241
|
-
begin
|
242
|
-
v = "must until"
|
243
|
-
arg = true
|
244
|
-
end until arg
|
245
|
-
end
|
246
|
-
|
247
|
-
def until4_cc2(arg)
|
248
|
-
v = "until"
|
249
|
-
until arg do
|
250
|
-
v = "no more until"
|
251
|
-
arg = true
|
252
|
-
end
|
253
|
-
v
|
254
|
-
end
|
255
|
-
|
256
|
-
end
|
257
|
-
|
258
|
-
end
|
259
|
-
|
260
|
-
class SyntaxTests
|
261
|
-
|
262
|
-
def here_docs_cc1
|
263
|
-
str = <<-EOF
|
264
|
-
Hello
|
265
|
-
This is a here doc
|
266
|
-
EOF
|
267
|
-
str
|
268
|
-
end
|
269
|
-
|
270
|
-
def SyntaxTests::colon_method_cc1
|
271
|
-
"cc1"
|
272
|
-
end
|
273
|
-
|
274
|
-
def symbol_test_cc1(arg)
|
275
|
-
{ :s1 => 1,
|
276
|
-
:class => "should not be a class",
|
277
|
-
}
|
278
|
-
end
|
279
|
-
|
280
|
-
def hash_with_hash1(arg)
|
281
|
-
h = {
|
282
|
-
:x => {
|
283
|
-
:q => arg
|
284
|
-
}
|
285
|
-
}
|
286
|
-
end
|
287
|
-
|
288
|
-
def hash_with_block_inside1(arg)
|
289
|
-
data = {
|
290
|
-
:x => 1,
|
291
|
-
:y => arg.map do |a|
|
292
|
-
a + 2
|
293
|
-
end,
|
294
|
-
}
|
295
|
-
end
|
296
|
-
|
297
|
-
def hash_with_block_inside2(arg)
|
298
|
-
data = {
|
299
|
-
:x => 1,
|
300
|
-
:y => arg.map do |a|
|
301
|
-
{
|
302
|
-
:q => b_meth { a }
|
303
|
-
}
|
304
|
-
end,
|
305
|
-
}
|
306
|
-
end
|
307
|
-
|
308
|
-
|
309
|
-
=begin
|
310
|
-
def begin_end_comment
|
311
|
-
"Should not be shown"
|
312
|
-
end
|
313
|
-
=end
|
314
|
-
|
315
|
-
end
|