Skip to content

Apply golangci-lint autofixes#632

Merged
sairon merged 1 commit into
home-assistant:masterfrom
scop:refactor/golangci-autofixes
Mar 31, 2026
Merged

Apply golangci-lint autofixes#632
sairon merged 1 commit into
home-assistant:masterfrom
scop:refactor/golangci-autofixes

Conversation

@scop
Copy link
Copy Markdown
Member

@scop scop commented Feb 2, 2026

Done with golangci-lint 2.8.0.

Summary by CodeRabbit

  • Refactor
    • Standardized internal error construction for certain HTTP error responses to simplify error types.
    • Standardized internal error construction for MTU validation checks.
    • No changes to user-facing behavior, control flow, or public APIs; functionality and error-triggering behavior remain the same.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Replaced fmt.Errorf with errors.New for specific error constructions in HTTP status handling and MTU validation. No control flow, exported API, or functional behavior was changed.

Changes

Cohort / File(s) Summary
HTTP Error Handling
client/client.go
Switched error construction from fmt.Errorf to errors.New for non-JSON response cases in GenericJSONErrorHandling for statuses 500, 401, 403, and 502. Other status handling remains unchanged.
MTU Validation Error
cmd/docker_options.go
Replaced fmt.Errorf with errors.New when MTU is outside allowed range (68–65535, or 0 to reset); behavior and exit paths unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: applying golangci-lint autofixes from version 2.8.0, which is reflected in both modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Failure to add the new IP will result in interrupted reviews.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@client/client.go`:
- Around line 31-43: The code uses errors.New in multiple HTTP response branches
(e.g., cases for http.StatusUnauthorized, http.StatusForbidden,
http.StatusBadGateway and the generic error branch) but the "errors" package is
not imported; add "errors" to the import block in client.go (alongside existing
imports like net/http and resty) so those errors.New calls compile, then run go
fmt/build to ensure imports are ordered and there are no unused-import issues.

In `@cmd/docker_options.go`:
- Line 48: The code calls errors.New in the docker options handling (see the
errors.New(...) passed to helper.PrintError) but the standard errors package is
not imported; add the missing import "errors" to the import block in
cmd/docker_options.go so the reference to errors.New compiles (update the file's
import list where helper.PrintError is used).

Comment thread client/client.go
Comment thread cmd/docker_options.go
@scop scop force-pushed the refactor/golangci-autofixes branch from 83d4b61 to e64d470 Compare February 3, 2026 17:11
Copy link
Copy Markdown
Member

@sairon sairon left a comment

Choose a reason for hiding this comment

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

Thanks!

@sairon sairon merged commit 00f94b2 into home-assistant:master Mar 31, 2026
9 checks passed
@scop scop deleted the refactor/golangci-autofixes branch April 1, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants