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

chore: add support for gci, sloglint, loggercheck, grouper #4058

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ linters:
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
- durationcheck # check for two durations multiplied together [fast: false, auto-fix: false]
- 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]
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
- goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
- 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]
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
Expand All @@ -25,16 +26,19 @@ linters:
- gosec #(gas): Inspects source code for security problems [fast: false, auto-fix: false]
- gosimple #(megacheck): Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false]
- 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]
- grouper # An analyzer to analyze expression groups. [fast: true, auto-fix: false]
- importas # Enforces consistent import aliases [fast: false, auto-fix: false]
- ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
- intrange # intrange is a linter to find places where for loops could make use of an integer range. [fast: true, auto-fix: false]
- loggercheck # (logrlint): Checks key value pairs for common logger libraries (kitlog,klog,logr,zap). [fast: false, auto-fix: false]
- misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true]
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
- prealloc # Finds slice declarations that could potentially be pre-allocated [fast: true, auto-fix: false]
- predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
- sloglint # ensure consistent code style when using log/slog [fast: false, auto-fix: false]
- staticcheck
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]
Expand Down
3 changes: 1 addition & 2 deletions internal/alias/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"fmt"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/alias"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/alias"
)

func TestConfig_ResolveAliases(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/args/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (
"testing"
"time"

"github.com/scaleway/scaleway-cli/v2/internal/args"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/args"
"github.com/scaleway/scaleway-sdk-go/scw"
"github.com/stretchr/testify/require"
)
Expand Down
4 changes: 1 addition & 3 deletions internal/args/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/scaleway/scaleway-cli/v2/internal/args"

"github.com/scaleway/scaleway-sdk-go/scw"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestMarshal(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions internal/args/unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/scaleway/scaleway-cli/v2/internal/args"

"github.com/scaleway/scaleway-sdk-go/scw"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func init() {
Expand Down
3 changes: 1 addition & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (
"runtime"
"text/template"

"gopkg.in/yaml.v3"

"github.com/scaleway/scaleway-cli/v2/internal/alias"
"github.com/scaleway/scaleway-sdk-go/scw"
"gopkg.in/yaml.v3"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions internal/core/alias_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package core_test
import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/alias"
"github.com/scaleway/scaleway-cli/v2/internal/core"
)

func TestCommandMatchAlias(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/core/arg_specs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package core_test
import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/core"
)

func TestOneOf(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/core/autocomplete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/scaleway/scaleway-cli/v2/internal/platform/terminal"
"github.com/scaleway/scaleway-sdk-go/scw"
"github.com/stretchr/testify/assert"
Expand Down
3 changes: 1 addition & 2 deletions internal/core/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"reflect"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/args"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
)

Expand Down
3 changes: 1 addition & 2 deletions internal/core/build_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (
"testing"
"time"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/hashicorp/go-version"
"github.com/scaleway/scaleway-cli/v2/internal/args"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-sdk-go/scw"
"github.com/stretchr/testify/require"
)
Expand Down
3 changes: 1 addition & 2 deletions internal/core/checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
"testing"
"time"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/core"
iam "github.com/scaleway/scaleway-sdk-go/api/iam/v1alpha1"
"github.com/scaleway/scaleway-sdk-go/scw"
)
Expand Down
3 changes: 1 addition & 2 deletions internal/core/cobra_usage_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"reflect"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/core"
)

type ServerColor string
Expand Down
3 changes: 1 addition & 2 deletions internal/core/cobra_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"testing"
"time"

"github.com/scaleway/scaleway-cli/v2/internal/args"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/stretchr/testify/assert"

"github.com/scaleway/scaleway-cli/v2/internal/args"
)

type testType struct {
Expand Down
3 changes: 1 addition & 2 deletions internal/core/command_interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"context"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/core"
)

func Test_CombineCommandInterceptor(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/core/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"context"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/args"
"github.com/scaleway/scaleway-cli/v2/internal/core"
)

func Test_ApplyDefaultValues(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/core/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (
"strings"
"text/template"

"gopkg.in/yaml.v3"

"github.com/scaleway/scaleway-cli/v2/internal/gofields"
"github.com/scaleway/scaleway-cli/v2/internal/human"
"gopkg.in/yaml.v3"
)

// Type defines an formatter format.
Expand Down
3 changes: 1 addition & 2 deletions internal/core/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"fmt"
"strings"

"github.com/fatih/color"
"github.com/scaleway/scaleway-cli/v2/internal/human"
"github.com/scaleway/scaleway-cli/v2/internal/interactive"

"github.com/fatih/color"
"github.com/scaleway/scaleway-cli/v2/internal/terminal"
"github.com/scaleway/scaleway-sdk-go/strcase"
)
Expand Down
4 changes: 1 addition & 3 deletions internal/core/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package core_test
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestResult(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/core/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package core_test
import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/core"
)

func TestShell_OptionToArgSpecName(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/core/testing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"regexp"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/core"
)

func TestGoldenIgnoreLines(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/editor/editor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package editor_test
import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/editor"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/editor"
)

func Test_updateResourceEditor(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/editor/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"reflect"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/editor"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/editor"
)

func Test_createGetResourceRequest(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/gofields/gofields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"strings"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/gofields"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/gofields"
)

type Friends struct {
Expand Down
5 changes: 2 additions & 3 deletions internal/human/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import (
"strconv"
"strings"

"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/fatih/color"
"github.com/scaleway/scaleway-cli/v2/internal/gofields"
"github.com/scaleway/scaleway-cli/v2/internal/tabwriter"
"github.com/scaleway/scaleway-cli/v2/internal/terminal"
"github.com/scaleway/scaleway-sdk-go/logger"
"github.com/scaleway/scaleway-sdk-go/strcase"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

// Padding between column
Expand Down
3 changes: 1 addition & 2 deletions internal/human/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import (
"testing"
"time"

"github.com/scaleway/scaleway-cli/v2/internal/human"

"github.com/alecthomas/assert"
"github.com/dustin/go-humanize"
"github.com/scaleway/scaleway-cli/v2/internal/human"
"github.com/scaleway/scaleway-sdk-go/scw"
)

Expand Down
3 changes: 1 addition & 2 deletions internal/interactive/print_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"bytes"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/interactive"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
)

func TestPrint(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/interactive/prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"context"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/interactive"

"github.com/alecthomas/assert"
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
"github.com/stretchr/testify/require"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package applesilicon_test
import (
"testing"

applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"

"github.com/scaleway/scaleway-cli/v2/internal/core"
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
)

func Test_ServerSSH(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package applesilicon_test
import (
"testing"

applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"

"github.com/scaleway/scaleway-cli/v2/internal/core"
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
)

func Test_ServerTypeList(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/namespaces/autocomplete/autocomplete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/namespaces/autocomplete"

"github.com/stretchr/testify/assert"
)

Expand Down
3 changes: 1 addition & 2 deletions internal/namespaces/baremetal/v1/custom_offer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package baremetal_test
import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1"

"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1"
)

func Test_baremetalGetOffer(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package baremetal_test
import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1"

"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1"
iam "github.com/scaleway/scaleway-cli/v2/internal/namespaces/iam/v1alpha1"
)

Expand Down
Loading
Loading