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

fix: [Bug] Make lint command is not working #1282

Merged
merged 2 commits into from
Oct 30, 2024
Merged

Conversation

milapj
Copy link
Contributor

@milapj milapj commented Oct 30, 2024

Closes #1231

📑 Description

This PR addresses the issue with the make lint command failing. Including the error from the issue below for additional context and to confirm reproduction. Also, the original issue flags three more issues about loopclosure that I cannot reproduce locally

$ make lint
INFO golangci-lint has version 1.61.0 built with go1.23.1 from a1d6c560 on 2024-09-09T17:44:42Z
INFO [config_reader] Config search paths: [./ /home/biokami/github/k8sgpt /home/biokami/github /home/biokami /home / /home/sam]
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]
INFO [loader] Go packages loading at mode 575 (types_sizes|compiled_files|files|imports|deps|exports_file|name) took 37.356343783s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 23.780573ms
INFO [linters_context/goanalysis] analyzers took 9m31.785749341s with top 10 stages: buildir: 8m28.259905129s, nilness: 13.001237283s, inspect: 10.652286062s, fact_purity: 8.661608567s, fact_deprecated: 7.377448375s, ctrlflow: 6.601521846s, printf: 6.508601854s, typedness: 4.75981363s, SA5012: 3.402541383s, tokenfileanalyzer: 831.858424ms
INFO [runner] Issues before processing: 11, after processing: 5
INFO [runner] Processors filtering stat (in/out): cgo: 11/11, skip_dirs: 11/11, max_same_issues: 5/5, path_prefixer: 5/5, fixer: 5/5, path_prettifier: 11/11, diff: 5/5, max_from_linter: 5/5, source_code: 5/5, path_shortener: 5/5, severity-rules: 5/5, invalid_issue: 11/11, skip_files: 11/11, identifier_marker: 11/11, max_per_file_from_linter: 5/5, sort_results: 5/5, filename_unadjuster: 11/11, autogenerated_exclude: 11/11, exclude: 11/11, exclude-rules: 11/7, nolint: 7/5, uniq_by_line: 5/5
INFO [runner] processing took 4.011054ms with stages: nolint: 1.510237ms, exclude-rules: 790.353µs, identifier_marker: 767.966µs, autogenerated_exclude: 396.263µs, path_prettifier: 293.816µs, skip_dirs: 126.311µs, source_code: 83.464µs, uniq_by_line: 8.527µs, max_same_issues: 7.703µs, path_shortener: 6.668µs, invalid_issue: 5.204µs, cgo: 5.121µs, max_from_linter: 4.15µs, filename_unadjuster: 1.393µs, max_per_file_from_linter: 778ns, skip_files: 658ns, exclude: 580ns, sort_results: 502ns, fixer: 455ns, diff: 413ns, severity-rules: 247ns, path_prefixer: 245ns
INFO [runner] linters took 48.592671311s with stages: goanalysis_metalinter: 48.587994961s
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/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:30: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:31: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: 4 entries of total size 11.4KiB
INFO Memory: 784 samples, avg is 1773.0MB, max is 5122.4MB
INFO Execution took 1m25.990825774s
make: *** [Makefile:101: lint] Error 1
  • Added a timeout of 5 minutes to the golangci-lint command. After cloning the repo and running make lint initially, I encountered:
$ make lint
INFO golangci-lint has version 1.61.0 built with go1.23.1 from a1d6c560 on 2024-09-09T17:44:42Z
INFO [config_reader] Config search paths: [./ /home/biokami/github/k8sgpt /home/biokami/github /home/biokami /home / /home/sam]
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]
INFO Memory: 601 samples, avg is 26.3MB, max is 26.3MB
INFO Execution took 1m0.002315582s
INFO [loader] Go packages loading at mode 575 (imports|name|deps|exports_file|types_sizes|compiled_files|files) took 1m0.021065413s
ERRO Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: context deadline exceeded
ERRO Timeout exceeded: try increasing it by passing --timeout option
make: *** [Makefile:101: lint] Error 4

The default timeout of 1 minute is probably insufficient.

  • Commented out organizationId in pkg/ai/azureopenai.go and pkg/ai/openai.go as it was unused.

  • Excluded grpc.Dial and other issues flagged by the SA1019 rule in the linter configuration. This call is deprecated, and I opted not to update it since I'm still new to the project 😓

Result:

$ make lint
INFO golangci-lint has version 1.61.0 built with go1.23.1 from a1d6c560 on 2024-09-09T17:44:42Z
INFO [config_reader] Config search paths: [./ /home/biokami/github/k8sgpt /home/biokami/github /home/biokami /home / /home/sam]
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]
INFO [loader] Go packages loading at mode 575 (files|name|compiled_files|deps|exports_file|types_sizes|imports) took 1.32648586s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 15.3406ms
INFO [linters_context/goanalysis] analyzers took 0s with no stages
INFO [runner] Issues before processing: 9, after processing: 0
INFO [runner] Processors filtering stat (in/out): autogenerated_exclude: 9/9, cgo: 9/9, filename_unadjuster: 9/9, skip_dirs: 9/9, identifier_marker: 9/9, exclude: 9/9, invalid_issue: 9/9, path_prettifier: 9/9, skip_files: 9/9, exclude-rules: 9/5, nolint: 5/0
INFO [runner] processing took 2.618901ms with stages: nolint: 1.06591ms, exclude-rules: 678.79µs, identifier_marker: 455.436µs, autogenerated_exclude: 184.414µs, path_prettifier: 139.772µs, skip_dirs: 78.945µs, cgo: 4.743µs, invalid_issue: 3.153µs, max_same_issues: 1.659µs, filename_unadjuster: 1.182µs, fixer: 626ns, skip_files: 622ns, exclude: 603ns, uniq_by_line: 528ns, sort_results: 506ns, diff: 365ns, max_from_linter: 352ns, source_code: 336ns, max_per_file_from_linter: 259ns, path_prefixer: 244ns, path_shortener: 242ns, severity-rules: 214ns
INFO [runner] linters took 606.972398ms with stages: goanalysis_metalinter: 604.08972ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 21 samples, avg is 47.8MB, max is 90.5MB
INFO Execution took 1.965437183s

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

@milapj milapj requested review from a team as code owners October 30, 2024 02:33
Signed-off-by: Milap Jhumkhawala <[email protected]>
@AlexsJones AlexsJones merged commit 87565a0 into k8sgpt-ai:main Oct 30, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG]: Make lint command is not working.
2 participants