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,8 +1,9 @@
1
- ##
2
- # Constant: Fixnum
3
- # Created: 2013-04-01 18:33:54 +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 20:17:38 +0100
5
+ # Platform: rbx 2.1.1
6
+
6
7
  RubyLint::GlobalScope.definitions.define_constant('Fixnum') do |klass|
7
8
  klass.inherits(RubyLint::GlobalScope.constant_proxy('Integer'))
8
9
 
@@ -10,8 +11,6 @@ RubyLint::GlobalScope.definitions.define_constant('Fixnum') do |klass|
10
11
  method.define_argument('obj')
11
12
  end
12
13
 
13
- klass.define_method('__class_init__')
14
-
15
14
  klass.define_method('induced_from') do |method|
16
15
  method.define_argument('obj')
17
16
  end
@@ -36,6 +35,8 @@ RubyLint::GlobalScope.definitions.define_constant('Fixnum') do |klass|
36
35
  method.define_argument('o')
37
36
  end
38
37
 
38
+ klass.define_instance_method('+@')
39
+
39
40
  klass.define_instance_method('-') do |method|
40
41
  method.define_argument('o')
41
42
  end
@@ -82,6 +83,10 @@ RubyLint::GlobalScope.definitions.define_constant('Fixnum') do |klass|
82
83
  method.define_argument('other')
83
84
  end
84
85
 
86
+ klass.define_instance_method('[]') do |method|
87
+ method.define_argument('index')
88
+ end
89
+
85
90
  klass.define_instance_method('^') do |method|
86
91
  method.define_argument('o')
87
92
  end
@@ -90,10 +95,35 @@ RubyLint::GlobalScope.definitions.define_constant('Fixnum') do |klass|
90
95
  method.define_argument('ms')
91
96
  end
92
97
 
98
+ klass.define_instance_method('abs')
99
+
100
+ klass.define_instance_method('abs2')
101
+
102
+ klass.define_instance_method('angle')
103
+
104
+ klass.define_instance_method('arg')
105
+
106
+ klass.define_instance_method('between?') do |method|
107
+ method.define_argument('min')
108
+ method.define_argument('max')
109
+ end
110
+
111
+ klass.define_instance_method('ceil')
112
+
113
+ klass.define_instance_method('chr') do |method|
114
+ method.define_optional_argument('enc')
115
+ end
116
+
93
117
  klass.define_instance_method('coerce') do |method|
94
118
  method.define_argument('other')
95
119
  end
96
120
 
121
+ klass.define_instance_method('conj')
122
+
123
+ klass.define_instance_method('conjugate')
124
+
125
+ klass.define_instance_method('denominator')
126
+
97
127
  klass.define_instance_method('div') do |method|
98
128
  method.define_argument('o')
99
129
  end
@@ -106,29 +136,133 @@ RubyLint::GlobalScope.definitions.define_constant('Fixnum') do |klass|
106
136
  method.define_argument('other')
107
137
  end
108
138
 
139
+ klass.define_instance_method('downto') do |method|
140
+ method.define_argument('val')
141
+ end
142
+
143
+ klass.define_instance_method('even?')
144
+
109
145
  klass.define_instance_method('fdiv') do |method|
110
146
  method.define_argument('n')
111
147
  end
112
148
 
149
+ klass.define_instance_method('floor')
150
+
151
+ klass.define_instance_method('gcd') do |method|
152
+ method.define_argument('other')
153
+ end
154
+
155
+ klass.define_instance_method('gcdlcm') do |method|
156
+ method.define_argument('other')
157
+ end
158
+
159
+ klass.define_instance_method('i')
160
+
161
+ klass.define_instance_method('imag')
162
+
113
163
  klass.define_instance_method('imaginary')
114
164
 
165
+ klass.define_instance_method('initialize_copy') do |method|
166
+ method.define_argument('other')
167
+ end
168
+
115
169
  klass.define_instance_method('inspect')
116
170
 
171
+ klass.define_instance_method('integer?')
172
+
173
+ klass.define_instance_method('lcm') do |method|
174
+ method.define_argument('other')
175
+ end
176
+
177
+ klass.define_instance_method('magnitude')
178
+
117
179
  klass.define_instance_method('modulo') do |method|
118
180
  method.define_argument('o')
119
181
  end
120
182
 
183
+ klass.define_instance_method('next')
184
+
185
+ klass.define_instance_method('nonzero?')
186
+
187
+ klass.define_instance_method('numerator')
188
+
189
+ klass.define_instance_method('odd?')
190
+
191
+ klass.define_instance_method('ord')
192
+
193
+ klass.define_instance_method('phase')
194
+
195
+ klass.define_instance_method('polar')
196
+
197
+ klass.define_instance_method('prec') do |method|
198
+ method.define_argument('klass')
199
+ end
200
+
201
+ klass.define_instance_method('prec_f')
202
+
203
+ klass.define_instance_method('prec_i')
204
+
205
+ klass.define_instance_method('pred')
206
+
207
+ klass.define_instance_method('quo') do |method|
208
+ method.define_argument('other')
209
+ end
210
+
211
+ klass.define_instance_method('rationalize') do |method|
212
+ method.define_optional_argument('eps')
213
+ end
214
+
215
+ klass.define_instance_method('real')
216
+
217
+ klass.define_instance_method('real?')
218
+
219
+ klass.define_instance_method('rect')
220
+
221
+ klass.define_instance_method('rectangular')
222
+
223
+ klass.define_instance_method('redo_compare') do |method|
224
+ method.define_argument('meth')
225
+ method.define_argument('right')
226
+ end
227
+
228
+ klass.define_instance_method('remainder') do |method|
229
+ method.define_argument('other')
230
+ end
231
+
232
+ klass.define_instance_method('round') do |method|
233
+ method.define_optional_argument('ndigits')
234
+ end
235
+
121
236
  klass.define_instance_method('size')
122
237
 
123
- klass.define_instance_method('taint')
238
+ klass.define_instance_method('step') do |method|
239
+ method.define_argument('limit')
240
+ method.define_optional_argument('step')
241
+ end
242
+
243
+ klass.define_instance_method('succ')
244
+
245
+ klass.define_instance_method('times')
246
+
247
+ klass.define_instance_method('to_c')
124
248
 
125
249
  klass.define_instance_method('to_f')
126
250
 
251
+ klass.define_instance_method('to_i')
252
+
253
+ klass.define_instance_method('to_int')
254
+
255
+ klass.define_instance_method('to_r')
256
+
127
257
  klass.define_instance_method('to_s') do |method|
128
258
  method.define_optional_argument('base')
129
259
  end
130
260
 
131
- klass.define_instance_method('untaint')
261
+ klass.define_instance_method('truncate')
262
+
263
+ klass.define_instance_method('upto') do |method|
264
+ method.define_argument('val')
265
+ end
132
266
 
133
267
  klass.define_instance_method('zero?')
134
268
 
@@ -139,20 +273,442 @@ RubyLint::GlobalScope.definitions.define_constant('Fixnum') do |klass|
139
273
  klass.define_instance_method('~')
140
274
  end
141
275
 
142
- ##
143
- # Constant: Fixnum::MAX
144
- # Created: 2013-04-01 18:33:54 +0200
145
- # Platform: rbx 2.0.0.rc1
146
- #
147
276
  RubyLint::GlobalScope.definitions.define_constant('Fixnum::MAX') do |klass|
277
+ klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
278
+
279
+ klass.define_method('%') do |method|
280
+ method.define_argument('o')
281
+ end
282
+
283
+ klass.define_method('&') do |method|
284
+ method.define_argument('o')
285
+ end
286
+
287
+ klass.define_method('*') do |method|
288
+ method.define_argument('o')
289
+ end
290
+
291
+ klass.define_method('**') do |method|
292
+ method.define_argument('o')
293
+ end
294
+
295
+ klass.define_method('+') do |method|
296
+ method.define_argument('o')
297
+ end
298
+
299
+ klass.define_method('+@')
300
+
301
+ klass.define_method('-') do |method|
302
+ method.define_argument('o')
303
+ end
304
+
305
+ klass.define_method('-@')
306
+
307
+ klass.define_method('/') do |method|
308
+ method.define_argument('o')
309
+ end
310
+
311
+ klass.define_method('<<') do |method|
312
+ method.define_argument('other')
313
+ end
314
+
315
+ klass.define_method('>>') do |method|
316
+ method.define_argument('other')
317
+ end
318
+
319
+ klass.define_method('[]') do |method|
320
+ method.define_argument('index')
321
+ end
322
+
323
+ klass.define_method('^') do |method|
324
+ method.define_argument('o')
325
+ end
326
+
327
+ klass.define_method('abs')
328
+
329
+ klass.define_method('abs2')
330
+
331
+ klass.define_method('angle')
332
+
333
+ klass.define_method('arg')
334
+
335
+ klass.define_method('between?') do |method|
336
+ method.define_argument('min')
337
+ method.define_argument('max')
338
+ end
339
+
340
+ klass.define_method('ceil')
341
+
342
+ klass.define_method('chr') do |method|
343
+ method.define_optional_argument('enc')
344
+ end
345
+
346
+ klass.define_method('coerce') do |method|
347
+ method.define_argument('other')
348
+ end
349
+
350
+ klass.define_method('conj')
351
+
352
+ klass.define_method('conjugate')
353
+
354
+ klass.define_method('denominator')
355
+
356
+ klass.define_method('div') do |method|
357
+ method.define_argument('o')
358
+ end
359
+
360
+ klass.define_method('divide') do |method|
361
+ method.define_argument('o')
362
+ end
363
+
364
+ klass.define_method('divmod') do |method|
365
+ method.define_argument('other')
366
+ end
367
+
368
+ klass.define_method('downto') do |method|
369
+ method.define_argument('val')
370
+ end
371
+
372
+ klass.define_method('even?')
373
+
374
+ klass.define_method('fdiv') do |method|
375
+ method.define_argument('n')
376
+ end
377
+
378
+ klass.define_method('floor')
379
+
380
+ klass.define_method('gcd') do |method|
381
+ method.define_argument('other')
382
+ end
383
+
384
+ klass.define_method('gcdlcm') do |method|
385
+ method.define_argument('other')
386
+ end
387
+
388
+ klass.define_method('i')
389
+
390
+ klass.define_method('imag')
391
+
392
+ klass.define_method('imaginary')
393
+
394
+ klass.define_method('integer?')
395
+
396
+ klass.define_method('lcm') do |method|
397
+ method.define_argument('other')
398
+ end
399
+
400
+ klass.define_method('magnitude')
401
+
402
+ klass.define_method('modulo') do |method|
403
+ method.define_argument('o')
404
+ end
405
+
406
+ klass.define_method('next')
407
+
408
+ klass.define_method('nonzero?')
409
+
410
+ klass.define_method('numerator')
411
+
412
+ klass.define_method('odd?')
413
+
414
+ klass.define_method('ord')
415
+
416
+ klass.define_method('phase')
417
+
418
+ klass.define_method('polar')
419
+
420
+ klass.define_method('prec') do |method|
421
+ method.define_argument('klass')
422
+ end
423
+
424
+ klass.define_method('prec_f')
425
+
426
+ klass.define_method('prec_i')
427
+
428
+ klass.define_method('pred')
429
+
430
+ klass.define_method('quo') do |method|
431
+ method.define_argument('other')
432
+ end
433
+
434
+ klass.define_method('rationalize') do |method|
435
+ method.define_optional_argument('eps')
436
+ end
437
+
438
+ klass.define_method('real')
439
+
440
+ klass.define_method('real?')
441
+
442
+ klass.define_method('rect')
443
+
444
+ klass.define_method('rectangular')
445
+
446
+ klass.define_method('redo_compare') do |method|
447
+ method.define_argument('meth')
448
+ method.define_argument('right')
449
+ end
450
+
451
+ klass.define_method('remainder') do |method|
452
+ method.define_argument('other')
453
+ end
454
+
455
+ klass.define_method('round') do |method|
456
+ method.define_optional_argument('ndigits')
457
+ end
458
+
459
+ klass.define_method('size')
460
+
461
+ klass.define_method('step') do |method|
462
+ method.define_argument('limit')
463
+ method.define_optional_argument('step')
464
+ end
465
+
466
+ klass.define_method('succ')
467
+
468
+ klass.define_method('times')
469
+
470
+ klass.define_method('to_c')
471
+
472
+ klass.define_method('to_f')
473
+
474
+ klass.define_method('to_i')
475
+
476
+ klass.define_method('to_int')
477
+
478
+ klass.define_method('to_r')
479
+
480
+ klass.define_method('truncate')
481
+
482
+ klass.define_method('upto') do |method|
483
+ method.define_argument('val')
484
+ end
485
+
486
+ klass.define_method('zero?')
487
+
488
+ klass.define_method('|') do |method|
489
+ method.define_argument('o')
490
+ end
491
+
492
+ klass.define_method('~')
148
493
  end
149
494
 
150
- ##
151
- # Constant: Fixnum::MIN
152
- # Created: 2013-04-01 18:33:54 +0200
153
- # Platform: rbx 2.0.0.rc1
154
- #
155
495
  RubyLint::GlobalScope.definitions.define_constant('Fixnum::MIN') do |klass|
496
+ klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
497
+
498
+ klass.define_method('%') do |method|
499
+ method.define_argument('o')
500
+ end
501
+
502
+ klass.define_method('&') do |method|
503
+ method.define_argument('o')
504
+ end
505
+
506
+ klass.define_method('*') do |method|
507
+ method.define_argument('o')
508
+ end
509
+
510
+ klass.define_method('**') do |method|
511
+ method.define_argument('o')
512
+ end
513
+
514
+ klass.define_method('+') do |method|
515
+ method.define_argument('o')
516
+ end
517
+
518
+ klass.define_method('+@')
519
+
520
+ klass.define_method('-') do |method|
521
+ method.define_argument('o')
522
+ end
523
+
524
+ klass.define_method('-@')
525
+
526
+ klass.define_method('/') do |method|
527
+ method.define_argument('o')
528
+ end
529
+
530
+ klass.define_method('<<') do |method|
531
+ method.define_argument('other')
532
+ end
533
+
534
+ klass.define_method('>>') do |method|
535
+ method.define_argument('other')
536
+ end
537
+
538
+ klass.define_method('[]') do |method|
539
+ method.define_argument('index')
540
+ end
541
+
542
+ klass.define_method('^') do |method|
543
+ method.define_argument('o')
544
+ end
545
+
546
+ klass.define_method('abs')
547
+
548
+ klass.define_method('abs2')
549
+
550
+ klass.define_method('angle')
551
+
552
+ klass.define_method('arg')
553
+
554
+ klass.define_method('between?') do |method|
555
+ method.define_argument('min')
556
+ method.define_argument('max')
557
+ end
558
+
559
+ klass.define_method('ceil')
560
+
561
+ klass.define_method('chr') do |method|
562
+ method.define_optional_argument('enc')
563
+ end
564
+
565
+ klass.define_method('coerce') do |method|
566
+ method.define_argument('other')
567
+ end
568
+
569
+ klass.define_method('conj')
570
+
571
+ klass.define_method('conjugate')
572
+
573
+ klass.define_method('denominator')
574
+
575
+ klass.define_method('div') do |method|
576
+ method.define_argument('o')
577
+ end
578
+
579
+ klass.define_method('divide') do |method|
580
+ method.define_argument('o')
581
+ end
582
+
583
+ klass.define_method('divmod') do |method|
584
+ method.define_argument('other')
585
+ end
586
+
587
+ klass.define_method('downto') do |method|
588
+ method.define_argument('val')
589
+ end
590
+
591
+ klass.define_method('even?')
592
+
593
+ klass.define_method('fdiv') do |method|
594
+ method.define_argument('n')
595
+ end
596
+
597
+ klass.define_method('floor')
598
+
599
+ klass.define_method('gcd') do |method|
600
+ method.define_argument('other')
601
+ end
602
+
603
+ klass.define_method('gcdlcm') do |method|
604
+ method.define_argument('other')
605
+ end
606
+
607
+ klass.define_method('i')
608
+
609
+ klass.define_method('imag')
610
+
611
+ klass.define_method('imaginary')
612
+
613
+ klass.define_method('integer?')
614
+
615
+ klass.define_method('lcm') do |method|
616
+ method.define_argument('other')
617
+ end
618
+
619
+ klass.define_method('magnitude')
620
+
621
+ klass.define_method('modulo') do |method|
622
+ method.define_argument('o')
623
+ end
624
+
625
+ klass.define_method('next')
626
+
627
+ klass.define_method('nonzero?')
628
+
629
+ klass.define_method('numerator')
630
+
631
+ klass.define_method('odd?')
632
+
633
+ klass.define_method('ord')
634
+
635
+ klass.define_method('phase')
636
+
637
+ klass.define_method('polar')
638
+
639
+ klass.define_method('prec') do |method|
640
+ method.define_argument('klass')
641
+ end
642
+
643
+ klass.define_method('prec_f')
644
+
645
+ klass.define_method('prec_i')
646
+
647
+ klass.define_method('pred')
648
+
649
+ klass.define_method('quo') do |method|
650
+ method.define_argument('other')
651
+ end
652
+
653
+ klass.define_method('rationalize') do |method|
654
+ method.define_optional_argument('eps')
655
+ end
656
+
657
+ klass.define_method('real')
658
+
659
+ klass.define_method('real?')
660
+
661
+ klass.define_method('rect')
662
+
663
+ klass.define_method('rectangular')
664
+
665
+ klass.define_method('redo_compare') do |method|
666
+ method.define_argument('meth')
667
+ method.define_argument('right')
668
+ end
669
+
670
+ klass.define_method('remainder') do |method|
671
+ method.define_argument('other')
672
+ end
673
+
674
+ klass.define_method('round') do |method|
675
+ method.define_optional_argument('ndigits')
676
+ end
677
+
678
+ klass.define_method('size')
679
+
680
+ klass.define_method('step') do |method|
681
+ method.define_argument('limit')
682
+ method.define_optional_argument('step')
683
+ end
684
+
685
+ klass.define_method('succ')
686
+
687
+ klass.define_method('times')
688
+
689
+ klass.define_method('to_c')
690
+
691
+ klass.define_method('to_f')
692
+
693
+ klass.define_method('to_i')
694
+
695
+ klass.define_method('to_int')
696
+
697
+ klass.define_method('to_r')
698
+
699
+ klass.define_method('truncate')
700
+
701
+ klass.define_method('upto') do |method|
702
+ method.define_argument('val')
703
+ end
704
+
705
+ klass.define_method('zero?')
706
+
707
+ klass.define_method('|') do |method|
708
+ method.define_argument('o')
709
+ end
710
+
711
+ klass.define_method('~')
156
712
  end
157
713
 
158
- RubyLint::GlobalScope.definitions.lookup(:const, 'Fixnum').deep_freeze
714
+ RubyLint::GlobalScope.definitions.lookup(:const, 'Fixnum').deep_freeze