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

Fix new lint failures and drop deprecated linters. #1055

Merged
merged 2 commits into from Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions .golangci.yml
Expand Up @@ -5,7 +5,6 @@ linters:
disable-all: true
# TODO(GODRIVER-2156): Enable all commented-out linters.
enable:
- deadcode
- errcheck
# - errorlint
- gocritic
Expand All @@ -20,12 +19,10 @@ linters:
- prealloc
- revive
- staticcheck
- structcheck
- typecheck
- unused
Copy link
Contributor

Choose a reason for hiding this comment

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

So deadcode, structcheck and varcheck are now all a subset of unused?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's correct. According to the linters documentation, the unused linter replaces the unmaintained deadcode, structcheck and varcheck linters.

- unconvert
- unparam
- varcheck

linters-settings:
errcheck:
Expand Down Expand Up @@ -97,7 +94,6 @@ issues:
- path: x/mongo/driver/auth/internal/awsv4
linters:
- unused
- structcheck
# Disable "unused" linter for code files that depend on the "mongocrypt.MongoCrypt" type because
# the linter build doesn't work correctly with CGO enabled. As a result, all calls to a
# "mongocrypt.MongoCrypt" API appear to always panic (see mongocrypt_not_enabled.go), leading
Expand All @@ -115,9 +111,12 @@ issues:
# "benchmark" directories.
- path: (internal\/|benchmark\/)
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
# Disable deadcode and unused linter for "golang.org/x/exp/rand" package in internal/randutil/rand.
# Ignore missing package comments for directories that aren't frequently used by external users.
# TODO(GODRIVER-2517): Remove "mongo/testaws" and "mongo/testatlas" from the ignored paths when
# TODO we move those packages to the "cmd/" directory.
- path: (internal\/|benchmark\/|x\/|cmd\/|mongo\/integration\/|mongo\/(testaws\/|testatlas\/))
text: should have a package comment
# Disable unused linter for "golang.org/x/exp/rand" package in internal/randutil/rand.
- path: internal/randutil/rand
linters:
- deadcode
- unused
- varcheck
8 changes: 8 additions & 0 deletions bson/bsonoptions/doc.go
@@ -0,0 +1,8 @@
// Copyright (C) MongoDB, Inc. 2022-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

// Package bsonoptions defines the optional configurations for the BSON codecs.
package bsonoptions
1 change: 1 addition & 0 deletions bson/bsonrw/bsonrwtest/bsonrwtest.go
Expand Up @@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

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

import (
Expand Down
1 change: 1 addition & 0 deletions mongo/address/addr.go
Expand Up @@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

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

import (
Expand Down
1 change: 1 addition & 0 deletions mongo/description/description.go
Expand Up @@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

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

// Unknown is an unknown server or topology kind.
Expand Down
8 changes: 8 additions & 0 deletions mongo/options/doc.go
@@ -0,0 +1,8 @@
// Copyright (C) MongoDB, Inc. 2022-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

// Package options asdfasdfa.
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't seriously mean asdfasdfa, do you?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haha, good catch. Will update to an actual description 🤦

package options
1 change: 1 addition & 0 deletions mongo/readconcern/readconcern.go
Expand Up @@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

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

import (
Expand Down
1 change: 1 addition & 0 deletions mongo/readpref/readpref.go
Expand Up @@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

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

import (
Expand Down
1 change: 1 addition & 0 deletions mongo/writeconcern/writeconcern.go
Expand Up @@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

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

import (
Expand Down
1 change: 1 addition & 0 deletions tag/tag.go
Expand Up @@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

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

import (
Expand Down
1 change: 1 addition & 0 deletions version/version.go
Expand Up @@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

// Package version defines the Go Driver version.
package version // import "go.mongodb.org/mongo-driver/version"

// Driver is the current version of the driver.
Expand Down