ruby-lint 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56bd721e0aca3a78130df4c345585657f7f01118
4
- data.tar.gz: 3c9631f8a0740b18165f13bdc4bea569fd11fadd
3
+ metadata.gz: a5355b24009dac40be5b9313a612e968f2b71336
4
+ data.tar.gz: d1b276f90c9fadb73252b8f07f934764cca283f0
5
5
  SHA512:
6
- metadata.gz: 6cb899c24380a7d86fe129f0b56a3893bf3de04a4b4319544c587974ac19a44294e979851c7b10522bb2ace0643dff0ecc23070ed03b60788f104eda7e7fb2df
7
- data.tar.gz: c5b17aad2123653d3ec0be97f715d5986e9ee2b0ef09739c606fcee003af2cabb6f8174724207ecf0fc76bee9c3e347bec8bfb7e4c68a797336788ed43a61f14
6
+ metadata.gz: f12df86be5066b3d541656d5e14f52bd8ab89948653fd295d9f3ddc0280850c5042531594b6efe8b68cceb3c69004a28f166e8d985a6bf26727200335d69f1ae
7
+ data.tar.gz: 6ad9f338d114d2346a488192fea36d9360dad21204d8b990543eea99e5af55220f5e4d02d255ec58f64196e7994ec855dfffe4fd4bc8d16a5ebe0a508276e60f
data/README.md CHANGED
@@ -83,32 +83,27 @@ the following output:
83
83
  test.rb: warning: line 12, column 1: unused local variable greeting
84
84
  test.rb: error: line 14, column 1: wrong number of arguments (expected 0 but got 1)
85
85
 
86
- ## Integration
87
-
88
- * Vim using [Syntastic][syntastic]
89
- * Emacs using [Flycheck][flycheck]
90
-
91
- ## ruby-lint versus Rubocop
86
+ ## ruby-lint versus RuboCop
92
87
 
93
88
  A question commonly asked is what purpose ruby-lint serves compared to other
94
- tools such as [Rubocop][rubocop]. After all, upon first sight the two tools
89
+ tools such as [RuboCop][rubocop]. After all, upon first sight the two tools
95
90
  look pretty similar.
96
91
 
97
- The big difference between ruby-lint and Rubocop is that ruby-lint focuses
92
+ The big difference between ruby-lint and RuboCop is that ruby-lint focuses
98
93
  primarily on technical problems such as the use of undefined methods/variables,
99
- unused variables/method arguments and more. Rubocop on the other hand focuses
94
+ unused variables/method arguments and more. RuboCop on the other hand focuses
100
95
  mostly on style related issues based on a community driven Ruby style guide.
101
96
  This means that it will for example warn you about methods written using
102
97
  camelCase and method bodies that are considered to be too long.
103
98
 
104
- Personally I have little interest in adding style related analysis as Rubocop
99
+ Personally I have little interest in adding style related analysis as RuboCop
105
100
  already does that and in my opinion does a far better job at it. I also simply
106
101
  think it's too boring to write analysis like this. Having said that, ruby-lint
107
102
  has some basic style related analysis (e.g. the use of `BEGIN`) but this mostly
108
103
  serves as a simple example on how to write analysis code.
109
104
 
110
105
  In the end it depends on what your needs are. If you have a team that's having
111
- trouble following a consistent coding style then Rubocop is probably the right
106
+ trouble following a consistent coding style then RuboCop is probably the right
112
107
  tool for the job. On the other hand, if you're trying to debug a nasty bug then
113
108
  ruby-lint will most likely be more useful.
114
109
 
@@ -141,7 +136,5 @@ All source code in this repository is licensed under the MIT license unless
141
136
  specified otherwise. A copy of this license can be found in the file "LICENSE"
142
137
  in the root directory of this repository.
143
138
 
144
- [syntastic]: https://github.com/scrooloose/syntastic
145
- [flycheck]: https://github.com/flycheck/flycheck/
146
139
  [rubocop]: https://github.com/bbatsov/rubocop
147
140
  [yard]: http://yardoc.org/
@@ -0,0 +1 @@
1
+ 74d06cbed15bf1cbadd58a35a36e1984ba9081c68b9e0db9ed324197c05b9139e382ec26e667bfac1a5336ba31f91feb2a2f0fccef687df24f506fdc7331624d
@@ -5,6 +5,18 @@ This document contains a short summary of the various releases of ruby-lint.
5
5
  For a full list of commits included in each release see the corresponding Git
6
6
  tags (named after the versions).
7
7
 
8
+ ## 2.0.3 - 2015-01-09
9
+
10
+ * ruby-lint now adds errors for certain iteration/loop keywords that are used
11
+ outside of loops. See <http://git.io/dsVzhA> for more information.
12
+ * The FileScanner was modified to allow it to process directories containing
13
+ dashes, see <http://git.io/eNiq9A> for more information.
14
+ * Definitions for Mongoid, Sinatra, win32ole, glib2, gtk3, libxml, RubyTree, and
15
+ the ALM REST API were added.
16
+ * Usage of `Array#|` has been replaced with `Array#+` in
17
+ `RubyObject#determine_parent`, leading to a small performance boost, see
18
+ <http://git.io/1SIguw> for more information.
19
+
8
20
  ## 2.0.2 - 2014-08-05
9
21
 
10
22
  * Definitions for Celluloid have been added.
@@ -67,6 +67,7 @@ require_relative 'ruby-lint/analysis/undefined_methods'
67
67
  require_relative 'ruby-lint/analysis/argument_amount'
68
68
  require_relative 'ruby-lint/analysis/pedantics'
69
69
  require_relative 'ruby-lint/analysis/useless_equality_checks'
70
+ require_relative 'ruby-lint/analysis/loop_keywords'
70
71
 
71
72
  require_relative 'ruby-lint/report'
72
73
  require_relative 'ruby-lint/report/entry'
@@ -0,0 +1,66 @@
1
+ module RubyLint
2
+ module Analysis
3
+ ##
4
+ # Analysis class that checks if certain keywords are used inside a
5
+ # block/loop or not. For example, the following is not valid Ruby code:
6
+ #
7
+ # next
8
+ #
9
+ # But the following is valid:
10
+ #
11
+ # [10, 20].each do |n|
12
+ # next
13
+ # end
14
+ #
15
+ # The following isn't valid either:
16
+ #
17
+ # def foo
18
+ # next
19
+ # end
20
+ #
21
+ # See {KEYWORDS} for a list of the keywords that can only be used inside a
22
+ # loop.
23
+ #
24
+ class LoopKeywords < Base
25
+ register 'loop_keywords'
26
+
27
+ ##
28
+ # List of keywords that can only be used inside a loop.
29
+ #
30
+ # @return [Array]
31
+ #
32
+ KEYWORDS = [:next, :break]
33
+
34
+ ##
35
+ # List of statements that do allow the use of the various keywords.
36
+ #
37
+ # @return [Array]
38
+ #
39
+ STATEMENTS = [:while, :until, :for]
40
+
41
+ KEYWORDS.each do |kw|
42
+ define_method("on_#{kw}") { |node| verify_keyword(kw, node) }
43
+ end
44
+
45
+ STATEMENTS.each do |statement|
46
+ define_method("on_#{statement}") do
47
+ @allow_keyword = true
48
+ end
49
+
50
+ define_method("after_#{statement}") do
51
+ @allow_keyword = false
52
+ end
53
+ end
54
+
55
+ ##
56
+ # @param [Symbol] keyword
57
+ # @param [RubyLint::AST::Node] node
58
+ #
59
+ def verify_keyword(keyword, node)
60
+ if current_scope.type != :block and !@allow_keyword
61
+ error("#{keyword} can only be used inside a loop/block", node)
62
+ end
63
+ end
64
+ end # BlockKeywords
65
+ end # Analysis
66
+ end # RubyLint
@@ -1,9 +1,20 @@
1
1
  module RubyLint
2
2
  module Analysis
3
3
  ##
4
- # The {RubyLint::Analysis::UselessRuby} class checks for various useless
5
- # Ruby features, the use of redundant tokens such as `then` for `if`
6
- # statements and various other pedantics.
4
+ # This class adds (pedantic) warnings for various features that aren't
5
+ # really that useful or needed. This serves mostly as a simple example on
6
+ # how to write an analysis class.
7
+ #
8
+ # Currently warnings are added for the following:
9
+ #
10
+ # * BEGIN/END blocks
11
+ # * Statements that use `then` or `do` when it's not needed
12
+ #
13
+ # For example:
14
+ #
15
+ # BEGIN { puts 'foo' }
16
+ #
17
+ # This would result in the warning "BEGIN/END is useless" being added.
7
18
  #
8
19
  class Pedantics < Base
9
20
  register 'pedantics'
@@ -697,7 +697,9 @@ module RubyLint
697
697
  if parent.type == type and parent.name == name
698
698
  parent_definition = parent
699
699
  else
700
- parent_definition = parent.lookup(type, name, true, exclude | [self])
700
+ exclude = exclude + [self] unless exclude.include?(self)
701
+
702
+ parent_definition = parent.lookup(type, name, true, exclude)
701
703
  end
702
704
 
703
705
  return parent_definition
@@ -0,0 +1,312 @@
1
+ # This file was automatically generated, any manual changes will be lost the
2
+ # next time this file is generated.
3
+ #
4
+ # Platform: ruby 1.9.3
5
+
6
+ RubyLint.registry.register('WIN32OLE') do |defs|
7
+ defs.define_constant('WIN32OLE') do |klass|
8
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
9
+
10
+ klass.define_method('codepage')
11
+
12
+ klass.define_method('codepage=') do |method|
13
+ method.define_argument('arg1')
14
+ end
15
+
16
+ klass.define_method('connect') do |method|
17
+ method.define_rest_argument('arg1')
18
+ end
19
+
20
+ klass.define_method('const_load') do |method|
21
+ method.define_rest_argument('arg1')
22
+ end
23
+
24
+ klass.define_method('create_guid')
25
+
26
+ klass.define_method('locale')
27
+
28
+ klass.define_method('locale=') do |method|
29
+ method.define_argument('arg1')
30
+ end
31
+
32
+ klass.define_method('ole_free') do |method|
33
+ method.define_argument('arg1')
34
+ end
35
+
36
+ klass.define_method('ole_initialize')
37
+
38
+ klass.define_method('ole_reference_count') do |method|
39
+ method.define_argument('arg1')
40
+ end
41
+
42
+ klass.define_method('ole_show_help') do |method|
43
+ method.define_rest_argument('arg1')
44
+ end
45
+
46
+ klass.define_method('ole_uninitialize')
47
+
48
+ klass.define_instance_method('[]') do |method|
49
+ method.define_rest_argument('arg1')
50
+ end
51
+
52
+ klass.define_instance_method('[]=') do |method|
53
+ method.define_rest_argument('arg1')
54
+ end
55
+
56
+ klass.define_instance_method('_getproperty') do |method|
57
+ method.define_argument('arg1')
58
+ method.define_argument('arg2')
59
+ method.define_argument('arg3')
60
+ end
61
+
62
+ klass.define_instance_method('_invoke') do |method|
63
+ method.define_argument('arg1')
64
+ method.define_argument('arg2')
65
+ method.define_argument('arg3')
66
+ end
67
+
68
+ klass.define_instance_method('_setproperty') do |method|
69
+ method.define_argument('arg1')
70
+ method.define_argument('arg2')
71
+ method.define_argument('arg3')
72
+ end
73
+
74
+ klass.define_instance_method('each')
75
+
76
+ klass.define_instance_method('invoke') do |method|
77
+ method.define_rest_argument('arg1')
78
+ end
79
+
80
+ klass.define_instance_method('method_missing') do |method|
81
+ method.define_rest_argument('arg1')
82
+ end
83
+
84
+ klass.define_instance_method('ole_activex_initialize')
85
+
86
+ klass.define_instance_method('ole_free')
87
+
88
+ klass.define_instance_method('ole_func_methods')
89
+
90
+ klass.define_instance_method('ole_get_methods')
91
+
92
+ klass.define_instance_method('ole_method') do |method|
93
+ method.define_argument('arg1')
94
+ end
95
+
96
+ klass.define_instance_method('ole_method_help') do |method|
97
+ method.define_argument('arg1')
98
+ end
99
+
100
+ klass.define_instance_method('ole_methods')
101
+
102
+ klass.define_instance_method('ole_obj_help')
103
+
104
+ klass.define_instance_method('ole_put_methods')
105
+
106
+ klass.define_instance_method('ole_query_interface') do |method|
107
+ method.define_argument('arg1')
108
+ end
109
+
110
+ klass.define_instance_method('ole_respond_to?') do |method|
111
+ method.define_argument('arg1')
112
+ end
113
+
114
+ klass.define_instance_method('ole_type')
115
+
116
+ klass.define_instance_method('ole_typelib')
117
+
118
+ klass.define_instance_method('setproperty') do |method|
119
+ method.define_rest_argument('arg1')
120
+ end
121
+ end
122
+
123
+ defs.define_constant('WIN32OLE::ARGV') do |klass|
124
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
125
+
126
+ end
127
+
128
+ defs.define_constant('WIN32OLE::CP_ACP') do |klass|
129
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
130
+
131
+ end
132
+
133
+ defs.define_constant('WIN32OLE::CP_MACCP') do |klass|
134
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
135
+
136
+ end
137
+
138
+ defs.define_constant('WIN32OLE::CP_OEMCP') do |klass|
139
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
140
+
141
+ end
142
+
143
+ defs.define_constant('WIN32OLE::CP_SYMBOL') do |klass|
144
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
145
+
146
+ end
147
+
148
+ defs.define_constant('WIN32OLE::CP_THREAD_ACP') do |klass|
149
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
150
+
151
+ end
152
+
153
+ defs.define_constant('WIN32OLE::CP_UTF7') do |klass|
154
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
155
+
156
+ end
157
+
158
+ defs.define_constant('WIN32OLE::CP_UTF8') do |klass|
159
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
160
+
161
+ end
162
+
163
+ defs.define_constant('WIN32OLE::LOCALE_SYSTEM_DEFAULT') do |klass|
164
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
165
+
166
+ end
167
+
168
+ defs.define_constant('WIN32OLE::LOCALE_USER_DEFAULT') do |klass|
169
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
170
+
171
+ end
172
+
173
+ defs.define_constant('WIN32OLE::VARIANT') do |klass|
174
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
175
+
176
+ end
177
+
178
+ defs.define_constant('WIN32OLE::VARIANT::VT_ARRAY') do |klass|
179
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
180
+
181
+ end
182
+
183
+ defs.define_constant('WIN32OLE::VARIANT::VT_BOOL') do |klass|
184
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
185
+
186
+ end
187
+
188
+ defs.define_constant('WIN32OLE::VARIANT::VT_BSTR') do |klass|
189
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
190
+
191
+ end
192
+
193
+ defs.define_constant('WIN32OLE::VARIANT::VT_BYREF') do |klass|
194
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
195
+
196
+ end
197
+
198
+ defs.define_constant('WIN32OLE::VARIANT::VT_CY') do |klass|
199
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
200
+
201
+ end
202
+
203
+ defs.define_constant('WIN32OLE::VARIANT::VT_DATE') do |klass|
204
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
205
+
206
+ end
207
+
208
+ defs.define_constant('WIN32OLE::VARIANT::VT_DISPATCH') do |klass|
209
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
210
+
211
+ end
212
+
213
+ defs.define_constant('WIN32OLE::VARIANT::VT_EMPTY') do |klass|
214
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
215
+
216
+ end
217
+
218
+ defs.define_constant('WIN32OLE::VARIANT::VT_ERROR') do |klass|
219
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
220
+
221
+ end
222
+
223
+ defs.define_constant('WIN32OLE::VARIANT::VT_I1') do |klass|
224
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
225
+
226
+ end
227
+
228
+ defs.define_constant('WIN32OLE::VARIANT::VT_I2') do |klass|
229
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
230
+
231
+ end
232
+
233
+ defs.define_constant('WIN32OLE::VARIANT::VT_I4') do |klass|
234
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
235
+
236
+ end
237
+
238
+ defs.define_constant('WIN32OLE::VARIANT::VT_I8') do |klass|
239
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
240
+
241
+ end
242
+
243
+ defs.define_constant('WIN32OLE::VARIANT::VT_INT') do |klass|
244
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
245
+
246
+ end
247
+
248
+ defs.define_constant('WIN32OLE::VARIANT::VT_NULL') do |klass|
249
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
250
+
251
+ end
252
+
253
+ defs.define_constant('WIN32OLE::VARIANT::VT_PTR') do |klass|
254
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
255
+
256
+ end
257
+
258
+ defs.define_constant('WIN32OLE::VARIANT::VT_R4') do |klass|
259
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
260
+
261
+ end
262
+
263
+ defs.define_constant('WIN32OLE::VARIANT::VT_R8') do |klass|
264
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
265
+
266
+ end
267
+
268
+ defs.define_constant('WIN32OLE::VARIANT::VT_UI1') do |klass|
269
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
270
+
271
+ end
272
+
273
+ defs.define_constant('WIN32OLE::VARIANT::VT_UI2') do |klass|
274
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
275
+
276
+ end
277
+
278
+ defs.define_constant('WIN32OLE::VARIANT::VT_UI4') do |klass|
279
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
280
+
281
+ end
282
+
283
+ defs.define_constant('WIN32OLE::VARIANT::VT_UI8') do |klass|
284
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
285
+
286
+ end
287
+
288
+ defs.define_constant('WIN32OLE::VARIANT::VT_UINT') do |klass|
289
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
290
+
291
+ end
292
+
293
+ defs.define_constant('WIN32OLE::VARIANT::VT_UNKNOWN') do |klass|
294
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
295
+
296
+ end
297
+
298
+ defs.define_constant('WIN32OLE::VARIANT::VT_USERDEFINED') do |klass|
299
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
300
+
301
+ end
302
+
303
+ defs.define_constant('WIN32OLE::VARIANT::VT_VARIANT') do |klass|
304
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
305
+
306
+ end
307
+
308
+ defs.define_constant('WIN32OLE::VERSION') do |klass|
309
+ klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
310
+
311
+ end
312
+ end