Skip to content

Commit 6a8b162

Browse files
Fix errcheck linting errors in test functions
- Change defer buf.Close() to defer func() { _ = buf.Close() }() to explicitly ignore error return values in test code - Fixes golangci-lint errcheck warnings for TestFormatterFloatFormatting, TestFormatterFloatFormattingExtremeValues, and TestFormatterRealFormatting Co-authored-by: dlevy-msft-sql <[email protected]>
1 parent a3b7a26 commit 6a8b162

8 files changed

Lines changed: 663 additions & 663 deletions

File tree

cmd/modern/root/query_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestQueryWithNonDefaultDatabase(t *testing.T) {
2828
if runtime.GOOS != "windows" {
2929
t.Skip("stuartpa: This is failing in the pipeline (Login failed for user 'sa'.)")
3030
}
31-
31+
3232
cmdparser.TestSetup(t)
3333

3434
setupContext(t)

cmd/sqlcmd/pipe_detection_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ package sqlcmd
66
import (
77
"os"
88
"testing"
9-
9+
1010
"github.com/stretchr/testify/assert"
1111
)
1212

1313
func TestStdinPipeDetection(t *testing.T) {
1414
// Get stdin info
1515
fi, err := os.Stdin.Stat()
1616
assert.NoError(t, err, "os.Stdin.Stat()")
17-
17+
1818
// On most CI systems, stdin will be a pipe or file (not a terminal)
1919
// We're testing the logic, not expecting a specific result
2020
isPipe := false
2121
if fi != nil && (fi.Mode()&os.ModeCharDevice) == 0 {
2222
isPipe = true
2323
}
24-
24+
2525
// Just making sure the detection code doesn't crash
2626
// The actual value will depend on the environment
2727
t.Logf("Stdin detected as pipe: %v", isPipe)
28-
}
28+
}

internal/secret/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const (
1717
)
1818

1919
// Generate generates a random password of a specified length. The password
20-
// will contain at least the specified number of special characters,
20+
// will contain at least the specified number of special characters,
2121
// numeric digits, and upper-case letters. The remaining characters in the
2222
// password will be selected from a combination of lower-case letters, special
2323
// characters, and numeric digits. The special characters are chosen from

pkg/console/console.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func NewConsole(historyFile string) sqlcmd.Console {
2828
historyFile: historyFile,
2929
stdinRedirected: isStdinRedirected(),
3030
}
31-
31+
3232
if c.stdinRedirected {
3333
c.stdinReader = bufio.NewReader(os.Stdin)
3434
} else {
@@ -52,7 +52,7 @@ func (c *console) Close() {
5252
f.Close()
5353
}
5454
}
55-
55+
5656
if !c.stdinRedirected {
5757
c.impl.Close()
5858
}
@@ -79,7 +79,7 @@ func (c *console) Readline() (string, error) {
7979
}
8080
return line, nil
8181
}
82-
82+
8383
// Interactive terminal mode with prompts
8484
s, err := c.impl.Prompt(c.prompt)
8585
if err == liner.ErrPromptAborted {

pkg/console/console_redirect.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
package console
55

66
import (
7-
"os"
87
"golang.org/x/term"
8+
"os"
99
)
1010

1111
// isStdinRedirected checks if stdin is coming from a pipe or redirection
@@ -15,13 +15,13 @@ func isStdinRedirected() bool {
1515
// If we can't determine, assume it's not redirected
1616
return false
1717
}
18-
18+
1919
// If it's not a character device, it's coming from a pipe or redirection
2020
if (stat.Mode() & os.ModeCharDevice) == 0 {
2121
return true
2222
}
23-
23+
2424
// Double-check using term.IsTerminal
2525
fd := int(os.Stdin.Fd())
2626
return !term.IsTerminal(fd)
27-
}
27+
}

pkg/console/console_redirect_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ func TestStdinRedirectionDetection(t *testing.T) {
5151

5252
// Clean up
5353
console.Close()
54-
}
54+
}

0 commit comments

Comments
 (0)