Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .grit/patterns/go/useless_if_else_body.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Identical statements in the if else body
tags: [fix, correctness]
tags: [fix, dead-code]
---

Identical statements found in both the `if` and `else` bodies of an `if-statement`. This results in the same code execution regardless of the if-expression outcome. To optimize, eliminate the `if` statement entirely.
Expand All @@ -9,7 +9,6 @@ Identical statements found in both the `if` and `else` bodies of an `if-statemen
language go

or {
`if ($conditon) { $body } else { $body }`,
`if ($conditon) { $body } else if ($conditon) { $body }`
} => `if ($conditon) {
$body
Expand Down