UNPKG

pi-lens

Version:

Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo

70 lines (57 loc) • 1.86 kB
# DISABLED (#PR-319 FP cleanup): too noisy in script files # # Original rule detected print() statements in Python, which is mostly a code-quality # lint (print is fine in scripts, debug code, etc., but should be logger.info() in # production code). # # PostHog validation showed 82% of fires (696/844) were in scripts/, commands/, and # migrations/ directories where print() is the right tool. The rule doesn't respect # # noqa: T201 suppressions (would require preprocessor pass on the source). # # Most legitimate production-code print() usage in pi-lens codebases is found by # ruff T201 already — this rule duplicates that with worse signal-to-noise. # Re-enable if a robust noqa-aware filter is added. id: python-print-statement name: Print Statement in Production severity: warning category: debugging defect_class: safety inline_tier: warning language: python message: "print() — remove debug output before committing" description: | print() calls are for debugging and should not appear in production code. Use a proper logger instead. ✅ FIX: Remove or replace with logging. import logging logger = logging.getLogger(__name__) logger.debug("value: %s", value) query: | (call function: (identifier) @FUNC (#eq? @FUNC "print") arguments: (argument_list) @ARGS) metavars: - FUNC - ARGS post_filter: not_in_test_block has_fix: true fix_action: remove tags: - debugging - code-quality examples: bad: | def process(data): print("Processing:", data) result = transform(data) print("Result:", result) return result good: | import logging logger = logging.getLogger(__name__) def process(data): logger.debug("Processing: %s", data) result = transform(data) logger.debug("Result: %s", result) return result