Skip to content

Commit

Permalink
Hygiene: enable additional linter presets.
Browse files Browse the repository at this point in the history
This PR enables golangci presets format, import, metalinter,
module, unused, test.

Code changes correspond to the issues found by linters.

There are no expected functional changes in this PR.

Context: #5899

/kind cleanup

- Submitter Checklist

As the author of this PR, please check off the items in this checklist:

- [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
- [N/A] Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
- [N/A] Release notes contains the string "action required" if the change requires additional action from users switching to the new release

- Release Notes

```release-note
NONE
```
  • Loading branch information
bendory authored and tekton-robot committed Feb 28, 2023
1 parent 5cc8bf2 commit 1ac8e49
Show file tree
Hide file tree
Showing 62 changed files with 76 additions and 141 deletions.
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ linters:
- unused
- usestdlibvars
- whitespace
presets:
- format
- import
- metalinter
- module
- test
- unused
output:
uniq-by-line: false
issues:
Expand Down
15 changes: 7 additions & 8 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ import (
"github.com/tektoncd/pipeline/pkg/reconciler/resolutionrequest"
"github.com/tektoncd/pipeline/pkg/reconciler/run"
"github.com/tektoncd/pipeline/pkg/reconciler/taskrun"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/jaeger"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource"
tracesdk "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
"go.opentelemetry.io/otel/trace"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/rest"
"k8s.io/utils/clock"
Expand All @@ -39,14 +46,6 @@ import (
"knative.dev/pkg/injection"
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/signals"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/jaeger"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource"
tracesdk "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
"go.opentelemetry.io/otel/trace"
)

const (
Expand Down
5 changes: 1 addition & 4 deletions hack/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
package tools

import (
_ "github.com/ahmetb/gen-crd-api-reference-docs"
_ "github.com/tektoncd/plumbing"
_ "github.com/tektoncd/plumbing/cmd/combine"
_ "github.com/tektoncd/plumbing/scripts"

_ "k8s.io/code-generator/cmd/client-gen"
_ "k8s.io/code-generator/cmd/deepcopy-gen"
_ "k8s.io/code-generator/cmd/defaulter-gen"
_ "k8s.io/code-generator/cmd/informer-gen"
_ "k8s.io/code-generator/cmd/lister-gen"
_ "k8s.io/kube-openapi/cmd/openapi-gen"

_ "knative.dev/pkg/codegen/cmd/injection-gen"

_ "github.com/ahmetb/gen-crd-api-reference-docs"
)
1 change: 0 additions & 1 deletion pkg/apis/config/trusted_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"

cm "knative.dev/pkg/configmap"
)

Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/pipeline/v1/pipeline_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"github.com/tektoncd/pipeline/test/diff"

"github.com/google/go-cmp/cmp"
)

func TestPipeline_SetDefaults(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
"github.com/tektoncd/pipeline/pkg/apis/version"

"github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
5 changes: 2 additions & 3 deletions pkg/apis/pipeline/v1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import (
"context"
"time"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"

"github.com/tektoncd/pipeline/pkg/apis/config"
apisconfig "github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
pod "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod"
runv1beta1 "github.com/tektoncd/pipeline/pkg/apis/run/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/clock"
Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/pipeline/v1beta1/pipeline_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import (
"context"
"testing"

"github.com/tektoncd/pipeline/test/diff"

"github.com/google/go-cmp/cmp"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/test/diff"
)

func TestPipeline_SetDefaults(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
"github.com/tektoncd/pipeline/pkg/apis/version"

"github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
5 changes: 2 additions & 3 deletions pkg/apis/pipeline/v1beta1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ import (
"context"
"time"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"

"github.com/tektoncd/pipeline/pkg/apis/config"
apisconfig "github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
pod "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/clock"
Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/resource/v1alpha1/storage/gcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package storage_test
import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/google/go-cmp/cmp"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
Expand All @@ -29,6 +27,7 @@ import (
"github.com/tektoncd/pipeline/test/diff"
"github.com/tektoncd/pipeline/test/names"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var images = pipeline.Images{
Expand Down
3 changes: 1 addition & 2 deletions pkg/credentials/dockercreds/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import (
"path/filepath"
"strings"

corev1 "k8s.io/api/core/v1"

"github.com/tektoncd/pipeline/pkg/credentials"
corev1 "k8s.io/api/core/v1"
)

const annotationPrefix = "tekton.dev/docker-"
Expand Down
3 changes: 1 addition & 2 deletions pkg/credentials/dockercreds/creds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/tektoncd/pipeline/pkg/credentials"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/tektoncd/pipeline/pkg/credentials"
)

func TestFlagHandling(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/credentials/gitcreds/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ import (
"path/filepath"
"strings"

corev1 "k8s.io/api/core/v1"

"github.com/tektoncd/pipeline/pkg/credentials"
corev1 "k8s.io/api/core/v1"
)

// As the flag is read, this status is populated.
Expand Down
3 changes: 1 addition & 2 deletions pkg/credentials/gitcreds/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import (
"flag"
"fmt"

corev1 "k8s.io/api/core/v1"

"github.com/tektoncd/pipeline/pkg/credentials"
corev1 "k8s.io/api/core/v1"
)

const (
Expand Down
9 changes: 3 additions & 6 deletions pkg/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ import (
"testing"
"time"

"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"

"knative.dev/pkg/kmeta"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/tektoncd/pipeline/pkg/apis/config"
Expand All @@ -42,9 +37,11 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fakek8s "k8s.io/client-go/kubernetes/fake"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
"knative.dev/pkg/kmeta"
logtesting "knative.dev/pkg/logging/testing"
"knative.dev/pkg/system"

_ "knative.dev/pkg/system/testing" // Setup system.Namespace()
)

Expand Down
1 change: 0 additions & 1 deletion pkg/reconciler/customrun/customrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"knative.dev/pkg/logging"
pkgreconciler "knative.dev/pkg/reconciler"
"knative.dev/pkg/system"

_ "knative.dev/pkg/system/testing" // Setup system.Namespace()
)

Expand Down
3 changes: 1 addition & 2 deletions pkg/reconciler/events/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import (
"errors"
"fmt"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"

cloudevents "github.com/cloudevents/sdk-go/v2"
lru "github.com/hashicorp/golang-lru"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
)

// Struct to unmarshal the event data
Expand Down
6 changes: 2 additions & 4 deletions pkg/reconciler/events/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ import (
"testing"
"time"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"

cloudevents "github.com/cloudevents/sdk-go/v2"
lru "github.com/hashicorp/golang-lru"

"github.com/cloudevents/sdk-go/v2/event"
cetypes "github.com/cloudevents/sdk-go/v2/types"
"github.com/google/go-cmp/cmp"
lru "github.com/hashicorp/golang-lru"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/test/diff"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down
6 changes: 2 additions & 4 deletions pkg/reconciler/events/cloudevent/cloudevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ import (
"fmt"
"strings"

"github.com/google/uuid"

cloudevents "github.com/cloudevents/sdk-go/v2"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"knative.dev/pkg/apis"

"github.com/google/uuid"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"knative.dev/pkg/apis"
)

// TektonEventType holds the types of cloud events sent by Tekton
Expand Down
8 changes: 3 additions & 5 deletions pkg/reconciler/pipelinerun/affinity_assistant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,19 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/tektoncd/pipeline/pkg/workspace"
"github.com/tektoncd/pipeline/test/diff"
"github.com/tektoncd/pipeline/test/parse"

"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/pod"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/pkg/workspace"
"github.com/tektoncd/pipeline/test/diff"
"github.com/tektoncd/pipeline/test/parse"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fakek8s "k8s.io/client-go/kubernetes/fake"
logtesting "knative.dev/pkg/logging/testing"
"knative.dev/pkg/system"

_ "knative.dev/pkg/system/testing" // Setup system.Namespace()
)

Expand Down
1 change: 0 additions & 1 deletion pkg/reconciler/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import (
logtesting "knative.dev/pkg/logging/testing"
"knative.dev/pkg/reconciler"
"knative.dev/pkg/system"

_ "knative.dev/pkg/system/testing" // Setup system.Namespace()
)

Expand Down
3 changes: 1 addition & 2 deletions pkg/reconciler/pipelinerun/resources/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ import (
"strings"

"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources"
"github.com/tektoncd/pipeline/pkg/substitution"
)

Expand Down
5 changes: 2 additions & 3 deletions pkg/reconciler/resolutionrequest/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ package resolutionrequest
import (
"context"

resolutionrequestinformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest"
resolutionrequestreconciler "github.com/tektoncd/pipeline/pkg/client/resolution/injection/reconciler/resolution/v1beta1/resolutionrequest"
"k8s.io/utils/clock"
"knative.dev/pkg/configmap"
"knative.dev/pkg/controller"

resolutionrequestinformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest"
resolutionrequestreconciler "github.com/tektoncd/pipeline/pkg/client/resolution/injection/reconciler/resolution/v1beta1/resolutionrequest"
)

// NewController returns a func that returns a knative controller for processing
Expand Down
1 change: 0 additions & 1 deletion pkg/reconciler/resolutionrequest/resolutionrequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
"knative.dev/pkg/logging"
pkgreconciler "knative.dev/pkg/reconciler"
"knative.dev/pkg/system"

_ "knative.dev/pkg/system/testing" // Setup system.Namespace()
)

Expand Down
9 changes: 3 additions & 6 deletions pkg/reconciler/run/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ import (
"strings"
"testing"

duckv1 "knative.dev/pkg/apis/duck/v1"
"knative.dev/pkg/controller"
"knative.dev/pkg/logging"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/tektoncd/pipeline/pkg/apis/config"
Expand All @@ -38,11 +34,12 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
cminformer "knative.dev/pkg/configmap/informer"
"knative.dev/pkg/controller"
"knative.dev/pkg/logging"
pkgreconciler "knative.dev/pkg/reconciler"

"knative.dev/pkg/system"

_ "knative.dev/pkg/system/testing" // Setup system.Namespace()
)

Expand Down
Loading

0 comments on commit 1ac8e49

Please sign in to comment.