Skip to content

Commit

Permalink
errcheck is being newly cranky about type assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
neilotoole committed Nov 18, 2024
1 parent fdf4a96 commit 9dd02ca
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ linters-settings:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions: true
check-type-assertions: false

exhaustive:
# Program elements to check for exhaustiveness.
Expand Down
2 changes: 1 addition & 1 deletion cli/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewContext(ctx context.Context, ru *Run) context.Context {

// FromContext extracts the Run added to ctx via NewContext.
func FromContext(ctx context.Context) *Run {
return ctx.Value(runKey{}).(*Run)
return ctx.Value(runKey{}).(*Run) //nolint:errcheck
}

// Run is a container for injectable resources passed
Expand Down
2 changes: 1 addition & 1 deletion drivers/sqlite3/internal/sqlparser/create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func parseCreateTableStmt(input string) (*sqlite.Create_table_stmtContext, error
return nil, errz.Err(err)
}

return qCtx.(*sqlite.Create_table_stmtContext), nil
return qCtx.(*sqlite.Create_table_stmtContext), nil //nolint:errcheck
}

// ExtractTableIdentFromCreateTableStmt extracts table name (and the
Expand Down
2 changes: 1 addition & 1 deletion libsq/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func buildAST(log *slog.Logger, query slq.IQueryContext) (*AST, error) {
tree := &parseTreeVisitor{log: log}

if err := q.Accept(tree); err != nil {
return nil, err.(error)
return nil, err.(error) //nolint:errcheck
}

visitors := []struct {
Expand Down
2 changes: 1 addition & 1 deletion libsq/ast/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (in *Inspector) FindTableSegments() []*SegmentNode {
func (in *Inspector) FindFirstHandle() (handle string) {
nodes := in.FindNodes(typeHandleNode)
if len(nodes) > 0 {
handle = nodes[0].(*HandleNode).Handle()
handle = nodes[0].(*HandleNode).Handle() //nolint:errcheck
return handle
}

Expand Down
2 changes: 1 addition & 1 deletion libsq/core/errz/errz.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func WithExitCode(err error, code int) error {

var _ ExitCoder = (*exitCoder)(nil)

type exitCoder struct {
type exitCoder struct { //nolint:errname
errz
code int
}
Expand Down
2 changes: 1 addition & 1 deletion libsq/core/errz/errz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestUnwrapChain(t *testing.T) {
require.Equal(t, "huzzah", gotCustomErr.msg)

gotUnwrap := errz.UnwrapChain(err)
require.Equal(t, *originalErr.(*customError), *gotUnwrap.(*customError)) //nolint:errorlint
require.Equal(t, *originalErr.(*customError), *gotUnwrap.(*customError)) //nolint:errorlint,errcheck

Check failure on line 57 in libsq/core/errz/errz_test.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:errorlint,errcheck` is unused for linter "errcheck" (nolintlint)
}

type customError struct {
Expand Down
6 changes: 3 additions & 3 deletions libsq/core/errz/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import (
func TestAlienCause(t *testing.T) {
err := New("boo")

cause := err.(*errz).alienCause()
cause := err.(*errz).alienCause() //nolint:errcheck
require.Nil(t, cause)

err = Err(context.DeadlineExceeded)
cause = err.(*errz).alienCause()
cause = err.(*errz).alienCause() //nolint:errcheck
require.Equal(t, context.DeadlineExceeded, cause)

err = Err(context.DeadlineExceeded)
err = Wrap(err, "wrap")
cause = err.(*errz).alienCause()
cause = err.(*errz).alienCause() //nolint:errcheck
require.Equal(t, context.DeadlineExceeded, cause)
}

Expand Down
2 changes: 1 addition & 1 deletion libsq/core/execz/execz.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func Exec(ctx context.Context, cmd *Cmd) (err error) {
if _, ok := cmd.Stdout.(*os.File); ok && !cmd.NoProgress {
bar := progress.FromContext(ctx).NewFilesizeCounter(
langz.NonEmptyOf(cmd.Label, cmd.Name),
cmd.Stdout.(*os.File),
cmd.Stdout.(*os.File), //nolint:errcheck
"",
progress.OptTimer,
)
Expand Down
4 changes: 2 additions & 2 deletions libsq/core/ioz/httpz/httpz.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func NewClient(opts ...Opt) *http.Client {
c.Timeout = 0
var tr *http.Transport
if c.Transport == nil {
tr = (http.DefaultTransport.(*http.Transport)).Clone()
tr = (http.DefaultTransport.(*http.Transport)).Clone() //nolint:errcheck

Check failure on line 43 in libsq/core/ioz/httpz/httpz.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:errcheck` is unused for linter "errcheck" (nolintlint)
} else {
tr = (c.Transport.(*http.Transport)).Clone()
tr = (c.Transport.(*http.Transport)).Clone() //nolint:errcheck
}

DefaultTLSVersion.apply(tr)
Expand Down
2 changes: 1 addition & 1 deletion libsq/core/ioz/ioz.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ type nopWriteCloserReaderFrom struct {
func (nopWriteCloserReaderFrom) Close() error { return nil }

func (c nopWriteCloserReaderFrom) ReadFrom(r io.Reader) (int64, error) {
return c.Writer.(io.ReaderFrom).ReadFrom(r)
return c.Writer.(io.ReaderFrom).ReadFrom(r) //nolint:errcheck

Check failure on line 352 in libsq/core/ioz/ioz.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:errcheck` is unused for linter "errcheck" (nolintlint)
}

// DrainClose drains rc, returning the number of bytes read, and any error.
Expand Down
2 changes: 1 addition & 1 deletion libsq/core/sqlz/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ type connectorCloser struct {

// Close implements io.Closer.
func (c connectorCloser) Close() error {
return c.impl.(io.Closer).Close()
return c.impl.(io.Closer).Close() //nolint:errcheck

Check failure on line 69 in libsq/core/sqlz/connector.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:errcheck` is unused for linter "errcheck" (nolintlint)
}
2 changes: 1 addition & 1 deletion libsq/files/internal/downloader/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func TestCachePreservedOnFailedRefresh(t *testing.T) {
sentBody = stringz.UniqSuffix("baaaaad")
_, err := w.Write([]byte(sentBody))
assert.NoError(t, err)
w.(http.Flusher).Flush()
w.(http.Flusher).Flush() //nolint:errcheck
time.Sleep(time.Millisecond * 10)
srvr.CloseClientConnections()
// The client should get an io.ErrUnexpectedEOF.
Expand Down
2 changes: 1 addition & 1 deletion libsq/files/internal/downloader/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (sh *SinkHandler) Reset() {
sh.Downloaded = nil

for _, stream := range sh.Streams {
_ = stream.Source().(io.Closer).Close()
_ = stream.Source().(io.Closer).Close() //nolint:errcheck
}

sh.Streams = nil
Expand Down

0 comments on commit 9dd02ca

Please sign in to comment.