Skip to content

Commit

Permalink
Replace gometalinter with GolangCI-Lint
Browse files Browse the repository at this point in the history
Running test.sh is down from 34s to 20s on my
machine.

Also, from now on, run go lint.

Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed May 30, 2018
1 parent 8c13026 commit cb0c4c4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 39 deletions.
20 changes: 0 additions & 20 deletions hack/gometalinter.json

This file was deleted.

30 changes: 17 additions & 13 deletions hack/gometalinter.sh → hack/linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@

set -e -o pipefail

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

install_gometalinter() {
echo "Installing gometalinter.v2"
go get -u gopkg.in/alecthomas/gometalinter.v2
gometalinter.v2 --install
}

if ! [ -x "$(command -v gometalinter.v2)" ]; then
install_gometalinter
if ! [ -x "$(command -v golangci-lint)" ]; then
echo "Installing GolangCI-Lint"
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
fi

gometalinter.v2 \
--deadline 5m \
--config $SCRIPTDIR/gometalinter.json ./...
golangci-lint run \
--no-config \
-E goimports \
-E interfacer \
-E unconvert \
-E goconst \
-E maligned \
-D errcheck

# From now on, run go lint.
golangci-lint run \
--disable-all \
-E golint \
--new-from-rev bed41e9a77431990cc8504c0955252c851934b89
5 changes: 2 additions & 3 deletions pkg/skaffold/kubernetes/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewLogAggregator(out io.Writer, podSelector PodSelector, colorPicker ColorP
}
}

func (a *LogAggregator) Start(ctx context.Context, client corev1.CoreV1Interface) error {
func (a *LogAggregator) Start(ctx context.Context, client corev1.PodsGetter) error {
a.startTime = time.Now()

watcher, err := client.Pods("").Watch(meta_v1.ListOptions{
Expand Down Expand Up @@ -91,8 +91,7 @@ func (a *LogAggregator) Start(ctx context.Context, client corev1.CoreV1Interface
return nil
}

// nolint: interfacer
func (a *LogAggregator) streamLogs(ctx context.Context, client corev1.CoreV1Interface, pod *v1.Pod) error {
func (a *LogAggregator) streamLogs(ctx context.Context, client corev1.PodsGetter, pod *v1.Pod) error {
pods := client.Pods(pod.Namespace)
if err := WaitForPodReady(pods, pod.Name); err != nil {
return errors.Wrap(err, "waiting for pod ready")
Expand Down
3 changes: 1 addition & 2 deletions pkg/skaffold/kubernetes/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ func (s *PodStore) Stop() {
close(s.stopCh)
}

// nolint: interfacer
func NewPodStore(c kubernetes.Interface, namespace string, label labels.Selector, field fields.Selector) *PodStore {
func NewPodStore(c kubernetes.Interface, namespace string, label fmt.Stringer, field fmt.Stringer) *PodStore {
lw := &cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
options.LabelSelector = label.String()
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ echo "Running validation scripts..."
scripts=(
"hack/boilerplate.sh"
"hack/gofmt.sh"
"hack/gometalinter.sh"
"hack/linter.sh"
"hack/dep.sh"
)
fail=0
Expand Down

0 comments on commit cb0c4c4

Please sign in to comment.