Skip to content

refactor: improve testability and reduce complexity#48

Merged
idebeijer merged 9 commits intomainfrom
refactor/improve-testability-reduce-complexity
Feb 14, 2026
Merged

refactor: improve testability and reduce complexity#48
idebeijer merged 9 commits intomainfrom
refactor/improve-testability-reduce-complexity

Conversation

@idebeijer
Copy link
Owner

@idebeijer idebeijer commented Feb 14, 2026

This pull request introduces a comprehensive refactoring to improve testability and reduce complexity across the codebase by implementing the options pattern for multiple commands. The changes enable better unit testing through dependency injection while maintaining backward compatibility.

Changes:

  • Implements options pattern (Complete/Validate/Run) for exec, kubectl, context, and namespace commands with injectable dependencies for improved testability
  • Adds comprehensive test suites covering various scenarios including error handling, interactive/non-interactive modes, and edge cases
  • Refactors protection info and kubeconfig lint code into smaller, more focused functions for better readability and maintainability

Signed-off-by: Igor de Beijer <71566757+idebeijer@users.noreply.github.com>
Signed-off-by: Igor de Beijer <71566757+idebeijer@users.noreply.github.com>
Signed-off-by: Igor de Beijer <71566757+idebeijer@users.noreply.github.com>
Signed-off-by: Igor de Beijer <71566757+idebeijer@users.noreply.github.com>
Signed-off-by: Igor de Beijer <71566757+idebeijer@users.noreply.github.com>
Signed-off-by: Igor de Beijer <71566757+idebeijer@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a comprehensive refactoring to improve testability and reduce complexity across the codebase by implementing the options pattern for multiple commands. The changes enable better unit testing through dependency injection while maintaining backward compatibility.

Changes:

  • Implements options pattern (Complete/Validate/Run) for exec, kubectl, context, and namespace commands with injectable dependencies for improved testability
  • Adds comprehensive test suites covering various scenarios including error handling, interactive/non-interactive modes, and edge cases
  • Refactors protection info and kubeconfig lint code into smaller, more focused functions for better readability and maintainability

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/fzf/fzf.go Renamed IsInteractiveShell to IsInteractive for consistency
internal/fzf/fzf_test.go Added tests for argument parsing and fzf argument building logic
internal/config/config_test.go Added tests for default configuration and YAML generation
cmd/context.go Refactored to use options pattern with injectable dependencies
cmd/context_test.go Added comprehensive tests for context command with helper function
cmd/namespace.go Refactored to use options pattern with injectable dependencies
cmd/namespace_test.go Added comprehensive tests for namespace command
cmd/kubectl.go Refactored to use options pattern with injectable dependencies
cmd/kubectl_test.go Added comprehensive tests for kubectl command
cmd/exec.go Refactored to use options pattern with injectable dependencies
cmd/exec_test.go Added comprehensive tests for exec command
cmd/protection/info.go Extracted helper functions for better code organization
cmd/kubeconfig/lint.go Extracted validation functions for improved readability
Makefile Added test-cover target for coverage analysis
.golangci.yml Added errcheck exclusions for fmt functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Igor de Beijer <71566757+idebeijer@users.noreply.github.com>
@idebeijer idebeijer merged commit 29a2e76 into main Feb 14, 2026
4 checks passed
@idebeijer idebeijer deleted the refactor/improve-testability-reduce-complexity branch February 14, 2026 21:01
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