Skip to content

Commit

Permalink
Update golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Jan 16, 2022
1 parent 6d779e5 commit ecf9d88
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 259 deletions.
19 changes: 9 additions & 10 deletions .golangci-required.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ linters:
- deadcode
- depguard
- goimports
- golint
- gosec
- govet
- ineffassign
Expand All @@ -33,13 +32,13 @@ issues:
- "G201: SQL string formatting"
- "G202: SQL string concatenation"

# golint - matches database/sql.Result.LastInsertId()
# > method LastInsertIdMethod should be LastInsertIDMethod
# > type `LastInsertIdMethod` should be `LastInsertIDMethod`
# > var `lastInsertIdMethod` should be `lastInsertIDMethod`
- "`?LastInsertIdMethod`? should be `?LastInsertIDMethod`?"
# # golint - matches database/sql.Result.LastInsertId()
# # > method LastInsertIdMethod should be LastInsertIDMethod
# # > type `LastInsertIdMethod` should be `LastInsertIDMethod`
# # > var `lastInsertIdMethod` should be `lastInsertIDMethod`
# - "`?LastInsertIdMethod`? should be `?LastInsertIDMethod`?"

exclude-rules:
- path: internal/test/models/
linters:
- golint
# exclude-rules:
# - path: internal/test/models/
# linters:
# - golint
17 changes: 9 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ linters:
enable-all: true
disable:
- goerr113 # reform v1 should not wrap errors to keep SemVer compatibility
- golint # deprecated
- gomnd # too annoying
- interfacer # deprecated
- lll # too annoying
Expand All @@ -31,16 +32,16 @@ issues:
- "G201: SQL string formatting"
- "G202: SQL string concatenation"

# golint - matches database/sql.Result.LastInsertId()
# > method LastInsertIdMethod should be LastInsertIDMethod
# > type `LastInsertIdMethod` should be `LastInsertIDMethod`
# > var `lastInsertIdMethod` should be `lastInsertIDMethod`
- "`?LastInsertIdMethod`? should be `?LastInsertIDMethod`?"
# # golint - matches database/sql.Result.LastInsertId()
# # > method LastInsertIdMethod should be LastInsertIDMethod
# # > type `LastInsertIdMethod` should be `LastInsertIDMethod`
# # > var `lastInsertIdMethod` should be `lastInsertIDMethod`
# - "`?LastInsertIdMethod`? should be `?LastInsertIDMethod`?"

exclude-rules:
- path: internal/test/models/
linters:
- golint
# - path: internal/test/models/
# linters:
# - golint
- path: _test\.go
linters:
- funlen # tests may be long
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ help: ## Display this help message.
# SHELL = go run .github/shell.go

init: ## Install development tools.
# emulate -modfile flag for older Go
make -C tools
rm -fr bin
go mod tidy -go=1.17 -compat=1.17
cd tools && go mod tidy -go=1.17 -compat=1.17
go mod verify
cd tools && go generate -tags=tools -x

env-up: ## Start development environment.
docker-compose up --force-recreate --abort-on-container-exit --renew-anon-volumes --remove-orphans
Expand Down Expand Up @@ -202,8 +205,8 @@ ci-check-changes:
# `go mod tidy` could remove old checksums from that file, and that's okay on CI,
# and actually expected for PRs made by @dependabot.
# Checksums of actually used modules are checked by previous CI steps.
cd tools && pwd && go mod tidy && git checkout go.sum
pwd && go mod tidy && git checkout go.sum
cd tools && pwd && go mod tidy -go=1.17 -compat=1.17 && git checkout go.sum
pwd && go mod tidy -go=1.17 -compat=1.17 && git checkout go.sum
git status
git diff --exit-code

Expand Down
10 changes: 4 additions & 6 deletions base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ import (
. "gopkg.in/reform.v1/internal/test/models"
)

var (
// DB is a global connection pool shared by tests and examples.
//
// Deprecated: do not add new tests using it as using a global pool makes tests more brittle.
DB *reform.DB
)
// DB is a global connection pool shared by tests and examples.
//
// Deprecated: do not add new tests using it as using a global pool makes tests more brittle.
var DB *reform.DB

func TestMain(m *testing.M) {
flag.Parse()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ require (
require (
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c // indirect
golang.org/x/text v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/denisenkom/go-mssqldb v0.10.0 h1:QykgLZBorFE95+gO3u9esLd0BmbvpWp0/waN
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 h1:vr3AYkKovP8uR8AvSGGUK1IDqRa5lAAvEkZG1LKaCRc=
Expand All @@ -28,8 +28,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down
2 changes: 1 addition & 1 deletion reform-db/cmd_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ and edited manually.

func gofmt(path string) {
if *gofmtF {
cmd := exec.Command("gofmt", "-s", "-w", path) //nolint:gosec
cmd := exec.Command("gofmt", "-s", "-w", path)
logger.Debugf(strings.Join(cmd.Args, " "))
b, err := cmd.CombinedOutput()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions reform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func processFile(path, file, pack string) error {

func gofmt(path string) {
if *gofmtF {
cmd := exec.Command("gofmt", "-s", "-w", path) //nolint:gosec
cmd := exec.Command("gofmt", "-s", "-w", path)
logger.Debugf(strings.Join(cmd.Args, " "))
b, err := cmd.CombinedOutput()
if err != nil {
Expand All @@ -112,7 +112,7 @@ func goformat(filePath string) {
logger.Fatalf("go/format formatting error: %s", err)
}
if !reflect.DeepEqual(in, out) {
if err := ioutil.WriteFile(filePath, out, 0644); err != nil { //nolint:gosec
if err := ioutil.WriteFile(filePath, out, 0o644); err != nil { //nolint:gosec
logger.Fatalf("go/format write error: %s", err)
}
}
Expand Down
6 changes: 0 additions & 6 deletions tools/Makefile

This file was deleted.

Loading

0 comments on commit ecf9d88

Please sign in to comment.