Skip to content

Commit

Permalink
Hygiene: enable ineffassign linter. 🧹🧹🧹
Browse files Browse the repository at this point in the history
This linter identifies unused variable assignments.

- Fixes identified lint issues.
- Updated configuration to ignore inefective assignments in unit tests.

Context: tektoncd#5899

/kind cleanup

<!-- 🎉🎉🎉 Thank you for the PR!!! 🎉🎉🎉 -->

- [N/A] Has [Docs](https://github.com/tektoncd/community/blob/main/standards.md#docs) included if any changes are user facing
- [N/A] Has [Tests](https://github.com/tektoncd/community/blob/main/standards.md#tests) included if any functionality added or changed
- [x] Follows the [commit message standard](https://github.com/tektoncd/community/blob/main/standards.md#commits)
- [x] Meets the [Tekton contributor standards](https://github.com/tektoncd/community/blob/main/standards.md) (including functionality, content, code)
- [x] Has a kind label. You can add one by adding a comment on this PR that contains `/kind <type>`. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
- [x] Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
- [x] Release notes contains the string "action required" if the change requires additional action from users switching to the new release
  • Loading branch information
bendory authored and EmmaMunley committed Mar 9, 2023
1 parent 99a17f8 commit b4a5e54
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ linters:
- usestdlibvars
- whitespace
disable:
- ineffassign
- staticcheck
# Enabling presets means that new linters that we automatically adopt new
# linters that augment a preset. This also opts us in for replacement linters
Expand Down Expand Up @@ -70,6 +69,7 @@ issues:
- dogsled
- errcheck
- gosec
- ineffassign
- path: test/pipelinerun_test\.go
linters:
- unused
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipelinerunmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func viewRegister(cfg *config.Metrics) error {
r.mutex.Lock()
defer r.mutex.Unlock()

prunTag := []tag.Key{}
var prunTag []tag.Key

switch cfg.PipelinerunLevel {
case config.PipelinerunLevelAtPipelinerun:
Expand Down
2 changes: 1 addition & 1 deletion pkg/pod/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func filterResultsAndResources(results []v1beta1.PipelineResourceResult, specRes
for _, r := range results {
switch r.ResultType {
case v1beta1.TaskRunResultType:
taskRunResult := v1beta1.TaskRunResult{}
var taskRunResult v1beta1.TaskRunResult
if neededTypes[r.Key] == v1beta1.ResultsTypeString {
taskRunResult = v1beta1.TaskRunResult{
Name: r.Key,
Expand Down
2 changes: 1 addition & 1 deletion pkg/resolution/resolver/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func GetEntry(ctx context.Context, keychain authn.Keychain, opts RequestOptions)
obj, err := readTarLayer(layerMap[l.Digest.String()])
if err != nil {
// This could still be a raw layer so try to read it as that instead.
obj, err = readRawLayer(layers[idx])
obj, _ = readRawLayer(layers[idx])
}
return &ResolvedResource{
data: obj,
Expand Down
2 changes: 1 addition & 1 deletion pkg/resolution/resolver/bundle/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (r *Resolver) Resolve(ctx context.Context, params []pipelinev1beta1.Param)
return nil, err
}
namespace := common.RequestNamespace(ctx)
kc, err := k8schain.New(ctx, r.kubeClientSet, k8schain.Options{
kc, _ := k8schain.New(ctx, r.kubeClientSet, k8schain.Options{
Namespace: namespace,
ServiceAccountName: opts.ServiceAccount,
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/taskrunmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ func viewRegister(cfg *config.Metrics) error {
r.mutex.Lock()
defer r.mutex.Unlock()

prunTag := []tag.Key{}
trunTag := []tag.Key{}
var prunTag []tag.Key
switch cfg.PipelinerunLevel {
case config.PipelinerunLevelAtPipelinerun:
prunTag = []tag.Key{pipelineTag, pipelinerunTag}
Expand All @@ -151,6 +150,7 @@ func viewRegister(cfg *config.Metrics) error {
return errors.New("invalid config for PipelinerunLevel: " + cfg.PipelinerunLevel)
}

var trunTag []tag.Key
switch cfg.TaskrunLevel {
case config.TaskrunLevelAtTaskrun:
trunTag = []tag.Key{taskTag, taskrunTag}
Expand Down

0 comments on commit b4a5e54

Please sign in to comment.