github / github/codeql

Ruby: Traditional if-else not detected as `StringConstArrayInclusionCallBarrier` compared to conditional assignment.

Đang mở
#11,558 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
question Ruby
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

**Information**
CodeQL Version:
7f5df4fc0e9ec8ffed0e8eefe78fb5544be46dc4

**Description of the issue**
Create a database for this ruby code:
```ruby
aaa = "imagine this is derived from a remote source"
if ["fff", "eee"].include?(aaa) # {1}
# accept aaa as is
else
aaa = "Value"
end

aaa = if ["fff", "eee"].include?(aaa) # {2}
aaa
else
"Value"
end
```

**Expected**
1. {1} and {2} are detected as a `StringConstArrayInclusionCall` (using quick-eval)
2. {1} and {2} are detected as a `StringConstArrayInclusionCallBarrier` (using quick-eval)

**Actual**
1. {1} and {2} are detected as a `StringConstArrayInclusionCall` (using quick-eval)
2. {1} **is not** detected as a `StringConstArrayInclusionCallBarrier` (using quick-eval)
3. {2} **is** detected as a `StringConstArrayInclusionCallBarrier` (using quick-eval)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.