Skip to content

Commit

Permalink
CI: use staticcheck (go-sql-driver#1449)
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed Jun 16, 2023
1 parent 943264b commit 564dee9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ env:
MYSQL_TEST_CONCURRENT: 1

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dominikh/staticcheck-action@v1.3.0
with:
version: "2023.1.3"

list:
runs-on: ubuntu-latest
outputs:
Expand Down
2 changes: 1 addition & 1 deletion auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
// parse public key
block, rest := pem.Decode(data[1:])
if block == nil {
return fmt.Errorf("No Pem data found, data: %s", rest)
return fmt.Errorf("no pem data found, data: %s", rest)
}
pkix, err := x509.ParsePKIXPublicKey(block.Bytes)
if err != nil {
Expand Down
11 changes: 7 additions & 4 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ func TestMultiQuery(t *testing.T) {
rows := dbt.mustQuery("SELECT value FROM test WHERE id=1;")
if rows.Next() {
rows.Scan(&out)
if 5 != out {
dbt.Errorf("5 != %d", out)
if out != 5 {
dbt.Errorf("expected 5, got %d", out)
}

if rows.Next() {
Expand Down Expand Up @@ -1293,7 +1293,7 @@ func TestLoadData(t *testing.T) {
_, err = dbt.db.Exec("LOAD DATA LOCAL INFILE 'Reader::doesnotexist' INTO TABLE test")
if err == nil {
dbt.Fatal("load non-existent Reader didn't fail")
} else if err.Error() != "Reader 'doesnotexist' is not registered" {
} else if err.Error() != "reader 'doesnotexist' is not registered" {
dbt.Fatal(err.Error())
}
})
Expand Down Expand Up @@ -1401,6 +1401,7 @@ func TestReuseClosedConnection(t *testing.T) {
if err != nil {
t.Fatalf("error preparing statement: %s", err.Error())
}
//lint:ignore SA1019 this is a test
_, err = stmt.Exec(nil)
if err != nil {
t.Fatalf("error executing statement: %s", err.Error())
Expand All @@ -1415,6 +1416,7 @@ func TestReuseClosedConnection(t *testing.T) {
t.Errorf("panic after reusing a closed connection: %v", err)
}
}()
//lint:ignore SA1019 this is a test
_, err = stmt.Exec(nil)
if err != nil && err != driver.ErrBadConn {
t.Errorf("unexpected error '%s', expected '%s'",
Expand Down Expand Up @@ -2432,6 +2434,7 @@ func TestExecMultipleResults(t *testing.T) {
t.Fatalf("failed to connect: %v", err)
}
conn.Raw(func(conn interface{}) error {
//lint:ignore SA1019 this is a test
ex := conn.(driver.Execer)
res, err := ex.Exec(`
INSERT INTO test (value) VALUES ('a'), ('b');
Expand Down Expand Up @@ -2489,8 +2492,8 @@ func TestQueryMultipleResults(t *testing.T) {
t.Fatalf("failed to connect: %v", err)
}
conn.Raw(func(conn interface{}) error {
//lint:ignore SA1019 this is a test
qr := conn.(driver.Queryer)

c := conn.(*mysqlConn)

// Demonstrate that repeated queries reset the affectedRows
Expand Down
2 changes: 1 addition & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
ErrMalformPkt = errors.New("malformed packet")
ErrNoTLS = errors.New("TLS requested but server does not support TLS")
ErrCleartextPassword = errors.New("this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN")
ErrNativePassword = errors.New("this user requires mysql native password authentication.")
ErrNativePassword = errors.New("this user requires mysql native password authentication")
ErrOldPassword = errors.New("this user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords")
ErrUnknownPlugin = errors.New("this authentication plugin is not supported")
ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+")
Expand Down
4 changes: 2 additions & 2 deletions infile.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ func (mc *okHandler) handleInFileRequest(name string) (err error) {
defer deferredClose(&err, cl)
}
} else {
err = fmt.Errorf("Reader '%s' is <nil>", name)
err = fmt.Errorf("reader '%s' is <nil>", name)
}
} else {
err = fmt.Errorf("Reader '%s' is not registered", name)
err = fmt.Errorf("reader '%s' is not registered", name)
}
} else { // File
name = strings.Trim(name, `"`)
Expand Down
2 changes: 1 addition & 1 deletion nulltime.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (nt *NullTime) Scan(value interface{}) (err error) {
}

nt.Valid = false
return fmt.Errorf("Can't convert %T to time.Time", value)
return fmt.Errorf("can't convert %T to time.Time", value)
}

// Value implements the driver Valuer interface.
Expand Down

0 comments on commit 564dee9

Please sign in to comment.