Skip to content

Commit

Permalink
add golangci-lint to project
Browse files Browse the repository at this point in the history
fix #792
  • Loading branch information
masihtehrani committed May 8, 2020
1 parent 927e1d9 commit 69a9404
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 16 deletions.
71 changes: 71 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- lll
- misspell
- nakedret
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
- gocognit
- godox
- maligned
- prealloc
- wsl
- godot
- nestif
- gomodguard
- asciicheck

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- path: test
linters:
- gomnd
- dupl
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ verify:
hack/verify-gencode.sh
hack/verify-vendor.sh

lint: ## Lint the files
golangci-lint version
golangci-lint run

verify-generated-yaml:
./hack/check-generated-yaml.sh

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/job/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func readFile(filename string) (*vcbatch.Job, error) {

var job vcbatch.Job
if err := yaml.Unmarshal(file, &job); err != nil {
return nil, fmt.Errorf("Failed to unmarshal file, err: %v", err)
return nil, fmt.Errorf("failed to unmarshal file, err: %v", err)
}

return &job, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/queue/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func DeleteQueue() error {
}

if len(deleteQueueFlags.Name) == 0 {
return fmt.Errorf("Queue name must be specified")
return fmt.Errorf("queue name must be specified")
}

queueClient := versioned.NewForConfigOrDie(config)
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/queue/operate.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func OperateQueue() error {
}

if len(operateQueueFlags.Name) == 0 {
return fmt.Errorf("Queue name must be specified")
return fmt.Errorf("queue name must be specified")
}

var action v1alpha1.Action
Expand All @@ -79,7 +79,7 @@ func OperateQueue() error {
action = v1alpha1.CloseQueueAction
case ActionUpdate:
if operateQueueFlags.Weight == 0 {
return fmt.Errorf("When %s queue %s, weight must be specified, "+
return fmt.Errorf("when %s queue %s, weight must be specified, "+
"the value must be greater than 0", ActionUpdate, operateQueueFlags.Name)
}

Expand All @@ -89,9 +89,9 @@ func OperateQueue() error {

return err
case "":
return fmt.Errorf("Action can not be null")
return fmt.Errorf("action can not be null")
default:
return fmt.Errorf("Action %s invalid, valid actions are %s, %s and %s",
return fmt.Errorf("action %s invalid, valid actions are %s, %s and %s",
operateQueueFlags.Action, ActionOpen, ActionClose, ActionUpdate)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/queue/queue_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (c *Controller) handleCommand(cmd *busv1alpha1.Command) error {

err := c.vcClient.BusV1alpha1().Commands(cmd.Namespace).Delete(cmd.Name, nil)
if err != nil {
if true == apierrors.IsNotFound(err) {
if apierrors.IsNotFound(err) {
return nil
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/controllers/queue/state/closed.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,4 @@ func (cs *closedState) Execute(action v1alpha1.Action) error {
return
})
}

return nil
}
2 changes: 0 additions & 2 deletions pkg/controllers/queue/state/closing.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,4 @@ func (cs *closingState) Execute(action v1alpha1.Action) error {
return
})
}

return nil
}
2 changes: 0 additions & 2 deletions pkg/controllers/queue/state/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,4 @@ func (os *openState) Execute(action v1alpha1.Action) error {
return
})
}

return nil
}
3 changes: 1 addition & 2 deletions test/e2e/job_controlled_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ var _ = Describe("Job E2E Test: Test Job PVCs", func() {
ctx := initTestContext(options{})
defer cleanupTestContext(ctx)

var tt v12.HostPathType
tt = "DirectoryOrCreate"
var tt v12.HostPathType = "DirectoryOrCreate"

storageClsName := "standard"

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/job_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ var _ = Describe("Job E2E Test: Test Job Plugins", func() {
Expect(err).NotTo(HaveOccurred())

// Check whether network policy is created with job name
networkPolicyName := fmt.Sprintf("%s", jobName)
networkPolicyName := jobName
_, err = ctx.kubeclient.NetworkingV1().NetworkPolicies(ctx.namespace).Get(networkPolicyName, v1.GetOptions{})
// Error will occur because there is no policy should be created
Expect(err).To(HaveOccurred())
Expand Down

0 comments on commit 69a9404

Please sign in to comment.