Avoid exponential recursion while finding variable references in scopes (#203)

* Avoid exponential recursion while finding variable references in scopes

* Adjust source example in test
This commit is contained in:
Vitalii Elenhaupt 2021-01-31 16:40:44 +02:00 committed by GitHub
parent d28f9f756e
commit 51b0a07e81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 5 deletions

View file

@ -1006,6 +1006,48 @@ module Ameba::Rule::Lint
end
end
it "does not report if variable is referenced and there is a deep level scope" do
s = Source.new %(
response = JSON.build do |json|
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
json.object do
anything
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
response = JSON.parse(response)
response
)
subject.catch(s).should be_valid
end
context "uninitialized" do
it "reports if uninitialized assignment is not referenced at a top level" do
s = Source.new %(