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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CONTRIBUTING.md +9 -11
- data/Gemfile +6 -3
- data/MANIFEST +7 -1
- data/README.md +15 -24
- data/benchmark/bootup.rb +13 -0
- data/checksum/ruby-lint-0.9.1.gem.sha512 +1 -0
- data/doc/code_analysis.md +20 -0
- data/doc/css/common.css +1 -0
- data/doc/images/flow.png +0 -0
- data/lib/ruby-lint.rb +1 -3
- data/lib/ruby-lint/analysis/base.rb +12 -2
- data/lib/ruby-lint/analysis/undefined_variables.rb +3 -2
- data/lib/ruby-lint/analysis/unused_variables.rb +3 -2
- data/lib/ruby-lint/ast/node.rb +1 -1
- data/lib/ruby-lint/benchmark/average.rb +115 -0
- data/lib/ruby-lint/cli/analyze.rb +19 -1
- data/lib/ruby-lint/constant_loader.rb +1 -3
- data/lib/ruby-lint/constant_path.rb +112 -0
- data/lib/ruby-lint/definition_builder/base.rb +0 -2
- data/lib/ruby-lint/definition_builder/ruby_module.rb +1 -1
- data/lib/ruby-lint/definitions/core/array.rb +304 -73
- data/lib/ruby-lint/definitions/core/fixnum.rb +575 -19
- data/lib/ruby-lint/definitions/core/float.rb +2650 -95
- data/lib/ruby-lint/definitions/core/hash.rb +926 -85
- data/lib/ruby-lint/definitions/core/ruby_copyright.rb +3 -1
- data/lib/ruby-lint/definitions/core/ruby_description.rb +3 -1
- data/lib/ruby-lint/definitions/core/ruby_engine.rb +3 -1
- data/lib/ruby-lint/definitions/core/ruby_patchlevel.rb +3 -1
- data/lib/ruby-lint/definitions/core/ruby_platform.rb +3 -1
- data/lib/ruby-lint/definitions/core/ruby_release_date.rb +3 -1
- data/lib/ruby-lint/definitions/core/ruby_version.rb +3 -1
- data/lib/ruby-lint/definitions/core/string.rb +847 -134
- data/lib/ruby-lint/definitions/core/string_io.rb +370 -25
- data/lib/ruby-lint/definitions/core/struct.rb +611 -146
- data/lib/ruby-lint/file_loader.rb +5 -6
- data/lib/ruby-lint/file_scanner.rb +44 -11
- data/lib/ruby-lint/inspector.rb +12 -2
- data/lib/ruby-lint/runner.rb +6 -2
- data/lib/ruby-lint/version.rb +1 -1
- data/lib/ruby-lint/virtual_machine.rb +19 -5
- data/ruby-lint.gemspec +1 -3
- data/spec/ruby-lint/analysis/argument_amount_spec.rb +5 -5
- data/spec/ruby-lint/analysis/base_spec.rb +4 -0
- data/spec/ruby-lint/analysis/shadowing_variables_spec.rb +4 -4
- data/spec/ruby-lint/analysis/undefined_methods_spec.rb +6 -6
- data/spec/ruby-lint/analysis/undefined_variables_spec.rb +5 -5
- data/spec/ruby-lint/analysis/unused_variables_spec.rb +12 -12
- data/spec/ruby-lint/cli/analyze_spec.rb +10 -0
- data/spec/ruby-lint/constant_path.rb +63 -0
- data/spec/ruby-lint/definition/ruby_object_spec.rb +2 -2
- data/spec/ruby-lint/report_spec.rb +2 -2
- data/spec/ruby-lint/runner_spec.rb +17 -0
- data/spec/ruby-lint/virtual_machine/assignments/assignment_arguments_spec.rb +14 -0
- data/spec/ruby-lint/virtual_machine/assignments/constants_spec.rb +23 -0
- data/spec/ruby-lint/virtual_machine/location_spec.rb +4 -4
- data/spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb +4 -4
- data/task/build.rake +2 -7
- data/task/doc.rake +3 -1
- data/task/generate.rake +3 -0
- metadata +20 -36
- checksums.yaml.gz.asc +0 -17
- data.tar.gz.asc +0 -17
- data/lib/ruby-lint/helper/constant_paths.rb +0 -50
- metadata.gz.asc +0 -17
@@ -11,8 +11,6 @@ module RubyLint
|
|
11
11
|
# @return [Hash] Hash containing the loaded constants.
|
12
12
|
#
|
13
13
|
class ConstantLoader < Iterator
|
14
|
-
include Helper::ConstantPaths
|
15
|
-
|
16
14
|
attr_reader :loaded
|
17
15
|
|
18
16
|
##
|
@@ -36,7 +34,7 @@ module RubyLint
|
|
36
34
|
# @param [RubyLint::Node] node
|
37
35
|
#
|
38
36
|
def on_const(node)
|
39
|
-
load_constant(
|
37
|
+
load_constant(ConstantPath.new(node).root_node[1])
|
40
38
|
end
|
41
39
|
|
42
40
|
##
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module RubyLint
|
2
|
+
##
|
3
|
+
# The ConstantPath class can be used for various operations on a constant AST
|
4
|
+
# node such as generating the full constant name.
|
5
|
+
#
|
6
|
+
# @!attribute [r] node
|
7
|
+
# @return [RubyLint::AST::Node]
|
8
|
+
#
|
9
|
+
class ConstantPath
|
10
|
+
attr_reader :node
|
11
|
+
|
12
|
+
##
|
13
|
+
# Hash containing node types to remap when resolving them.
|
14
|
+
#
|
15
|
+
# @return [Hash]
|
16
|
+
#
|
17
|
+
REMAP_TYPES = {
|
18
|
+
:casgn => :const
|
19
|
+
}
|
20
|
+
|
21
|
+
##
|
22
|
+
# @param [RubyLint::AST::Node] node
|
23
|
+
#
|
24
|
+
def initialize(node)
|
25
|
+
@node = node
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Retrieves the definition associated with the constant path and returns
|
30
|
+
# it, or `nil` if no definition was found.
|
31
|
+
#
|
32
|
+
# @param [RubyLint::Definition::RubyObject] scope The scope to use for the
|
33
|
+
# lookups.
|
34
|
+
# @return [RubyLint::Definition::RubyObject]
|
35
|
+
#
|
36
|
+
def resolve(scope)
|
37
|
+
current = scope
|
38
|
+
|
39
|
+
constant_segments.each_with_index do |(type, name), index|
|
40
|
+
type = REMAP_TYPES.fetch(type, type)
|
41
|
+
found = current.lookup(type, name, index == 0)
|
42
|
+
|
43
|
+
if found
|
44
|
+
current = found.const? ? found : found.value
|
45
|
+
else
|
46
|
+
return
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
return current
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Returns the very first segment of the constant path as an AST node.
|
55
|
+
#
|
56
|
+
# @return [RubyLint::AST::Node]
|
57
|
+
#
|
58
|
+
def root_node
|
59
|
+
return constant_segments.first
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Returns a String containing the full constant path, e.g.
|
64
|
+
# "RubyLint::Runner".
|
65
|
+
#
|
66
|
+
# @return [String]
|
67
|
+
#
|
68
|
+
def to_s
|
69
|
+
return constant_segments.map { |seg| seg[1] }.join('::')
|
70
|
+
end
|
71
|
+
|
72
|
+
##
|
73
|
+
# Returns an Array containing the segments of a constant path.
|
74
|
+
#
|
75
|
+
# @param [RubyLint::AST::Node] node
|
76
|
+
# @return [Array<String>]
|
77
|
+
#
|
78
|
+
def constant_segments(node = self.node)
|
79
|
+
segments = []
|
80
|
+
|
81
|
+
if has_child_node?(node)
|
82
|
+
segments.concat(constant_segments(node.children[0]))
|
83
|
+
end
|
84
|
+
|
85
|
+
segments << [node.type, name_for_node(node)]
|
86
|
+
|
87
|
+
return segments
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
##
|
93
|
+
# @param [RubyLint::AST::Node] node
|
94
|
+
# @return [TrueClass|FalseClass]
|
95
|
+
#
|
96
|
+
def has_child_node?(node)
|
97
|
+
return node.children[0] && node.children[0].is_a?(AST::Node)
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# @param [RubyLint::AST::Node] node
|
102
|
+
# @return [String]
|
103
|
+
#
|
104
|
+
def name_for_node(node)
|
105
|
+
if node.type == :casgn
|
106
|
+
return node.children[1].to_s
|
107
|
+
else
|
108
|
+
return node.name
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end # ConstantPath
|
112
|
+
end # RubyLint
|
@@ -28,7 +28,7 @@ module RubyLint
|
|
28
28
|
# name_prefix contains the constant path leading up to the name. For
|
29
29
|
# example, if the name is `A::B::C` this node would contain `A::B`.
|
30
30
|
if name_prefix
|
31
|
-
found =
|
31
|
+
found = ConstantPath.new(name_prefix).resolve(current_scope)
|
32
32
|
scope = found if found
|
33
33
|
end
|
34
34
|
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Created: 2013-04-01 18:33:52 +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:16:57 +0100
|
5
|
+
# Platform: rbx 2.1.1
|
6
|
+
|
6
7
|
RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
7
8
|
klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
|
8
9
|
|
@@ -10,8 +11,6 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
10
11
|
method.define_rest_argument('args')
|
11
12
|
end
|
12
13
|
|
13
|
-
klass.define_method('__class_init__')
|
14
|
-
|
15
14
|
klass.define_method('allocate')
|
16
15
|
|
17
16
|
klass.define_method('try_convert') do |method|
|
@@ -69,6 +68,10 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
69
68
|
method.define_argument('exception')
|
70
69
|
end
|
71
70
|
|
71
|
+
klass.define_instance_method('all?')
|
72
|
+
|
73
|
+
klass.define_instance_method('any?')
|
74
|
+
|
72
75
|
klass.define_instance_method('assoc') do |method|
|
73
76
|
method.define_argument('obj')
|
74
77
|
end
|
@@ -77,12 +80,18 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
77
80
|
method.define_argument('idx')
|
78
81
|
end
|
79
82
|
|
83
|
+
klass.define_instance_method('chunk') do |method|
|
84
|
+
method.define_optional_argument('initial_state')
|
85
|
+
end
|
86
|
+
|
80
87
|
klass.define_instance_method('clear')
|
81
88
|
|
82
89
|
klass.define_instance_method('collect')
|
83
90
|
|
84
91
|
klass.define_instance_method('collect!')
|
85
92
|
|
93
|
+
klass.define_instance_method('collect_concat')
|
94
|
+
|
86
95
|
klass.define_instance_method('combination') do |method|
|
87
96
|
method.define_argument('num')
|
88
97
|
end
|
@@ -95,9 +104,12 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
95
104
|
method.define_argument('other')
|
96
105
|
end
|
97
106
|
|
107
|
+
klass.define_instance_method('count') do |method|
|
108
|
+
method.define_optional_argument('item')
|
109
|
+
end
|
110
|
+
|
98
111
|
klass.define_instance_method('cycle') do |method|
|
99
112
|
method.define_optional_argument('n')
|
100
|
-
method.define_block_argument('block')
|
101
113
|
end
|
102
114
|
|
103
115
|
klass.define_instance_method('delete') do |method|
|
@@ -108,20 +120,48 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
108
120
|
method.define_argument('idx')
|
109
121
|
end
|
110
122
|
|
111
|
-
klass.define_instance_method('delete_if')
|
112
|
-
|
123
|
+
klass.define_instance_method('delete_if')
|
124
|
+
|
125
|
+
klass.define_instance_method('detect') do |method|
|
126
|
+
method.define_optional_argument('ifnone')
|
113
127
|
end
|
114
128
|
|
115
129
|
klass.define_instance_method('drop') do |method|
|
116
130
|
method.define_argument('n')
|
117
131
|
end
|
118
132
|
|
133
|
+
klass.define_instance_method('drop_while')
|
134
|
+
|
119
135
|
klass.define_instance_method('each')
|
120
136
|
|
137
|
+
klass.define_instance_method('each_cons') do |method|
|
138
|
+
method.define_argument('num')
|
139
|
+
end
|
140
|
+
|
141
|
+
klass.define_instance_method('each_entry') do |method|
|
142
|
+
method.define_rest_argument('pass')
|
143
|
+
end
|
144
|
+
|
121
145
|
klass.define_instance_method('each_index')
|
122
146
|
|
147
|
+
klass.define_instance_method('each_slice') do |method|
|
148
|
+
method.define_argument('slice_size')
|
149
|
+
end
|
150
|
+
|
151
|
+
klass.define_instance_method('each_with_index') do |method|
|
152
|
+
method.define_rest_argument('args')
|
153
|
+
end
|
154
|
+
|
155
|
+
klass.define_instance_method('each_with_object') do |method|
|
156
|
+
method.define_argument('memo')
|
157
|
+
end
|
158
|
+
|
123
159
|
klass.define_instance_method('empty?')
|
124
160
|
|
161
|
+
klass.define_instance_method('entries') do |method|
|
162
|
+
method.define_rest_argument('arg')
|
163
|
+
end
|
164
|
+
|
125
165
|
klass.define_instance_method('eql?') do |method|
|
126
166
|
method.define_argument('other')
|
127
167
|
end
|
@@ -137,6 +177,12 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
137
177
|
method.define_optional_argument('c')
|
138
178
|
end
|
139
179
|
|
180
|
+
klass.define_instance_method('find') do |method|
|
181
|
+
method.define_optional_argument('ifnone')
|
182
|
+
end
|
183
|
+
|
184
|
+
klass.define_instance_method('find_all')
|
185
|
+
|
140
186
|
klass.define_instance_method('find_index') do |method|
|
141
187
|
method.define_optional_argument('obj')
|
142
188
|
end
|
@@ -145,6 +191,8 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
145
191
|
method.define_optional_argument('n')
|
146
192
|
end
|
147
193
|
|
194
|
+
klass.define_instance_method('flat_map')
|
195
|
+
|
148
196
|
klass.define_instance_method('flatten') do |method|
|
149
197
|
method.define_optional_argument('level')
|
150
198
|
end
|
@@ -153,6 +201,12 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
153
201
|
method.define_optional_argument('level')
|
154
202
|
end
|
155
203
|
|
204
|
+
klass.define_instance_method('grep') do |method|
|
205
|
+
method.define_argument('pattern')
|
206
|
+
end
|
207
|
+
|
208
|
+
klass.define_instance_method('group_by')
|
209
|
+
|
156
210
|
klass.define_instance_method('hash')
|
157
211
|
|
158
212
|
klass.define_instance_method('include?') do |method|
|
@@ -163,6 +217,11 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
163
217
|
method.define_optional_argument('obj')
|
164
218
|
end
|
165
219
|
|
220
|
+
klass.define_instance_method('inject') do |method|
|
221
|
+
method.define_optional_argument('initial')
|
222
|
+
method.define_optional_argument('sym')
|
223
|
+
end
|
224
|
+
|
166
225
|
klass.define_instance_method('insert') do |method|
|
167
226
|
method.define_argument('idx')
|
168
227
|
method.define_rest_argument('items')
|
@@ -174,20 +233,36 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
174
233
|
method.define_optional_argument('sep')
|
175
234
|
end
|
176
235
|
|
177
|
-
klass.define_instance_method('keep_if')
|
178
|
-
method.define_block_argument('block')
|
179
|
-
end
|
236
|
+
klass.define_instance_method('keep_if')
|
180
237
|
|
181
238
|
klass.define_instance_method('last') do |method|
|
182
239
|
method.define_optional_argument('n')
|
183
240
|
end
|
184
241
|
|
242
|
+
klass.define_instance_method('lazy')
|
243
|
+
|
185
244
|
klass.define_instance_method('length')
|
186
245
|
|
187
246
|
klass.define_instance_method('map')
|
188
247
|
|
189
248
|
klass.define_instance_method('map!')
|
190
249
|
|
250
|
+
klass.define_instance_method('max')
|
251
|
+
|
252
|
+
klass.define_instance_method('max_by')
|
253
|
+
|
254
|
+
klass.define_instance_method('member?') do |method|
|
255
|
+
method.define_argument('obj')
|
256
|
+
end
|
257
|
+
|
258
|
+
klass.define_instance_method('min')
|
259
|
+
|
260
|
+
klass.define_instance_method('min_by')
|
261
|
+
|
262
|
+
klass.define_instance_method('minmax')
|
263
|
+
|
264
|
+
klass.define_instance_method('minmax_by')
|
265
|
+
|
191
266
|
klass.define_instance_method('new_range') do |method|
|
192
267
|
method.define_argument('start')
|
193
268
|
method.define_argument('count')
|
@@ -199,13 +274,18 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
199
274
|
|
200
275
|
klass.define_instance_method('nitems')
|
201
276
|
|
277
|
+
klass.define_instance_method('none?')
|
278
|
+
|
279
|
+
klass.define_instance_method('one?')
|
280
|
+
|
202
281
|
klass.define_instance_method('pack') do |method|
|
203
282
|
method.define_argument('directives')
|
204
283
|
end
|
205
284
|
|
285
|
+
klass.define_instance_method('partition')
|
286
|
+
|
206
287
|
klass.define_instance_method('permutation') do |method|
|
207
288
|
method.define_optional_argument('num')
|
208
|
-
method.define_block_argument('block')
|
209
289
|
end
|
210
290
|
|
211
291
|
klass.define_instance_method('pop') do |method|
|
@@ -214,7 +294,6 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
214
294
|
|
215
295
|
klass.define_instance_method('product') do |method|
|
216
296
|
method.define_rest_argument('args')
|
217
|
-
method.define_block_argument('block')
|
218
297
|
end
|
219
298
|
|
220
299
|
klass.define_instance_method('push') do |method|
|
@@ -225,22 +304,21 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
225
304
|
method.define_argument('obj')
|
226
305
|
end
|
227
306
|
|
228
|
-
klass.define_instance_method('
|
229
|
-
method.
|
307
|
+
klass.define_instance_method('reduce') do |method|
|
308
|
+
method.define_optional_argument('initial')
|
309
|
+
method.define_optional_argument('sym')
|
230
310
|
end
|
231
311
|
|
232
|
-
klass.define_instance_method('reject
|
233
|
-
|
234
|
-
|
312
|
+
klass.define_instance_method('reject')
|
313
|
+
|
314
|
+
klass.define_instance_method('reject!')
|
235
315
|
|
236
316
|
klass.define_instance_method('repeated_combination') do |method|
|
237
317
|
method.define_argument('combination_size')
|
238
|
-
method.define_block_argument('block')
|
239
318
|
end
|
240
319
|
|
241
320
|
klass.define_instance_method('repeated_permutation') do |method|
|
242
321
|
method.define_argument('combination_size')
|
243
|
-
method.define_block_argument('block')
|
244
322
|
end
|
245
323
|
|
246
324
|
klass.define_instance_method('replace') do |method|
|
@@ -266,14 +344,13 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
266
344
|
end
|
267
345
|
|
268
346
|
klass.define_instance_method('sample') do |method|
|
269
|
-
method.
|
347
|
+
method.define_optional_argument('count')
|
348
|
+
method.define_optional_argument('options')
|
270
349
|
end
|
271
350
|
|
272
351
|
klass.define_instance_method('select')
|
273
352
|
|
274
|
-
klass.define_instance_method('select!')
|
275
|
-
method.define_block_argument('block')
|
276
|
-
end
|
353
|
+
klass.define_instance_method('select!')
|
277
354
|
|
278
355
|
klass.define_instance_method('shelljoin')
|
279
356
|
|
@@ -301,36 +378,42 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
301
378
|
method.define_optional_argument('length')
|
302
379
|
end
|
303
380
|
|
304
|
-
klass.define_instance_method('
|
305
|
-
method.
|
381
|
+
klass.define_instance_method('slice_before') do |method|
|
382
|
+
method.define_optional_argument('arg')
|
306
383
|
end
|
307
384
|
|
308
|
-
klass.define_instance_method('sort
|
309
|
-
method.define_block_argument('block')
|
310
|
-
end
|
385
|
+
klass.define_instance_method('sort')
|
311
386
|
|
312
|
-
klass.define_instance_method('
|
313
|
-
method.define_block_argument('block')
|
314
|
-
end
|
387
|
+
klass.define_instance_method('sort!')
|
315
388
|
|
316
|
-
klass.define_instance_method('
|
317
|
-
|
318
|
-
|
389
|
+
klass.define_instance_method('sort_by')
|
390
|
+
|
391
|
+
klass.define_instance_method('sort_by!')
|
392
|
+
|
393
|
+
klass.define_instance_method('sort_inplace')
|
319
394
|
|
320
395
|
klass.define_instance_method('start')
|
321
396
|
|
322
397
|
klass.define_instance_method('start=')
|
323
398
|
|
399
|
+
klass.define_instance_method('take') do |method|
|
400
|
+
method.define_argument('n')
|
401
|
+
end
|
402
|
+
|
403
|
+
klass.define_instance_method('take_while')
|
404
|
+
|
324
405
|
klass.define_instance_method('to_a')
|
325
406
|
|
326
407
|
klass.define_instance_method('to_ary')
|
327
408
|
|
328
|
-
klass.define_instance_method('to_generator') do |method|
|
329
|
-
method.define_argument('method')
|
330
|
-
end
|
331
|
-
|
332
409
|
klass.define_instance_method('to_s')
|
333
410
|
|
411
|
+
klass.define_instance_method('to_set') do |method|
|
412
|
+
method.define_optional_argument('klass')
|
413
|
+
method.define_rest_argument('args')
|
414
|
+
method.define_block_argument('block')
|
415
|
+
end
|
416
|
+
|
334
417
|
klass.define_instance_method('to_tuple')
|
335
418
|
|
336
419
|
klass.define_instance_method('total')
|
@@ -343,13 +426,9 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
343
426
|
|
344
427
|
klass.define_instance_method('tuple=')
|
345
428
|
|
346
|
-
klass.define_instance_method('uniq')
|
347
|
-
method.define_block_argument('block')
|
348
|
-
end
|
429
|
+
klass.define_instance_method('uniq')
|
349
430
|
|
350
|
-
klass.define_instance_method('uniq!')
|
351
|
-
method.define_block_argument('block')
|
352
|
-
end
|
431
|
+
klass.define_instance_method('uniq!')
|
353
432
|
|
354
433
|
klass.define_instance_method('unshift') do |method|
|
355
434
|
method.define_rest_argument('values')
|
@@ -359,6 +438,10 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
359
438
|
method.define_rest_argument('args')
|
360
439
|
end
|
361
440
|
|
441
|
+
klass.define_instance_method('with_object') do |method|
|
442
|
+
method.define_argument('memo')
|
443
|
+
end
|
444
|
+
|
362
445
|
klass.define_instance_method('zip') do |method|
|
363
446
|
method.define_rest_argument('others')
|
364
447
|
end
|
@@ -368,49 +451,197 @@ RubyLint::GlobalScope.definitions.define_constant('Array') do |klass|
|
|
368
451
|
end
|
369
452
|
end
|
370
453
|
|
371
|
-
|
372
|
-
# Constant: Array::SortedElement
|
373
|
-
# Created: 2013-04-01 18:33:52 +0200
|
374
|
-
# Platform: rbx 2.0.0.rc1
|
375
|
-
#
|
376
|
-
RubyLint::GlobalScope.definitions.define_constant('Array::SortedElement') do |klass|
|
454
|
+
RubyLint::GlobalScope.definitions.define_constant('Array::Enumerator') do |klass|
|
377
455
|
klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
|
378
456
|
|
379
|
-
klass.
|
457
|
+
klass.define_instance_method('all?')
|
380
458
|
|
381
|
-
klass.define_instance_method('
|
382
|
-
|
459
|
+
klass.define_instance_method('any?')
|
460
|
+
|
461
|
+
klass.define_instance_method('chunk') do |method|
|
462
|
+
method.define_optional_argument('initial_state')
|
383
463
|
end
|
384
464
|
|
385
|
-
klass.define_instance_method('
|
386
|
-
|
387
|
-
|
465
|
+
klass.define_instance_method('collect')
|
466
|
+
|
467
|
+
klass.define_instance_method('collect_concat')
|
468
|
+
|
469
|
+
klass.define_instance_method('count') do |method|
|
470
|
+
method.define_optional_argument('item')
|
388
471
|
end
|
389
472
|
|
390
|
-
klass.define_instance_method('
|
473
|
+
klass.define_instance_method('cycle') do |method|
|
474
|
+
method.define_optional_argument('many')
|
475
|
+
end
|
391
476
|
|
392
|
-
klass.define_instance_method('
|
393
|
-
|
477
|
+
klass.define_instance_method('detect') do |method|
|
478
|
+
method.define_optional_argument('ifnone')
|
479
|
+
end
|
394
480
|
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
# Platform: rbx 2.0.0.rc1
|
399
|
-
#
|
400
|
-
RubyLint::GlobalScope.definitions.define_constant('Array::ValueGenerator') do |klass|
|
401
|
-
klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
|
481
|
+
klass.define_instance_method('drop') do |method|
|
482
|
+
method.define_argument('n')
|
483
|
+
end
|
402
484
|
|
403
|
-
klass.
|
485
|
+
klass.define_instance_method('drop_while')
|
404
486
|
|
405
|
-
klass.define_instance_method('
|
406
|
-
method.
|
487
|
+
klass.define_instance_method('each') do |method|
|
488
|
+
method.define_rest_argument('args')
|
489
|
+
end
|
490
|
+
|
491
|
+
klass.define_instance_method('each_cons') do |method|
|
492
|
+
method.define_argument('num')
|
407
493
|
end
|
408
494
|
|
495
|
+
klass.define_instance_method('each_entry') do |method|
|
496
|
+
method.define_rest_argument('pass')
|
497
|
+
end
|
498
|
+
|
499
|
+
klass.define_instance_method('each_slice') do |method|
|
500
|
+
method.define_argument('slice_size')
|
501
|
+
end
|
502
|
+
|
503
|
+
klass.define_instance_method('each_with_index')
|
504
|
+
|
505
|
+
klass.define_instance_method('each_with_object') do |method|
|
506
|
+
method.define_argument('memo')
|
507
|
+
end
|
508
|
+
|
509
|
+
klass.define_instance_method('entries') do |method|
|
510
|
+
method.define_rest_argument('arg')
|
511
|
+
end
|
512
|
+
|
513
|
+
klass.define_instance_method('find') do |method|
|
514
|
+
method.define_optional_argument('ifnone')
|
515
|
+
end
|
516
|
+
|
517
|
+
klass.define_instance_method('find_all')
|
518
|
+
|
519
|
+
klass.define_instance_method('find_index') do |method|
|
520
|
+
method.define_optional_argument('value')
|
521
|
+
end
|
522
|
+
|
523
|
+
klass.define_instance_method('first') do |method|
|
524
|
+
method.define_optional_argument('n')
|
525
|
+
end
|
526
|
+
|
527
|
+
klass.define_instance_method('flat_map')
|
528
|
+
|
529
|
+
klass.define_instance_method('grep') do |method|
|
530
|
+
method.define_argument('pattern')
|
531
|
+
end
|
532
|
+
|
533
|
+
klass.define_instance_method('group_by')
|
534
|
+
|
535
|
+
klass.define_instance_method('include?') do |method|
|
536
|
+
method.define_argument('obj')
|
537
|
+
end
|
538
|
+
|
539
|
+
klass.define_instance_method('inject') do |method|
|
540
|
+
method.define_optional_argument('initial')
|
541
|
+
method.define_optional_argument('sym')
|
542
|
+
end
|
543
|
+
|
544
|
+
klass.define_instance_method('lazy')
|
545
|
+
|
546
|
+
klass.define_instance_method('map')
|
547
|
+
|
548
|
+
klass.define_instance_method('max')
|
549
|
+
|
550
|
+
klass.define_instance_method('max_by')
|
551
|
+
|
552
|
+
klass.define_instance_method('member?') do |method|
|
553
|
+
method.define_argument('obj')
|
554
|
+
end
|
555
|
+
|
556
|
+
klass.define_instance_method('min')
|
557
|
+
|
558
|
+
klass.define_instance_method('min_by')
|
559
|
+
|
560
|
+
klass.define_instance_method('minmax')
|
561
|
+
|
562
|
+
klass.define_instance_method('minmax_by')
|
563
|
+
|
409
564
|
klass.define_instance_method('next')
|
410
565
|
|
411
|
-
klass.define_instance_method('
|
566
|
+
klass.define_instance_method('next_values')
|
567
|
+
|
568
|
+
klass.define_instance_method('none?')
|
569
|
+
|
570
|
+
klass.define_instance_method('one?')
|
571
|
+
|
572
|
+
klass.define_instance_method('partition')
|
573
|
+
|
574
|
+
klass.define_instance_method('peek')
|
575
|
+
|
576
|
+
klass.define_instance_method('peek_values')
|
577
|
+
|
578
|
+
klass.define_instance_method('reduce') do |method|
|
579
|
+
method.define_optional_argument('initial')
|
580
|
+
method.define_optional_argument('sym')
|
581
|
+
end
|
582
|
+
|
583
|
+
klass.define_instance_method('reject')
|
584
|
+
|
585
|
+
klass.define_instance_method('reverse_each')
|
412
586
|
|
413
587
|
klass.define_instance_method('rewind')
|
588
|
+
|
589
|
+
klass.define_instance_method('select')
|
590
|
+
|
591
|
+
klass.define_instance_method('size')
|
592
|
+
|
593
|
+
klass.define_instance_method('slice_before') do |method|
|
594
|
+
method.define_optional_argument('arg')
|
595
|
+
end
|
596
|
+
|
597
|
+
klass.define_instance_method('sort')
|
598
|
+
|
599
|
+
klass.define_instance_method('sort_by')
|
600
|
+
|
601
|
+
klass.define_instance_method('take') do |method|
|
602
|
+
method.define_argument('n')
|
603
|
+
end
|
604
|
+
|
605
|
+
klass.define_instance_method('take_while')
|
606
|
+
|
607
|
+
klass.define_instance_method('to_a') do |method|
|
608
|
+
method.define_rest_argument('arg')
|
609
|
+
end
|
610
|
+
|
611
|
+
klass.define_instance_method('to_set') do |method|
|
612
|
+
method.define_optional_argument('klass')
|
613
|
+
method.define_rest_argument('args')
|
614
|
+
method.define_block_argument('block')
|
615
|
+
end
|
616
|
+
|
617
|
+
klass.define_instance_method('with_index') do |method|
|
618
|
+
method.define_optional_argument('offset')
|
619
|
+
end
|
620
|
+
|
621
|
+
klass.define_instance_method('with_object') do |method|
|
622
|
+
method.define_argument('memo')
|
623
|
+
end
|
624
|
+
|
625
|
+
klass.define_instance_method('zip') do |method|
|
626
|
+
method.define_rest_argument('args')
|
627
|
+
end
|
628
|
+
end
|
629
|
+
|
630
|
+
RubyLint::GlobalScope.definitions.define_constant('Array::SortedElement') do |klass|
|
631
|
+
klass.inherits(RubyLint::GlobalScope.constant_proxy('Object'))
|
632
|
+
|
633
|
+
klass.define_instance_method('<=>') do |method|
|
634
|
+
method.define_argument('other')
|
635
|
+
end
|
636
|
+
|
637
|
+
klass.define_instance_method('initialize') do |method|
|
638
|
+
method.define_argument('val')
|
639
|
+
method.define_argument('sort_id')
|
640
|
+
end
|
641
|
+
|
642
|
+
klass.define_instance_method('sort_id')
|
643
|
+
|
644
|
+
klass.define_instance_method('value')
|
414
645
|
end
|
415
646
|
|
416
|
-
RubyLint::GlobalScope.definitions.lookup(:const, 'Array').deep_freeze
|
647
|
+
RubyLint::GlobalScope.definitions.lookup(:const, 'Array').deep_freeze
|