rubycop 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/lib/rubycop.rb +6 -0
- data/lib/rubycop/analyzer.rb +6 -0
- data/lib/rubycop/analyzer/gray_list.rb +28 -0
- data/lib/rubycop/analyzer/node_builder.rb +523 -0
- data/lib/rubycop/analyzer/policy.rb +354 -0
- data/lib/rubycop/analyzer/ruby.rb +24 -0
- data/lib/rubycop/analyzer/ruby/args.rb +28 -0
- data/lib/rubycop/analyzer/ruby/array.rb +11 -0
- data/lib/rubycop/analyzer/ruby/assignment.rb +45 -0
- data/lib/rubycop/analyzer/ruby/assoc.rb +15 -0
- data/lib/rubycop/analyzer/ruby/blocks.rb +23 -0
- data/lib/rubycop/analyzer/ruby/call.rb +33 -0
- data/lib/rubycop/analyzer/ruby/case.rb +24 -0
- data/lib/rubycop/analyzer/ruby/constants.rb +49 -0
- data/lib/rubycop/analyzer/ruby/definitions.rb +27 -0
- data/lib/rubycop/analyzer/ruby/for.rb +17 -0
- data/lib/rubycop/analyzer/ruby/hash.rb +13 -0
- data/lib/rubycop/analyzer/ruby/if.rb +33 -0
- data/lib/rubycop/analyzer/ruby/list.rb +17 -0
- data/lib/rubycop/analyzer/ruby/node.rb +11 -0
- data/lib/rubycop/analyzer/ruby/operators.rb +54 -0
- data/lib/rubycop/analyzer/ruby/params.rb +23 -0
- data/lib/rubycop/analyzer/ruby/position.rb +15 -0
- data/lib/rubycop/analyzer/ruby/range.rb +17 -0
- data/lib/rubycop/analyzer/ruby/statements.rb +34 -0
- data/lib/rubycop/analyzer/ruby/string.rb +26 -0
- data/lib/rubycop/analyzer/ruby/tokens.rb +46 -0
- data/lib/rubycop/analyzer/ruby/variables.rb +26 -0
- data/lib/rubycop/analyzer/ruby/while.rb +29 -0
- data/lib/rubycop/version.rb +3 -0
- data/rubycop.gemspec +25 -0
- data/spec/node_builder_spec.rb +374 -0
- data/spec/policy_spec.rb +405 -0
- metadata +97 -0
data/spec/policy_spec.rb
ADDED
@@ -0,0 +1,405 @@
|
|
1
|
+
require 'rubycop'
|
2
|
+
|
3
|
+
describe Rubycop::Analyzer::Policy do
|
4
|
+
let(:policy) { described_class.new }
|
5
|
+
subject { policy }
|
6
|
+
|
7
|
+
RSpec::Matchers.define(:allow) do |ruby|
|
8
|
+
match { |policy| Rubycop::Analyzer::NodeBuilder.build(ruby).accept(policy) }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "assignment" do
|
12
|
+
context "class variables" do
|
13
|
+
it { should_not allow('@@x = 1') }
|
14
|
+
it { should_not allow('@@x ||= 1') }
|
15
|
+
it { should_not allow('@@x += 1') }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "constants" do
|
19
|
+
it { should allow('Foo = 1') }
|
20
|
+
it { should allow('Foo::Bar = 1') }
|
21
|
+
it { should allow('::Bar = 1') }
|
22
|
+
|
23
|
+
it { should_not allow('Foo = Kernel') }
|
24
|
+
it { should_not allow('Foo = ::Kernel') }
|
25
|
+
it { should_not allow('Foo = Object::Kernel') }
|
26
|
+
end
|
27
|
+
|
28
|
+
context "globals" do
|
29
|
+
it { should_not allow('$x = 1') }
|
30
|
+
it { should_not allow('$x ||= 1') }
|
31
|
+
it { should_not allow('$x += 1') }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "instance variables" do
|
35
|
+
it { should allow('@x = 1') }
|
36
|
+
it { should allow('@x += 1') }
|
37
|
+
it { should_not allow('@x = $x') }
|
38
|
+
it { should_not allow('@x = @@x') }
|
39
|
+
end
|
40
|
+
|
41
|
+
context "locals" do
|
42
|
+
it { should allow('x = 1') }
|
43
|
+
it { should allow('x ||= 1') }
|
44
|
+
it { should allow('x += 1') }
|
45
|
+
it { should_not allow('x = $x') }
|
46
|
+
it { should_not allow('x = @@x') }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "begin/rescue/ensure" do
|
51
|
+
it { should allow('begin; x; rescue; end') }
|
52
|
+
it { should allow('x rescue 1') }
|
53
|
+
|
54
|
+
it { should_not allow('begin; `ls`; rescue; x; end') }
|
55
|
+
it { should_not allow('begin; x; rescue; `ls`; end') }
|
56
|
+
it { should_not allow('begin; x; rescue; 1; ensure `ls`; end') }
|
57
|
+
it { should_not allow('`ls` rescue 1') }
|
58
|
+
it { should_not allow('x rescue `ls`') }
|
59
|
+
it { should_not allow('begin; x; rescue (`ls`; RuntimeError) => err; end') }
|
60
|
+
end
|
61
|
+
|
62
|
+
context "blocks" do
|
63
|
+
it { should_not allow('->(a = $x) { }') }
|
64
|
+
it { should_not allow('->(a) { $x }') }
|
65
|
+
it { should_not allow('lambda { $x }') }
|
66
|
+
it { should_not allow('proc { $x }') }
|
67
|
+
end
|
68
|
+
|
69
|
+
context "calls" do
|
70
|
+
it { should allow('foo { 1 }') }
|
71
|
+
it { should_not allow('foo { $x }') }
|
72
|
+
|
73
|
+
context "blacklist" do
|
74
|
+
# This is a tricky case where we want to allow methods like
|
75
|
+
# Enumerable#select, but not Kernel#select / IO#select.
|
76
|
+
it { should allow('[1, 2, 3].select { |x| x.odd? }') }
|
77
|
+
it { should_not allow('select([$stdin], nil, nil, 1.5)') }
|
78
|
+
|
79
|
+
# TODO: these are a possible concern because symbols are not GC'ed and
|
80
|
+
# an attacker could create a large number of them to eat up memory. If
|
81
|
+
# these methods are blacklisted, then dyna-symbols (:"foo#{x}") need to
|
82
|
+
# be restricted as well.
|
83
|
+
it { should allow('"abc".intern') }
|
84
|
+
it { should allow('"abc".to_sym') }
|
85
|
+
|
86
|
+
it { should_not allow('abort("fail")') }
|
87
|
+
it { should_not allow('alias :foo :bar') }
|
88
|
+
it { should_not allow('alias foo bar') }
|
89
|
+
it { should_not allow('alias_method(:foo, :bar)') }
|
90
|
+
it { should_not allow('at_exit { puts "Bye!" }')}
|
91
|
+
it { should_not allow('autoload(:Foo, "foo")') }
|
92
|
+
it { should_not allow('binding') }
|
93
|
+
it { should_not allow('binding()') }
|
94
|
+
it { should_not allow('callcc { |cont| }') }
|
95
|
+
it { should_not allow('caller') }
|
96
|
+
it { should_not allow('caller()') }
|
97
|
+
it { should_not allow('caller(1)') }
|
98
|
+
it { should_not allow('class_eval("$x = 1")') }
|
99
|
+
it { should_not allow('const_get(:Kernel)') }
|
100
|
+
it { should_not allow('const_set(:Foo, ::Kernel)') }
|
101
|
+
it { should_not allow('eval("`ls`")') }
|
102
|
+
it { should_not allow('exec("ls")') }
|
103
|
+
it { should_not allow('exit') }
|
104
|
+
it { should_not allow('exit()') }
|
105
|
+
it { should_not allow('fail') }
|
106
|
+
it { should_not allow('fail("failed")') }
|
107
|
+
it { should_not allow('fail()') }
|
108
|
+
it { should_not allow('fork { }') }
|
109
|
+
it { should_not allow('fork') }
|
110
|
+
it { should_not allow('fork()') }
|
111
|
+
it { should_not allow('gets') }
|
112
|
+
it { should_not allow('gets()') }
|
113
|
+
it { should_not allow('global_variables') }
|
114
|
+
it { should_not allow('global_variables()') }
|
115
|
+
it { should_not allow('load("foo")') }
|
116
|
+
it { should_not allow('loop { }') }
|
117
|
+
it { should_not allow('method(:eval)') }
|
118
|
+
it { should_not allow('module_eval("`ls`")') }
|
119
|
+
it { should_not allow('open("/etc/passwd")') }
|
120
|
+
it { should_not allow('readline') }
|
121
|
+
it { should_not allow('readline()') }
|
122
|
+
it { should_not allow('readlines') }
|
123
|
+
it { should_not allow('readlines()') }
|
124
|
+
it { should_not allow('redo') }
|
125
|
+
it { should_not allow('remove_const(:Kernel)') }
|
126
|
+
it { should_not allow('require("digest/md5")') }
|
127
|
+
it { should_not allow('send(:eval, "`ls`")') }
|
128
|
+
it { should_not allow('set_trace_func(proc { |event,file,line,id,binding,classname| })') }
|
129
|
+
it { should_not allow('sleep(100**100)') }
|
130
|
+
it { should_not allow('spawn("ls", :chdir => "/")') }
|
131
|
+
it { should_not allow('srand') }
|
132
|
+
it { should_not allow('srand()') }
|
133
|
+
it { should_not allow('srand(1)') }
|
134
|
+
it { should_not allow('syscall(4, 1, "hello\n", 6)') }
|
135
|
+
it { should_not allow('system("ls")') }
|
136
|
+
it { should_not allow('trap("EXIT") { }') }
|
137
|
+
it { should_not allow('undef :raise') }
|
138
|
+
it { should_not allow('undef raise') }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "case" do
|
143
|
+
it { should allow('case x; when 1; 2; end') }
|
144
|
+
|
145
|
+
it { should_not allow('case $x; when 1; 2; end') }
|
146
|
+
it { should_not allow('case $x = 1; when 1; 2; end') }
|
147
|
+
it { should_not allow('case x; when $x; 2; end') }
|
148
|
+
it { should_not allow('case x; when 1; $x; end') }
|
149
|
+
end
|
150
|
+
|
151
|
+
context "class / module definition" do
|
152
|
+
it { should allow("class Foo\nend") }
|
153
|
+
it { should allow("class Foo::Bar\nend") }
|
154
|
+
|
155
|
+
it { should allow("module Foo\nend") }
|
156
|
+
it { should allow("module Foo::Bar\nend") }
|
157
|
+
it { should_not allow("module Kernel\nend") }
|
158
|
+
it { should_not allow("module ::Kernel\nend") }
|
159
|
+
end
|
160
|
+
|
161
|
+
context "defined?" do
|
162
|
+
it { should_not allow('defined?(Kernel)') }
|
163
|
+
end
|
164
|
+
|
165
|
+
context "dynamic strings" do
|
166
|
+
it { should_not allow('"abc#{`ls`}"') }
|
167
|
+
it { should_not allow('"#{`ls`}abc"') }
|
168
|
+
it { should_not allow('"#$0"') }
|
169
|
+
end
|
170
|
+
|
171
|
+
context "dynamic symbols" do
|
172
|
+
it { should_not allow(':"abc#{`ls`}"') }
|
173
|
+
it { should_not allow(':"#{`ls`}abc"') }
|
174
|
+
end
|
175
|
+
|
176
|
+
context "for" do
|
177
|
+
it { should_not allow('for i in ENV; puts i; end') }
|
178
|
+
it { should_not allow('for $x in [1, 2, 3]; puts $x; end') }
|
179
|
+
end
|
180
|
+
|
181
|
+
context "if/elsif/else" do
|
182
|
+
it { should allow('x if true') }
|
183
|
+
|
184
|
+
it { should_not allow('$x ? 1 : 2') }
|
185
|
+
it { should_not allow('true ? $x : 2') }
|
186
|
+
it { should_not allow('true ? 1 : $x') }
|
187
|
+
it { should_not allow('if $x; 1; end') }
|
188
|
+
it { should_not allow('if true; $x; end') }
|
189
|
+
it { should_not allow('$x if true') }
|
190
|
+
it { should_not allow('true if $x') }
|
191
|
+
it { should_not allow('if $x; 1; else 2; end') }
|
192
|
+
it { should_not allow('if 1; $x; else 2; end') }
|
193
|
+
it { should_not allow('if 1; 1; else $x; end') }
|
194
|
+
it { should_not allow('if 1; 1; elsif 2; 2; else $x; end') }
|
195
|
+
end
|
196
|
+
|
197
|
+
context "literals" do
|
198
|
+
it { should allow('"abc"') }
|
199
|
+
it { should allow('/abc/') }
|
200
|
+
it { should allow('1') }
|
201
|
+
it { should allow('1..2') }
|
202
|
+
it { should allow('1.2') }
|
203
|
+
it { should allow('false') }
|
204
|
+
it { should allow('nil') }
|
205
|
+
it { should allow('true') }
|
206
|
+
it { should allow('[]') }
|
207
|
+
it { should allow('[1,2,3]') }
|
208
|
+
it { should allow('{}') }
|
209
|
+
it { should allow('{1 => 2}') }
|
210
|
+
end
|
211
|
+
|
212
|
+
context "magic variables" do
|
213
|
+
it { should_not allow('__callee__') }
|
214
|
+
it { should_not allow('__FILE__') }
|
215
|
+
it { should_not allow('__method__') }
|
216
|
+
end
|
217
|
+
|
218
|
+
context "methods" do
|
219
|
+
it { should allow('def initialize(attributes={}); end') }
|
220
|
+
end
|
221
|
+
|
222
|
+
context "singleton class" do
|
223
|
+
it { should_not allow('class << Kernel; end') }
|
224
|
+
it { should_not allow('class << Kernel; `ls`; end') }
|
225
|
+
end
|
226
|
+
|
227
|
+
context "super" do
|
228
|
+
it { should allow('super') }
|
229
|
+
it { should allow('super()') }
|
230
|
+
it { should allow('super(1)') }
|
231
|
+
it { should_not allow('super($x)') }
|
232
|
+
end
|
233
|
+
|
234
|
+
context "system" do
|
235
|
+
it { should_not allow('`ls`') }
|
236
|
+
it { should_not allow('%x[ls]') }
|
237
|
+
it { should_not allow('system("ls")') }
|
238
|
+
end
|
239
|
+
|
240
|
+
context "unless" do
|
241
|
+
it { should_not allow('unless $x; 1; end') }
|
242
|
+
it { should_not allow('unless true; $x; end') }
|
243
|
+
it { should_not allow('$x unless true') }
|
244
|
+
it { should_not allow('true unless $x') }
|
245
|
+
it { should_not allow('unless $x; 1; else 2; end') }
|
246
|
+
it { should_not allow('unless 1; $x; else 2; end') }
|
247
|
+
it { should_not allow('unless 1; 1; else $x; end') }
|
248
|
+
end
|
249
|
+
|
250
|
+
context "until" do
|
251
|
+
it { should_not allow('true until false') }
|
252
|
+
end
|
253
|
+
|
254
|
+
context "while" do
|
255
|
+
it { should_not allow('true while true') }
|
256
|
+
end
|
257
|
+
|
258
|
+
context "yield" do
|
259
|
+
it { should allow('def foo; yield; end') }
|
260
|
+
end
|
261
|
+
|
262
|
+
context "Rails for Zombies" do
|
263
|
+
before(:each) do
|
264
|
+
policy.whitelist_const('GenericController')
|
265
|
+
policy.whitelist_const('Tweet')
|
266
|
+
policy.whitelist_const('Weapon')
|
267
|
+
policy.whitelist_const('Zombie')
|
268
|
+
policy.whitelist_const('ZombiesController')
|
269
|
+
end
|
270
|
+
|
271
|
+
[
|
272
|
+
"1 = Ash\nAsh = Glen Haven Memorial Cemetary",
|
273
|
+
"<% zombies = Zombie.all %>\n\n<ul>\n <% zombies.each do |zombie| %>\n <li>\n <%= zombie.name %>\n <% if zombie.Tweet >= 1 %>\n <p><%= SMART ZOMBIE =%></p>\n <% end %>\n </li>\n <% end %>\n</ul>\n",
|
274
|
+
"class HelloRils",
|
275
|
+
"Class NAme\n\nend",
|
276
|
+
"class tweet < ActiveRecord::Base\n belongs_to :zombie \n z = zombie.find(2)\nend",
|
277
|
+
"class zombie < ActiveRecord :: Base\n\nend\n",
|
278
|
+
"Class Zombie < ActiveRecord::Base\n validates_presence_of :name\nend",
|
279
|
+
"Class Zombie < ActiveRecord::Base\nend",
|
280
|
+
"Class Zombie < ActiveRecord::Base\nvalidates_presence_of :status\nvalidates_presence_of :ww\nend",
|
281
|
+
"Class Zombie < ActiveRecord::Base{\ndef name\ndef graveyard\n\n}\n",
|
282
|
+
"class zombie < ActiveRecord\nend class",
|
283
|
+
"Class Zombie <ActiveRecord :: Base\n\nend\n\n\n",
|
284
|
+
"Class Zombie <ActiveRecord::Base>\nvalidates_presence_of\nend",
|
285
|
+
"class.load(Zombie)",
|
286
|
+
"Poop = Zombie.find(:id=1)",
|
287
|
+
"SELECT * WHERE ID = 1;",
|
288
|
+
"String myNewZombie = select name from Zombies where id=1",
|
289
|
+
"w = Weapon.find(1)\nZombie.create( :Weapon => \"Hammer\", Zombie => 1)\nend\n",
|
290
|
+
"Zodfsdsfdsdfsz=Zombies.find()1\n"
|
291
|
+
].each do |error|
|
292
|
+
it "raises SyntaxError on #{error.inspect}" do
|
293
|
+
expect { Rubycop::Analyzer::NodeBuilder.build(error) }.to raise_error(SyntaxError)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
[
|
298
|
+
"1\nZombie = 1\n",
|
299
|
+
"A = t.find(1)\n\n\n\n",
|
300
|
+
"Ash = 1\n",
|
301
|
+
"Ash = 1\n\n",
|
302
|
+
"Ash = Weapons.find.zombie_id(1)",
|
303
|
+
"Ash = Zombie.find(1)\nAsh.weapons.count",
|
304
|
+
"class Com\n\nhasmany dog\n\nend",
|
305
|
+
"class Finder < Tweet\n z = Tweet.find(1)\nend",
|
306
|
+
"class Post < ActiveRecord::Base\nend",
|
307
|
+
"class Weapons < ActiveRecord::Base\n belongs_to :Zombies\nend\n\nclass Zombies < ActiveRecord::Base\n has_many :Weapons\nend",
|
308
|
+
"Class Zombie < ActiveRecord::Base\n\nEnd",
|
309
|
+
"class Zombie < Rails::ActiveModel\n \nend",
|
310
|
+
"Class Zombie {\n validates :name, :presence => true\n}",
|
311
|
+
"Class Zombies < ActiveRecord::Base\nEnd",
|
312
|
+
"class ZombiesController < ApplicationController\n before_filter :find_zombie, :only => [:show]\n\n def show\n render :action => :show\n end\n\n def find_zombie\n @zombie = Zombie.find params[:id]\n @numTweets = Tweet.where(:zombie_id => @zombie).count\n if @numTweets < 1 \n redirect_to(zombies_path)\n end\n end\nend\n",
|
313
|
+
"class Zomvie <ActiveRecord::Base\nhas_many:Zombies\nend\n",
|
314
|
+
"class Zoombie < ActiveRecord::Base\nend\nz = Zoombie.last",
|
315
|
+
"class Zoombie\nend\nZoombie.create(:name => \"Jim\", :graveyard=> \"My Fathers Basement\")",
|
316
|
+
"cuntZombie=Zombies[1];",
|
317
|
+
"def create\n @newZombie = Zombie.create( :name => params[:name], :graveyard => params[:graveyard] )\n \n render action => :create\nend\n",
|
318
|
+
"Destroy Zombie where ID = 3",
|
319
|
+
"Find.Tweet.id = (1)\nZombie = Tweet.id",
|
320
|
+
"firstZombie = Zombies[id '1']\n",
|
321
|
+
"First_user = initialuser\n",
|
322
|
+
"Hash tag + lik",
|
323
|
+
"Hold = Tweets.find 1",
|
324
|
+
"jh = new Zombie()\njh.name = \"JHDI\"\njh.graveYard = \"JHDI cemetary\"\njh.save",
|
325
|
+
"Location = puts graveyard.Ash",
|
326
|
+
"newZombie = Zombie.new\nnewZombie.name = \"Craig\"\nnewZombie.graveyard = \"my cube\"\nnewZombie.save",
|
327
|
+
"newZombie = Zombie.new\nnewZombie['name'] = \"Renan\"\nnewZombie['graveyard'] = \"Lavras Cemetary\"\nnewZombie.save\n",
|
328
|
+
"newZombie = Zombies.new\nnewZombie.id = 4\nnewZombie.name = \"Arek\"\nnewZombie.graveyard = \"Centralny cmentarz komunalny\"\nnewZombie.save",
|
329
|
+
"newZombie=Zombie.new {}\nnewZombie.name = \"Manish\"\nnewZombie.graveyard = \"Shillong Bastards Cemetary\"",
|
330
|
+
"numeroUno = Zombie(1).name;\n",
|
331
|
+
"splatid = id.find(1)\nsplatName = splatid[:name]",
|
332
|
+
"t = new Tweet();\nminTweet == t.find(3);",
|
333
|
+
"t = Tweet.find(1)\nZombie = t.id",
|
334
|
+
"T = Zombie.find(3)\nT.graveyard = 'Benny Hills Memorial'\nT.save",
|
335
|
+
"t = Zombie.find(3)\nt.Zombie = \"Benny Hills Memorial\"\nt.save\n",
|
336
|
+
"T = Zombie.where(1)\nputs t.name\n",
|
337
|
+
"t= \nt.Name=\"Hello\"\nt.Graveyard=\"yes\"\nt.save",
|
338
|
+
"t=Zombie.find(3)\nt.Zombie = \"pucho\"",
|
339
|
+
"T=Zombie[1]\n",
|
340
|
+
"Ticket = Tweet.find(1)",
|
341
|
+
"Tweet = new Tweet;\na = Tweet.find(1);\n",
|
342
|
+
"Tweet = new Tweet\nt = Tweet.where(:id => 1)\n",
|
343
|
+
"Tweet = t\nt.zombie = 1",
|
344
|
+
"Tweet.find(1)\nZombie1 = tweet(1)",
|
345
|
+
"Tweet=id1\n",
|
346
|
+
"UPDATE Zombies\nSET name='vijay',graveyard='Ahmedabad'\nWhere Id='2';\n",
|
347
|
+
"w = Weapon.create(:name => \"Punto\", :Zombie => z)\nash = Zombie.find(1)",
|
348
|
+
"z = ID=1",
|
349
|
+
"Z = Zombie.find(1)\n",
|
350
|
+
"z = Zombie.find(1)\nWeapon.where( :Zombie => z )",
|
351
|
+
"z = Zombie.find(1)\nZombie1 = z.name",
|
352
|
+
"Z = Zombie.find(1)\n\n\n\n\n",
|
353
|
+
"Z = Zombie.find(3)",
|
354
|
+
"Z = zombie.id(1)",
|
355
|
+
"z = Zombie.new\nz.name = \"Charly\"\nz.Graveyard = \"EL carlos\"",
|
356
|
+
"Z=Zombie.new\nz.find(1)",
|
357
|
+
"Zombie = new Zombie",
|
358
|
+
"Zombie = Tweet.find(1)",
|
359
|
+
"Zombie = Zombie.find(Weapons.find(:zombie_id))",
|
360
|
+
"Zombie = Zombie.find[1]",
|
361
|
+
"Zombie = Zombies.find(1)",
|
362
|
+
"Zombie3=Zombie.find(3)\nZombie3.graveyard = \"Benny Hills Memorial\"\nZombie3.save",
|
363
|
+
"Zombies = '123456'",
|
364
|
+
"Zombies = id \nZombies.create( :name=>\"roger\" )",
|
365
|
+
"Zombies = Zombies.find(1)\nput Zombies",
|
366
|
+
"Zombies = {:Ash => \"Glen Haven mernorial Cemetary\"}\nvar = Zombies.find(1)\nvar.save\n\n",
|
367
|
+
"Zombies = {:name => [\"Ash\", \"Bob\", \"Jim\"], :graveyard => [\"Glen Haven Memorial Cemetary\",\"Chapel Hill Cemetary\",\"My Fathers Basement\"] }\na = z.find(1)",
|
368
|
+
"Zombies = {\n :id => 1 }\nt = zombie.find(1)",
|
369
|
+
"Zombies.find(1)\nputs Zombies.find(1)\nZ=Zombies.find(1)\nZ.lat=[:id]\nz.save\nz\n",
|
370
|
+
"zoombieID = table.find(1)\n",
|
371
|
+
'class << Zombie; self; end',
|
372
|
+
'myZombie = Tweet.find(1)',
|
373
|
+
'Zombie.create(:name => "Whoa. A Green String")',
|
374
|
+
'Zombie.create(name: "Fal", graveyard: "fail")',
|
375
|
+
].each do |good|
|
376
|
+
it "allows #{good.inspect}" do
|
377
|
+
should allow(good)
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
[
|
382
|
+
"Class",
|
383
|
+
"def show\n @zombie = Zombie.find(params[:id])\n\n respond_to do |format|\n `ls`\n end\nend\n",
|
384
|
+
"Module.delete(3)",
|
385
|
+
"Module.find(\"Ash\")",
|
386
|
+
"require 'tweet'\nt = Tweet.find(1)",
|
387
|
+
"require 'Tweet'\nTweet.find(2).name\n",
|
388
|
+
"require \"tempfile\"\nt = Zombies.new('Zombies')\nZombies.where(:id => 1)\nt.save",
|
389
|
+
"system('ls')",
|
390
|
+
"t = Zombies.open()",
|
391
|
+
"Tweet.find(1)\nDim var as String\nvar=Tweet.name",
|
392
|
+
"Zombie.load(1)\n\n",
|
393
|
+
"`echo 1`",
|
394
|
+
"`ls -l`",
|
395
|
+
"`ps ax`\n",
|
396
|
+
"`uname -a`",
|
397
|
+
'const_get',
|
398
|
+
'const_get()'
|
399
|
+
].each do |bad|
|
400
|
+
it "does not allow #{bad.inspect}" do
|
401
|
+
should_not allow(bad)
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubycop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dray Lacy
|
9
|
+
- Eric Allam
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-09-28 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: &70095569001460 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70095569001460
|
26
|
+
description: A semantic analyzer for Ruby 1.9
|
27
|
+
email:
|
28
|
+
- dray@envylabs.com
|
29
|
+
- rubymaverick@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/rubycop.rb
|
39
|
+
- lib/rubycop/analyzer.rb
|
40
|
+
- lib/rubycop/analyzer/gray_list.rb
|
41
|
+
- lib/rubycop/analyzer/node_builder.rb
|
42
|
+
- lib/rubycop/analyzer/policy.rb
|
43
|
+
- lib/rubycop/analyzer/ruby.rb
|
44
|
+
- lib/rubycop/analyzer/ruby/args.rb
|
45
|
+
- lib/rubycop/analyzer/ruby/array.rb
|
46
|
+
- lib/rubycop/analyzer/ruby/assignment.rb
|
47
|
+
- lib/rubycop/analyzer/ruby/assoc.rb
|
48
|
+
- lib/rubycop/analyzer/ruby/blocks.rb
|
49
|
+
- lib/rubycop/analyzer/ruby/call.rb
|
50
|
+
- lib/rubycop/analyzer/ruby/case.rb
|
51
|
+
- lib/rubycop/analyzer/ruby/constants.rb
|
52
|
+
- lib/rubycop/analyzer/ruby/definitions.rb
|
53
|
+
- lib/rubycop/analyzer/ruby/for.rb
|
54
|
+
- lib/rubycop/analyzer/ruby/hash.rb
|
55
|
+
- lib/rubycop/analyzer/ruby/if.rb
|
56
|
+
- lib/rubycop/analyzer/ruby/list.rb
|
57
|
+
- lib/rubycop/analyzer/ruby/node.rb
|
58
|
+
- lib/rubycop/analyzer/ruby/operators.rb
|
59
|
+
- lib/rubycop/analyzer/ruby/params.rb
|
60
|
+
- lib/rubycop/analyzer/ruby/position.rb
|
61
|
+
- lib/rubycop/analyzer/ruby/range.rb
|
62
|
+
- lib/rubycop/analyzer/ruby/statements.rb
|
63
|
+
- lib/rubycop/analyzer/ruby/string.rb
|
64
|
+
- lib/rubycop/analyzer/ruby/tokens.rb
|
65
|
+
- lib/rubycop/analyzer/ruby/variables.rb
|
66
|
+
- lib/rubycop/analyzer/ruby/while.rb
|
67
|
+
- lib/rubycop/version.rb
|
68
|
+
- rubycop.gemspec
|
69
|
+
- spec/node_builder_spec.rb
|
70
|
+
- spec/policy_spec.rb
|
71
|
+
homepage: ''
|
72
|
+
licenses: []
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project: rubycop
|
91
|
+
rubygems_version: 1.8.10
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: A semantic analyzer for Ruby 1.9
|
95
|
+
test_files:
|
96
|
+
- spec/node_builder_spec.rb
|
97
|
+
- spec/policy_spec.rb
|