Skip to content

Commit

Permalink
fix some problems of golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: gy95 <1015105054@qq.com>
  • Loading branch information
gy95 committed Aug 4, 2021
1 parent 1612fa1 commit 6b41aac
Show file tree
Hide file tree
Showing 28 changed files with 84 additions and 99 deletions.
116 changes: 47 additions & 69 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
- vendor
- test
skip-files:
- .*_test.go

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
Expand All @@ -9,80 +32,35 @@ output:
# print linter name in the end of issue text, default is true
print-linter-name: true

# make issues output unique by line, default is true
uniq-by-line: 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:
- deadcode
- errcheck
- gocritic
# linters maintained by golang.org
- gofmt
- goimports
- golint
- gosimple
- goimports
- golint
- govet
- ineffassign
- interfacer
- lll
- misspell
- staticcheck
- structcheck
- typecheck
- unconvert
- unparam
- varcheck
# linters default enabled by golangci-lint .
#- deadcode
#- errcheck
#- gosimple
#- ineffassign
#- staticcheck
#- structcheck
#- typecheck
#- unused
#- varcheck
# other linters supported by golangci-lint.
#- gosec
#- whitespace

linters-settings:
goimports:
local-prefixes: volcano.sh


issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- path: test
linters:
- gomnd
- dupl
# TODO: unknownState is totally same with closingState
- path: pkg/controllers/queue/state/unknown.go
linters:
- dupl
- path: v1beta1
linters:
- golint
- dupl
- path: pkg/scheduler
linters:
- godot
- path: clientset
linters:
- godot
- path: informers
linters:
- godot
- path: pkg/cli/queue/operate.go
linters:
- godot
- path: pkg/controllers/job/plugins/ssh/ssh.go
linters:
- godot
- path: v1alpha1
linters:
- godot
- path: generated
linters:
- golint
- deadcode
- path: fake
linters:
- golint
- deadcode
- godot
# TODO: fix lint issue
- path: pkg/api
linters:
- errcheck
- lll
- unparam
- unconvert
- goimports
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ verify:

lint: ## Lint the files
golangci-lint version
golangci-lint run pkg/kube pkg/version pkg/apis/...
golangci-lint run -v

verify-generated-yaml:
./hack/check-generated-yaml.sh
Expand Down
4 changes: 2 additions & 2 deletions cmd/webhook-manager/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"strconv"
"syscall"

"k8s.io/klog"

v1 "k8s.io/api/core/v1"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/tools/record"
"k8s.io/klog"

"volcano.sh/apis/pkg/apis/scheduling/scheme"
"volcano.sh/volcano/cmd/webhook-manager/app/options"
"volcano.sh/volcano/pkg/kube"
Expand Down
12 changes: 6 additions & 6 deletions pkg/cli/queue/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import (
"os"
"strings"

busv1alpha1 "volcano.sh/apis/pkg/apis/bus/v1alpha1"
"volcano.sh/apis/pkg/apis/helpers"
"volcano.sh/apis/pkg/client/clientset/versioned"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
// Initialize client auth plugin.
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

busv1alpha1 "volcano.sh/apis/pkg/apis/bus/v1alpha1"
"volcano.sh/apis/pkg/apis/helpers"
"volcano.sh/apis/pkg/client/clientset/versioned"
)

func homeDir() string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/apis/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package apis
import (
"fmt"

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

batch "volcano.sh/apis/pkg/apis/batch/v1alpha1"
)
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/apis/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package apis

import (
"fmt"

"volcano.sh/apis/pkg/apis/bus/v1alpha1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/cache/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package cache

import (
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"

"volcano.sh/apis/pkg/apis/batch/v1alpha1"
"volcano.sh/volcano/pkg/controllers/apis"
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/framework/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package framework

import (
"fmt"

"k8s.io/klog"
)

Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/framework/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package framework
import (
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"

vcclientset "volcano.sh/apis/pkg/client/clientset/versioned"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/job/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"time"

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

"volcano.sh/volcano/pkg/controllers/apis"
)
Expand Down
3 changes: 1 addition & 2 deletions pkg/controllers/job/job_controller_resync.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import (
"time"

"golang.org/x/time/rate"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/util/workqueue"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/job/plugins/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"sync"

"volcano.sh/volcano/pkg/controllers/job/plugins/env"
"volcano.sh/volcano/pkg/controllers/job/plugins/interface"
pluginsinterface "volcano.sh/volcano/pkg/controllers/job/plugins/interface"
"volcano.sh/volcano/pkg/controllers/job/plugins/ssh"
"volcano.sh/volcano/pkg/controllers/job/plugins/svc"
)
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/job/state/running.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package state

import (
v1 "k8s.io/api/core/v1"

vcbatch "volcano.sh/apis/pkg/apis/batch/v1alpha1"
"volcano.sh/apis/pkg/apis/bus/v1alpha1"
"volcano.sh/volcano/pkg/controllers/apis"
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/actions/allocate/allocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package allocate

import (
"k8s.io/klog"

"volcano.sh/apis/pkg/apis/scheduling"
"volcano.sh/volcano/pkg/scheduler/api"
"volcano.sh/volcano/pkg/scheduler/framework"
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/actions/elect/elect.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package elect

import (
"k8s.io/klog"

"volcano.sh/apis/pkg/apis/scheduling"
"volcano.sh/volcano/pkg/scheduler/api"
"volcano.sh/volcano/pkg/scheduler/framework"
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/api/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

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

"volcano.sh/apis/pkg/apis/scheduling/v1beta1"
)

Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/api/numa_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/topology"
"k8s.io/kubernetes/pkg/kubelet/cm/cpuset"

nodeinfov1alpha1 "volcano.sh/apis/pkg/apis/nodeinfo/v1alpha1"
)

Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/api/pod_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

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

"volcano.sh/apis/pkg/apis/scheduling/v1beta1"
)

Expand Down
4 changes: 1 addition & 3 deletions pkg/scheduler/cache/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ limitations under the License.

package cache

import (
"k8s.io/api/core/v1"
)
import v1 "k8s.io/api/core/v1"

// responsibleForPod returns true if the pod has asked to be scheduled by the given scheduler.
func responsibleForPod(pod *v1.Pod, schedulerName string) bool {
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/framework/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"

"k8s.io/klog"

"volcano.sh/volcano/pkg/scheduler/api"
"volcano.sh/volcano/pkg/scheduler/metrics"
)
Expand Down
2 changes: 2 additions & 0 deletions pkg/scheduler/plugins/predicates/proportional.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package predicates

import (
"fmt"

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

"volcano.sh/volcano/pkg/scheduler/api"
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/scheduler/plugins/reservation/reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ limitations under the License.
package reservation

import (
"k8s.io/klog"
"time"

"k8s.io/klog"

"volcano.sh/volcano/pkg/scheduler/api"
"volcano.sh/volcano/pkg/scheduler/framework"
"volcano.sh/volcano/pkg/scheduler/util"
Expand Down
5 changes: 3 additions & 2 deletions pkg/scheduler/plugins/task-topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ package tasktopology

import (
"fmt"
"k8s.io/klog"
"k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
"strings"
"time"

"k8s.io/klog"
"k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"

"volcano.sh/volcano/pkg/scheduler/api"
"volcano.sh/volcano/pkg/scheduler/framework"
)
Expand Down
4 changes: 0 additions & 4 deletions pkg/scheduler/plugins/util/k8s/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,17 @@ func (f *Framework) RejectWaitingPod(uid types.UID) {
// HasFilterPlugins returns true if at least one filter plugin is defined.
func (f *Framework) HasFilterPlugins() bool {
panic("not implemented")
return false
}

// HasScorePlugins returns true if at least one score plugin is defined.
func (f *Framework) HasScorePlugins() bool {
panic("not implemented")
return false
}

// ListPlugins returns a map of extension point name to plugin names configured at each extension
// point. Returns nil if no plugins where configred.
func (f *Framework) ListPlugins() map[string][]config.Plugin {
panic("not implemented")
return nil
}

// ClientSet returns a kubernetes clientset.
Expand All @@ -90,7 +87,6 @@ func (f *Framework) SharedInformerFactory() informers.SharedInformerFactory {
// VolumeBinder returns the volume binder used by scheduler.
func (f *Framework) VolumeBinder() scheduling.SchedulerVolumeBinder {
panic("not implemented")
return nil
}

// EventRecorder was introduced in k8s v1.19.6 and to be implemented
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/plugins/util/k8s/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"

"volcano.sh/volcano/pkg/scheduler/plugins/util"
)

Expand Down
Loading

0 comments on commit 6b41aac

Please sign in to comment.