Eliminate duplicate logic/config and reduce unnecessary complexity.
59 rules · 2 critical · 8 high · 49 low
Critical
Avoid Duplicating String Literals
Store repeated string literals in constants or variables to improve maintainability and reduce redundancy.
duplication-complexitymaintainability
Critical
Avoid Redundant `None` Comparisons
Identify cases where `x is None` or `x is not None` is used redundantly when `x` is always or never `None`. This may indicate a deeper logic issue.
duplication-complexityreadability-refactor+1
High
Avoid Functions That Always Return the Same Value
Identify functions that return the same value regardless of input. This may indicate poor design or a logic error.
duplication-complexityreadability-refactor+1
High
Avoid Unnecessary `toList()` with Spread Operator
Remove unnecessary calls to `.toList()` when using the spread operator (`...`) as it is already designed to work with iterable collections.
duplication-complexityperformance-efficiency+1
High
Avoid Unnecessary `toList()` with Spread Operator
Remove unnecessary `.toList()` calls when using the spread operator (`...`) to avoid redundant operations.
duplication-complexityperformance-efficiency+1
High
Consolidate duplicated permission checking logic
Provide a single permission check API (e.g., can(user, action, resource)) and reuse it across layers.
duplication-complexitymodule-architecture+1
High
Ensure Getters and Setters Access the Correct Fields
Copy-pasting code can lead to errors where getters or setters access the wrong fields. Always verify that properties interact with the expected fields.
duplication-complexitymaintainability
High
Forbid cross-package relative imports in JS/TS
In JS/TS workspaces, imports must use workspace package names (as defined in each package.json and exports) rather than relative paths crossing package boundaries.
monorepo-hygienemodule-architecture+1
High
Limit Lengthy LINQ Chains
Verify that LINQ queries are not excessively long. Break complex queries into smaller, more understandable expressions.
duplication-complexityreadability-refactor
High
Prefer Guard Clauses Over Nested Conditionals
Detect deeply nested conditionals and suggest using guard clauses (`return unless condition`) instead to improve readability.
duplication-complexityreadability-refactor
Low
Avoid Brain Methods (Methods Doing Too Many Tasks)
Ensure that methods perform a single, well-defined task. Large methods should be refactored into smaller, focused methods.
duplication-complexityreadability-refactor
Low
AVOID redundancy with the surrounding context
Check if the method, variable, or class title contains redundant context (e.g., using 'carDrive()' when 'drive()' would suffice). Ensure the title is concise and avoids repetition of surrounding context.
duplication-complexityreadability-refactor+2
Low
Avoid Redundant Null Checks with `instanceof`
Ensure that explicit null checks are not used with `instanceof`, as `null` is never an instance of any class.
duplication-complexity
Low
Avoid Unnecessary Defensive Programming
Identify overly defensive code that checks for unrealistic conditions, such as excessive `nil?` checks or redundant type verifications.
duplication-complexityreadability-refactor
Low
Centralize analytics tracking logic
Route all analytics events through a single service/helper instead of calling the SDK directly from widgets and blocs.
duplication-complexitymaintainability+2
Low
Centralize key generation logic
Generate cache/Redis keys through a single utility with clear namespaces and versioning.
caching-strategyduplication-complexity+1
Low
Centralize string constants
Define shared string literals (route names, keys, claim types) as constants/enums in a single place.
duplication-complexitymaintainability+1
Low
Combine Multiple Loops Over the Same Collection
Ensure that multiple loops over the same collection are combined into a single loop to improve efficiency.
duplication-complexityperformance-efficiency
Low
Consolidate duplicate Dockerfiles
Deduplicate near-identical Dockerfiles by sharing a common base stage (multi-stage) and varying only service-specific steps via build args/targets.
container-docker-hygieneduplication-complexity
Low
Consolidate duplicated query logic
Extract reusable SQL fragments/builders for commonly repeated WHERE/ORDER clauses.
Avoid maintaining multiple equivalent validators for the same shape; centralize checks in a single function/schema.
duplication-complexitymaintainability
Low
Consolidate message update functions
Provide a single updater that applies deltas/patches to messages rather than multiple ad-hoc updaters.
duplication-complexitymodule-architecture
Low
Consolidate multiple similar methods
Merge near-duplicate methods into a single parameterized method or strategy.
duplication-complexityreadability-refactor
Low
Consolidate repetitive configuration patterns
Replace repeated set/get config calls with data-driven loops or loaders from a single schema/source.
config-environmentduplication-complexity+2
Low
Create base controllers for shared concerns
Factor shared before_actions/filters/error handling into ApplicationController or a base controller.
duplication-complexitymodule-architecture
Low
Define dialog handlers once to avoid duplication
For confirm/cancel flows, define common callbacks (confirm/cancel) once and reuse across dialogs.
duplication-complexitystack-flutter+1
Low
Define hardcoded strings as shared constants
Replace magic strings with constants or enums sealed classes; keep them in a single source of truth.
duplication-complexitymaintainability+1
Low
Define reusable constants for repeated values
Create theme-like constants (radii, gaps, durations) and reuse across widgets.
duplication-complexitymaintainability+2
Low
Derive TypeScript types from validation schemas
Avoid duplicating runtime schemas and TypeScript types; derive types from constants/functions or declare as const tuples.
duplication-complexitystyle-conventions
Low
DON'T explicitly title libraries
Ensure that libraries are not explicitly titled. Dart provides automatic library titles, so avoid redundant naming of libraries in the code.
duplication-complexitystack-flutter+1
Low
Extract common parallel processing patterns
Encapsulate coroutine parallelization (map async/awaitAll, limited concurrency) into utilities.
concurrency-safetyduplication-complexity+1
Low
Extract common query logic
Factor repeated LINQ predicates/projections into reusable expressions or methods.
duplication-complexityreadability-refactor
Low
Extract duplicated API call logic
Factor repeated HTTP call setup/parsing/retry into a reusable helper or client.
duplication-complexitymodule-architecture
Low
Extract duplicated business logic
Move repeated domain rules into reusable methods/services; keep controllers and handlers thin.
duplication-complexitymodule-architecture+1
Low
Extract duplicated business logic
Move repeated domain calculations/transformations into named functions or service classes; keep controllers/scripts thin.
duplication-complexitymodule-architecture+1
Low
Extract duplicated business logic to models
Move domain behavior from controllers/views into models or service objects.
duplication-complexitymodule-architecture
Low
Extract duplicated field lists to constants
When the same set of attribute/field names is used in multiple places (strong params, serializers, queries), extract it to a constant and reuse.
duplication-complexitymaintainability
Low
Extract duplicated interaction handlers
Factor common interaction/message handling into reusable functions or classes with parameters for the differing bits.
duplication-complexityreadability-refactor
Low
Extract duplicated logic into functions
Duplicate sequences of statements must be extracted into a named function or utility.
duplication-complexityreadability-refactor
Low
Extract duplicated logic to helper functions
Move repeated sequences of operations into named helpers or utilities and reuse them.
duplication-complexitymaintainability+2
Low
Extract duplicated request validation to helper functions
For HTTP/RPC handlers, parse+validate inputs in dedicated functions. Return typed errors and reuse across endpoints.
api-conventionsduplication-complexity
Low
Extract duplicated widget logic to reusable methods
Factor identical widget trees or builders into private helpers or dedicated widgets.
duplication-complexityreadability-refactor+1
Low
Extract hardcoded versions to centralized configuration
Parameterize tool/runtime versions via ARGs (and CI build args) instead of hardcoding them across multiple Dockerfiles.
container-docker-hygieneduplication-complexity+1
Low
Extract query strings to constants
Define SQL strings as static final constants or in a repository, not inline across methods.
duplication-complexitymaintainability
Low
Extract shared Sidekiq queue names to constants
Centralize queue names and reuse across workers and tests.
duplication-complexitymaintainability
Low
Extract validation logic to separate methods
Centralize validation in dedicated functions/objects and reuse; return typed errors.
duplication-complexityerror-handling+1
Low
Keep Functions/Methods Single-Responsibility
Write functions and methods so each does one well-defined task. If a function handles distinct steps (validation, processing, saving, notifying), refactor into smaller focused functions.
duplication-complexityreadability-refactor+1
Low
Move generic helpers to ApplicationHelper
Place cross-controller view helpers in ApplicationHelper (or a shared module) for reuse.
duplication-complexitymodule-architecture
Low
Record alternatives considered and trade-offs
Add an 'Alternatives' section listing at least two plausible options with pros/cons and reasons for rejection.
docs-adrsduplication-complexity
Low
Refactor conditional logic into loops
Replace repeated similar if/elif blocks with data-driven loops or dispatch tables.
duplication-complexityreadability-refactor+1
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 duplicated modal creation logic
Create factories/builders for repeated dialog/modal construction with configurable parameters.
duplication-complexityui-robustness
Low
Refactor duplicated validation logic
Centralize repeated validation rules into helpers or small packages. Reuse them across handlers, services, and jobs.
duplication-complexitymaintainability
Low
Remove duplicated method definitions
Do not define the same method multiple times; consolidate behavior in one place.
duplication-complexitymaintainability
Low
Remove redundant database queries
Deduplicate identical queries within a request; reuse previously fetched data or preload in a single query.