saikuro 1.1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
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
@@ -0,0 +1,315 @@
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
data/lib/saikuro.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "saikuro/version"
2
+
3
+ module Saikuro
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Saikuro
2
+ VERSION = "1.1.1.1"
3
+ end
data/saikuro.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "saikuro/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "saikuro"
7
+ s.version = Saikuro::VERSION
8
+ s.authors = ["Zev Blut", "Roman V. Babenko"]
9
+ s.email = ["zb@ubit.com", "romanvbabenko@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Saikuro is a Ruby cyclomatic complexity analyzer}
12
+ s.description = %q{When given Ruby source code Saikuro will generate a report listing the cyclomatic complexity of each method found. In addition, Saikuro counts the number of lines per method and can generate a listing of the number of tokens on each line of code.}
13
+
14
+ s.rubyforge_project = "saikuro"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: saikuro
3
+ version: !ruby/object:Gem::Version
4
+ hash: 81
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 1
10
+ - 1
11
+ version: 1.1.1.1
12
+ platform: ruby
13
+ authors:
14
+ - Zev Blut
15
+ - Roman V. Babenko
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2011-09-27 00:00:00 Z
21
+ dependencies: []
22
+
23
+ description: When given Ruby source code Saikuro will generate a report listing the cyclomatic complexity of each method found. In addition, Saikuro counts the number of lines per method and can generate a listing of the number of tokens on each line of code.
24
+ email:
25
+ - zb@ubit.com
26
+ - romanvbabenko@gmail.com
27
+ executables:
28
+ - saikuro
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - .gitignore
35
+ - Gemfile
36
+ - Rakefile
37
+ - bin/saikuro
38
+ - examples/large_example.rb
39
+ - examples/samples.rb
40
+ - lib/saikuro.rb
41
+ - lib/saikuro/version.rb
42
+ - saikuro.gemspec
43
+ homepage: ""
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options: []
48
+
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ requirements: []
70
+
71
+ rubyforge_project: saikuro
72
+ rubygems_version: 1.8.10
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: Saikuro is a Ruby cyclomatic complexity analyzer
76
+ test_files: []
77
+