From 7fc7b245e1bd29878b7dbfa3ca1c4aa53ab432bd Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Wed, 19 Jun 2019 18:21:39 -0700 Subject: [PATCH] fix linting errors --- go.mod | 1 - go.sum | 1 + pkg/minikube/console/console_test.go | 8 ++++++-- pkg/minikube/extract/extract.go | 3 ++- pkg/minikube/extract/extract_test.go | 21 +++++++++++++++++++- pkg/minikube/extract/testdata/sample_file.go | 16 +++++++++++++++ 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 8fa59aefa8..56bb77c286 100644 --- a/go.mod +++ b/go.mod @@ -57,7 +57,6 @@ require ( github.com/moby/hyperkit v0.0.0-20171020124204-a12cd7250bcd github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect - github.com/nicksnyder/go-i18n/v2 v2.0.0-beta.7 github.com/olekukonko/tablewriter v0.0.0-20160923125401-bdcc175572fd github.com/onsi/ginkgo v1.8.0 // indirect github.com/onsi/gomega v1.5.0 // indirect diff --git a/go.sum b/go.sum index 89183a68a7..b336602e11 100644 --- a/go.sum +++ b/go.sum @@ -208,6 +208,7 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c h1:uOCk1iQW6Vc18bnC13MfzScl+wdKBmM9Y9kU7Z83/lw= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/pkg/minikube/console/console_test.go b/pkg/minikube/console/console_test.go index bcf5cd59fa..b1c3e86fec 100644 --- a/pkg/minikube/console/console_test.go +++ b/pkg/minikube/console/console_test.go @@ -87,7 +87,9 @@ func TestOut(t *testing.T) { } for _, tc := range testCases { t.Run(tc.format, func(t *testing.T) { - translate.SetPreferredLanguage(tc.lang) + if err := translate.SetPreferredLanguage(tc.lang); err != nil { + t.Errorf("unexpected error: %q", err) + } f := tests.NewFakeFile() SetOutFile(f) ErrLn("unrelated message") @@ -140,7 +142,9 @@ func TestSetPreferredLanguage(t *testing.T) { for _, tc := range tests { t.Run(tc.input, func(t *testing.T) { // Set something so that we can assert change. - translate.SetPreferredLanguage("is") + if err := translate.SetPreferredLanguage("is"); err != nil { + t.Errorf("unexpected error: %q", err) + } if err := translate.SetPreferredLanguage(tc.input); err != nil { t.Errorf("unexpected error: %q", err) } diff --git a/pkg/minikube/extract/extract.go b/pkg/minikube/extract/extract.go index 7c534b6021..d275738db7 100644 --- a/pkg/minikube/extract/extract.go +++ b/pkg/minikube/extract/extract.go @@ -56,7 +56,7 @@ type state struct { // The file we're currently checking filename string - // THe package we're currenly in + // The package we're currently in currentPackage string } @@ -71,6 +71,7 @@ func newExtractor(functionsToCheck []string) (*state, error) { fs := stack.New() for _, t := range functionsToCheck { + // Functions must be of the form "package.function" t2 := strings.Split(t, ".") if len(t2) < 2 { return nil, errors.Wrap(nil, fmt.Sprintf("Invalid function string %s. Needs package name as well.", t)) diff --git a/pkg/minikube/extract/extract_test.go b/pkg/minikube/extract/extract_test.go index e6feda4019..135e430fea 100644 --- a/pkg/minikube/extract/extract_test.go +++ b/pkg/minikube/extract/extract_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package extract import ( @@ -37,7 +53,10 @@ func TestExtract(t *testing.T) { t.Fatalf("Reading json file: %s", err) } - json.Unmarshal(f, &got) + err = json.Unmarshal(f, &got) + if err != nil { + t.Fatalf("Error unmarshalling json: %v", err) + } if !reflect.DeepEqual(expected, got) { t.Fatalf("Translation JSON not equal: expected %v, got %v", expected, got) diff --git a/pkg/minikube/extract/testdata/sample_file.go b/pkg/minikube/extract/testdata/sample_file.go index a6316ea5ca..2f28cd0d38 100644 --- a/pkg/minikube/extract/testdata/sample_file.go +++ b/pkg/minikube/extract/testdata/sample_file.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package extract import "fmt"