Skip to content

fix: resolve golangci-lint issues in pkg/downloader#1445

Merged
aknysh merged 1 commit intoupdate-go-getterfrom
go-getter-fix-lint
Sep 3, 2025
Merged

fix: resolve golangci-lint issues in pkg/downloader#1445
aknysh merged 1 commit intoupdate-go-getterfrom
go-getter-fix-lint

Conversation

@osterman
Copy link
Member

@osterman osterman commented Sep 3, 2025

what

  • Fixes 14 out of 20 golangci-lint issues in the pkg/downloader/ package
  • Reduces linting errors from critical issues to only complexity warnings
  • Ensures code follows Go best practices and project conventions

why

  • The PR Update go-getter to the latest version #1441 (update-go-getter) has failing linting checks that prevent it from being merged
  • These linting issues include deprecated packages, magic numbers, security warnings, and code quality issues
  • Fixing these issues improves code maintainability and follows the project's CLAUDE.md guidelines

Changes Made

Fixed Issues (14):

  1. Deprecated package - Replaced io/ioutil with os.CreateTemp
  2. Magic numbers - Created constants for base10, portBitSize, sshKeyFileMode
  3. String literals - Created constants for gitCommand, originRemote, gitArgSeparator
  4. Invalid URL in test - Fixed test to use programmatic URL construction
  5. Unused function returns - Removed unused returns from test helper functions
  6. Argument limit exceeded - Created gitOperationParams struct to reduce function arguments
  7. Index out of bounds - Added check for -1 before using string index
  8. Security warnings (G204) - Added #nosec comments with justification
  9. Formatting - Applied gofumpt formatting
  10. Heavy parameter - Changed struct to pass by pointer

Remaining Warnings (6):

  • Cognitive complexity warnings (can be addressed in future refactoring)
  • Nested block complexity warnings
  • Function length warning

All tests pass and the code compiles successfully.

references

- Replace deprecated io/ioutil with os.CreateTemp
- Add constants for magic numbers (base10, portBitSize, sshKeyFileMode)
- Add constants for repeated strings (gitCommand, originRemote, gitArgSeparator)
- Create gitOperationParams struct to reduce function arguments
- Fix invalid URL construction in tests
- Remove unused return values from test helper functions
- Fix potential index out of bounds issue
- Add #nosec comments for validated subprocess commands
- Apply gofumpt formatting

Reduces linting issues from 20 to 6 (remaining are complexity warnings)
@osterman osterman requested a review from a team as a code owner September 3, 2025 03:30
@mergify mergify bot added stacked Stacked triage Needs triage labels Sep 3, 2025
@codecov
Copy link

codecov bot commented Sep 3, 2025

Codecov Report

❌ Patch coverage is 89.79592% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.97%. Comparing base (3bdd0f6) to head (b404f10).
⚠️ Report is 1 commits behind head on update-go-getter.

Files with missing lines Patch % Lines
pkg/downloader/get_git.go 89.79% 5 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           update-go-getter    #1445      +/-   ##
====================================================
+ Coverage             55.91%   55.97%   +0.06%     
====================================================
  Files                   274      274              
  Lines                 28902    28928      +26     
====================================================
+ Hits                  16161    16193      +32     
+ Misses                10945    10941       -4     
+ Partials               1796     1794       -2     
Flag Coverage Δ
unittests 55.97% <89.79%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aknysh aknysh added no-release Do not create a new release (wait for additional code changes) and removed triage Needs triage labels Sep 3, 2025
@aknysh aknysh merged commit b612d26 into update-go-getter Sep 3, 2025
53 of 54 checks passed
@aknysh aknysh deleted the go-getter-fix-lint branch September 3, 2025 04:48
aknysh added a commit that referenced this pull request Sep 3, 2025
* updates

* updates

* updates

* updates

* updates

* updates

* [autofix.ci] apply automated fixes

* updates

* [autofix.ci] apply automated fixes

* updates

* updates

* updates

* updates

* test: increase test coverage for go-getter downloader to 77.7% (#1443)

* test: increase test coverage for go-getter downloader to 77.7%

- Add comprehensive tests for GetCustom() method covering various scenarios (89.1% coverage)
- Add tests for git operations: clone (90.9%), update (86.5%), checkout (100%), fetchSubmodules (100%)
- Add tests for findRemoteDefaultBranch() method (100% coverage)
- Add tests for CustomGitGetter.Get() method (100% coverage)
- Define static errors in errors/errors.go to comply with golangci-lint err113
- Format code with gofumpt
- Overall package coverage increased from 46.1% to 77.7%

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [autofix.ci] apply automated fixes

* updates

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: aknysh <andriy.knysh@gmail.com>

* fix: resolve golangci-lint issues in pkg/downloader (#1445)

- Replace deprecated io/ioutil with os.CreateTemp
- Add constants for magic numbers (base10, portBitSize, sshKeyFileMode)
- Add constants for repeated strings (gitCommand, originRemote, gitArgSeparator)
- Create gitOperationParams struct to reduce function arguments
- Fix invalid URL construction in tests
- Remove unused return values from test helper functions
- Fix potential index out of bounds issue
- Add #nosec comments for validated subprocess commands
- Apply gofumpt formatting

Reduces linting issues from 20 to 6 (remaining are complexity warnings)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>
Co-authored-by: Claude <noreply@anthropic.com>
osterman added a commit that referenced this pull request Sep 23, 2025
* updates

* updates

* updates

* updates

* updates

* updates

* [autofix.ci] apply automated fixes

* updates

* [autofix.ci] apply automated fixes

* updates

* updates

* updates

* updates

* test: increase test coverage for go-getter downloader to 77.7% (#1443)

* test: increase test coverage for go-getter downloader to 77.7%

- Add comprehensive tests for GetCustom() method covering various scenarios (89.1% coverage)
- Add tests for git operations: clone (90.9%), update (86.5%), checkout (100%), fetchSubmodules (100%)
- Add tests for findRemoteDefaultBranch() method (100% coverage)
- Add tests for CustomGitGetter.Get() method (100% coverage)
- Define static errors in errors/errors.go to comply with golangci-lint err113
- Format code with gofumpt
- Overall package coverage increased from 46.1% to 77.7%

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [autofix.ci] apply automated fixes

* updates

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: aknysh <andriy.knysh@gmail.com>

* fix: resolve golangci-lint issues in pkg/downloader (#1445)

- Replace deprecated io/ioutil with os.CreateTemp
- Add constants for magic numbers (base10, portBitSize, sshKeyFileMode)
- Add constants for repeated strings (gitCommand, originRemote, gitArgSeparator)
- Create gitOperationParams struct to reduce function arguments
- Fix invalid URL construction in tests
- Remove unused return values from test helper functions
- Fix potential index out of bounds issue
- Add #nosec comments for validated subprocess commands
- Apply gofumpt formatting

Reduces linting issues from 20 to 6 (remaining are complexity warnings)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Do not create a new release (wait for additional code changes) stacked Stacked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants