Will It Vibe logoWill It Vibe?
PY-013Low severity-4 points

Bare global statement

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

A global statement lets a function mutate module-level state directly, making its behavior depend on and change something outside its own arguments. Heuristic style check: some module-level counters and caches are a reasonable, deliberate choice.

Why it matters

A global statement lets a function mutate module-level state directly, which means the function behavior now depends on, and changes, something outside its own arguments and return value. As more functions touch the same global, it becomes difficult to reason about who changed it and when, and the code becomes hard to test in isolation since tests must reset the global between runs. This check is a style heuristic, not a hard bug: some global counters and caches are a reasonable, deliberate choice.

How to fix it

Where practical, replace the global with an explicit parameter and return value, or wrap the state in a small class or object that owns it so the mutation is explicit at the call site (counter.increment() instead of a bare global mutation). If the global genuinely needs to be process-wide (a cache, a registry), keep it, but consider isolating it behind a small module-level function so callers do not need to know it is a global at all.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks