Skip to content

Commit

Permalink
refactor: enable ineffassign linter (#2500)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
phillebaba committed May 20, 2024
1 parent 41c0ad7 commit 1537260
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ linters:
enable:
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- revive
Expand Down
18 changes: 4 additions & 14 deletions src/pkg/packager/filters/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 1537260

Please sign in to comment.