From 153726043f53baec00c4c72a75ef6936846cb02f Mon Sep 17 00:00:00 2001 From: Philip Laine Date: Mon, 20 May 2024 15:31:28 +0200 Subject: [PATCH] refactor: enable ineffassign linter (#2500) ## Description This change enables the ineffassign linter and fixes the only complaint by refactoring the select state filter. ## Related Issue Part of #2503 Depends on #2499 ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/.github/CONTRIBUTING.md#developer-workflow) followed --- .golangci.yaml | 1 + src/pkg/packager/filters/select.go | 18 ++++-------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 276faf17ae..cd775b13e2 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -5,6 +5,7 @@ linters: enable: - gosimple - govet + - ineffassign - staticcheck - unused - revive diff --git a/src/pkg/packager/filters/select.go b/src/pkg/packager/filters/select.go index 457643a3c6..2927fb827c 100644 --- a/src/pkg/packager/filters/select.go +++ b/src/pkg/packager/filters/select.go @@ -26,26 +26,16 @@ type selectStateFilter struct { // Apply applies the filter. func (f *selectStateFilter) Apply(pkg types.ZarfPackage) ([]types.ZarfComponent, error) { isPartial := len(f.requestedComponents) > 0 && f.requestedComponents[0] != "" - result := []types.ZarfComponent{} - for _, component := range pkg.Components { - selectState := unknown - + selectState := included if isPartial { selectState, _ = includedOrExcluded(component.Name, f.requestedComponents) - - if selectState == excluded { - continue - } - } else { - selectState = included } - - if selectState == included { - result = append(result, component) + if selectState != included { + continue } + result = append(result, component) } - return result, nil }