Skip to content

Commit 6d786b5

Browse files
committed
Group imports by package.
1 parent df4f676 commit 6d786b5

37 files changed

+74
-116
lines changed

internal/errorutil/errors.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package errorutil
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
)
46

57
// PanicError can be used to not print stacktrace twice
68
type PanicError struct {

internal/pkgcache/pkgcache.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ import (
99
"sort"
1010
"sync"
1111

12-
"github.com/golangci/golangci-lint/pkg/logutils"
13-
14-
"github.com/golangci/golangci-lint/pkg/timeutils"
15-
1612
"github.com/pkg/errors"
1713
"golang.org/x/tools/go/packages"
1814

1915
"github.com/golangci/golangci-lint/internal/cache"
16+
"github.com/golangci/golangci-lint/pkg/logutils"
17+
"github.com/golangci/golangci-lint/pkg/timeutils"
2018
)
2119

2220
// Cache is a per-package data cache. A cached data is invalidated when

pkg/commands/config.go

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

7+
"github.com/spf13/cobra"
78
"github.com/spf13/viper"
89

910
"github.com/golangci/golangci-lint/pkg/exitcodes"
1011
"github.com/golangci/golangci-lint/pkg/fsutils"
11-
12-
"github.com/spf13/cobra"
1312
)
1413

1514
func (e *Executor) initConfig() {

pkg/commands/executor.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@ import (
55
"github.com/spf13/cobra"
66
"github.com/spf13/pflag"
77

8-
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis/load"
9-
108
"github.com/golangci/golangci-lint/internal/pkgcache"
11-
"github.com/golangci/golangci-lint/pkg/timeutils"
12-
13-
"github.com/golangci/golangci-lint/pkg/fsutils"
14-
159
"github.com/golangci/golangci-lint/pkg/config"
10+
"github.com/golangci/golangci-lint/pkg/fsutils"
11+
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis/load"
1612
"github.com/golangci/golangci-lint/pkg/goutil"
1713
"github.com/golangci/golangci-lint/pkg/lint"
1814
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
1915
"github.com/golangci/golangci-lint/pkg/logutils"
2016
"github.com/golangci/golangci-lint/pkg/report"
17+
"github.com/golangci/golangci-lint/pkg/timeutils"
2118
)
2219

2320
type Executor struct {

pkg/commands/run.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import (
1010
"strings"
1111
"time"
1212

13-
"github.com/golangci/golangci-lint/pkg/packages"
14-
"github.com/golangci/golangci-lint/pkg/result/processors"
15-
1613
"github.com/fatih/color"
1714
"github.com/pkg/errors"
1815
"github.com/spf13/cobra"
@@ -23,8 +20,10 @@ import (
2320
"github.com/golangci/golangci-lint/pkg/lint"
2421
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
2522
"github.com/golangci/golangci-lint/pkg/logutils"
23+
"github.com/golangci/golangci-lint/pkg/packages"
2624
"github.com/golangci/golangci-lint/pkg/printers"
2725
"github.com/golangci/golangci-lint/pkg/result"
26+
"github.com/golangci/golangci-lint/pkg/result/processors"
2827
)
2928

3029
func getDefaultIssueExcludeHelp() string {

pkg/config/reader.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ import (
77
"path/filepath"
88
"strings"
99

10+
homedir "github.com/mitchellh/go-homedir"
1011
"github.com/spf13/viper"
1112

1213
"github.com/golangci/golangci-lint/pkg/fsutils"
1314
"github.com/golangci/golangci-lint/pkg/logutils"
14-
15-
homedir "github.com/mitchellh/go-homedir"
1615
)
1716

1817
type FileReader struct {

pkg/fsutils/filecache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"io/ioutil"
66
"sync"
77

8-
"github.com/golangci/golangci-lint/pkg/logutils"
9-
108
"github.com/pkg/errors"
9+
10+
"github.com/golangci/golangci-lint/pkg/logutils"
1111
)
1212

1313
type FileCache struct {

pkg/golinters/depguard.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,31 @@ import (
55
"strings"
66
"sync"
77

8+
"github.com/OpenPeeDeeP/depguard"
89
"golang.org/x/tools/go/analysis"
910
"golang.org/x/tools/go/loader"
1011

1112
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
12-
13-
depguardAPI "github.com/OpenPeeDeeP/depguard"
14-
1513
"github.com/golangci/golangci-lint/pkg/lint/linter"
1614
"github.com/golangci/golangci-lint/pkg/result"
1715
)
1816

19-
func setDepguardListType(dg *depguardAPI.Depguard, lintCtx *linter.Context) error {
17+
func setDepguardListType(dg *depguard.Depguard, lintCtx *linter.Context) error {
2018
listType := lintCtx.Settings().Depguard.ListType
2119
var found bool
22-
dg.ListType, found = depguardAPI.StringToListType[strings.ToLower(listType)]
20+
dg.ListType, found = depguard.StringToListType[strings.ToLower(listType)]
2321
if !found {
2422
if listType != "" {
2523
return fmt.Errorf("unsure what list type %s is", listType)
2624
}
27-
dg.ListType = depguardAPI.LTBlacklist
25+
dg.ListType = depguard.LTBlacklist
2826
}
2927

3028
return nil
3129
}
3230

33-
func setupDepguardPackages(dg *depguardAPI.Depguard, lintCtx *linter.Context) {
34-
if dg.ListType == depguardAPI.LTBlacklist {
31+
func setupDepguardPackages(dg *depguard.Depguard, lintCtx *linter.Context) {
32+
if dg.ListType == depguard.LTBlacklist {
3533
// if the list type was a blacklist the packages with error messages should
3634
// be included in the blacklist package list
3735

@@ -66,7 +64,7 @@ func NewDepguard() *goanalysis.Linter {
6664
dgSettings := &lintCtx.Settings().Depguard
6765
analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
6866
prog := goanalysis.MakeFakeLoaderProgram(pass)
69-
dg := &depguardAPI.Depguard{
67+
dg := &depguard.Depguard{
7068
Packages: dgSettings.Packages,
7169
IncludeGoRoot: dgSettings.IncludeGoRoot,
7270
}
@@ -87,7 +85,7 @@ func NewDepguard() *goanalysis.Linter {
8785
return nil, nil
8886
}
8987
msgSuffix := "is in the blacklist"
90-
if dg.ListType == depguardAPI.LTWhitelist {
88+
if dg.ListType == depguard.LTWhitelist {
9189
msgSuffix = "is not in the whitelist"
9290
}
9391
res := make([]result.Issue, 0, len(issues))

pkg/golinters/errcheck.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import (
1010
"strings"
1111
"sync"
1212

13-
"golang.org/x/tools/go/analysis"
14-
15-
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
16-
17-
errcheckAPI "github.com/golangci/errcheck/golangci"
13+
errcheck "github.com/golangci/errcheck/golangci"
1814
"github.com/pkg/errors"
15+
"golang.org/x/tools/go/analysis"
1916

2017
"github.com/golangci/golangci-lint/pkg/config"
2118
"github.com/golangci/golangci-lint/pkg/fsutils"
19+
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
2220
"github.com/golangci/golangci-lint/pkg/lint/linter"
2321
"github.com/golangci/golangci-lint/pkg/result"
2422
)
@@ -44,7 +42,7 @@ func NewErrcheck() *goanalysis.Linter {
4442
if err != nil {
4543
return nil, err
4644
}
47-
errcheckIssues, err := errcheckAPI.RunWithConfig(prog, errCfg)
45+
errcheckIssues, err := errcheck.RunWithConfig(prog, errCfg)
4846
if err != nil {
4947
return nil, err
5048
}
@@ -106,13 +104,13 @@ func parseIgnoreConfig(s string) (map[string]*regexp.Regexp, error) {
106104
return cfg, nil
107105
}
108106

109-
func genConfig(errCfg *config.ErrcheckSettings) (*errcheckAPI.Config, error) {
107+
func genConfig(errCfg *config.ErrcheckSettings) (*errcheck.Config, error) {
110108
ignoreConfig, err := parseIgnoreConfig(errCfg.Ignore)
111109
if err != nil {
112110
return nil, errors.Wrap(err, "failed to parse 'ignore' directive")
113111
}
114112

115-
c := &errcheckAPI.Config{
113+
c := &errcheck.Config{
116114
Ignore: ignoreConfig,
117115
Blank: errCfg.CheckAssignToBlank,
118116
Asserts: errCfg.CheckTypeAssertions,

pkg/golinters/funlen.go

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

8+
"github.com/ultraware/funlen"
89
"golang.org/x/tools/go/analysis"
910

1011
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
1112
"github.com/golangci/golangci-lint/pkg/lint/linter"
1213
"github.com/golangci/golangci-lint/pkg/result"
13-
14-
"github.com/ultraware/funlen"
1514
)
1615

1716
const funlenLinterName = "funlen"

0 commit comments

Comments
 (0)