Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run lint static analysis on the repository as part of CI #771

Open
1 of 2 tasks
YuviGold opened this issue Sep 11, 2022 · 0 comments
Open
1 of 2 tasks

Run lint static analysis on the repository as part of CI #771

YuviGold opened this issue Sep 11, 2022 · 0 comments

Comments

@YuviGold
Copy link
Contributor

Expected Behaviour

Fail CI on linting errors

Current Behaviour

No static analysis validations.

Are you a GitHub Sponsor yet (Yes/No?)

  • Yes
  • No

Possible Solution

Use https://github.com/golangci/golangci-lint as make lint.

Context

The arkade repository is becoming bigger, and it's recommended to follow some linting rules as a standard. There are static analysis tools that can take of that.
Using a linter is a best practice and might even find some bugs.

Running golangci-lint on arkade
➜  arkade git:(master) golangci-lint run ./...
pkg/archive/untar.go:116:6: `validRelativeDir` is unused (deadcode)
func validRelativeDir(dir string) bool {
     ^
pkg/archive/unzip.go:25:15: copylocks: call of unzip copies lock value: archive/zip.Reader contains sync.Once contains sync.Mutex (govet)
	return unzip(*zipReader, dir, quiet)
	             ^
pkg/archive/unzip.go:28:14: copylocks: unzip passes lock by value: archive/zip.Reader contains sync.Once contains sync.Mutex (govet)
func unzip(r zip.Reader, dir string, quiet bool) (err error) {
             ^
cmd/apps/minio_app.go:152:8: `clientOS` is unused (deadcode)
var _, clientOS = env.GetClientArch()
       ^
cmd/apps/osm_app.go:163:5: `osmInstallMsg` is unused (deadcode)
var osmInstallMsg = `=======================================================================
    ^
pkg/get/get.go:373:10: Error return value of `t.Parse` is not checked (errcheck)
		t.Parse(`Run the following to copy to install the tool:
		       ^
pkg/get/get.go:381:10: Error return value of `t.Parse` is not checked (errcheck)
		t.Parse(`# Add arkade binary directory to your PATH variable
		       ^
cmd/apps/metallb_app.go:80:13: Error return value of `rand.Read` is not checked (errcheck)
			rand.Read(randomToken)
			         ^
cmd/apps/of_loki.go:63:14: Error return value of `k8s.Kubectl` is not checked (errcheck)
		k8s.Kubectl("-n", openfaasNamespace,
		           ^
cmd/apps/openfaas_app.go:297:12: Error return value of `pem.Encode` is not checked (errcheck)
	pem.Encode(&privOut, &pem.Block{Type: "EC PRIVATE KEY", Bytes: ecder})
	          ^
cmd/apps/openfaas_app.go:306:12: Error return value of `pem.Encode` is not checked (errcheck)
	pem.Encode(&pubOut, &pem.Block{Type: "PUBLIC KEY", Bytes: pubder})
	          ^
cmd/completion.go:57:32: Error return value of `(*github.com/spf13/cobra.Command).GenBashCompletion` is not checked (errcheck)
			cmd.Root().GenBashCompletion(os.Stdout)
			                            ^
cmd/completion.go:61:32: Error return value of `(*github.com/spf13/cobra.Command).GenFishCompletion` is not checked (errcheck)
			cmd.Root().GenFishCompletion(os.Stdout, true)
			                            ^
cmd/completion.go:63:38: Error return value of `(*github.com/spf13/cobra.Command).GenPowerShellCompletion` is not checked (errcheck)
			cmd.Root().GenPowerShellCompletion(os.Stdout)
			                                  ^
cmd/completion.go:77:31: Error return value of `(*github.com/spf13/cobra.Command).GenZshCompletion` is not checked (errcheck)
	rootCmd(cmd).GenZshCompletion(out)
	                             ^
cmd/completion.go:78:16: Error return value of `io.WriteString` is not checked (errcheck)
	io.WriteString(out, zshCompdef)
	              ^
main.go:22:12: Error return value of `cmd.Help` is not checked (errcheck)
			cmd.Help()
			        ^
cmd/apps/inletsoperator_app.go:176:9: S1002: should omit comparison to bool constant, can be simplified to `!fileFlagChanged` (gosimple)
					if fileFlagChanged == false {
					   ^
cmd/apps/openfaas_app.go:192:6: S1002: should omit comparison to bool constant, can be simplified to `!basicAuthEnabled` (gosimple)
		if basicAuthEnabled == false {
		   ^
pkg/get/download.go:63:68: S1002: should omit comparison to bool constant, can be simplified to `!tool.NoExtension` (gosimple)
	if strings.Contains(strings.ToLower(operatingSystem), "mingw") && tool.NoExtension == false {
	                                                                  ^
pkg/get/download.go:201:68: S1002: should omit comparison to bool constant, can be simplified to `!tool.NoExtension` (gosimple)
	if strings.Contains(strings.ToLower(operatingSystem), "mingw") && tool.NoExtension == false {
	                                                                  ^
cmd/apps/linkerd_app.go:169:16: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
		Command:     fmt.Sprintf("%s", env.LocalBinary("linkerd2", "")),
		             ^
cmd/apps/osm_app.go:126:16: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
		Command:     fmt.Sprintf("%s", env.LocalBinary("osm", "")),
		             ^
pkg/get/get_test.go:143:11: S1025: the argument's underlying type is a slice of bytes, should use a simple conversion instead of fmt.Sprintf (gosimple)
			got := fmt.Sprintf("%s", msg)
			       ^
pkg/helm/helm.go:93:16: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
		Command:     fmt.Sprintf("%s", env.LocalBinary("helm", subdir)),
		             ^
cmd/apps/openfaas_app.go:276:3: S1023: redundant break statement (gosimple)
		break
		^
cmd/apps/openfaas_app.go:279:3: S1023: redundant break statement (gosimple)
		break
		^
cmd/apps/minio_app.go:113:15: ineffectual assignment to err (ineffassign)
			accessKey, err = gen.Generate(20, 10, 0, false, true)
			           ^
cmd/apps/minio_app.go:117:15: ineffectual assignment to err (ineffassign)
			secretKey, err = gen.Generate(40, 10, 5, false, true)
			           ^
cmd/apps/openfaas_ingress_app.go:173:3: SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
		log.Printf(tempDirectory)
		^
cmd/apps/registry_app.go:155:4: SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
			fmt.Printf(fmt.Sprintf("Registry credentials: %s %s\nexport PASSWORD=%s\n", username, pass, pass))

Your Environment

  • What Kubernetes distribution are you using?
kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"clean", BuildDate:"2021-09-15T21:38:50Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}
  • Operating System and version (e.g. Linux, Windows, MacOS):
uname -a

Linux yuvalgold 5.10.0-1050-oem #52-Ubuntu SMP Wed Oct 6 12:58:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

  • What arkade version is this?
arkade version
            _             _      
  __ _ _ __| | ____ _  __| | ___ 
 / _` | '__| |/ / _` |/ _` |/ _ \
| (_| | |  |   < (_| | (_| |  __/
 \__,_|_|  |_|\_\__,_|\__,_|\___|

Open Source Marketplace For Developer Tools

Version: 0.8.42
Git Commit: cd54f6a171afb07ef27f8e8e23e9cb13a4e3878b

 🐳 arkade needs your support: https://github.com/sponsors/alexellis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant