Skip to content

chore: drop redundant length guard around range - #104

Open
andig wants to merge 1 commit into
enbility:devfrom
andig:chore/redundant-nil-checks
Open

chore: drop redundant length guard around range#104
andig wants to merge 1 commit into
enbility:devfrom
andig:chore/redundant-nil-checks

Conversation

@andig

@andig andig commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Ranging over an empty slice is a no-op, so the surrounding length guard adds nothing.

  • ship/connection_race_test.goif len(closedCalls) > 0 { around a range closedCalls

Found with an AST pass over the whole repo rather than a text search. This is the only occurrence in ship-go; the similar-looking checks elsewhere (e.g. service == nil || len(service.Text) == 0, r.TLS == nil || len(r.TLS.PeerCertificates) == 0) are not redundant, since the nil check guards a dereference and the len() applies to a different value.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant