Skip to content

Conversation

julienschmidt
Copy link
Member

@julienschmidt julienschmidt commented Aug 14, 2020

Description

This PR includes a collection of different kinds of fixes (see commit messages below) to issues found with the help of several linters, ranging from missing error checks, to resource leaks because of unclosed rows / statements (luckily only in tests), a benchmark calling a wrong function, typos, shadowing issues and scope issues to bad coding style / formatting issues.

This PR also serves as a preparation for adding better linters to our CI pipeline.

Checklist

  • Code compiles correctly
  • All tests passing

@methane
Copy link
Member

methane commented Aug 16, 2020

LGTM.

But 0ea749d seems too strict to me. I usually use this variable hiding. Which linter do you want to use?

@maku693
Copy link

maku693 commented Aug 16, 2020

According to the documentation comment of converter.ConvertValue(),

ConvertValue mirrors the reference/default converter in database/sql/driver with one exception

I think alignment with driver.defaultConverter.ConvertValue() is more important than coding style consistency here, so fixes in that method seems overdoing to me.

If these changes are merged, it will be difficult to check what is changed from reference implementation.

@julienschmidt julienschmidt modified the milestones: v1.6.0, v1.7.0 Apr 1, 2021
Copy link

@haxandmat haxandmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great changes, we would like to see them in the next version.

Comment on lines +348 to +349
if err = parseDSNParams(cfg, dsn[j+1:]); err != nil {
return
Copy link

@haxandmat haxandmat Oct 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not return values like this here for consistency?
return cfg, err

var name string
name, err = url.QueryUnescape(value)
if err != nil {
return fmt.Errorf("invalid value for server pub key name: %v", err)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter message:
non-wrapping format verb for fmt.Errorf. Use %w to format errors (errorlint)
return fmt.Errorf("invalid value for server pub key name: %w", err)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case this is just a general DSN syntax error. The decoding error shouldn't be wrapped.

}

return
return err

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to use return nil, because no error is returned in this case.

@methane methane modified the milestones: v1.7.0, v1.8.0 May 2, 2023
@methane methane removed this from the v1.8.0 milestone May 24, 2023
@dolmen
Copy link
Contributor

dolmen commented Jun 2, 2023

@julienschmidt It would be better to resubmit each lint error fix as separate MR. It would be easier to review and accept at least some of them.

@methane methane closed this Jun 2, 2023
@methane methane deleted the misc_fixes branch March 16, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants