// rule category
Handle errors explicitly; avoid silent failures; propagate safely.
145 rules · 9 critical · 87 high · 49 low
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.
Identify function definitions where a mutable object (e.g., list, dictionary, set) is used as a default argument. This can cause shared state across function calls, leading to unintended behavior. Suggest using `None` as a default and initializing the object inside the function.
If the PR claims to fix a specific issue (e.g., 'Fixes #123' / 'Fix PAY-123'), validate it against the real production error. - If an observability MCP is available (Sentry/Datadog/Bugsnag): fetch the event/stack trace and confirm the change addresses the root cause. - Require a regression test (or a clearly documented reason why a test cannot be added). Call out fixes that only hide symptoms (catch-and-ignore, broader retries, defaulting values) without removing the underlying failure mode.
Verify that after loading a PyTorch model, either `model.eval()` or `model.train()` is called. Failing to do so can result in incorrect behavior, especially for layers like dropout and batch normalization.
Use the 'comma, ok' idiom for type assertions to safely handle cases when the assertion fails. Only use a single-value type assertion (which panics on failure) if you are absolutely sure (by prior checks or program logic) that the interface holds the correct type.
Ensure that resources such as files, sockets, or database connections are managed using the `with` statement. Code that explicitly calls `.close()` without `with` should be refactored to use context managers for automatic resource cleanup.