Handle empty async/reactive results with appropriate responses
When using Optional/CompletableFuture/Publisher-like types, map empty values to a clear outcome (e.g., 404) rather than returning null.
api-conventionserror-handling
Low
Handle null values with coalescing operators
Use ?? and the nullsafe operator (?->) to provide defaults and avoid notices when values may be null.
error-handlingstack-php
Low
Handle StateError from firstWhere operations
Always provide `orElse` to firstWhere (or use a safe helper) when the match may not exist.
error-handlingstack-flutter
Low
Handle Time.parse and Date.parse errors
Parse dates/times in begin/rescue blocks and validate expected format/timezone.
error-handling
Low
Initialize properties with default values
Set sensible defaults for properties/fields or enforce via constructors.
error-handlingstyle-conventions
Low
Initialize variables to prevent NameError
Always initialize variables before use and avoid conditionally-defined locals.
error-handlingstyle-conventions
Low
Keep `try` Blocks Small and Focused
Detect `try` blocks that contain excessive code. Large `try` blocks make it harder to debug errors. Recommend narrowing the scope of the `try` block to only the necessary code.
error-handlingreadability-refactor+1
Low
Log warning for unhandled cases
In when/else or default branches, log a warning with the unexpected value to surface silent failures.
error-handlingobservability-logging
Low
Provide Meaningful Default Values for Hash Keys
Check for hash key lookups without default values. If a missing key is accessed, suggest using `fetch` with a default value.
error-handlingresilience-retries-idempotency
Low
Refactor duplicated dialog action logic
Centralize repeated dialog creation/action handlers into a helper to ensure consistent UX and error handling.
duplication-complexityerror-handling+2
Low
Refactor nested flatMap chains
Break deep map/flatMap chains into named suspend functions or use runCatching/Result for clearer composition.
error-handlingreadability-refactor
Low
Release External Resources After Use
After using external resources (DB connections, open files, sockets), release them properly. Use fclose(), close database connections or finally blocks to ensure cleanup even if errors occur.
error-handlingstack-php+1
Low
Replace unsafe type casts with explicit checking
Use safe casts (as?) with null checks or require statements instead of unchecked as.
error-handlingsecurity-hardening
Low
Return zero values on error for clarity
When returning (T, error), return the zero value for T (or nil for pointers/slices/maps) whenever error != nil.
error-handlingstyle-conventions
Low
Start Enums at 1, Reserve 0 for Default
When using iota to create enums (constant sets), start from 1 and use 0 as a 'zero value' meaning undefined or default. This way, an uninitialized variable of that enum type will not accidentally hold a valid value.
error-handlingstyle-conventions
Low
Use `is` When Comparing with `None`
Identify occurrences where `== None` or `!= None` is used. Using `is None` and `is not None` is more reliable because it checks identity instead of equality, preventing potential issues with overloaded `__eq__` methods.
error-handlingstack-python+1
Low
Use Consistent Error Message Style
Error strings should start with a lowercase letter and not end with punctuation. They should state what went wrong in a concise, factual manner (for example, "file not found", not "File not found!").
error-handlingstyle-conventions
Low
Use Descriptive Exception Variable Names
Ensure that exception variables in `rescue` blocks use meaningful titles instead of generic ones like `e`.
error-handlingreadability-refactor
Low
Use dict.get() with defaults for safe key access
When keys may be absent, prefer dict.get(key, default) or setdefault instead of direct indexing.
error-handlingstack-python
Low
Use idiomatic Kotlin null-handling patterns
Use safe calls (?.), the Elvis operator (?:), let/run/also for scoped handling, and early returns for invalid input.
error-handlingreadability-refactor+1
Low
Use Promise.allSettled for batch operations with partial failures
For many independent tasks, prefer Promise.allSettled and handle per-item results.
error-handlingresilience-retries-idempotency
Low
Use safe type casting with as operator
Use the as operator or pattern matching for safe casts and guard null results before usage.
error-handlingstyle-conventions
Low
Use Try-With-Resources for Resource Management
Ensure that resources such as streams or file handlers are managed using try-with-resources to avoid leaks.
error-handlingperformance-efficiency
Low
Validate parameter types before casting
Use instanceof/pattern matching and guard before casts; avoid ClassCastException.