-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved linting and fixed linting issues in code
- Loading branch information
1 parent
ba0ba3e
commit 561685f
Showing
51 changed files
with
464 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
linters: | ||
disable-all: true | ||
enable: | ||
- asasalint | ||
- asciicheck | ||
- bodyclose | ||
- containedctx | ||
- copyloopvar | ||
- decorder | ||
- dogsled | ||
- errcheck | ||
- errchkjson | ||
- execinquery | ||
# - gci | ||
- goconst | ||
# - gocritic | ||
- gocyclo | ||
- godot | ||
- gofmt | ||
- goimports | ||
- goprintffuncname | ||
# - gosec | ||
- gosimple | ||
- govet | ||
# - importas | ||
- ineffassign | ||
- misspell | ||
- nakedret | ||
- nilerr | ||
- noctx | ||
- nolintlint | ||
- nosprintfhostport | ||
- prealloc | ||
- predeclared | ||
- reassign | ||
# - revive | ||
- rowserrcheck | ||
- staticcheck | ||
# - stylecheck | ||
# - thelper | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- usestdlibvars | ||
- whitespace | ||
|
||
linters-settings: | ||
gocyclo: | ||
min-complexity: 20 | ||
godot: | ||
# declarations - for top level declaration comments (default); | ||
# toplevel - for top level comments; | ||
# all - for all comments. | ||
scope: toplevel | ||
exclude: | ||
- '^ \+.*' | ||
- '^ ANCHOR.*' | ||
gci: | ||
sections: | ||
- standard | ||
- default | ||
- prefix(github.com/IBM) | ||
- prefix(k8s.io) | ||
- prefix(sigs.k8s.io) | ||
- blank | ||
- dot | ||
importas: | ||
no-unaliased: true | ||
alias: | ||
# Kubernetes | ||
- pkg: k8s.io/api/core/v1 | ||
alias: corev1 | ||
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 | ||
alias: apiextensionsv1 | ||
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1 | ||
alias: metav1 | ||
- pkg: k8s.io/apimachinery/pkg/api/errors | ||
alias: apierrors | ||
- pkg: k8s.io/apimachinery/pkg/util/errors | ||
alias: kerrors | ||
# Controller Runtime | ||
- pkg: sigs.k8s.io/controller-runtime | ||
alias: ctrl | ||
nolintlint: | ||
allow-unused: false | ||
# allow-leading-space: false | ||
require-specific: true | ||
gosec: | ||
excludes: | ||
- G307 # Deferring unsafe method "Close" on type "\*os.File" | ||
- G108 # Profiling endpoint is automatically exposed on /debug/pprof | ||
gocritic: | ||
enabled-tags: | ||
- experimental | ||
disabled-checks: | ||
- appendAssign | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- evalOrder | ||
- ifElseChain | ||
- octalLiteral | ||
- regexpSimplify | ||
- sloppyReassign | ||
- truncateCmp | ||
- typeDefFirst | ||
- unnamedResult | ||
- unnecessaryDefer | ||
- whyNoLint | ||
- wrapperFunc | ||
unused: | ||
go: "1.22" | ||
issues: | ||
exclude-files: | ||
- "zz_generated.*\\.go$" | ||
max-same-issues: 0 | ||
max-issues-per-linter: 0 | ||
# We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant | ||
# changes in PRs and avoid nitpicking. | ||
exclude-use-default: false | ||
exclude-rules: | ||
- linters: | ||
- gci | ||
path: _test\.go | ||
- linters: | ||
- revive | ||
text: "exported: exported method .*\\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported" | ||
- linters: | ||
- errcheck | ||
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked | ||
# Exclude some packages or code to require comments, for example test code, or fake clients. | ||
- linters: | ||
- revive | ||
text: exported (method|function|type|const) (.+) should have comment or be unexported | ||
source: (func|type).*Fake.* | ||
- linters: | ||
- revive | ||
text: exported (method|function|type|const) (.+) should have comment or be unexported | ||
path: fake_\.go | ||
- linters: | ||
- revive | ||
text: exported (method|function|type|const) (.+) should have comment or be unexported | ||
path: "(framework|e2e)/.*.go" | ||
# Disable unparam "always receives" which might not be really | ||
# useful when building libraries. | ||
- linters: | ||
- unparam | ||
text: always receives | ||
# Dot imports for gomega or ginkgo are allowed | ||
# within test files. | ||
- path: _test\.go | ||
text: should not use dot imports | ||
- path: (framework|e2e)/.*.go | ||
text: should not use dot imports | ||
- path: _test\.go | ||
text: cyclomatic complexity | ||
# Append should be able to assign to a different var/slice. | ||
- linters: | ||
- gocritic | ||
text: "appendAssign: append result not assigned to the same slice" | ||
# Disable linters for conversion | ||
- linters: | ||
- staticcheck | ||
text: "SA1019: in.(.+) is deprecated" | ||
path: .*(api|types)\/.*\/.*conversion.*\.go$ | ||
- linters: | ||
- revive | ||
text: exported (method|function|type|const) (.+) should have comment or be unexported | ||
path: .*(api|types)\/.*\/.*conversion.*\.go$ | ||
- linters: | ||
- revive | ||
text: "var-naming: don't use underscores in Go names;" | ||
path: .*(api|types)\/.*\/.*conversion.*\.go$ | ||
- linters: | ||
- revive | ||
text: "receiver-naming: receiver name" | ||
path: .*(api|types)\/.*\/.*conversion.*\.go$ | ||
- linters: | ||
- stylecheck | ||
text: "ST1003: should not use underscores in Go names;" | ||
path: .*(api|types)\/.*\/.*conversion.*\.go$ | ||
- linters: | ||
- stylecheck | ||
text: "ST1016: methods on the same type should have the same receiver name" | ||
path: .*(api|types)\/.*\/.*conversion.*\.go$ | ||
# hack/tools | ||
- linters: | ||
- typecheck | ||
text: import (".+") is a program, not an importable package | ||
path: ^tools\.go$ | ||
# We don't care about defer in for loops in test files. | ||
- linters: | ||
- gocritic | ||
text: "deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop" | ||
path: _test\.go | ||
|
||
run: | ||
timeout: 10m | ||
build-tags: | ||
- tools | ||
- e2e | ||
allow-parallel-runners: true | ||
go: "1.22" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,13 @@ import ( | |
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/klog/v2" | ||
|
||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/ibm-powervs-block-csi-driver/pkg/cloud" | ||
) | ||
|
||
// NodeUpdateReconciler reconciles a NodeUpdate object | ||
// NodeUpdateReconciler reconciles a NodeUpdate object. | ||
type NodeUpdateReconciler struct { | ||
Client client.Client | ||
Scheme *runtime.Scheme | ||
|
@@ -41,7 +42,6 @@ type NodeUpdateReconciler struct { | |
// For more details, check Reconcile and its Result here: | ||
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *NodeUpdateReconciler) Reconcile(_ context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
|
||
// Fetch the Node instance | ||
node := corev1.Node{} | ||
err := r.Client.Get(context.Background(), req.NamespacedName, &node) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ limitations under the License. | |
|
||
package options | ||
|
||
//DONE | ||
// DONE. | ||
|
||
import ( | ||
"flag" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ limitations under the License. | |
|
||
package options | ||
|
||
//DONE | ||
// DONE. | ||
|
||
import ( | ||
"flag" | ||
|
Oops, something went wrong.