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

build: upgrade staticcheck, fix new linter warnings #21957

Merged
merged 2 commits into from
Jul 28, 2021
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
5 changes: 2 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,8 @@ jobs:
- run: make checkgenerate
- run: make vet
- run: make checkfmt
- run: GO111MODULE=on go mod vendor # staticcheck looks in vendor for dependencies.
- run: GO111MODULE=on go install honnef.co/go/tools/cmd/staticcheck # Install staticcheck from the version we specify in go.mod.
- run: GO111MODULE=on ./env staticcheck ./...
- run: go install honnef.co/go/tools/cmd/staticcheck
- run: staticcheck ./...

gotest:
docker:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ require (
gopkg.in/vmihailenco/msgpack.v2 v2.9.1 // indirect
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
honnef.co/go/tools v0.1.3
honnef.co/go/tools v0.2.0
labix.org/v2/mgo v0.0.0-20140701140051-000000000287 // indirect
)

Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,9 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.1.3 h1:qTakTkI6ni6LFD5sBwwsdSO+AQqbSIxOauHTTQKZ/7o=
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
honnef.co/go/tools v0.2.0 h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
honnef.co/go/tools v0.2.0/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY=
labix.org/v2/mgo v0.0.0-20140701140051-000000000287 h1:L0cnkNl4TfAXzvdrqsYEmxOHOCv2p5I3taaReO8BWFs=
labix.org/v2/mgo v0.0.0-20140701140051-000000000287/go.mod h1:Lg7AYkt1uXJoR9oeSZ3W/8IXLdvOfIITgZnommstyz4=
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
Expand Down
3 changes: 1 addition & 2 deletions influxql/query/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ func (e *Executor) recover(query *influxql.Query, results chan *Result) {

if willCrash {
e.log.Error("\n\n=====\nAll goroutines now follow:")
buf := debug.Stack()
e.log.Error(fmt.Sprintf("%s", buf))
e.log.Error(string(debug.Stack()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Style nitpick

os.Exit(1)
}
}
Expand Down
10 changes: 5 additions & 5 deletions query/stdlib/influxdata/influxdb/to.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ type Stats struct {
NTags int
}

func (s Stats) Update(o Stats) {
func (s Stats) Update(o Stats) Stats {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug: This method does a lot of updates to the fields of s, but since it wasn't being passed as a reference none of the updates were having an effect. I decided to keep the pass-by-value here and return the new data because at the callsite s is a member of a map, so getting a reference to it is a pain.

s.NRows += o.NRows
if s.Latest.IsZero() || o.Latest.Unix() > s.Latest.Unix() {
s.Latest = o.Latest
Expand All @@ -516,6 +516,7 @@ func (s Stats) Update(o Stats) {
if o.NTags > s.NTags {
s.NTags = o.NTags
}
return s
}

func writeTable(ctx context.Context, t *ToTransformation, tbl flux.Table) (err error) {
Expand Down Expand Up @@ -654,11 +655,10 @@ func writeTable(ctx context.Context, t *ToTransformation, tbl flux.Table) (err e
NTags: len(kv) / 2,
}
_, ok := measurementStats[measurementName]
if !ok {
measurementStats[measurementName] = mstats
} else {
measurementStats[measurementName].Update(mstats)
if ok {
mstats = measurementStats[measurementName].Update(mstats)
}
measurementStats[measurementName] = mstats

tags, _ = models.NewTagsKeyValues(tags, kv...)
pt, err := models.NewPoint(measurementName, tags, fields, pointTime)
Expand Down