Skip to content

Commit 69a9404

Browse files
committed
add golangci-lint to project
fix #792
1 parent 927e1d9 commit 69a9404

File tree

11 files changed

+84
-16
lines changed

11 files changed

+84
-16
lines changed

.golangci.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# output configuration options
2+
output:
3+
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
4+
format: colored-line-number
5+
6+
# print lines of code with issue, default is true
7+
print-issued-lines: true
8+
9+
# print linter name in the end of issue text, default is true
10+
print-linter-name: true
11+
12+
linters:
13+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
14+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
15+
disable-all: true
16+
enable:
17+
- bodyclose
18+
- deadcode
19+
- depguard
20+
- dogsled
21+
- dupl
22+
- errcheck
23+
- funlen
24+
- gochecknoinits
25+
- goconst
26+
- gocritic
27+
- gocyclo
28+
- gofmt
29+
- goimports
30+
- golint
31+
- gomnd
32+
- goprintffuncname
33+
- gosec
34+
- gosimple
35+
- govet
36+
- ineffassign
37+
- interfacer
38+
- lll
39+
- misspell
40+
- nakedret
41+
- rowserrcheck
42+
- scopelint
43+
- staticcheck
44+
- structcheck
45+
- stylecheck
46+
- typecheck
47+
- unconvert
48+
- unparam
49+
- unused
50+
- varcheck
51+
- whitespace
52+
- gocognit
53+
- godox
54+
- maligned
55+
- prealloc
56+
- wsl
57+
- godot
58+
- nestif
59+
- gomodguard
60+
- asciicheck
61+
62+
issues:
63+
# Excluding configuration per-path, per-linter, per-text and per-source
64+
exclude-rules:
65+
- path: _test\.go
66+
linters:
67+
- gomnd
68+
- path: test
69+
linters:
70+
- gomnd
71+
- dupl

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ verify:
8989
hack/verify-gencode.sh
9090
hack/verify-vendor.sh
9191

92+
lint: ## Lint the files
93+
golangci-lint version
94+
golangci-lint run
95+
9296
verify-generated-yaml:
9397
./hack/check-generated-yaml.sh
9498

pkg/cli/job/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func readFile(filename string) (*vcbatch.Job, error) {
128128

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

134134
return &job, nil

pkg/cli/queue/delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func DeleteQueue() error {
5050
}
5151

5252
if len(deleteQueueFlags.Name) == 0 {
53-
return fmt.Errorf("Queue name must be specified")
53+
return fmt.Errorf("queue name must be specified")
5454
}
5555

5656
queueClient := versioned.NewForConfigOrDie(config)

pkg/cli/queue/operate.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func OperateQueue() error {
6767
}
6868

6969
if len(operateQueueFlags.Name) == 0 {
70-
return fmt.Errorf("Queue name must be specified")
70+
return fmt.Errorf("queue name must be specified")
7171
}
7272

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

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

9090
return err
9191
case "":
92-
return fmt.Errorf("Action can not be null")
92+
return fmt.Errorf("action can not be null")
9393
default:
94-
return fmt.Errorf("Action %s invalid, valid actions are %s, %s and %s",
94+
return fmt.Errorf("action %s invalid, valid actions are %s, %s and %s",
9595
operateQueueFlags.Action, ActionOpen, ActionClose, ActionUpdate)
9696
}
9797

pkg/controllers/queue/queue_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func (c *Controller) handleCommand(cmd *busv1alpha1.Command) error {
298298

299299
err := c.vcClient.BusV1alpha1().Commands(cmd.Namespace).Delete(cmd.Name, nil)
300300
if err != nil {
301-
if true == apierrors.IsNotFound(err) {
301+
if apierrors.IsNotFound(err) {
302302
return nil
303303
}
304304

pkg/controllers/queue/state/closed.go

-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,4 @@ func (cs *closedState) Execute(action v1alpha1.Action) error {
5454
return
5555
})
5656
}
57-
58-
return nil
5957
}

pkg/controllers/queue/state/closing.go

-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,4 @@ func (cs *closingState) Execute(action v1alpha1.Action) error {
6464
return
6565
})
6666
}
67-
68-
return nil
6967
}

pkg/controllers/queue/state/open.go

-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,4 @@ func (os *openState) Execute(action v1alpha1.Action) error {
6464
return
6565
})
6666
}
67-
68-
return nil
6967
}

test/e2e/job_controlled_resource.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ var _ = Describe("Job E2E Test: Test Job PVCs", func() {
3535
ctx := initTestContext(options{})
3636
defer cleanupTestContext(ctx)
3737

38-
var tt v12.HostPathType
39-
tt = "DirectoryOrCreate"
38+
var tt v12.HostPathType = "DirectoryOrCreate"
4039

4140
storageClsName := "standard"
4241

test/e2e/job_plugins.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ var _ = Describe("Job E2E Test: Test Job Plugins", func() {
206206
Expect(err).NotTo(HaveOccurred())
207207

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

0 commit comments

Comments
 (0)