1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-29 22:28:23 +02:00

refactor: extract shared code for linting if-else chains (#821)

* refactor: extract shared code for linting if-else chains

The rules "early-return", "indent-error-flow" and
"superfluous-else" have a similar structure. This
moves the common logic for classifying if-else chains
to a common package.

A few side benefits:
- "early-return" now handles os.Exit/log.Panicf/etc
- "superfluous-else" now handles (builtin) panic
- "superfluous-else" and "indent-error-flow" now handle if/else
  chains with 2+ "if" branches

* internal/ifelse: style fixes, renames, spelling
This commit is contained in:
Miles Delahunty
2023-05-17 21:51:35 +10:00
committed by GitHub
parent 81d85b505d
commit 4bb48df5d2
13 changed files with 490 additions and 345 deletions

6
internal/ifelse/doc.go Normal file
View File

@@ -0,0 +1,6 @@
// Package ifelse provides helpers for analysing the control flow in if-else chains,
// presently used by the following rules:
// - early-return
// - indent-error-flow
// - superfluous-else
package ifelse