Skip to content

CSP-P007: Pure Call in Loop

Category: Performance

Severity: LOW

Description

Pure builtin calls with invariant arguments inside loops can be hoisted.

Vulnerable Code Example

for x in items:
    limit = len(items)
    handle(x, limit)

Safer Code Example

limit = len(items)
for x in items:
    handle(x, limit)

How to Suppress a Finding

# ignore
# or
# noqa: CSP-P007