k8sgpt-ai/k8sgpt

[BUG]: Make lint command is not working.

Closed this issue · 2 comments

Checklist

  • I've searched for similar issues and couldn't find anything matching
  • I've included steps to reproduce the behavior

Affected Components

  • K8sGPT (CLI)
  • K8sGPT Operator

K8sGPT Version

v0.3.40

Kubernetes Version

v1.30.2

Host OS and its Version

Suse Linux

Steps to reproduce

Download the codebase and try to run the command make lint.

Command - make lint
Expected Output - All analysis should be done on the codebase and a report should be visible in the terminal ourput.

Expected behaviour

make lint command should output all the linter issues in the codebase. Any static type checking should be highlighted after running this command.

Actual behaviour

The command is not working even though we see a separate section under the makefile.PHONY section.

Additional Information

kakarot27:~/codes/k8sgpt # make lint
installing golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /bin v1.54.2
golangci/golangci-lint info checking GitHub for tag 'v1.54.2'
golangci/golangci-lint info found version: 1.54.2 for v1.54.2/linux/amd64
golangci/golangci-lint info installed /bin/golangci-lint
INFO [config_reader] Config search paths: [./ /root/codes/k8sgpt /root/codes /root /]
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]
INFO [loader] Go packages loading at mode 575 (types_sizes|compiled_files|deps|exports_file|files|imports|name) took 19.092261514s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 12.871198ms
INFO [linters_context/goanalysis] analyzers took 5m49.829589415s with top 10 stages: buildir: 4m18.607594704s, nilness: 15.310217343s, fact_deprecated: 12.827593479s, printf: 12.108849907s, ctrlflow: 11.808527989s, fact_purity: 11.604008722s, typedness: 10.097794594s, SA5012: 9.110693981s, inspect: 7.201857076s, isgenerated: 122.943191ms
INFO [runner/max_same_issues] 1/4 issues with text "loopclosure: loop variable cAnalyzer captured by func literal" were hidden, use --max-same-issues
INFO [runner] Issues before processing: 15, after processing: 8
INFO [runner] Processors filtering stat (out/in): skip_dirs: 15/15, autogenerated_exclude: 15/15, identifier_marker: 15/15, diff: 9/9, max_same_issues: 8/9, path_prefixer: 8/8, filename_unadjuster: 15/15, severity-rules: 8/8, sort_results: 8/8, source_code: 8/8, skip_files: 15/15, exclude: 15/15, exclude-rules: 11/15, uniq_by_line: 9/9, max_per_file_from_linter: 9/9, fixer: 8/8, path_prettifier: 15/15, nolint: 9/11, max_from_linter: 8/8, path_shortener: 8/8, cgo: 15/15
INFO [runner] processing took 20.025377ms with stages: nolint: 11.711938ms, autogenerated_exclude: 5.915518ms, source_code: 1.237623ms, exclude-rules: 567.943µs, identifier_marker: 307.3µs, path_prettifier: 136.398µs, skip_dirs: 64.16µs, max_same_issues: 50.954µs, uniq_by_line: 7.864µs, max_from_linter: 7.328µs, path_shortener: 5.897µs, cgo: 4.622µs, filename_unadjuster: 2.254µs, max_per_file_from_linter: 1.236µs, skip_files: 1.056µs, fixer: 753ns, severity-rules: 748ns, sort_results: 692ns, exclude: 516ns, diff: 366ns, path_prefixer: 211ns
INFO [runner] linters took 51.393224521s with stages: goanalysis_metalinter: 51.373089596s
pkg/ai/azureopenai.go:20:2: field organizationId is unused (unused)
organizationId string
^
pkg/ai/openai.go:34:2: field organizationId is unused (unused)
organizationId string
^
pkg/analysis/analysis.go:186:39: loopclosure: loop variable cAnalyzer captured by func literal (govet)
canClient, err := custom.NewClient(cAnalyzer.Connection)
^
pkg/analysis/analysis.go:189:86: loopclosure: loop variable cAnalyzer captured by func literal (govet)
a.Errors = append(a.Errors, fmt.Sprintf("Client creation error for %s analyzer", cAnalyzer.Name))
^
pkg/analysis/analysis.go:199:19: loopclosure: loop variable cAnalyzer captured by func literal (govet)
result.Kind = cAnalyzer.Name
^
pkg/custom/client.go:20:15: SA1019: grpc.Dial is deprecated: use NewClient instead. Will be supported throughout 1.x. (staticcheck)
conn, err := grpc.Dial(fmt.Sprintf("%s:%s", c.Url, c.Port), grpc.WithTransportCredentials(insecure.NewCredentials()))
^
pkg/server/server.go:29:6: SA1019: "buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2/schema/v1/server_analyzer_service/schemav1gateway" is deprecated: This package has moved to "buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2/schema/v1/schemav1gateway". Use that import path instead. (staticcheck)
gw2 "buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2/schema/v1/server_analyzer_service/schemav1gateway"
^
pkg/server/server.go:30:5: SA1019: "buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2/schema/v1/server_config_service/schemav1gateway" is deprecated: This package has moved to "buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2/schema/v1/schemav1gateway". Use that import path instead. (staticcheck)
gw "buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc-ecosystem/gateway/v2/schema/v1/server_config_service/schemav1gateway"
^
INFO File cache stats: 5 entries of total size 22.6KiB
INFO Memory: 618 samples, avg is 1174.8MB, max is 2853.5MB
INFO Execution took 1m10.515440652s
make: *** [Makefile:103: lint] Error 1

I can work on this issue with this proposed solution.

  1. Check if the lint-cli is installed already. If installed already we should be able to run the command make lint and should be able to get the linter issues.
  2. If lint-cli is not installed we install the cli and identify the issues and fix them.

How are you getting on with this @DonCorleone92 ?