Skip to content

Conversation

@bupd
Copy link
Contributor

@bupd bupd commented Dec 23, 2025

Comprehensive Summary of your change

Add error handling linters to catch common bugs:

  • nilerr - Catches returning nil when error is not nil
  • nilnil - Catches returning (nil, nil) in (value, error) functions
  • Fixed all violations with proper error handling
  • Added //nolint comments for intentional patterns with justification

Issue being fixed

Fixes #22665
Fixes #22666

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/update"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@bupd bupd requested a review from a team as a code owner December 23, 2025 00:35
bupd added 2 commits December 23, 2025 06:06
Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: bupd <bupdprasanth@gmail.com>
@bupd bupd force-pushed the lint/error-handling branch from 78d24ae to 2ee8005 Compare December 23, 2025 00:36
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 35.13514% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.52%. Comparing base (c8c11b4) to head (a19c17c).
⚠️ Report is 611 commits behind head on main.

Files with missing lines Patch % Lines
src/controller/scanner/base_controller.go 0.00% 4 Missing ⚠️
src/server/middleware/quota/copy_artifact.go 0.00% 3 Missing ⚠️
src/pkg/reg/manager.go 0.00% 2 Missing ⚠️
src/controller/proxy/local.go 0.00% 1 Missing ⚠️
src/controller/replication/model/model.go 50.00% 1 Missing ⚠️
src/controller/robot/controller.go 0.00% 1 Missing ⚠️
src/controller/securityhub/controller.go 0.00% 1 Missing ⚠️
src/core/auth/authenticator.go 0.00% 1 Missing ⚠️
src/core/auth/db/db.go 0.00% 1 Missing ⚠️
src/pkg/immutable/manager.go 0.00% 1 Missing ⚠️
... and 8 more
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #22669       +/-   ##
===========================================
+ Coverage   45.36%   68.52%   +23.15%     
===========================================
  Files         244      821      +577     
  Lines       13333   101859    +88526     
  Branches     2719        0     -2719     
===========================================
+ Hits         6049    69802    +63753     
- Misses       6983    28174    +21191     
- Partials      301     3883     +3582     
Flag Coverage Δ
unittests 68.52% <35.13%> (+23.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/controller/artifact/processor/chart/chart.go 61.76% <ø> (ø)
src/controller/scandataexport/execution.go 87.91% <100.00%> (ø)
src/controller/systemartifact/execution.go 75.28% <ø> (ø)
src/controller/task/sweep.go 10.76% <ø> (ø)
src/core/auth/authproxy/auth.go 45.51% <ø> (ø)
src/core/auth/uaa/uaa.go 77.35% <100.00%> (ø)
src/jobservice/logger/base.go 85.61% <ø> (ø)
src/pkg/allowlist/dao/dao.go 60.97% <100.00%> (ø)
src/pkg/p2p/preheat/models/policy/policy.go 74.73% <100.00%> (ø)
src/pkg/queuestatus/dao/dao.go 62.85% <ø> (ø)
... and 25 more

... and 1018 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bupd bupd force-pushed the lint/error-handling branch 2 times, most recently from eb65c12 to 704e8d0 Compare December 23, 2025 01:47
Signed-off-by: bupd <bupdprasanth@gmail.com>
@bupd bupd force-pushed the lint/error-handling branch from 704e8d0 to a19c17c Compare December 23, 2025 09:08
@reasonerjt
Copy link
Contributor

I see you are adding tens of "// nolint:nilnil", so is it really needed?

@reasonerjt reasonerjt assigned reasonerjt and unassigned chlins and MinerYang Dec 29, 2025
@bupd
Copy link
Contributor Author

bupd commented Dec 29, 2025

I see you are adding tens of "// nolint:nilnil", so is it really needed?

Yeah, it's not a best practice to return nil, nil

And currently we are having this and the problem is, when I change it creates differences in the entire logic of how this handled in some cascading into more and more changes.

Just added nolint for the already present, in hopes of preventing this kind of antipatterns. Any new additions will fail the linter.

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.

Add errorlint to enforce proper Go 1.13+ error handling Add more linters to catch bugs earlier

5 participants