Skip to content

Commit edd76d8

Browse files
authored
chore: add support for gci, sloglint, loggercheck, grouper (#4058)
1 parent 151e9de commit edd76d8

File tree

96 files changed

+102
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+102
-197
lines changed

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ linters:
1616
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
1717
- durationcheck # check for two durations multiplied together [fast: false, auto-fix: false]
1818
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
19+
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
1920
- goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
2021
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
2122
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
@@ -25,16 +26,19 @@ linters:
2526
- gosec #(gas): Inspects source code for security problems [fast: false, auto-fix: false]
2627
- gosimple #(megacheck): Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false]
2728
- govet #(vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false]
29+
- grouper # An analyzer to analyze expression groups. [fast: true, auto-fix: false]
2830
- importas # Enforces consistent import aliases [fast: false, auto-fix: false]
2931
- ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
3032
- intrange # intrange is a linter to find places where for loops could make use of an integer range. [fast: true, auto-fix: false]
33+
- loggercheck # (logrlint): Checks key value pairs for common logger libraries (kitlog,klog,logr,zap). [fast: false, auto-fix: false]
3134
- misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true]
3235
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
3336
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
3437
- prealloc # Finds slice declarations that could potentially be pre-allocated [fast: true, auto-fix: false]
3538
- predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
3639
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
3740
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
41+
- sloglint # ensure consistent code style when using log/slog [fast: false, auto-fix: false]
3842
- staticcheck
3943
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
4044
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]

internal/alias/config_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/scaleway/scaleway-cli/v2/internal/alias"
8-
97
"github.com/alecthomas/assert"
8+
"github.com/scaleway/scaleway-cli/v2/internal/alias"
109
)
1110

1211
func TestConfig_ResolveAliases(t *testing.T) {

internal/args/args_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/scaleway/scaleway-cli/v2/internal/args"
11-
1210
"github.com/alecthomas/assert"
11+
"github.com/scaleway/scaleway-cli/v2/internal/args"
1312
"github.com/scaleway/scaleway-sdk-go/scw"
1413
"github.com/stretchr/testify/require"
1514
)

internal/args/marshal_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import (
44
"testing"
55
"time"
66

7-
"github.com/stretchr/testify/require"
8-
97
"github.com/scaleway/scaleway-cli/v2/internal/args"
10-
118
"github.com/scaleway/scaleway-sdk-go/scw"
129
"github.com/stretchr/testify/assert"
10+
"github.com/stretchr/testify/require"
1311
)
1412

1513
func TestMarshal(t *testing.T) {

internal/args/unmarshal_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ import (
66
"testing"
77
"time"
88

9-
"github.com/stretchr/testify/require"
10-
119
"github.com/scaleway/scaleway-cli/v2/internal/args"
12-
1310
"github.com/scaleway/scaleway-sdk-go/scw"
1411
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
1513
)
1614

1715
func init() {

internal/config/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import (
88
"runtime"
99
"text/template"
1010

11-
"gopkg.in/yaml.v3"
12-
1311
"github.com/scaleway/scaleway-cli/v2/internal/alias"
1412
"github.com/scaleway/scaleway-sdk-go/scw"
13+
"gopkg.in/yaml.v3"
1514
)
1615

1716
const (

internal/core/alias_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ package core_test
33
import (
44
"testing"
55

6-
"github.com/scaleway/scaleway-cli/v2/internal/core"
7-
86
"github.com/alecthomas/assert"
97
"github.com/scaleway/scaleway-cli/v2/internal/alias"
8+
"github.com/scaleway/scaleway-cli/v2/internal/core"
109
)
1110

1211
func TestCommandMatchAlias(t *testing.T) {

internal/core/arg_specs_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ package core_test
33
import (
44
"testing"
55

6-
"github.com/scaleway/scaleway-cli/v2/internal/core"
7-
86
"github.com/alecthomas/assert"
7+
"github.com/scaleway/scaleway-cli/v2/internal/core"
98
)
109

1110
func TestOneOf(t *testing.T) {

internal/core/autocomplete_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"testing"
99

1010
"github.com/scaleway/scaleway-cli/v2/internal/core"
11-
1211
"github.com/scaleway/scaleway-cli/v2/internal/platform/terminal"
1312
"github.com/scaleway/scaleway-sdk-go/scw"
1413
"github.com/stretchr/testify/assert"

internal/core/bootstrap_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import (
55
"reflect"
66
"testing"
77

8-
"github.com/scaleway/scaleway-cli/v2/internal/core"
9-
108
"github.com/alecthomas/assert"
119
"github.com/scaleway/scaleway-cli/v2/internal/args"
10+
"github.com/scaleway/scaleway-cli/v2/internal/core"
1211
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
1312
)
1413

internal/core/build_info_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/scaleway/scaleway-cli/v2/internal/core"
11-
1210
"github.com/alecthomas/assert"
1311
"github.com/hashicorp/go-version"
1412
"github.com/scaleway/scaleway-cli/v2/internal/args"
13+
"github.com/scaleway/scaleway-cli/v2/internal/core"
1514
"github.com/scaleway/scaleway-sdk-go/scw"
1615
"github.com/stretchr/testify/require"
1716
)

internal/core/checks_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/scaleway/scaleway-cli/v2/internal/core"
13-
1412
"github.com/alecthomas/assert"
13+
"github.com/scaleway/scaleway-cli/v2/internal/core"
1514
iam "github.com/scaleway/scaleway-sdk-go/api/iam/v1alpha1"
1615
"github.com/scaleway/scaleway-sdk-go/scw"
1716
)

internal/core/cobra_usage_builder_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"reflect"
66
"testing"
77

8-
"github.com/scaleway/scaleway-cli/v2/internal/core"
9-
108
"github.com/alecthomas/assert"
9+
"github.com/scaleway/scaleway-cli/v2/internal/core"
1110
)
1211

1312
type ServerColor string

internal/core/cobra_utils_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/scaleway/scaleway-cli/v2/internal/args"
1011
"github.com/scaleway/scaleway-cli/v2/internal/core"
1112
"github.com/stretchr/testify/assert"
12-
13-
"github.com/scaleway/scaleway-cli/v2/internal/args"
1413
)
1514

1615
type testType struct {

internal/core/command_interceptor_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import (
44
"context"
55
"testing"
66

7-
"github.com/scaleway/scaleway-cli/v2/internal/core"
8-
97
"github.com/alecthomas/assert"
8+
"github.com/scaleway/scaleway-cli/v2/internal/core"
109
)
1110

1211
func Test_CombineCommandInterceptor(t *testing.T) {

internal/core/default_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import (
44
"context"
55
"testing"
66

7-
"github.com/scaleway/scaleway-cli/v2/internal/core"
8-
97
"github.com/alecthomas/assert"
108
"github.com/scaleway/scaleway-cli/v2/internal/args"
9+
"github.com/scaleway/scaleway-cli/v2/internal/core"
1110
)
1211

1312
func Test_ApplyDefaultValues(t *testing.T) {

internal/core/printer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import (
88
"strings"
99
"text/template"
1010

11-
"gopkg.in/yaml.v3"
12-
1311
"github.com/scaleway/scaleway-cli/v2/internal/gofields"
1412
"github.com/scaleway/scaleway-cli/v2/internal/human"
13+
"gopkg.in/yaml.v3"
1514
)
1615

1716
// Type defines an formatter format.

internal/core/result.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import (
55
"fmt"
66
"strings"
77

8+
"github.com/fatih/color"
89
"github.com/scaleway/scaleway-cli/v2/internal/human"
910
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
10-
11-
"github.com/fatih/color"
1211
"github.com/scaleway/scaleway-cli/v2/internal/terminal"
1312
"github.com/scaleway/scaleway-sdk-go/strcase"
1413
)

internal/core/result_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ package core_test
33
import (
44
"testing"
55

6-
"github.com/stretchr/testify/require"
7-
86
"github.com/scaleway/scaleway-cli/v2/internal/core"
9-
107
"github.com/stretchr/testify/assert"
8+
"github.com/stretchr/testify/require"
119
)
1210

1311
func TestResult(t *testing.T) {

internal/core/shell_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ package core_test
33
import (
44
"testing"
55

6-
"github.com/scaleway/scaleway-cli/v2/internal/core"
7-
86
"github.com/alecthomas/assert"
7+
"github.com/scaleway/scaleway-cli/v2/internal/core"
98
)
109

1110
func TestShell_OptionToArgSpecName(t *testing.T) {

internal/core/testing_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import (
44
"regexp"
55
"testing"
66

7-
"github.com/scaleway/scaleway-cli/v2/internal/core"
8-
97
"github.com/alecthomas/assert"
8+
"github.com/scaleway/scaleway-cli/v2/internal/core"
109
)
1110

1211
func TestGoldenIgnoreLines(t *testing.T) {

internal/editor/editor_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ package editor_test
33
import (
44
"testing"
55

6-
"github.com/scaleway/scaleway-cli/v2/internal/editor"
7-
86
"github.com/alecthomas/assert"
7+
"github.com/scaleway/scaleway-cli/v2/internal/editor"
98
)
109

1110
func Test_updateResourceEditor(t *testing.T) {

internal/editor/request_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import (
44
"reflect"
55
"testing"
66

7-
"github.com/scaleway/scaleway-cli/v2/internal/editor"
8-
97
"github.com/alecthomas/assert"
8+
"github.com/scaleway/scaleway-cli/v2/internal/editor"
109
)
1110

1211
func Test_createGetResourceRequest(t *testing.T) {

internal/gofields/gofields_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"strings"
66
"testing"
77

8-
"github.com/scaleway/scaleway-cli/v2/internal/gofields"
9-
108
"github.com/alecthomas/assert"
9+
"github.com/scaleway/scaleway-cli/v2/internal/gofields"
1110
)
1211

1312
type Friends struct {

internal/human/marshal.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ import (
88
"strconv"
99
"strings"
1010

11-
"golang.org/x/text/cases"
12-
"golang.org/x/text/language"
13-
1411
"github.com/fatih/color"
1512
"github.com/scaleway/scaleway-cli/v2/internal/gofields"
1613
"github.com/scaleway/scaleway-cli/v2/internal/tabwriter"
1714
"github.com/scaleway/scaleway-cli/v2/internal/terminal"
1815
"github.com/scaleway/scaleway-sdk-go/logger"
1916
"github.com/scaleway/scaleway-sdk-go/strcase"
17+
"golang.org/x/text/cases"
18+
"golang.org/x/text/language"
2019
)
2120

2221
// Padding between column

internal/human/marshal_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import (
66
"testing"
77
"time"
88

9-
"github.com/scaleway/scaleway-cli/v2/internal/human"
10-
119
"github.com/alecthomas/assert"
1210
"github.com/dustin/go-humanize"
11+
"github.com/scaleway/scaleway-cli/v2/internal/human"
1312
"github.com/scaleway/scaleway-sdk-go/scw"
1413
)
1514

internal/interactive/print_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import (
66
"bytes"
77
"testing"
88

9-
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
10-
119
"github.com/alecthomas/assert"
10+
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
1211
)
1312

1413
func TestPrint(t *testing.T) {

internal/interactive/prompt_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"context"
66
"testing"
77

8-
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
9-
108
"github.com/alecthomas/assert"
9+
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
1110
"github.com/stretchr/testify/require"
1211
)
1312

internal/namespaces/applesilicon/v1alpha1/custom_server_ssh_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ package applesilicon_test
33
import (
44
"testing"
55

6-
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
7-
86
"github.com/scaleway/scaleway-cli/v2/internal/core"
7+
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
98
)
109

1110
func Test_ServerSSH(t *testing.T) {

internal/namespaces/applesilicon/v1alpha1/custom_server_types_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ package applesilicon_test
33
import (
44
"testing"
55

6-
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
7-
86
"github.com/scaleway/scaleway-cli/v2/internal/core"
7+
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
98
)
109

1110
func Test_ServerTypeList(t *testing.T) {

internal/namespaces/autocomplete/autocomplete_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"testing"
55

66
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/autocomplete"
7-
87
"github.com/stretchr/testify/assert"
98
)
109

internal/namespaces/baremetal/v1/custom_offer_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ package baremetal_test
33
import (
44
"testing"
55

6-
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1"
7-
86
"github.com/scaleway/scaleway-cli/v2/internal/core"
7+
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1"
98
)
109

1110
func Test_baremetalGetOffer(t *testing.T) {

internal/namespaces/baremetal/v1/custom_server_install_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ package baremetal_test
33
import (
44
"testing"
55

6-
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1"
7-
86
"github.com/scaleway/scaleway-cli/v2/internal/core"
7+
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1"
98
iam "github.com/scaleway/scaleway-cli/v2/internal/namespaces/iam/v1alpha1"
109
)
1110

0 commit comments

Comments
 (0)