Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump golangci-lint version #320

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:
branches:
- '**'
schedule:
- cron: '27 0 * * *'
- cron: '28 0 * * *'

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: ["1.21", "1.22"]
go-version: ["1.22", "1.23"]
edgedb-version: [stable, nightly]
os: [ubuntu-latest, macos-latest]
steps:
Expand All @@ -33,6 +33,11 @@ jobs:
run: |
go install
make lint && make gendocs-lint
make gen
if [[ "$(git status --porcelain)" != "" ]]; then
echo "Generated code is out of sync. Run make gen."
exit 1
fi

- name: Build
run: |
Expand Down
43 changes: 10 additions & 33 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ run:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-files:
- doc_test.go
- cmd/edgeql-go/doc.go

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
Expand All @@ -59,9 +49,6 @@ run:

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

Expand Down Expand Up @@ -92,11 +79,6 @@ linters-settings:
# default is false: such cases aren't reported by default.
check-blank: false

# [deprecated] comma-separated list of pairs of the form pkg:regex
# the regex is used to ignore names within pkg. (default "fmt:.*").
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
ignore: fmt:.*,io/ioutil:^Read.*

# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
# exclude: /path/to/file.txt
Expand All @@ -110,11 +92,6 @@ linters-settings:
funlen:
lines: 60
statements: 40
gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
local-prefixes: github.com/org/project
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
Expand Down Expand Up @@ -183,11 +160,9 @@ linters-settings:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
gomnd:
settings:
mnd:
# the list of enabled checks,
# see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: argument,case,condition,operation,return,assign
# the list of enabled checks,
# see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: argument,case,condition,operation,return,assign
gomodguard:
allowed:
# List of allowed modules
Expand Down Expand Up @@ -216,9 +191,6 @@ linters-settings:
# # Reason why the version constraint exists. (Optional)
# reason: "testing if blocked version constraint works."
govet:
# report about shadowed variables
check-shadowing: true

# settings per analyzer
settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers
Expand Down Expand Up @@ -364,6 +336,7 @@ linters-settings:
linters:
enable:
- errcheck
- gci
- gocritic
- gofmt
- goheader
Expand All @@ -372,10 +345,10 @@ linters:
- govet
- ineffassign
- lll
- revive
- prealloc
- revive
- staticcheck
- typecheck
# - typecheck
- unconvert
- unused
- whitespace
Expand Down Expand Up @@ -458,6 +431,10 @@ issues:

# Show only new issues created in git patch with set file path.
# new-from-patch: path/to/patch/file

exclude-files:
- doc_test.go
- cmd/edgeql-go/doc.go

severity:
# Default value is empty string.
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
CHANGES:=$(shell git status --porcelain)

quality: lint test bench

lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1 run --sort-results
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 run --sort-results

test:
go test -v -count=1 -race -bench=$$^ -timeout=20m ./...
Expand All @@ -24,6 +26,9 @@ errors:
go run internal/cmd/generrexport/main.go > errors_gen.go
make format

gen:
go generate ./...

gendocs:
go run internal/cmd/gendocs/*.go

Expand Down
2 changes: 1 addition & 1 deletion cmd/edgeql-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var (
)

func usage() {
fmt.Fprintf(flag.CommandLine.Output(), ""+
_, _ = fmt.Fprintf(flag.CommandLine.Output(), ""+
"Generate go functions from edgeql files.\n"+
"\n"+
"USAGE:\n"+
Expand Down
4 changes: 2 additions & 2 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
// limitations under the License.

// Package edgedb is the official Go driver for [EdgeDB]. Additionally,
// [github.com/edgedb/edgedb-go/cmd/edgeql-go] is a code generator that generates go functions from edgeql
// files.
// [github.com/edgedb/edgedb-go/cmd/edgeql-go] is a code generator that
// generates go functions from edgeql files.
//
// Typical client usage looks like this:
//
Expand Down
2 changes: 1 addition & 1 deletion doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"log"
"time"

"github.com/edgedb/edgedb-go"
edgedb "github.com/edgedb/edgedb-go"
)

type User struct {
Expand Down
6 changes: 3 additions & 3 deletions export.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type (
// ErrorTag is the argument type to Error.HasTag().
ErrorTag = edgedb.ErrorTag

// Executor is a common interface between Client and Tx,
// Executor is a common interface between *Client and *Tx,
// that can run queries on an EdgeDB database.
Executor = edgedb.Executor

Expand Down Expand Up @@ -238,7 +238,7 @@ type (
// before making the next attempt when retrying a transaction.
RetryBackoff = edgedb.RetryBackoff

// RetryCondition represents scenarios that can caused a transaction
// RetryCondition represents scenarios that can cause a transaction
// run in Tx() methods to be retried.
RetryCondition = edgedb.RetryCondition

Expand Down Expand Up @@ -428,7 +428,7 @@ var (
// NewRelativeDuration returns a new RelativeDuration
NewRelativeDuration = edgedbtypes.NewRelativeDuration

// NewRetryOptions returns the default RetryOptions value.
// NewRetryOptions returns the default retry options.
NewRetryOptions = edgedb.NewRetryOptions

// NewRetryRule returns the default RetryRule value.
Expand Down
5 changes: 2 additions & 3 deletions internal/buff/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ package buff
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

types "github.com/edgedb/edgedb-go/internal/edgedbtypes"
"github.com/edgedb/edgedb-go/internal/soc"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestNext(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/client/aspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package edgedb

//go:generate stringer -type Aspect
//go:generate go run golang.org/x/tools/cmd/stringer@v0.25.0 -type Aspect

// Aspect is the description aspect from protocol version 0.X
type Aspect uint8
Expand Down
2 changes: 1 addition & 1 deletion internal/client/cardinality.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package edgedb

//go:generate stringer -type Cardinality
//go:generate go run golang.org/x/tools/cmd/stringer@v0.25.0 -type Cardinality

// Cardinality is the result cardinality for a command.
type Cardinality uint8
Expand Down
2 changes: 1 addition & 1 deletion internal/client/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package edgedb

//go:generate stringer -type Format
//go:generate go run golang.org/x/tools/cmd/stringer@v0.25.0 -type Format

// Format is the query response format.
type Format uint8
Expand Down
2 changes: 1 addition & 1 deletion internal/client/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package edgedb

//go:generate stringer -type Cardinality
//go:generate go run golang.org/x/tools/cmd/stringer@v0.25.0 -type Message

// Message is a protocol message type.
type Message uint8
Expand Down
79 changes: 79 additions & 0 deletions internal/client/message_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/cmd/export/names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ CreateClient
CreateClientDSN
DateDuration
Duration
DurationFromNanoseconds
Error
ErrorCategory
ErrorTag
Executor
IsolationLevel
LocalDate
LocalDateTime
Expand Down Expand Up @@ -50,6 +52,7 @@ NewRangeInt64
NewRangeLocalDate
NewRangeLocalDateTime
NewRelativeDuration
NewRetryOptions
NewRetryRule
NewTxOptions
Optional
Expand Down
4 changes: 2 additions & 2 deletions internal/codecs/codecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func buildScalarDecoder(
expectedType = "edgedb.Duration or edgedb.OptionalDuration"
}
case JSONID:
ptr := reflect.PtrTo(typ)
ptr := reflect.PointerTo(typ)

switch {
case typ == bytesType:
Expand Down Expand Up @@ -751,7 +751,7 @@ func buildScalarDecoderV2(
expectedType = "edgedb.Duration or edgedb.OptionalDuration"
}
case JSONID:
ptr := reflect.PtrTo(typ)
ptr := reflect.PointerTo(typ)

switch {
case typ == bytesType:
Expand Down
4 changes: 2 additions & 2 deletions internal/codecs/namedtuple.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func buildNamedTupleDecoder(

decoder := namedTupleDecoder{desc.ID, fields}

if reflect.PtrTo(typ).Implements(optionalUnmarshalerType) {
if reflect.PointerTo(typ).Implements(optionalUnmarshalerType) {
return &optionalNamedTupleDecoder{decoder, typ}, nil
}

Expand Down Expand Up @@ -191,7 +191,7 @@ func buildNamedTupleDecoderV2(

decoder := namedTupleDecoder{desc.ID, fields}

if reflect.PtrTo(typ).Implements(optionalUnmarshalerType) {
if reflect.PointerTo(typ).Implements(optionalUnmarshalerType) {
return &optionalNamedTupleDecoder{decoder, typ}, nil
}

Expand Down
Loading
Loading