🌱 Upgrade golanglint from 2.7.2 to 2.8.0 and fix issues#2487
🌱 Upgrade golanglint from 2.7.2 to 2.8.0 and fix issues#2487openshift-merge-bot[bot] merged 1 commit intooperator-framework:mainfrom
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR upgrades golangci-lint from version 2.7.2 to 2.8.0 and addresses linter warnings by implementing slice preallocation optimizations throughout the codebase. The changes focus on preallocating slices with appropriate capacities before appending elements in loops to improve memory allocation efficiency.
Changes:
- Updated golangci-lint dependency from v2.7.2 to v2.8.0 in build configuration files
- Added slice preallocation with capacity hints in 8 Go source files to address
prealloclinter warnings - Preallocated slices reduce memory allocations by reserving capacity upfront when the final size can be estimated
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| .bingo/variables.env | Updated golangci-lint version variable to v2.8.0 |
| .bingo/golangci-lint.mod | Updated golangci-lint module requirement to v2.8.0 |
| .bingo/Variables.mk | Updated golangci-lint binary version references and build commands |
| .bingo/golangci-lint.sum | Updated checksums for golangci-lint v2.8.0 and its dependencies |
| internal/operator-controller/rukpak/render/render.go | Preallocated error slice with capacity based on number of validators |
| internal/operator-controller/rukpak/render/registryv1/validators/validator.go | Preallocated error slices in three validator functions with calculated capacities |
| internal/operator-controller/resolve/catalog.go | Preallocated catalog slice with capacity based on resolved bundles count |
| internal/operator-controller/controllers/clusterextensionrevision_controller_internal_test.go | Preallocated names slice in test with capacity based on previous revisions count |
| internal/operator-controller/authorization/rbac.go | Preallocated authorization records slice with estimated capacity calculation |
| internal/operator-controller/applier/helm.go | Preallocated descriptions slice after counting total missing rules |
| internal/operator-controller/applier/boxcutter.go | Preallocated objects slice after counting total objects across phases |
| internal/catalogd/garbagecollection/garbage_collector_test.go | Preallocated runtime objects slice in test with capacity based on existing catalogs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/operator-controller/rukpak/render/registryv1/validators/validator.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2487 +/- ##
==========================================
+ Coverage 69.73% 73.82% +4.09%
==========================================
Files 102 102
Lines 8471 8496 +25
==========================================
+ Hits 5907 6272 +365
+ Misses 2091 1743 -348
- Partials 473 481 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // getObjects returns a slice of all objects in the revision | ||
| func getObjects(rev *ocv1.ClusterExtensionRevision) []client.Object { | ||
| var objs []client.Object | ||
| totalObjects := 0 |
There was a problem hiding this comment.
should we just nolint instead? it seems like over optimization somehow...or are there good reasons to do this?
There was a problem hiding this comment.
nolint we ignore the error
IHMO we should fix. Why not fix the error?
PS.: All still passing on the tests so I think we can be confident that nothing change here.
There was a problem hiding this comment.
We normally fix the issues and not add //nolint.
I think you raised the concern because a comment in OPM.operator-framework/operator-registry#1898 (comment)
But that is because the project is like legacy one and either we must understand better with jordan what he meant with that.
There was a problem hiding this comment.
it just feels like extra complexity for the sole purpose of avoiding adding // nolint. Don't get me wrong, I think it should be used sparingly and we definitely should try to fix the issues rather than sidestep them. I'm just trying to understand if the added code is worth it (i.e. are we in a situation in which it makes some sense to use nolint?)
So, besides removing the lint issue, what do we gain by running ahead of every slice allocation to allocated it to the exact right size in these cases?
There was a problem hiding this comment.
Yes that is an optimization / performance / memory
| var preAuthErrors []error | ||
| if len(missingRules) > 0 { | ||
| var missingRuleDescriptions []string | ||
| totalMissingRules := 0 |
|
Are all these changes consequences of upgrading lint version? |
Yes. They are. The changes here are to face the issue: I am adding it to the description as well. |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: perdasilva The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1624bed
into
operator-framework:main
Upgrade the lint version and fix the issues: