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

PMM-7 Fix linter config and some errors #2504

Merged
merged 6 commits into from
Sep 27, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ linters-settings:
max-complexity: 30

depguard:
list-type: blacklist
include-go-root: true
packages:
# use "github.com/pkg/errors" instead
- errors
# use "github.com/golang/protobuf/proto" instead
- github.com/gogo/protobuf/proto
# use only forked parser
- github.com/percona/go-mysql/log/slow
# use "github.com/percona-platform/saas" instead
- github.com/percona-platform/platform
# use "gopkg.in/yaml.v3" instead
- gopkg.in/yaml.v2
rules:
main:
deny:
- pkg: "errors"
desc: use "github.com/pkg/errors" instead
- pkg: "github.com/gogo/protobuf/proto"
desc: use "github.com/golang/protobuf/proto" instead
- pkg: "github.com/percona/go-mysql/log/slow"
desc: only use the forked parser
- pkg: "github.com/percona-platform/platform"
desc: use "github.com/percona-platform/saas" instead
- pkg: "gopkg.in/yaml.v2"
desc: use "gopkg.in/yaml.v3" instead

gci:
sections:
Expand Down Expand Up @@ -103,8 +103,12 @@ linters:
- maligned # deprecated
- nlreturn # too annoying
- nosnakecase # deprecated
- rowserrcheck # disabled because of generics
- scopelint # too many false positives
- structcheck # replaced by unused
- varcheck # replaced by unused
- varnamelen # useless
- wastedassign # disabled because of generics
- wrapcheck # we do not use wrapping everywhere
- wsl # too annoying

Expand Down
2 changes: 1 addition & 1 deletion agent/runner/jobs/pbm_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func waitForPBMBackup(ctx context.Context, l logrus.FieldLogger, dbURL *string,
return nil
case "canceled":
return errors.New("backup was canceled")
case "error": //nolint:goconst
case "error":
return errors.New(info.Error)
}

Expand Down
2 changes: 1 addition & 1 deletion managed/services/agents/grpc/agent_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s *agentServer) Connect(stream agentpb.Agent_ConnectServer) error {
return s.handler.Run(stream)
}

// check interfaces
// check interfaces.
var (
_ agentpb.AgentServer = (*agentServer)(nil)
)
4 changes: 2 additions & 2 deletions managed/services/agents/log_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"github.com/percona/pmm/version"
)

// Log level available in exporters with pmm 2.28
// Log level available in exporters with pmm 2.28.
var exporterLogLevelCommandVersion = version.MustParse("2.27.99")

// withLogLevel - append CLI args --log.level
// mysqld_exporter, node_exporter and postgres_exporter don't support --log.level=fatal
// mysqld_exporter, node_exporter and postgres_exporter don't support --log.level=fatal.
func withLogLevel(args []string, logLevel *string, pmmAgentVersion *version.Parsed, supportLogLevelFatal bool) []string {
level := pointer.GetString(logLevel)

Expand Down
2 changes: 1 addition & 1 deletion managed/services/backup/pitr_timerange_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func getTimelines(slices []*oplogChunk) []Timeline {
var timelines []Timeline
var prevEnd primitive.Timestamp
for _, s := range slices {
if prevEnd.T != 0 && primitive.CompareTimestamp(prevEnd, s.StartTS) == -1 {
if prevEnd.T != 0 && prevEnd.Compare(s.StartTS) == -1 {
timelines = append(timelines, tl)
tl = Timeline{}
}
Expand Down
2 changes: 1 addition & 1 deletion managed/services/management/grpc/actions_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (s *actionsServer) StartPostgreSQLShowIndexAction(ctx context.Context, req
}, nil
}

// StartMongoDBExplainAction starts MongoDB Explain action
// StartMongoDBExplainAction starts MongoDB Explain action.
func (s *actionsServer) StartMongoDBExplainAction(ctx context.Context, req *managementpb.StartMongoDBExplainActionRequest) (
*managementpb.StartMongoDBExplainActionResponse, error,
) {
Expand Down
2 changes: 1 addition & 1 deletion managed/services/management/grpc/mongodb_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/percona/pmm/managed/services/management"
)

// TODO merge into ../mongodb.go
// TODO merge into ../mongodb.go.
type mongoDBServer struct {
svc *management.MongoDBService

Expand Down
2 changes: 1 addition & 1 deletion managed/services/management/grpc/mysql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/percona/pmm/managed/services/management"
)

// TODO merge into ../mysql.go
// TODO merge into ../mysql.go.
type mySQLServer struct {
svc *management.MySQLService

Expand Down
2 changes: 1 addition & 1 deletion managed/services/management/grpc/node_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/percona/pmm/managed/services/management"
)

// TODO merge into ../node.go
// TODO merge into ../node.go.
type nodeServer struct {
svc *management.NodeService

Expand Down
2 changes: 1 addition & 1 deletion managed/services/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (s *Service) DistributionMethod() serverpb.DistributionMethod {
func (s *Service) processSendCh(ctx context.Context) {
var reportsBufSync sync.Mutex
var reportsBuf []*pmmv1.ServerMetric
var sendCtx context.Context
var sendCtx context.Context //nolint:contextcheck
var cancel context.CancelFunc

for {
Expand Down