github / github/codeql

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

Open
#11,558 2 comments 0 reactions 0 assignees View on GitHub
question Ruby
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

**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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.