Skip to content

Commit

Permalink
chore: More opinionated linting (#5072)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec committed Feb 13, 2021
1 parent 19b22f2 commit a50ddb2
Show file tree
Hide file tree
Showing 174 changed files with 466 additions and 627 deletions.
15 changes: 14 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://github.com/golangci/golangci/wiki/Configuration
# https://golangci-lint.run/usage/quick-start/
run:
skip-dirs:
- pkg/client
Expand All @@ -14,7 +14,20 @@ run:
- functional
linters:
enable:
- deadcode
- errcheck
- goimports
- gci
- gofumpt
- gosimple
- govet
- misspell
- staticcheck
- structcheck
- typecheck
- unparam
- unused
- varcheck
linters-settings:
goimports:
local-prefixes: github.com/argoproj/argo-workflows/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ manifests/install.yaml: $(CRDS) dist/kustomize
# lint/test/etc

$(GOPATH)/bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.33.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.36.0

.PHONY: lint
lint: server/static/files.go $(GOPATH)/bin/golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/archive/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func NewDeleteCommand() *cobra.Command {
var command = &cobra.Command{
command := &cobra.Command{
Use: "delete UID...",
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient()
Expand Down
6 changes: 2 additions & 4 deletions cmd/argo/commands/archive/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import (
)

func NewGetCommand() *cobra.Command {
var (
output string
)
var command = &cobra.Command{
var output string
command := &cobra.Command{
Use: "get UID",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 1 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/archive/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewListCommand() *cobra.Command {
output string
chunkSize int64
)
var command = &cobra.Command{
command := &cobra.Command{
Use: "list",
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient()
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/archive/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func NewArchiveCommand() *cobra.Command {
var command = &cobra.Command{
command := &cobra.Command{
Use: "archive",
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/auth/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func NewAuthCommand() *cobra.Command {
var command = &cobra.Command{
command := &cobra.Command{
Use: "auth",
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
Expand Down
6 changes: 4 additions & 2 deletions cmd/argo/commands/client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import (
"github.com/argoproj/argo-workflows/v3/util/kubeconfig"
)

var argoServerOpts = apiclient.ArgoServerOpts{}
var instanceID string
var (
argoServerOpts = apiclient.ArgoServerOpts{}
instanceID string
)

var overrides = clientcmd.ConfigOverrides{}

Expand Down
1 change: 0 additions & 1 deletion cmd/argo/commands/client/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ func TestGetAuthString(t *testing.T) {
_ = os.Setenv("ARGO_TOKEN", "my-token")
defer func() { _ = os.Unsetenv("ARGO_TOKEN") }()
assert.Equal(t, "my-token", GetAuthString())

}

func TestNamespace(t *testing.T) {
Expand Down
6 changes: 2 additions & 4 deletions cmd/argo/commands/clustertemplate/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ type cliCreateOpts struct {
}

func NewCreateCommand() *cobra.Command {
var (
cliCreateOpts cliCreateOpts
)
var command = &cobra.Command{
var cliCreateOpts cliCreateOpts
command := &cobra.Command{
Use: "create FILE1 FILE2...",
Short: "create a cluster workflow template",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
1 change: 0 additions & 1 deletion cmd/argo/commands/clustertemplate/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ spec:
`

func TestUnmarshalCWFT(t *testing.T) {

clusterwfts, err := unmarshalClusterWorkflowTemplates([]byte(cwfts), false)
if assert.NoError(t, err) {
assert.Equal(t, 2, len(clusterwfts))
Expand Down
9 changes: 3 additions & 6 deletions cmd/argo/commands/clustertemplate/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ package clustertemplate
import (
"fmt"

"github.com/spf13/cobra"

"github.com/argoproj/pkg/errors"
"github.com/spf13/cobra"

"github.com/argoproj/argo-workflows/v3/cmd/argo/commands/client"
"github.com/argoproj/argo-workflows/v3/pkg/apiclient/clusterworkflowtemplate"
)

// NewDeleteCommand returns a new instance of an `argo delete` command
func NewDeleteCommand() *cobra.Command {
var (
all bool
)
var all bool

var command = &cobra.Command{
command := &cobra.Command{
Use: "delete WORKFLOW_TEMPLATE",
Short: "delete a cluster workflow template",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
9 changes: 3 additions & 6 deletions cmd/argo/commands/clustertemplate/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@ import (
"fmt"
"log"

"github.com/argoproj/pkg/humanize"
"github.com/spf13/cobra"
"sigs.k8s.io/yaml"

"github.com/argoproj/pkg/humanize"

"github.com/argoproj/argo-workflows/v3/cmd/argo/commands/client"
clusterworkflowtmplpkg "github.com/argoproj/argo-workflows/v3/pkg/apiclient/clusterworkflowtemplate"
wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
)

func NewGetCommand() *cobra.Command {
var (
output string
)
var output string

var command = &cobra.Command{
command := &cobra.Command{
Use: "get CLUSTER WORKFLOW_TEMPLATE...",
Short: "display details about a cluster workflow template",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
9 changes: 3 additions & 6 deletions cmd/argo/commands/clustertemplate/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@ import (
"os"
"path/filepath"

"github.com/spf13/cobra"

"github.com/argoproj/pkg/errors"
"github.com/spf13/cobra"

"github.com/argoproj/argo-workflows/v3/cmd/argo/commands/client"
"github.com/argoproj/argo-workflows/v3/pkg/apiclient/clusterworkflowtemplate"
"github.com/argoproj/argo-workflows/v3/workflow/validate"
)

func NewLintCommand() *cobra.Command {
var (
strict bool
)
var command = &cobra.Command{
var strict bool
command := &cobra.Command{
Use: "lint FILE...",
Short: "validate files or directories of cluster workflow template manifests",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
7 changes: 2 additions & 5 deletions cmd/argo/commands/clustertemplate/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ type listFlags struct {
}

func NewListCommand() *cobra.Command {
var (
listArgs listFlags
)
var command = &cobra.Command{
var listArgs listFlags
command := &cobra.Command{
Use: "list",
Short: "list cluster workflow templates",
Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -42,7 +40,6 @@ func NewListCommand() *cobra.Command {
default:
log.Fatalf("Unknown output mode: %s", listArgs.output)
}

},
}
command.Flags().StringVarP(&listArgs.output, "output", "o", "", "Output format. One of: wide|name")
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/clustertemplate/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func NewClusterTemplateCommand() *cobra.Command {
var command = &cobra.Command{
command := &cobra.Command{
Use: "cluster-template",
Aliases: []string{"cwftmpl", "cwft"},
Short: "manipulate cluster workflow templates",
Expand Down
3 changes: 1 addition & 2 deletions cmd/argo/commands/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"strconv"
"strings"

"github.com/spf13/cobra"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ __argo_custom_func() {
)

func NewCompletionCommand() *cobra.Command {
var command = &cobra.Command{
command := &cobra.Command{
Use: "completion SHELL",
Short: "output shell completion code for the specified shell (bash or zsh)",
Long: `Write bash or zsh shell completion code to standard output.
Expand Down
4 changes: 1 addition & 3 deletions cmd/argo/commands/cron/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/argoproj/argo-workflows/v3/cmd/argo/commands/client"
cronworkflowpkg "github.com/argoproj/argo-workflows/v3/pkg/apiclient/cronworkflow"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/workflow/common"
"github.com/argoproj/argo-workflows/v3/workflow/util"
Expand All @@ -27,7 +26,7 @@ func NewCreateCommand() *cobra.Command {
cliCreateOpts cliCreateOpts
submitOpts wfv1.SubmitOpts
)
var command = &cobra.Command{
command := &cobra.Command{
Use: "create FILE1 FILE2...",
Short: "create a cron workflow",
Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -48,7 +47,6 @@ func NewCreateCommand() *cobra.Command {
}

func CreateCronWorkflows(filePaths []string, cliOpts *cliCreateOpts, submitOpts *wfv1.SubmitOpts) {

ctx, apiClient := client.NewAPIClient()
serviceClient := apiClient.NewCronWorkflowServiceClient()

Expand Down
6 changes: 2 additions & 4 deletions cmd/argo/commands/cron/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import (

// NewDeleteCommand returns a new instance of an `argo delete` command
func NewDeleteCommand() *cobra.Command {
var (
all bool
)
var all bool

var command = &cobra.Command{
command := &cobra.Command{
Use: "delete [CRON_WORKFLOW... | --all]",
Short: "delete a cron workflow",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 2 additions & 4 deletions cmd/argo/commands/cron/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ import (
)

func NewGetCommand() *cobra.Command {
var (
output string
)
var output string

var command = &cobra.Command{
command := &cobra.Command{
Use: "get CRON_WORKFLOW...",
Short: "display details about a cron workflow",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 2 additions & 4 deletions cmd/argo/commands/cron/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import (
)

func NewLintCommand() *cobra.Command {
var (
strict bool
)
var command = &cobra.Command{
var strict bool
command := &cobra.Command{
Use: "lint FILE...",
Short: "validate files or directories of cron workflow manifests",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
7 changes: 2 additions & 5 deletions cmd/argo/commands/cron/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/argoproj/pkg/errors"
"github.com/argoproj/pkg/humanize"

"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand All @@ -25,10 +24,8 @@ type listFlags struct {
}

func NewListCommand() *cobra.Command {
var (
listArgs listFlags
)
var command = &cobra.Command{
var listArgs listFlags
command := &cobra.Command{
Use: "list",
Short: "list cron workflows",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/cron/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// NewSuspendCommand returns a new instance of an `argo suspend` command
func NewResumeCommand() *cobra.Command {
var command = &cobra.Command{
command := &cobra.Command{
Use: "resume [CRON_WORKFLOW...]",
Short: "resume zero or more cron workflows",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/cron/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func NewCronWorkflowCommand() *cobra.Command {
var command = &cobra.Command{
command := &cobra.Command{
Use: "cron",
Short: "manage cron workflows",
Long: `NextScheduledRun assumes that the workflow-controller uses UTC as its timezone`,
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/cron/suspend.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// NewSuspendCommand returns a new instance of an `argo suspend` command
func NewSuspendCommand() *cobra.Command {
var command = &cobra.Command{
command := &cobra.Command{
Use: "suspend CRON_WORKFLOW...",
Short: "suspend zero or more cron workflows",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewDeleteCommand() *cobra.Command {
allNamespaces bool
dryRun bool
)
var command = &cobra.Command{
command := &cobra.Command{
Use: "delete [--dry-run] [WORKFLOW...|[--all] [--older] [--completed] [--resubmitted] [--prefix PREFIX] [--selector SELECTOR]]",
Short: "delete workflows",
Example: `# Delete a workflow:
Expand Down

0 comments on commit a50ddb2

Please sign in to comment.