Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit 8406b52

Browse files
author
Ganesh Maharaj Mahalingam
committed
Switch go linters
gometalinter is now officially deprecated and will be archived end of Q1. Their recommendation is to switch to golangci-lint(https://github.com/golangci/golangci-lint) which is apparently 5x faster than gometalinter Signed-off-by: Ganesh Maharaj Mahalingam <[email protected]>
1 parent 3403d97 commit 8406b52

9 files changed

+24
-43
lines changed

.golangci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
linters:
2+
enable:
3+
- gofmt
4+
- gocyclo
5+
- misspell
6+
linters-settings:
7+
gocyclo:
8+
min-complexity: 15

.travis.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
language: go
22

33
go:
4-
- 1.9
5-
- "1.10"
4+
- "1.11"
5+
- "1.12"
66
- tip
77

8+
env:
9+
- GOLANGCILINT=$(curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/golangci/golangci-lint/releases/latest | awk -F '/' '{print $8}')
10+
811
go_import_path: github.com/intel/ccloudvm
912

1013
matrix:
1114
allow_failures:
1215
- go: tip
1316

1417
before_install:
15-
- go get github.com/alecthomas/gometalinter
16-
- gometalinter --install
18+
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCILINT}
1719

1820
script:
1921
- go env
20-
- gometalinter --tests --vendor --disable-all --enable=misspell --enable=vet --enable=ineffassign --enable=gofmt --enable=gocyclo --cyclo-over=15 --enable=golint --enable=errcheck --enable=deadcode ./...
22+
- golangci-lint run -c ./.golangci.yml ./...

ccvm/download_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func testDownloadCancelOneOfTwo(ctx context.Context, t *testing.T, downloadCh ch
180180

181181
cancel()
182182
ret1 := <-params[0].ch
183-
_ = <-params[1].ch
183+
<-params[1].ch
184184

185185
if ret1.err != nil {
186186
t.Errorf("Download failed : %v", ret1.err)

ccvm/instance.go

-29
Original file line numberDiff line numberDiff line change
@@ -67,35 +67,6 @@ func defaultWorkload() *workload {
6767
}
6868
}
6969

70-
func unmarshal(in *types.VMSpec, data []byte) error {
71-
err := yaml.Unmarshal(data, in)
72-
if err != nil {
73-
return errors.Wrap(err, "Unable to unmarshal instance state")
74-
}
75-
76-
for i := range in.Mounts {
77-
if err := types.CheckDirectory(in.Mounts[i].Path); err != nil {
78-
return fmt.Errorf("Bad mount %s specified: %v",
79-
in.Mounts[i].Path, err)
80-
}
81-
}
82-
83-
return nil
84-
}
85-
86-
func unmarshalWithTemplate(in *types.VMSpec, ws *workspace, data string) error {
87-
tmpl, err := template.New("instance-data").Parse(string(data))
88-
if err != nil {
89-
return errors.Wrap(err, "Unable to parse instance data template")
90-
}
91-
var buf bytes.Buffer
92-
err = tmpl.Execute(&buf, ws)
93-
if err != nil {
94-
return errors.Wrap(err, "Unable to execute instance data template")
95-
}
96-
return unmarshal(in, buf.Bytes())
97-
}
98-
9970
func (ins *workloadSpec) unmarshal(data []byte) error {
10071
err := yaml.Unmarshal(data, ins)
10172
if err != nil {

ccvm/prepare.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func buildISOImage(ctx context.Context, resultCh chan interface{}, userData []by
303303
Line: string(userData),
304304
}
305305
resultCh <- types.CreateResult{
306-
Line: string(mdBuf.Bytes()),
306+
Line: mdBuf.String(),
307307
}
308308
}
309309

ccvm/server.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var hostnameRegexp *regexp.Regexp
5050

5151
func init() {
5252
flag.BoolVar(&systemd, "systemd", true, "Use systemd socket activation if true")
53-
hostnameRegexp = regexp.MustCompile("^[A-Za-z0-9\\-]+$")
53+
hostnameRegexp = regexp.MustCompile(`^[A-Za-z0-9\-]+$`)
5454
}
5555

5656
type service interface {
@@ -239,7 +239,7 @@ func (s *ccvmService) findFreeIP() (net.IP, uint32, error) {
239239
func (s *ccvmService) findExistingInstances() {
240240
instancesDir := filepath.Join(s.ccvmDir, "instances")
241241

242-
_ = filepath.Walk(instancesDir, func(path string, info os.FileInfo, err error) error {
242+
_ = filepath.Walk(instancesDir, func(path string, info os.FileInfo, ferr error) error {
243243
if path == instancesDir {
244244
return nil
245245
}
@@ -496,7 +496,7 @@ func (s *ccvmService) processAction(action interface{}) {
496496
}
497497
if s.shutdownTimer != nil {
498498
if !s.shutdownTimer.Stop() {
499-
_ = <-s.shutdownTimer.C
499+
<-s.shutdownTimer.C
500500
}
501501
s.shutdownTimer = nil
502502
s.cases[TimeChIndex].Chan = reflect.ValueOf(nil)
@@ -563,7 +563,7 @@ DONE:
563563
fmt.Printf("Signal received active transactions = %d\n", len(s.transactions))
564564
if s.shutdownTimer != nil {
565565
if !s.shutdownTimer.Stop() {
566-
_ = <-s.shutdownTimer.C
566+
<-s.shutdownTimer.C
567567
}
568568
}
569569
for _, t := range s.transactions {

ccvm/server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ func TestServerShutdownPending(t *testing.T) {
500500
transCh: transCh,
501501
}
502502

503-
_ = <-transCh
503+
<-transCh
504504

505505
close(doneCh)
506506
wg.Wait()

ccvm/vm.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func startHTTPServer(ctx context.Context, resultCh chan interface{}, downloadCh
193193
// TODO: Figure out what to do here
194194
return
195195
}
196-
line := string(b.Bytes())
196+
line := b.String()
197197
if line == "FINISHED" {
198198
finished = true
199199
_ = listener.Close()

ccvm/workload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const ccloudvmPkg = "github.com/intel/ccloudvm"
4444
var indentedRegexp *regexp.Regexp
4545

4646
func init() {
47-
indentedRegexp = regexp.MustCompile("\\s+.*")
47+
indentedRegexp = regexp.MustCompile(`\s+.*`)
4848
}
4949

5050
type workload struct {

0 commit comments

Comments
 (0)