Skip to content

chore: remove redundant nil checks - #258

Open
andig wants to merge 4 commits into
enbility:devfrom
andig:chore/redundant-nil-checks
Open

chore: remove redundant nil checks#258
andig wants to merge 4 commits into
enbility:devfrom
andig:chore/redundant-nil-checks

Conversation

@andig

@andig andig commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

len() is defined on nil slices and returns 0, so the paired == nil check is redundant. Likewise, ranging over a nil slice is a no-op, so the guard around it adds nothing.

  • features/internal/deviceconfiguration.godescriptions == nil || len(descriptions) == 0
  • usecases/cs/lpc/usecase.godata.LoadControlLimitData == nil || len(data.LoadControlLimitData) == 0
  • usecases/cs/lpp/usecase.go — same
  • features/internal/electricalconnection.goif set.Range != nil { for _, rangeItem := range set.Range { guard removed

The outer data == nil checks are kept — those guard the pointer dereference.

Found with an AST pass over the whole repo rather than a text search, so the set is complete for these shapes: x == nil || len(x) == 0 and x != nil && len(x) > 0 in either operand order and including the < 1 / <= 0 / != 0 / >= 1 spellings, plus nil guards wrapping a range or append on the same value.

🤖 Generated with Claude Code

@andig andig changed the title chore: remove redundant nil checks before len() chore: remove redundant nil checks Jul 31, 2026
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