Skip to content

Commit 25d3f34

Browse files
committed
refactor(extensions): enhance modularity and update dependencies across multiple extensions
- Restructured various extensions to improve modularity and maintainability, including updates to configuration and core functionalities. - Added new helper functions and improved existing ones for better clarity and usability. - Updated dependencies in `go.mod` and `go.sum` files across multiple extensions to ensure compatibility with the latest versions. - Enhanced documentation and comments for better understanding and guidance on extension usage. Signed-off-by: Rex Raphael <rex.raphael@outlook.com>
1 parent 22af781 commit 25d3f34

262 files changed

Lines changed: 6288 additions & 7331 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ linters:
204204
- linters:
205205
- staticcheck
206206
text: "SA9003:"
207+
# Exclude SA5011 from test files (nil pointer checks are intentional in tests)
208+
- path: _test\.go
209+
linters:
210+
- staticcheck
211+
text: "SA5011"
207212
# Exclude `lll` issues for long lines with `go:generate`.
208213
- linters:
209214
- lll

app_impl.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,11 @@ func newApp(config AppConfig) *app {
148148
)
149149
}
150150
}
151-
} else {
151+
} else if logger != nil {
152152
// Auto-discovery failed, but that's okay - we'll create a default manager
153-
if logger != nil {
154-
logger.Debug("config auto-discovery did not find files, using empty config",
155-
F("error", err.Error()),
156-
)
157-
}
153+
logger.Debug("config auto-discovery did not find files, using empty config",
154+
F("error", err.Error()),
155+
)
158156
}
159157
}
160158

cli/color.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func isTerminal(w io.Writer) bool {
7272

7373
// ConfigureColors configures the global color settings.
7474
func ConfigureColors(config ColorConfig) {
75-
if config.NoColor {
75+
if config.NoColor { //nolint:gocritic // ifElseChain: priority-based config clearer with if-else
7676
color.NoColor = true
7777
} else if config.ForceColor {
7878
color.NoColor = false

cli/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
// commandContext implements the CommandContext interface.
1212
type commandContext struct {
13-
ctx context.Context
13+
ctx context.Context //nolint:containedctx // context needed for command lifecycle and cancellation
1414
cmd Command
1515
args []string
1616
flags map[string]*flagValue

cli/flag.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ func WithValidator(validator func(any) error) FlagOption {
202202
}
203203

204204
// ValidateRange validates that an int flag is within a range.
205-
func ValidateRange(min, max int) FlagOption {
205+
func ValidateRange(minVal, maxVal int) FlagOption {
206206
return WithValidator(func(value any) error {
207207
v, ok := value.(int)
208208
if !ok {
209209
return errors.New("expected int value")
210210
}
211211

212-
if v < min || v > max {
213-
return fmt.Errorf("value must be between %d and %d", min, max)
212+
if v < minVal || v > maxVal {
213+
return fmt.Errorf("value must be between %d and %d", minVal, maxVal)
214214
}
215215

216216
return nil

cli/prompt.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func interactiveSelect(question string, options []string, multi bool) ([]string,
255255

256256
fmt.Fprint(os.Stdout, "\r\n") // CR+LF after instructions
257257
fmt.Fprint(os.Stdout, "\r\n") // Empty line before options
258-
os.Stdout.Sync() // Flush header before rendering options
258+
os.Stdout.Sync() // Flush header before rendering options
259259

260260
for {
261261
// Render options
@@ -283,8 +283,8 @@ func interactiveSelect(question string, options []string, multi bool) ([]string,
283283

284284
case 27: // ESC sequence
285285
// Arrow keys send ESC [ A/B/C/D
286-
if n >= 3 && buf[1] == '[' {
287-
switch buf[2] {
286+
if n >= 3 && buf[1] == '[' { //nolint:gosec // G602: bounds checked with n >= 3
287+
switch buf[2] { //nolint:gosec // G602: bounds checked with n >= 3
288288
case 'A': // Up arrow
289289
if cursor > 0 {
290290
cursor--
@@ -375,9 +375,9 @@ func renderOptions(options []string, cursor int, selected map[int]bool, multi bo
375375
prefix := " "
376376
optText := opt
377377

378-
if i == cursor {
378+
if i == cursor { //nolint:gocritic // ifElseChain: UI state logic clearer with nested if-else
379379
// Highlighted item
380-
if multi && selected[i] {
380+
if multi && selected[i] { //nolint:gocritic // ifElseChain: checkbox state clearer with if-else
381381
prefix = Green("▸ [✓]")
382382
} else if multi {
383383
prefix = Green("▸ [ ]")
@@ -443,7 +443,6 @@ func setRawMode() (*term.State, error) {
443443
// restoreMode restores the terminal to normal mode.
444444
func restoreMode(oldState *term.State) {
445445
if oldState != nil {
446-
//nolint:errcheck // Terminal restore errors are not critical
447446
_ = term.Restore(int(os.Stdin.Fd()), oldState)
448447
}
449448
}

cmd/forge/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ require (
8888
github.com/xdg-go/scram v1.1.2 // indirect
8989
github.com/xdg-go/stringprep v1.0.4 // indirect
9090
github.com/xraph/confy v0.0.3 // indirect
91-
github.com/xraph/go-utils v0.0.10 // indirect
92-
github.com/xraph/vessel v0.0.1 // indirect
91+
github.com/xraph/go-utils v0.0.11 // indirect
92+
github.com/xraph/vessel v0.0.3 // indirect
9393
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
9494
go.mongodb.org/mongo-driver v1.17.4 // indirect
9595
go.uber.org/multierr v1.11.0 // indirect

cmd/forge/go.sum

Lines changed: 4 additions & 146 deletions
Large diffs are not rendered by default.

examples/cors_preflight/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ require (
5555
github.com/uptrace/bunrouter v1.0.23 // indirect
5656
github.com/x448/float16 v0.8.4 // indirect
5757
github.com/xraph/confy v0.0.3 // indirect
58-
github.com/xraph/go-utils v0.0.10 // indirect
59-
github.com/xraph/vessel v0.0.1 // indirect
58+
github.com/xraph/go-utils v0.0.11 // indirect
59+
github.com/xraph/vessel v0.0.3 // indirect
6060
go.uber.org/multierr v1.11.0 // indirect
6161
go.uber.org/zap v1.27.1 // indirect
6262
go.yaml.in/yaml/v2 v2.4.3 // indirect

0 commit comments

Comments
 (0)