Skip to content

Commit fd05106

Browse files
matthewdaleBenji Rewis
authored andcommitted
Fix new lint failures and drop deprecated linters. (#1055)
1 parent 9481568 commit fd05106

File tree

11 files changed

+38
-7
lines changed

11 files changed

+38
-7
lines changed

.golangci.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ linters:
55
disable-all: true
66
# TODO(GODRIVER-2156): Enable all commented-out linters.
77
enable:
8-
- deadcode
98
- errcheck
109
# - errorlint
1110
- goimports
@@ -19,12 +18,10 @@ linters:
1918
- prealloc
2019
- revive
2120
- staticcheck
22-
- structcheck
2321
- typecheck
2422
- unused
2523
- unconvert
2624
- unparam
27-
- varcheck
2825

2926
linters-settings:
3027
errcheck:
@@ -92,10 +89,11 @@ issues:
9289
- path: x/mongo/driver/auth/internal/awsv4
9390
linters:
9491
- unused
95-
- structcheck
96-
# Disable "unused" linter for "crypt.go" because the linter doesn't work correctly without
97-
# enabling CGO.
98-
- path: x/mongo/driver/crypt.go
92+
# Disable "unused" linter for code files that depend on the "mongocrypt.MongoCrypt" type because
93+
# the linter build doesn't work correctly with CGO enabled. As a result, all calls to a
94+
# "mongocrypt.MongoCrypt" API appear to always panic (see mongocrypt_not_enabled.go), leading
95+
# to confusing messages about unused code.
96+
- path: x/mongo/driver/crypt.go|mongo/(crypt_retrievers|mongocryptd).go
9997
linters:
10098
- unused
10199
# Ignore "TLS MinVersion too low", "TLS InsecureSkipVerify set true", and "Use of weak random
@@ -108,3 +106,12 @@ issues:
108106
# "benchmark" directories.
109107
- path: (internal\/|benchmark\/)
110108
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
109+
# Ignore missing package comments for directories that aren't frequently used by external users.
110+
# TODO(GODRIVER-2517): Remove "mongo/testaws" and "mongo/testatlas" from the ignored paths when
111+
# TODO we move those packages to the "cmd/" directory.
112+
- path: (internal\/|benchmark\/|x\/|cmd\/|mongo\/integration\/|mongo\/(testaws\/|testatlas\/))
113+
text: should have a package comment
114+
# Disable unused linter for "golang.org/x/exp/rand" package in internal/randutil/rand.
115+
- path: internal/randutil/rand
116+
linters:
117+
- unused

bson/bsonoptions/doc.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (C) MongoDB, Inc. 2022-present.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
// not use this file except in compliance with the License. You may obtain
5+
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
// Package bsonoptions defines the optional configurations for the BSON codecs.
8+
package bsonoptions

bson/bsonrw/bsonrwtest/bsonrwtest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// not use this file except in compliance with the License. You may obtain
55
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
66

7+
// Package bsonrwtest provides utilities for testing the "bson/bsonrw" package.
78
package bsonrwtest // import "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest"
89

910
import (

mongo/address/addr.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// not use this file except in compliance with the License. You may obtain
55
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
66

7+
// Package address provides structured representations of network addresses.
78
package address // import "go.mongodb.org/mongo-driver/mongo/address"
89

910
import (

mongo/description/description.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// not use this file except in compliance with the License. You may obtain
55
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
66

7+
// Package description contains types and functions for describing the state of MongoDB clusters.
78
package description // import "go.mongodb.org/mongo-driver/mongo/description"
89

910
// Unknown is an unknown server or topology kind.

mongo/options/doc.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (C) MongoDB, Inc. 2022-present.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
// not use this file except in compliance with the License. You may obtain
5+
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
// Package options defines the optional configurations for the MongoDB Go Driver.
8+
package options

mongo/readconcern/readconcern.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// not use this file except in compliance with the License. You may obtain
55
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
66

7+
// Package readconcern defines read concerns for MongoDB operations.
78
package readconcern // import "go.mongodb.org/mongo-driver/mongo/readconcern"
89

910
import (

mongo/readpref/readpref.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// not use this file except in compliance with the License. You may obtain
55
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
66

7+
// Package readpref defines read preferences for MongoDB queries.
78
package readpref // import "go.mongodb.org/mongo-driver/mongo/readpref"
89

910
import (

mongo/writeconcern/writeconcern.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// not use this file except in compliance with the License. You may obtain
55
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
66

7+
// Package writeconcern defines write concerns for MongoDB operations.
78
package writeconcern // import "go.mongodb.org/mongo-driver/mongo/writeconcern"
89

910
import (

tag/tag.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// not use this file except in compliance with the License. You may obtain
55
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
66

7+
// Package tag provides a way to define filters for tagged servers.
78
package tag // import "go.mongodb.org/mongo-driver/tag"
89

910
import (

0 commit comments

Comments
 (0)