ruby-lint 0.9.1 → 1.0.0.pre.preview1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CONTRIBUTING.md +9 -11
  4. data/Gemfile +6 -3
  5. data/MANIFEST +7 -1
  6. data/README.md +15 -24
  7. data/benchmark/bootup.rb +13 -0
  8. data/checksum/ruby-lint-0.9.1.gem.sha512 +1 -0
  9. data/doc/code_analysis.md +20 -0
  10. data/doc/css/common.css +1 -0
  11. data/doc/images/flow.png +0 -0
  12. data/lib/ruby-lint.rb +1 -3
  13. data/lib/ruby-lint/analysis/base.rb +12 -2
  14. data/lib/ruby-lint/analysis/undefined_variables.rb +3 -2
  15. data/lib/ruby-lint/analysis/unused_variables.rb +3 -2
  16. data/lib/ruby-lint/ast/node.rb +1 -1
  17. data/lib/ruby-lint/benchmark/average.rb +115 -0
  18. data/lib/ruby-lint/cli/analyze.rb +19 -1
  19. data/lib/ruby-lint/constant_loader.rb +1 -3
  20. data/lib/ruby-lint/constant_path.rb +112 -0
  21. data/lib/ruby-lint/definition_builder/base.rb +0 -2
  22. data/lib/ruby-lint/definition_builder/ruby_module.rb +1 -1
  23. data/lib/ruby-lint/definitions/core/array.rb +304 -73
  24. data/lib/ruby-lint/definitions/core/fixnum.rb +575 -19
  25. data/lib/ruby-lint/definitions/core/float.rb +2650 -95
  26. data/lib/ruby-lint/definitions/core/hash.rb +926 -85
  27. data/lib/ruby-lint/definitions/core/ruby_copyright.rb +3 -1
  28. data/lib/ruby-lint/definitions/core/ruby_description.rb +3 -1
  29. data/lib/ruby-lint/definitions/core/ruby_engine.rb +3 -1
  30. data/lib/ruby-lint/definitions/core/ruby_patchlevel.rb +3 -1
  31. data/lib/ruby-lint/definitions/core/ruby_platform.rb +3 -1
  32. data/lib/ruby-lint/definitions/core/ruby_release_date.rb +3 -1
  33. data/lib/ruby-lint/definitions/core/ruby_version.rb +3 -1
  34. data/lib/ruby-lint/definitions/core/string.rb +847 -134
  35. data/lib/ruby-lint/definitions/core/string_io.rb +370 -25
  36. data/lib/ruby-lint/definitions/core/struct.rb +611 -146
  37. data/lib/ruby-lint/file_loader.rb +5 -6
  38. data/lib/ruby-lint/file_scanner.rb +44 -11
  39. data/lib/ruby-lint/inspector.rb +12 -2
  40. data/lib/ruby-lint/runner.rb +6 -2
  41. data/lib/ruby-lint/version.rb +1 -1
  42. data/lib/ruby-lint/virtual_machine.rb +19 -5
  43. data/ruby-lint.gemspec +1 -3
  44. data/spec/ruby-lint/analysis/argument_amount_spec.rb +5 -5
  45. data/spec/ruby-lint/analysis/base_spec.rb +4 -0
  46. data/spec/ruby-lint/analysis/shadowing_variables_spec.rb +4 -4
  47. data/spec/ruby-lint/analysis/undefined_methods_spec.rb +6 -6
  48. data/spec/ruby-lint/analysis/undefined_variables_spec.rb +5 -5
  49. data/spec/ruby-lint/analysis/unused_variables_spec.rb +12 -12
  50. data/spec/ruby-lint/cli/analyze_spec.rb +10 -0
  51. data/spec/ruby-lint/constant_path.rb +63 -0
  52. data/spec/ruby-lint/definition/ruby_object_spec.rb +2 -2
  53. data/spec/ruby-lint/report_spec.rb +2 -2
  54. data/spec/ruby-lint/runner_spec.rb +17 -0
  55. data/spec/ruby-lint/virtual_machine/assignments/assignment_arguments_spec.rb +14 -0
  56. data/spec/ruby-lint/virtual_machine/assignments/constants_spec.rb +23 -0
  57. data/spec/ruby-lint/virtual_machine/location_spec.rb +4 -4
  58. data/spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb +4 -4
  59. data/task/build.rake +2 -7
  60. data/task/doc.rake +3 -1
  61. data/task/generate.rake +3 -0
  62. metadata +20 -36
  63. checksums.yaml.gz.asc +0 -17
  64. data.tar.gz.asc +0 -17
  65. data/lib/ruby-lint/helper/constant_paths.rb +0 -50
  66. metadata.gz.asc +0 -17
@@ -1,13 +1,12 @@
1
- ##
2
- # Constant: StringIO
3
- # Created: 2013-04-01 18:33:55 +0200
4
- # Platform: rbx 2.0.0.rc1
1
+ # This file was automatically generated, any manual changes will be lost the
2
+ # next time this file is generated.
5
3
  #
4
+ # Created: 2013-11-11 21:26:59 +0100
5
+ # Platform: rbx 2.1.1
6
+
6
7
  RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
7
8
  klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
8
9
 
9
- klass.define_method('__class_init__')
10
-
11
10
  klass.define_method('open') do |method|
12
11
  method.define_rest_argument('args')
13
12
  end
@@ -18,12 +17,20 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
18
17
 
19
18
  klass.define_instance_method('__data__')
20
19
 
20
+ klass.define_instance_method('all?')
21
+
22
+ klass.define_instance_method('any?')
23
+
21
24
  klass.define_instance_method('binmode')
22
25
 
23
26
  klass.define_instance_method('bytes')
24
27
 
25
28
  klass.define_instance_method('chars')
26
29
 
30
+ klass.define_instance_method('chunk') do |method|
31
+ method.define_optional_argument('initial_state')
32
+ end
33
+
27
34
  klass.define_instance_method('close')
28
35
 
29
36
  klass.define_instance_method('close_read')
@@ -40,6 +47,28 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
40
47
  method.define_block_argument('block')
41
48
  end
42
49
 
50
+ klass.define_instance_method('collect')
51
+
52
+ klass.define_instance_method('collect_concat')
53
+
54
+ klass.define_instance_method('count') do |method|
55
+ method.define_optional_argument('item')
56
+ end
57
+
58
+ klass.define_instance_method('cycle') do |method|
59
+ method.define_optional_argument('many')
60
+ end
61
+
62
+ klass.define_instance_method('detect') do |method|
63
+ method.define_optional_argument('ifnone')
64
+ end
65
+
66
+ klass.define_instance_method('drop') do |method|
67
+ method.define_argument('n')
68
+ end
69
+
70
+ klass.define_instance_method('drop_while')
71
+
43
72
  klass.define_instance_method('each') do |method|
44
73
  method.define_optional_argument('sep')
45
74
  method.define_optional_argument('limit')
@@ -53,11 +82,39 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
53
82
  method.define_block_argument('block')
54
83
  end
55
84
 
85
+ klass.define_instance_method('each_cons') do |method|
86
+ method.define_argument('num')
87
+ end
88
+
89
+ klass.define_instance_method('each_entry') do |method|
90
+ method.define_rest_argument('pass')
91
+ end
92
+
56
93
  klass.define_instance_method('each_line') do |method|
57
94
  method.define_optional_argument('sep')
58
95
  method.define_optional_argument('limit')
59
96
  end
60
97
 
98
+ klass.define_instance_method('each_slice') do |method|
99
+ method.define_argument('slice_size')
100
+ end
101
+
102
+ klass.define_instance_method('each_with_index') do |method|
103
+ method.define_rest_argument('args')
104
+ end
105
+
106
+ klass.define_instance_method('each_with_object') do |method|
107
+ method.define_argument('memo')
108
+ end
109
+
110
+ klass.define_instance_method('encode_with') do |method|
111
+ method.define_argument('coder')
112
+ end
113
+
114
+ klass.define_instance_method('entries') do |method|
115
+ method.define_rest_argument('arg')
116
+ end
117
+
61
118
  klass.define_instance_method('eof')
62
119
 
63
120
  klass.define_instance_method('eof?')
@@ -68,6 +125,22 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
68
125
 
69
126
  klass.define_instance_method('fileno')
70
127
 
128
+ klass.define_instance_method('find') do |method|
129
+ method.define_optional_argument('ifnone')
130
+ end
131
+
132
+ klass.define_instance_method('find_all')
133
+
134
+ klass.define_instance_method('find_index') do |method|
135
+ method.define_optional_argument('value')
136
+ end
137
+
138
+ klass.define_instance_method('first') do |method|
139
+ method.define_optional_argument('n')
140
+ end
141
+
142
+ klass.define_instance_method('flat_map')
143
+
71
144
  klass.define_instance_method('flush')
72
145
 
73
146
  klass.define_instance_method('fsync')
@@ -87,10 +160,36 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
87
160
  method.define_optional_argument('limit')
88
161
  end
89
162
 
163
+ klass.define_instance_method('grep') do |method|
164
+ method.define_argument('pattern')
165
+ end
166
+
167
+ klass.define_instance_method('group_by')
168
+
169
+ klass.define_instance_method('include?') do |method|
170
+ method.define_argument('obj')
171
+ end
172
+
173
+ klass.define_instance_method('init_with') do |method|
174
+ method.define_argument('coder')
175
+ end
176
+
177
+ klass.define_instance_method('initialize') do |method|
178
+ method.define_optional_argument('string')
179
+ method.define_optional_argument('mode')
180
+ end
181
+
182
+ klass.define_instance_method('inject') do |method|
183
+ method.define_optional_argument('initial')
184
+ method.define_optional_argument('sym')
185
+ end
186
+
90
187
  klass.define_instance_method('internal_encoding')
91
188
 
92
189
  klass.define_instance_method('isatty')
93
190
 
191
+ klass.define_instance_method('lazy')
192
+
94
193
  klass.define_instance_method('length')
95
194
 
96
195
  klass.define_instance_method('lineno')
@@ -104,6 +203,24 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
104
203
  method.define_optional_argument('limit')
105
204
  end
106
205
 
206
+ klass.define_instance_method('map')
207
+
208
+ klass.define_instance_method('max')
209
+
210
+ klass.define_instance_method('max_by')
211
+
212
+ klass.define_instance_method('member?') do |method|
213
+ method.define_argument('obj')
214
+ end
215
+
216
+ klass.define_instance_method('min')
217
+
218
+ klass.define_instance_method('min_by')
219
+
220
+ klass.define_instance_method('minmax')
221
+
222
+ klass.define_instance_method('minmax_by')
223
+
107
224
  klass.define_instance_method('mode_from_integer') do |method|
108
225
  method.define_argument('mode')
109
226
  end
@@ -112,6 +229,12 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
112
229
  method.define_argument('mode')
113
230
  end
114
231
 
232
+ klass.define_instance_method('none?')
233
+
234
+ klass.define_instance_method('one?')
235
+
236
+ klass.define_instance_method('partition')
237
+
115
238
  klass.define_instance_method('pid')
116
239
 
117
240
  klass.define_instance_method('pos')
@@ -165,11 +288,20 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
165
288
  method.define_optional_argument('buffer')
166
289
  end
167
290
 
291
+ klass.define_instance_method('reduce') do |method|
292
+ method.define_optional_argument('initial')
293
+ method.define_optional_argument('sym')
294
+ end
295
+
296
+ klass.define_instance_method('reject')
297
+
168
298
  klass.define_instance_method('reopen') do |method|
169
299
  method.define_optional_argument('string')
170
300
  method.define_optional_argument('mode')
171
301
  end
172
302
 
303
+ klass.define_instance_method('reverse_each')
304
+
173
305
  klass.define_instance_method('rewind')
174
306
 
175
307
  klass.define_instance_method('seek') do |method|
@@ -177,6 +309,8 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
177
309
  method.define_optional_argument('whence')
178
310
  end
179
311
 
312
+ klass.define_instance_method('select')
313
+
180
314
  klass.define_instance_method('set_encoding') do |method|
181
315
  method.define_argument('external')
182
316
  method.define_optional_argument('internal')
@@ -185,6 +319,14 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
185
319
 
186
320
  klass.define_instance_method('size')
187
321
 
322
+ klass.define_instance_method('slice_before') do |method|
323
+ method.define_optional_argument('arg')
324
+ end
325
+
326
+ klass.define_instance_method('sort')
327
+
328
+ klass.define_instance_method('sort_by')
329
+
188
330
  klass.define_instance_method('string')
189
331
 
190
332
  klass.define_instance_method('string=') do |method|
@@ -206,8 +348,26 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
206
348
  method.define_argument('str')
207
349
  end
208
350
 
351
+ klass.define_instance_method('take') do |method|
352
+ method.define_argument('n')
353
+ end
354
+
355
+ klass.define_instance_method('take_while')
356
+
209
357
  klass.define_instance_method('tell')
210
358
 
359
+ klass.define_instance_method('to_a') do |method|
360
+ method.define_rest_argument('arg')
361
+ end
362
+
363
+ klass.define_instance_method('to_set') do |method|
364
+ method.define_optional_argument('klass')
365
+ method.define_rest_argument('args')
366
+ method.define_block_argument('block')
367
+ end
368
+
369
+ klass.define_instance_method('to_yaml_properties')
370
+
211
371
  klass.define_instance_method('truncate') do |method|
212
372
  method.define_argument('length')
213
373
  end
@@ -222,6 +382,10 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
222
382
  method.define_argument('char')
223
383
  end
224
384
 
385
+ klass.define_instance_method('with_object') do |method|
386
+ method.define_argument('memo')
387
+ end
388
+
225
389
  klass.define_instance_method('write') do |method|
226
390
  method.define_argument('str')
227
391
  end
@@ -229,17 +393,27 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO') do |klass|
229
393
  klass.define_instance_method('write_nonblock') do |method|
230
394
  method.define_argument('str')
231
395
  end
396
+
397
+ klass.define_instance_method('yaml_initialize') do |method|
398
+ method.define_argument('type')
399
+ method.define_argument('val')
400
+ end
401
+
402
+ klass.define_instance_method('zip') do |method|
403
+ method.define_rest_argument('args')
404
+ end
232
405
  end
233
406
 
234
- ##
235
- # Constant: StringIO::Data
236
- # Created: 2013-04-01 18:33:55 +0200
237
- # Platform: rbx 2.0.0.rc1
238
- #
239
407
  RubyLint::GlobalScope.definitions.define_constant('StringIO::Data') do |klass|
240
408
  klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
241
409
 
242
- klass.define_method('__class_init__')
410
+ klass.define_instance_method('encoding')
411
+
412
+ klass.define_instance_method('encoding=')
413
+
414
+ klass.define_instance_method('initialize') do |method|
415
+ method.define_argument('string')
416
+ end
243
417
 
244
418
  klass.define_instance_method('lineno')
245
419
 
@@ -254,15 +428,190 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO::Data') do |klass|
254
428
  klass.define_instance_method('string=')
255
429
  end
256
430
 
257
- ##
258
- # Constant: StringIO::SortedElement
259
- # Created: 2013-04-01 18:33:55 +0200
260
- # Platform: rbx 2.0.0.rc1
261
- #
262
- RubyLint::GlobalScope.definitions.define_constant('StringIO::SortedElement') do |klass|
431
+ RubyLint::GlobalScope.definitions.define_constant('StringIO::Enumerator') do |klass|
263
432
  klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
264
433
 
265
- klass.define_method('__class_init__')
434
+ klass.define_instance_method('all?')
435
+
436
+ klass.define_instance_method('any?')
437
+
438
+ klass.define_instance_method('chunk') do |method|
439
+ method.define_optional_argument('initial_state')
440
+ end
441
+
442
+ klass.define_instance_method('collect')
443
+
444
+ klass.define_instance_method('collect_concat')
445
+
446
+ klass.define_instance_method('count') do |method|
447
+ method.define_optional_argument('item')
448
+ end
449
+
450
+ klass.define_instance_method('cycle') do |method|
451
+ method.define_optional_argument('many')
452
+ end
453
+
454
+ klass.define_instance_method('detect') do |method|
455
+ method.define_optional_argument('ifnone')
456
+ end
457
+
458
+ klass.define_instance_method('drop') do |method|
459
+ method.define_argument('n')
460
+ end
461
+
462
+ klass.define_instance_method('drop_while')
463
+
464
+ klass.define_instance_method('each') do |method|
465
+ method.define_rest_argument('args')
466
+ end
467
+
468
+ klass.define_instance_method('each_cons') do |method|
469
+ method.define_argument('num')
470
+ end
471
+
472
+ klass.define_instance_method('each_entry') do |method|
473
+ method.define_rest_argument('pass')
474
+ end
475
+
476
+ klass.define_instance_method('each_slice') do |method|
477
+ method.define_argument('slice_size')
478
+ end
479
+
480
+ klass.define_instance_method('each_with_index')
481
+
482
+ klass.define_instance_method('each_with_object') do |method|
483
+ method.define_argument('memo')
484
+ end
485
+
486
+ klass.define_instance_method('entries') do |method|
487
+ method.define_rest_argument('arg')
488
+ end
489
+
490
+ klass.define_instance_method('find') do |method|
491
+ method.define_optional_argument('ifnone')
492
+ end
493
+
494
+ klass.define_instance_method('find_all')
495
+
496
+ klass.define_instance_method('find_index') do |method|
497
+ method.define_optional_argument('value')
498
+ end
499
+
500
+ klass.define_instance_method('first') do |method|
501
+ method.define_optional_argument('n')
502
+ end
503
+
504
+ klass.define_instance_method('flat_map')
505
+
506
+ klass.define_instance_method('grep') do |method|
507
+ method.define_argument('pattern')
508
+ end
509
+
510
+ klass.define_instance_method('group_by')
511
+
512
+ klass.define_instance_method('include?') do |method|
513
+ method.define_argument('obj')
514
+ end
515
+
516
+ klass.define_instance_method('initialize') do |method|
517
+ method.define_optional_argument('receiver_or_size')
518
+ method.define_optional_argument('method_name')
519
+ method.define_rest_argument('method_args')
520
+ end
521
+
522
+ klass.define_instance_method('inject') do |method|
523
+ method.define_optional_argument('initial')
524
+ method.define_optional_argument('sym')
525
+ end
526
+
527
+ klass.define_instance_method('lazy')
528
+
529
+ klass.define_instance_method('map')
530
+
531
+ klass.define_instance_method('max')
532
+
533
+ klass.define_instance_method('max_by')
534
+
535
+ klass.define_instance_method('member?') do |method|
536
+ method.define_argument('obj')
537
+ end
538
+
539
+ klass.define_instance_method('min')
540
+
541
+ klass.define_instance_method('min_by')
542
+
543
+ klass.define_instance_method('minmax')
544
+
545
+ klass.define_instance_method('minmax_by')
546
+
547
+ klass.define_instance_method('next')
548
+
549
+ klass.define_instance_method('next_values')
550
+
551
+ klass.define_instance_method('none?')
552
+
553
+ klass.define_instance_method('one?')
554
+
555
+ klass.define_instance_method('partition')
556
+
557
+ klass.define_instance_method('peek')
558
+
559
+ klass.define_instance_method('peek_values')
560
+
561
+ klass.define_instance_method('reduce') do |method|
562
+ method.define_optional_argument('initial')
563
+ method.define_optional_argument('sym')
564
+ end
565
+
566
+ klass.define_instance_method('reject')
567
+
568
+ klass.define_instance_method('reverse_each')
569
+
570
+ klass.define_instance_method('rewind')
571
+
572
+ klass.define_instance_method('select')
573
+
574
+ klass.define_instance_method('size')
575
+
576
+ klass.define_instance_method('slice_before') do |method|
577
+ method.define_optional_argument('arg')
578
+ end
579
+
580
+ klass.define_instance_method('sort')
581
+
582
+ klass.define_instance_method('sort_by')
583
+
584
+ klass.define_instance_method('take') do |method|
585
+ method.define_argument('n')
586
+ end
587
+
588
+ klass.define_instance_method('take_while')
589
+
590
+ klass.define_instance_method('to_a') do |method|
591
+ method.define_rest_argument('arg')
592
+ end
593
+
594
+ klass.define_instance_method('to_set') do |method|
595
+ method.define_optional_argument('klass')
596
+ method.define_rest_argument('args')
597
+ method.define_block_argument('block')
598
+ end
599
+
600
+ klass.define_instance_method('with_index') do |method|
601
+ method.define_optional_argument('offset')
602
+ end
603
+
604
+ klass.define_instance_method('with_object') do |method|
605
+ method.define_argument('memo')
606
+ end
607
+
608
+ klass.define_instance_method('zip') do |method|
609
+ method.define_rest_argument('args')
610
+ end
611
+ end
612
+
613
+ RubyLint::GlobalScope.definitions.define_constant('StringIO::SortedElement') do |klass|
614
+ klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
266
615
 
267
616
  klass.define_instance_method('<=>') do |method|
268
617
  method.define_argument('other')
@@ -278,12 +627,8 @@ RubyLint::GlobalScope.definitions.define_constant('StringIO::SortedElement') do
278
627
  klass.define_instance_method('value')
279
628
  end
280
629
 
281
- ##
282
- # Constant: StringIO::Undefined
283
- # Created: 2013-04-01 18:33:55 +0200
284
- # Platform: rbx 2.0.0.rc1
285
- #
286
630
  RubyLint::GlobalScope.definitions.define_constant('StringIO::Undefined') do |klass|
631
+ klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
287
632
  end
288
633
 
289
- RubyLint::GlobalScope.definitions.lookup(:const, 'StringIO').deep_freeze
634
+ RubyLint::GlobalScope.definitions.lookup(:const, 'StringIO').deep_freeze