Repository navigation
chore(lint): enable forcetypeassert in golangci-lint - #1821
SaidAltury-ibm merged 1 commit into
Conversation
|
Hey @mbrandenburger 👋 thanks for the PR! This comment updates automatically as you push changes -- think of it as your PR's live scoreboard! PR Checks✅ DCO Sign-off -- All commits have valid sign-offs. Nice work! ❌ GPG Signature -- Heads up! The following commits don't have a verified GPG signature:
You'll need to sign your commits with GPG (e.g. ✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing! ❌ Issue Link -- This PR is not linked to any issue. Please reference an issue using a closing keyword (e.g. ⏳ All checks must pass before this PR can be reviewed. You've got this! |
SaidAltury-ibm
left a comment
There was a problem hiding this comment.
thank you @mbrandenburger , LGTM
…ertion Every production-code finding (100 across 33 packages when the linter was enabled) is fixed with a checked assertion: an error return for functions that already report errors, panic for the ones that don't, and either propagated to satisfy loop or bool-predicate conditions. Test fixtures and the nwo integration harness are excluded since a mismatch there is a test bug, not a security concern. Also uses proto.CloneOf, a new generic panic-safe clone helper, in place of proto.Clone(x).(*T) where that pattern showed up among the fixes. Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
8616ac4 to
1441db3
Compare
|
Tick the box to add this pull request to the merge queue (same as
|
Summary
forcetypeassertlinter, which flags unchecked type assertions (x.(T)without the, okform).errors.Errorffor error-returning functions,panic(errors.Errorf(...))for non-error-returning functions, restructured predicates forif v, ok := x.(T); ok && ...conditions, and collapsed a few redundant double-assertions into one.pkg/utils/proto.CloneOfhelper and use it inplatform/fabric/core/generic/discovery/client.goin place ofproto.Clone(x).(*T)+ assertion.forcetypeassertforintegration/,_test.go,_test_utils.go, andfake/— hand-written test doubles and the integration harness aren't attacker-reachable, so an unchecked assertion there is a test bug at worst.This is part of #1755
Test plan
go build ./...golangci-lint run --enable-only forcetypeassert ./...— 0 issuesmake checksacross all 5 modules