[audit]: x/gov/client/cli: PromptMetadata has non-idiomatic code pattern creates variables up top yet could perform an early return #17849
Labels
Type: Code Hygiene
General cleanup and restructuring of code to provide clarity, flexibility, and modularity.
Is there an existing issue for this?
What happened?
While auditing the v0.50.0.* code I noticed this pattern
cosmos-sdk/x/gov/client/cli/prompt.go
Lines 201 to 211 in 63d046d
that pattern is very non-Go and more C-like, notice that we have harder code to read just to avoid initialize 2 variables, and end up throwing err all around as if that variable needs to be captured and reused in both branches of the if statement.
Really that can be fixed by early returns https://cyber.orijtech.com/scsec/cosmos-go-coding-guide#reduce-code-nesting-with-early-returns-and-inversions
/cc @elias-orijtech
Cosmos SDK Version
v0.50.0-rc.0
How to reproduce?
No response
The text was updated successfully, but these errors were encountered: