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

[ISSUE-1229] Resolve failing linter: unused and enable back #1230

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

jameskim0987
Copy link
Contributor

@jameskim0987 jameskim0987 commented Sep 25, 2024

Fixes issue #1229

Output of make lint after enabling back unused:

jameskim:~/workspace/terraform-provider-digitalocean $ make lint
INFO golangci-lint has version 1.61.0 built with go1.23.1 from a1d6c56 on 2024-09-09T14:33:19Z
INFO [config_reader] Config search paths: [./ /Users/jameskim/workspace/terraform-provider-digitalocean /Users/jameskim/workspace /Users/jameskim /Users /]
INFO [config_reader] Used config file .golangci.yml
WARN [config_reader] The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`.
INFO [lintersdb] Active 7 linters: [gofmt goimports gosimple govet staticcheck unconvert unused]
INFO [loader] Go packages loading at mode 575 (name|types_sizes|compiled_files|exports_file|imports|deps|files) took 3.105408387s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 60.098237ms
INFO [linters_context/goanalysis] analyzers took 0s with no stages
INFO [runner] Issues before processing: 114, after processing: 1
INFO [runner] Processors filtering stat (in/out): uniq_by_line: 1/1, diff: 1/1, invalid_issue: 114/114, identifier_marker: 114/114, exclude-rules: 114/1, max_per_file_from_linter: 1/1, source_code: 1/1, path_shortener: 1/1, severity-rules: 1/1, fixer: 1/1, filename_unadjuster: 114/114, skip_files: 114/114, exclude:
 114/114, max_same_issues: 1/1, sort_results: 1/1, cgo: 114/114, path_prettifier: 114/114, nolint: 1/1, max_from_linter: 1/1, path_prefixer: 1/1, skip_dirs: 114/114, autogenerated_exclude: 114/114
INFO [runner] processing took 31.851946ms with stages: identifier_marker: 16.062064ms, invalid_issue: 5.125848ms, nolint: 3.88447ms, autogenerated_exclude: 2.265732ms, path_prettifier: 1.981865ms, exclude-rules: 1.091937ms, source_code: 915.043µs, skip_dirs: 478.295µs, cgo: 25.83µs, filename_unadjuster: 5.481µs, ma
x_from_linter: 4.065µs, uniq_by_line: 2.674µs, path_shortener: 2.445µs, max_per_file_from_linter: 2.036µs, max_same_issues: 1.395µs, exclude: 528ns, fixer: 517ns, skip_files: 493ns, sort_results: 458ns, diff: 311ns, severity-rules: 266ns, path_prefixer: 193ns
INFO [runner] linters took 428.258507ms with stages: goanalysis_metalinter: 395.938952ms
digitalocean/kubernetes/resource_kubernetes_cluster_test.go:884:6: func `testAccDigitalOceanKubernetesConfigBasic5` is unused (unused)
func testAccDigitalOceanKubernetesConfigBasic5(testClusterVersion string, rName string) string {
     ^
INFO File cache stats: 1 entries of total size 44.3KiB
INFO Memory: 38 samples, avg is 29.6MB, max is 54.2MB
INFO Execution took 3.617533898s
make: *** [lint] Error 1

Looking through the test, I found that essentially testAccDigitalOceanKubernetesConfigBasic4 covers what testAccDigitalOceanKubernetesConfigBasic5 was trying to achieve. The only difference I observed was testAccDigitalOceanKubernetesConfigBasic4 has addition checks for surge_upgrade and ha checks.

Changes made in this PR:

  1. add back unused linter in .golangci.yml
  2. remove the unused function testAccDigitalOceanKubernetesConfigBasic5 ( redundant test function )

Output of make lint after enabling back unused with the PR changes:

jameskim:~/workspace/terraform-provider-digitalocean $ make lint
INFO golangci-lint has version 1.61.0 built with go1.23.1 from a1d6c56 on 2024-09-09T14:33:19Z
INFO [config_reader] Config search paths: [./ /Users/jameskim/workspace/terraform-provider-digitalocean /Users/jameskim/workspace /Users/jameskim /Users /]
INFO [config_reader] Used config file .golangci.yml
WARN [config_reader] The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`.
INFO [lintersdb] Active 7 linters: [gofmt goimports gosimple govet staticcheck unconvert unused]
INFO [loader] Go packages loading at mode 575 (exports_file|files|name|types_sizes|compiled_files|deps|imports) took 4.866297169s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 127.308393ms
INFO [linters_context/goanalysis] analyzers took 810.269674ms with top 10 stages: buildir: 188.196073ms, unconvert: 118.508405ms, goimports: 96.291208ms, S1038: 62.830719ms, gofmt: 58.418609ms, S1002: 26.114926ms, SA4016: 25.214608ms, unused: 19.453293ms, SA5009: 17.791958ms, SA4019: 15.474008ms
INFO [runner] Issues before processing: 113, after processing: 0
INFO [runner] Processors filtering stat (in/out): filename_unadjuster: 113/113, skip_files: 113/113, autogenerated_exclude: 113/113, identifier_marker: 113/113, path_prettifier: 113/113, exclude-rules: 113/0, cgo: 113/113, invalid_issue: 113/113, skip_dirs: 113/113, exclude: 113/113
INFO [runner] processing took 20.3465ms with stages: identifier_marker: 8.589125ms, autogenerated_exclude: 7.793611ms, path_prettifier: 2.124903ms, exclude-rules: 1.253684ms, skip_dirs: 478.955µs, cgo: 79.262µs, invalid_issue: 12.871µs, filename_unadjuster: 6.048µs, nolint: 2.099µs, max_same_issues: 1.322µs, skip_files: 658ns, uniq_by_line: 596ns, fixer: 487ns, exclude: 421ns, max_from_linter: 407ns, sort_results: 395ns, diff: 375ns, max_per_file_from_linter: 318ns, path_shortener: 286ns, source_code: 284ns, severity-rules: 221ns, path_prefixer: 172ns
INFO [runner] linters took 3.148740789s with stages: goanalysis_metalinter: 3.127650354s
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 83 samples, avg is 45.2MB, max is 132.2MB
INFO Execution took 8.178608358s

@jameskim0987 jameskim0987 marked this pull request as ready for review September 25, 2024 04:13
@jameskim0987 jameskim0987 changed the title Issue 1229 linter unused [ISSUE-1229] Resolve failing linter: unused and enable back Sep 25, 2024
@jameskim0987
Copy link
Contributor Author

Hi @loosla, this PR is ready for review

@loosla
Copy link
Contributor

loosla commented Sep 25, 2024

🚀 Excellent work! Thank you for your contribution.

Copy link
Contributor

@loosla loosla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 🚀 🚀

@loosla loosla merged commit 66d78dd into digitalocean:main Sep 25, 2024
3 checks passed
@jameskim0987
Copy link
Contributor Author

@loosla Thank you!

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

Successfully merging this pull request may close these issues.

2 participants