Skip to content

Commit d8ebcce

Browse files
committed
fix: resolve golangci-lint issues in timeout feature
- Fix gofmt formatting in root.go, utils.go, utils_test.go - Fix empty-block revive issue in utils.go by inverting condition
1 parent 4de56ed commit d8ebcce

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

cmd/mcptools/commands/root.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ import (
99

1010
// flags.
1111
const (
12-
FlagFormat = "--format"
13-
FlagFormatShort = "-f"
14-
FlagParams = "--params"
15-
FlagParamsShort = "-p"
16-
FlagHelp = "--help"
17-
FlagHelpShort = "-h"
18-
FlagServerLogs = "--server-logs"
19-
FlagTransport = "--transport"
20-
FlagAuthUser = "--auth-user"
21-
FlagAuthHeader = "--auth-header"
22-
FlagTimeout = "--timeout"
23-
FlagTimeoutShort = "-t"
12+
FlagFormat = "--format"
13+
FlagFormatShort = "-f"
14+
FlagParams = "--params"
15+
FlagParamsShort = "-p"
16+
FlagHelp = "--help"
17+
FlagHelpShort = "-h"
18+
FlagServerLogs = "--server-logs"
19+
FlagTransport = "--transport"
20+
FlagAuthUser = "--auth-user"
21+
FlagAuthHeader = "--auth-header"
22+
FlagTimeout = "--timeout"
23+
FlagTimeoutShort = "-t"
2424
)
2525

2626
// entity types.

cmd/mcptools/commands/utils.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,56 +34,55 @@ func IsHTTP(str string) bool {
3434
// It returns the header value and a cleaned URL (with embedded credentials removed).
3535
func buildAuthHeader(originalURL string) (string, string, error) {
3636
cleanURL := originalURL
37-
37+
3838
// First, check if we have explicit auth-user flag with username:password format
3939
if AuthUser != "" {
4040
// Parse username:password format
4141
if !strings.Contains(AuthUser, ":") {
4242
return "", originalURL, fmt.Errorf("auth-user must be in username:password format (missing colon)")
4343
}
44-
44+
4545
parts := strings.SplitN(AuthUser, ":", 2)
4646
username := parts[0]
4747
password := parts[1]
48-
48+
4949
// Allow empty username or password, but not both
50-
if username == "" && password == "" {
51-
// Both empty, treat as no auth
52-
} else {
50+
if username != "" || password != "" {
5351
// Create basic auth header
5452
auth := base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
5553
header := "Basic " + auth
5654
return header, cleanURL, nil
5755
}
56+
// Both empty, treat as no auth - fall through
5857
}
59-
58+
6059
// Check for custom auth header
6160
if AuthHeader != "" {
6261
return AuthHeader, cleanURL, nil
6362
}
64-
63+
6564
// Extract credentials from URL if embedded
6665
parsedURL, err := url.Parse(originalURL)
6766
if err != nil {
6867
return "", originalURL, err
6968
}
70-
69+
7170
if parsedURL.User != nil {
7271
username := parsedURL.User.Username()
7372
password, _ := parsedURL.User.Password()
74-
73+
7574
if username != "" {
7675
// Create basic auth header
7776
auth := base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
78-
77+
7978
// Clean the URL by removing user info
8079
parsedURL.User = nil
8180
cleanURL = parsedURL.String()
82-
81+
8382
return "Basic " + auth, cleanURL, nil
8483
}
8584
}
86-
85+
8786
return "", cleanURL, nil
8887
}
8988

cmd/mcptools/commands/utils_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ nested {"key":"value"}`[1:] // remove first newline
191191
}
192192
}
193193

194-
195194
func TestProcessFlagsTimeout(t *testing.T) {
196195
originalTimeout := InitTimeout
197196
defer func() { InitTimeout = originalTimeout }()

0 commit comments

Comments
 (0)