mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
22 lines
621 B
Ruby
22 lines
621 B
Ruby
|
|
class DetectTest
|
|
def test
|
|
# These are bad
|
|
[].select { |i| true }.first
|
|
[].select { |i| true }.last
|
|
[].select { |i| true }[0]
|
|
[].select { |i| true }[-1]
|
|
[].filter { |i| true }.first
|
|
[].find_all { |i| true }.last
|
|
selection1 = [].select { |i| true }
|
|
selection1.first
|
|
|
|
# These are good
|
|
[].select("").first # Selecting a string
|
|
[].select { |i| true }[1] # Selecting the second element
|
|
selection2 = [].select { |i| true }
|
|
selection2.first # Selection used elsewhere
|
|
selection3 = selection2
|
|
end
|
|
end
|