SKY-L009 · Logic and resilience
Debug leftover
A call left over from debugging. It can be a breakpoint() or pdb.set_trace() that stops the program, an ic() from the icecream library, or a print() that dumps a variable with a DEBUG label or the {value=} f-string form.
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
A forgotten breakpoint() freezes the request or job that reaches it: a web worker waits forever for someone to type at a debugger prompt that nobody can see. Debug prints can also write order details or user data to logs that are kept and shared.
What Skylos flags
"""Apply promotion codes at checkout.""" from shop.promotions import lookup_discount def apply_discount(order, code): discount = lookup_discount(code) breakpoint() order.total = max(order.total - discount, 0) return orderWhat Skylos leaves alone
"""Apply promotion codes at checkout.""" from shop.promotions import lookup_discount def apply_discount(order, code): discount = lookup_discount(code) print(f"Applied {code}: {discount} off order {order.id}") order.total = max(order.total - discount, 0) return orderWhy Skylos leaves it alone
A plain print() is ordinary output: command-line tools and scripts print on purpose. Skylos only reports a print() that carries evidence of debugging, such as a DEBUG: label, {discount=} or a dump of locals(). A logger is still the better choice in library code.
How Skylos decides
- Runs with
--qualityon Python files, test files included. Looks at every function call. - Reports HIGH for
breakpoint()andic()written as bare names, and forpdb.set_trace(),ipdb.set_trace(),pudb.set_trace()andcode.interact(). - Reports LOW for
print(),pprint(),pprint.pprint()orbuiltins.print()only when the output looks like debugging: the first argument starts withDEBUG,DBG,[DEBUG]or[DBG]; an f-string uses the{name=}debug form; or an argument islocals(),globals(),vars()or an object's__dict__. - Any other
print()is left alone. The finding is on the line of the call.
How to fix it
Delete the debugger call. If you need to see the value later, log it at debug level, where the log configuration decides whether it is written.
"""Apply promotion codes at checkout.""" Added: import loggingAdded: from shop.promotions import lookup_discount Added: logger = logging.getLogger(__name__) Added: def apply_discount(order, code): discount = lookup_discount(code)Removed: breakpoint()Added: logger.debug("discount %s for code %s", discount, code) order.total = max(order.total - discount, 0) return orderWhen it can be wrong
- A developer tool or management command that is meant to open a debugger or print
DEBUG:lines is reported. - A local function you named
icorbreakpointis reported as if it were the debugger. - It misses debugger calls written another way, such as
import pdb as p; p.set_trace()orfrom pdb import set_trace.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put the marker on the line of the call.
Python breakpoint() # skylos: ignore[SKY-L009] dev-only debug command[tool.skylos] ignore = ["SKY-L009"]turns the rule off for the project.