Remove-Redundant-If-Statement
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery rule id: remove-redundant-if-statement
Section titled “Sourcery rule id: remove-redundant-if-statement”Description
Section titled “Description”Remove an if statement where the condition is true.
Before
Section titled “Before”if (true) { console.log("great!")}console.log("great!")Explanation
Section titled “Explanation”If the condition of an if statement is true, its body will always be executed. Conversely, if the condition
is always false, then its body will never be executed. In the first case, we can replace the if statement with
its body, and in the second case we can remove it altogether.