Simplify conditional logic

Break down complex conditional expressions and control flow into simpler, more readable forms. Use early returns and guard clauses to reduce nesting and avoid unnecessary computations. Avoid chaining multiple conditions with || or && operators when the logic can be made clearer through restructuring.

copy reviewer prompt

Prompt

Reviewer Prompt
Break down complex conditional expressions and control flow into simpler, more readable forms. Use early returns and guard clauses to reduce nesting and avoid unnecessary computations. Avoid chaining multiple conditions with   or && operators when the logic can be made clearer through restructuring.

Examples of improvements:

  • Use early returns for exclusion checks: if (excludeKeywords.includes(model)) return false;
  • Add missing break statements in switch cases to prevent fall-through bugs
  • Replace complex   chains with clearer conditional structures or separate the logic into multiple steps

This approach makes code easier to understand, debug, and maintain by reducing cognitive load and making the control flow more explicit.

Source discussions