Skip to content

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

Open
@intrigus-lgtm

Description

@intrigus-lgtm

Information
CodeQL Version:
7f5df4f

Description of the issue
Create a database for this ruby code:

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    RubyquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions