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

Put local imports in a separate import group #222

Merged
merged 6 commits into from
Jun 25, 2019
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
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# all available settings of specific linters
linters-settings:
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: sigs.k8s.io/krew

# options for analysis running
run:
# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs:
- hack
- docs

linters:
enable:
- gocritic
- goimports
- golint
- gosimple
- interfacer
- maligned
- misspell
- unconvert
- unparam
- stylecheck
- staticcheck
- structcheck
- prealloc
disable:
- errcheck
1 change: 1 addition & 0 deletions cmd/krew/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/pkg/errors"
"github.com/spf13/cobra"

"sigs.k8s.io/krew/pkg/installation"
)

Expand Down
10 changes: 5 additions & 5 deletions cmd/krew/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import (
"flag"
"os"

isatty "github.com/mattn/go-isatty"
"github.com/pkg/errors"
"sigs.k8s.io/krew/pkg/environment"
"sigs.k8s.io/krew/pkg/gitutil"

"github.com/golang/glog"
"github.com/mattn/go-isatty"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"sigs.k8s.io/krew/pkg/environment"
"sigs.k8s.io/krew/pkg/gitutil"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions cmd/krew/cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"strings"

"github.com/pkg/errors"
"sigs.k8s.io/krew/pkg/index/indexscanner"

"github.com/sahilm/fuzzy"
"github.com/spf13/cobra"

"sigs.k8s.io/krew/pkg/index"
"sigs.k8s.io/krew/pkg/index/indexscanner"
"sigs.k8s.io/krew/pkg/installation"
)

Expand Down
6 changes: 3 additions & 3 deletions cmd/krew/cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"fmt"
"os"

"github.com/pkg/errors"
"sigs.k8s.io/krew/pkg/installation"

"github.com/golang/glog"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"sigs.k8s.io/krew/pkg/installation"
)

// uninstallCmd represents the uninstall command
Expand Down
1 change: 1 addition & 0 deletions cmd/krew/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/golang/glog"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"sigs.k8s.io/krew/pkg/constants"
"sigs.k8s.io/krew/pkg/gitutil"
)
Expand Down
1 change: 1 addition & 0 deletions cmd/krew/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/golang/glog"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"sigs.k8s.io/krew/pkg/constants"
"sigs.k8s.io/krew/pkg/environment"
"sigs.k8s.io/krew/pkg/version"
Expand Down
1 change: 1 addition & 0 deletions cmd/krew/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"github.com/golang/glog"

"sigs.k8s.io/krew/cmd/krew/cmd"
)

Expand Down
1 change: 1 addition & 0 deletions cmd/validate-krew-manifest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"gopkg.in/yaml.v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"sigs.k8s.io/krew/pkg/constants"
"sigs.k8s.io/krew/pkg/index"
"sigs.k8s.io/krew/pkg/testutil"
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTOR_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ go get golang.org/x/tools/cmd/goimports
and run:

```bash
goimports -w cmd pkg
goimports -local sigs.k8s.io/krew -w cmd pkg test
```

In addition, a boilerplate license header is expected in all source files.
Expand Down
21 changes: 2 additions & 19 deletions hack/run-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,11 @@

set -euo pipefail

SCRIPTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

if ! [[ -x "$GOPATH/bin/golangci-lint" ]]
then
echo 'Installing golangci-lint'
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b "$GOPATH/bin" v1.16.0
fi

"$GOPATH/bin/golangci-lint" run \
--no-config \
-D errcheck \
-E gocritic \
-E goimports \
-E golint \
-E gosimple \
-E interfacer \
-E maligned \
-E misspell \
-E unconvert \
-E unparam \
-E stylecheck \
-E staticcheck \
-E structcheck \
-E prealloc \
--skip-dirs hack,docs
# configured by .golangci.yml
"$GOPATH/bin/golangci-lint" run
6 changes: 4 additions & 2 deletions hack/verify-gofmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

files=$(find . -name "*.go" | grep -v vendor/ | xargs gofmt -l -s)
set -euo pipefail

files=$(find . -name "*.go" -not -path './vendor/*' -print0 | xargs -0 gofmt -l -s)
if [[ $files ]]; then
echo "Gofmt errors in files:"
echo "$files"
diff=$(find . -name "*.go" | grep -v vendor/ | xargs gofmt -d -s)
diff=$(find . -name "*.go" -not -path './vendor/*' -print0 | xargs -0 gofmt -d -s)
echo "$diff"
exit 1
fi
5 changes: 3 additions & 2 deletions pkg/download/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"testing"

"github.com/pkg/errors"

"sigs.k8s.io/krew/pkg/testutil"
)

Expand Down Expand Up @@ -247,12 +248,12 @@ func Test_download(t *testing.T) {
}
downloadedData, err := ioutil.ReadAll(io.NewSectionReader(reader, 0, size))
if err != nil {
t.Errorf("failed to read downlaod data: %v", err)
t.Errorf("failed to read download data: %v", err)
return
}
wantData, err := ioutil.ReadAll(io.NewSectionReader(tt.wantReader, 0, tt.wantSize))
if err != nil {
t.Errorf("failed to read downlaod data: %v", err)
t.Errorf("failed to read download data: %v", err)
return
}

Expand Down
1 change: 1 addition & 0 deletions pkg/environment/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"

"k8s.io/client-go/util/homedir"

"sigs.k8s.io/krew/pkg/testutil"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/index/indexscanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (
"path/filepath"
"strings"

"github.com/pkg/errors"
"sigs.k8s.io/krew/pkg/index"

"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/yaml"

"sigs.k8s.io/krew/pkg/index"
)

// LoadPluginListFromFS will parse and retrieve all plugin files.
Expand Down
2 changes: 1 addition & 1 deletion pkg/index/indexscanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func Test_readIndexFile(t *testing.T) {
return
}
if !sel.Matches(tt.matchFirst) || sel.Matches(neverMatch) {
t.Errorf("readIndexFile() didn't parse label selector propperly: %##v", sel)
t.Errorf("readIndexFile() didn't parse label selector properly: %##v", sel)
return
}
})
Expand Down
1 change: 1 addition & 0 deletions pkg/index/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"strings"

"github.com/pkg/errors"

"sigs.k8s.io/krew/pkg/constants"
)

Expand Down
1 change: 1 addition & 0 deletions pkg/index/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"sigs.k8s.io/krew/pkg/constants"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/installation/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"runtime"
"strings"

"github.com/golang/glog"
"github.com/pkg/errors"

"sigs.k8s.io/krew/pkg/download"
"sigs.k8s.io/krew/pkg/environment"
"sigs.k8s.io/krew/pkg/index"
"sigs.k8s.io/krew/pkg/pathutil"

"github.com/golang/glog"
)

// Plugin Lifecycle Errors
Expand Down
1 change: 1 addition & 0 deletions pkg/installation/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"

v1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"sigs.k8s.io/krew/pkg/index"
)

Expand Down
1 change: 1 addition & 0 deletions test/krew/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"sync"

"github.com/golang/glog"

"sigs.k8s.io/krew/pkg/constants"
)

Expand Down
1 change: 1 addition & 0 deletions test/krew/krew.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/golang/glog"
"github.com/pkg/errors"

"sigs.k8s.io/krew/pkg/testutil"
)

Expand Down