Repository navigation
refactor(api): extract certificate normalization from AddCertificate - #1333
Merged
Merged
Conversation
rsdmike
force-pushed
the
refactor/add-certificate-complexity
branch
from
October 16, 2026 22:03
dc27b60 to
4de2317
Compare
rsdmike
enabled auto-merge (squash)
October 16, 2026 22:04
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Empty normalization results now reach device operations instead of returning early, violating the intended behavior preservation.
1 open issue
What changed in this PR
Extracts certificate normalization into a helper to reduce AddCertificate complexity and resolve the reported lint failure.
Changes:
- Moves decoding, parsing, and expiry checks into
normalizeCertificate. - Calls the helper before setting up the device client.
| File | Description |
|---|---|
| internal/usecase/devices/certificates.go | Extracts certificate normalization from AddCertificate. |
Review effort: Balanced
golangci-lint v2.15.0 reports AddCertificate at cognitive complexity 17 (limit 16). Move base64/PEM decoding and validation into normalizeCertificate with no behavior change. An expired certificate or a non-CERTIFICATE PEM block still returns early without contacting the device, now covered by tests.
rsdmike
force-pushed
the
refactor/add-certificate-complexity
branch
from
October 16, 2026 22:06
4de2317 to
ca5f267
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1333 +/- ##
==========================================
+ Coverage 62.17% 62.24% +0.06%
==========================================
Files 159 159
Lines 13414 13417 +3
==========================================
+ Hits 8340 8351 +11
+ Misses 5074 5066 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
graikhel-intel
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

CI installs the latest golangci-lint. v2.15.0 reports AddCertificate at cognitive complexity 17 (limit 16), which fails the golangci-lint job on every PR.
This moves the base64/PEM decode, parse, and expiry checks into normalizeCertificate with no behavior change. golangci-lint v2.15.0 reports 0 issues.