Skip to content

Commit

Permalink
[qfix] Enable depguard linter (#1490)
Browse files Browse the repository at this point in the history
* enable depguard linter

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter

Signed-off-by: Nikita Skrynnik <[email protected]>

* rerun CI

Signed-off-by: Nikita Skrynnik <[email protected]>

---------

Signed-off-by: Nikita Skrynnik <[email protected]>
  • Loading branch information
NikitaSkrynnik authored Jul 20, 2023
1 parent 7d9fde6 commit 8dc1419
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 25 deletions.
17 changes: 6 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ linters-settings:
min-len: 2
min-occurrences: 2
depguard:
list-type: blacklist
include-go-root: false
packages:
- errors
packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- errors: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports"
rules:
main:
deny:
- pkg: "errors"
desc: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports"
misspell:
locale: US
unparam:
Expand Down Expand Up @@ -129,11 +127,10 @@ linters-settings:
linters:
disable-all: true
enable:
# - rowserrcheck
- goheader
- bodyclose
- deadcode
# - depguard
- depguard
- dogsled
- dupl
- errcheck
Expand All @@ -150,7 +147,6 @@ linters:
- govet
- ineffassign
- interfacer
# - lll
- misspell
- nakedret
- scopelint
Expand All @@ -160,7 +156,6 @@ linters:
- typecheck
- unconvert
- unparam
# - unused
- varcheck
- whitespace
issues:
Expand Down
5 changes: 4 additions & 1 deletion pkg/networkservice/common/mechanisms/kernel/vlan/server.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2021-2022 Nordix Foundation.
//
// Copyright (c) 2023 Cisco Foundation.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,9 +24,10 @@ package vlan

import (
"context"
"errors"
"sync"

"github.com/pkg/errors"

"github.com/RoaringBitmap/roaring"
"github.com/golang/protobuf/ptypes/empty"

Expand Down
5 changes: 4 additions & 1 deletion pkg/networkservice/common/mechanisms/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// Copyright (c) 2021 Doc.ai and/or its affiliates.
//
// Copyright (c) 2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,9 +22,10 @@ package mechanisms_test

import (
"context"
"errors"
"testing"

"github.com/pkg/errors"

"github.com/stretchr/testify/require"

"github.com/networkservicemesh/sdk/pkg/networkservice/utils/checks/checkcontext"
Expand Down
7 changes: 3 additions & 4 deletions pkg/networkservice/common/timeout/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2020-2021 Doc.ai and/or its affiliates.
//
// Copyright (c) 2020-2022 Cisco Systems, Inc.
// Copyright (c) 2020-2023 Cisco Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -23,10 +23,9 @@ import (
"context"
"time"

iserror "errors"
"github.com/pkg/errors"

"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/begin"
"github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"
Expand Down Expand Up @@ -90,7 +89,7 @@ func (s *timeoutServer) Request(ctx context.Context, request *networkservice.Net

func (s *timeoutServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) {
_, err := next.Server(ctx).Close(ctx, conn)
if !(iserror.Is(err, context.DeadlineExceeded) || iserror.Is(err, context.Canceled)) {
if !(errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled)) {
if oldCancel, loaded := loadAndDelete(ctx, metadata.IsClient(s)); loaded {
oldCancel()
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/networkservice/connectioncontext/ipcontext/vl3/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 Cisco and/or its affiliates.
// Copyright (c) 2022-2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -20,7 +20,8 @@ package vl3

import (
"context"
"errors"

"github.com/pkg/errors"

"github.com/edwarnicke/serialize"
"github.com/golang/protobuf/ptypes/empty"
Expand Down
5 changes: 3 additions & 2 deletions pkg/networkservice/connectioncontext/ipcontext/vl3/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 Cisco and/or its affiliates.
// Copyright (c) 2022-2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -18,7 +18,8 @@ package vl3

import (
"context"
"errors"

"github.com/pkg/errors"

"github.com/golang/protobuf/ptypes/empty"
"github.com/networkservicemesh/api/pkg/api/ipam"
Expand Down
5 changes: 4 additions & 1 deletion pkg/networkservice/core/adapters/networkservice_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
//
// Copyright (c) 2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,9 +20,10 @@ package adapters_test

import (
"context"
"errors"
"testing"

"github.com/pkg/errors"

"github.com/golang/protobuf/ptypes/empty"
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/stretchr/testify/require"
Expand Down
3 changes: 2 additions & 1 deletion pkg/registry/common/dnsresolve/ns_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package dnsresolve

import (
"context"
"errors"
"net"

"github.com/pkg/errors"

"github.com/networkservicemesh/sdk/pkg/tools/clienturlctx"

"github.com/networkservicemesh/sdk/pkg/tools/interdomain"
Expand Down
4 changes: 3 additions & 1 deletion pkg/tools/grpcutils/errors.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2021 Doc.ai and/or its affiliates.
//
// Copyright (c) 2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,7 +19,7 @@
package grpcutils

import (
"errors"
"github.com/pkg/errors"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down
5 changes: 4 additions & 1 deletion pkg/tools/sandbox/fake_resolver.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2020-2022 Doc.ai and/or its affiliates.
//
// Copyright (c) 2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,13 +20,14 @@ package sandbox

import (
"context"
"errors"
"fmt"
"net"
"net/url"
"strconv"
"sync"

"github.com/pkg/errors"

"github.com/networkservicemesh/sdk/pkg/registry/common/dnsresolve"
)

Expand Down

0 comments on commit 8dc1419

Please sign in to comment.