Skip to content

Quality/housekeeping#369

Merged
cjimti merged 21 commits intomasterfrom
quality/housekeeping
Jan 7, 2026
Merged

Quality/housekeeping#369
cjimti merged 21 commits intomasterfrom
quality/housekeeping

Conversation

@cjimti
Copy link
Copy Markdown
Member

@cjimti cjimti commented Jan 7, 2026

Fix all GoLand default lint warnings to ensure code passes IDE lint checks that most maintainers use. This includes:

  • Exhaustive switch statements: Added missing cases for iota const types (Focus, EventType, MouseButton)
  • Unused parameters: Properly marked unused interface-required parameters with blank identifier _
  • Unhandled errors: Added explicit _ = for intentionally ignored errors in test HTTP handlers
  • Cyclomatic complexity: Extracted handlePodStatusChanged helper to keep functions under threshold

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Test improvement (new or updated tests)
  • Documentation update
  • Stability/performance improvement
  • Build/CI improvement

Note: New features are developed by maintainers only. See CONTRIBUTING.md for details.

Related Issues

Fixes # (GoLand lint compliance)

Testing

  • Ran go test ./... locally
  • Tested manually with a Kubernetes cluster
  • Added new tests for changes (if applicable)

Checklist

  • My code follows the project's style guidelines (go fmt, go vet)
  • I have read CONTRIBUTING.md
  • I have updated documentation if needed
  • This PR is focused and does not include unrelated changes

Screenshots/Logs (if applicable)

Before

golangci-lint run ./...
# 100+ revive unused-parameter warnings
# Missing switch case warnings in GoLand

After

$ golangci-lint run ./...
0 issues.

$ gocyclo -over 15 .
(no output - all functions under threshold)

$ go test ./...
ok  github.com/txn2/kubefwd/cmd/kubefwd/services
ok  github.com/txn2/kubefwd/pkg/fwdapi
ok  github.com/txn2/kubefwd/pkg/fwdmcp
ok  github.com/txn2/kubefwd/pkg/fwdtui
... (all packages pass)

Changes Summary

Switch Statement Fixes

File Issue Fix
pkg/fwdtui/ui.go:152 Missing EventType cases Added grouped case for unused event types
pkg/fwdtui/ui.go:789,818 Missing FocusDetail case Added explicit case with comment
pkg/fwdtui/components/services.go:184 Missing MouseButton cases Added default: for external type

Unused Parameter Fixes

File Count Pattern
pkg/fwdmcp/tools.go 28 handlers ctx, req -> _, _
pkg/fwdmcp/prompts.go 10 handlers ctx -> _
pkg/fwdmcp/resources.go 8 handlers ctx -> _
pkg/fwdmcp/tools.go 6 handlers input struct{} -> _ struct{}

Test File Fixes

File Fix
pkg/fwdmcp/tools_test.go Prefixed unused mock params with _, added _ = for json.Encode errors

Complexity Fix

  • Extracted handlePodStatusChanged() helper from handleEventForStore() to reduce cyclomatic complexity from 16 to under 15

Config Update

  • .golangci.yml: Added targeted test file exclusion for unused-parameter (standard practice for interface mocks)

cjimti added 21 commits January 6, 2026 13:56
…eadability:

- Separate concerns into helper functions (e.g., `resolveContextAndClient`, `buildPodLogOptions`, `readPodLogStream`).
- Simplify `GetPodLogs`, `ListPods`, and `convertPodToK8sPodDetail` methods.
- Modularize container port/resource handling and endpoint processing for cleaner code.
…y introducing helper functions `forwardMatchesSearch` and `forwardMatchesFilters`.
…owSizeMsg`, `handleKeyMsg`, and `handleMouseMsg` helper methods.
…troducing helper functions `calculateServiceStatus`, `matchesSearch`, and `serviceMatchesFilters`.
…methods `handleFilterKeyMsg`, `handleNormalKeyMsg`, and `handleMouseMsg`.
…oducing reusable comparison helper functions.
…er functions `buildConnectionInfoFromService`, `findServiceInState`, and `searchServicesByName`.
…thods `handlePodAddedEvent`, `handlePodStatusChangedEvent`, `handleServiceRemovedEvent`, and utility functions `buildForwardKey` and `parseStatusString`.
…determinePodStatusString`, `sortAndLimitEvents`, and `convertEventsToK8sEvents` helper functions.
- Includes tests for `buildPortMappings`, `setupPodAddedSubscription`, `waitForPodAdded`, `checkPodForwarded`, `determinePodStatusString`, `sortAndLimitEvents`, and `convertEventsToK8sEvents`.
- Includes tests for `buildConnectionInfoFromService`, `findServiceInState`, `searchServicesByName`, and `calculateMCPServiceStatus`.
…ming, modularization of state access, and improved function naming.
…ks, improving clarity around unused parameters.
…nderscores, and improve consistency with helper functions.
…s and test helpers, and ensure consistent error handling in HTTP responses.
@cjimti cjimti self-assigned this Jan 7, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 86.29283% with 88 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.07%. Comparing base (bdacb6d) to head (f740b12).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/fwdapi/adapters.go 82.07% 32 Missing and 6 partials ⚠️
pkg/fwdport/fwdport.go 0.00% 21 Missing ⚠️
pkg/fwdtui/ui.go 84.00% 11 Missing and 1 partial ⚠️
pkg/fwdmcp/tools.go 91.86% 8 Missing and 2 partials ⚠️
pkg/fwdtui/components/services.go 95.23% 2 Missing and 1 partial ⚠️
pkg/fwdapi/handlers/services.go 92.85% 2 Missing ⚠️
pkg/fwdtui/state/store.go 94.44% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #369      +/-   ##
==========================================
+ Coverage   80.48%   81.07%   +0.59%     
==========================================
  Files          70       70              
  Lines       12620    12662      +42     
==========================================
+ Hits        10157    10266     +109     
+ Misses       2050     1992      -58     
+ Partials      413      404       -9     
Files with missing lines Coverage Δ
pkg/fwdapi/handlers/forwards.go 95.69% <100.00%> (+0.09%) ⬆️
pkg/fwdapi/middleware/middleware.go 100.00% <ø> (ø)
pkg/fwdmcp/prompts.go 100.00% <100.00%> (ø)
pkg/fwdmcp/resources.go 89.21% <100.00%> (ø)
pkg/fwdservice/fwdservice.go 78.40% <100.00%> (+1.18%) ⬆️
pkg/fwdtui/components/logs.go 85.20% <100.00%> (+0.54%) ⬆️
pkg/fwdapi/handlers/services.go 96.76% <92.85%> (+0.05%) ⬆️
pkg/fwdtui/state/store.go 97.72% <94.44%> (+1.44%) ⬆️
pkg/fwdtui/components/services.go 89.37% <95.23%> (+0.34%) ⬆️
pkg/fwdmcp/tools.go 86.30% <91.86%> (+1.09%) ⬆️
... and 3 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cjimti cjimti merged commit cd084ca into master Jan 7, 2026
12 checks passed
@cjimti cjimti deleted the quality/housekeeping branch January 7, 2026 00:51
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.

1 participant