Skip to content

Commit bd7e282

Browse files
author
Mikhail Podtserkovskiy
authored
Merge pull request #43 from qa-dev/add_golangci-lint
add golangci-lint
2 parents ff181d6 + 9a5c9ea commit bd7e282

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+566
-143
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,5 @@
2323

2424
# Your local config
2525
config.json
26-
/bindata.go
2726
dist/
28-
dbconfig.yml
29-
storage/migrations/mysql/bindata.go
27+
dbconfig.yml

.golangci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
linters-settings:
2+
goimports:
3+
local-prefixes: github.com/qa-dev/jsonwire-grid
4+
linters:
5+
enable:
6+
- goimports
7+
- gofmt

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ all: get-deps build
66

77
help:
88
@echo "build - build application from sources"
9-
@echo "fmt - format application sources"
9+
@echo "lint - lint and fix application sources"
1010
@echo "gen - generate files"
1111
@echo "prepare - prepare project to build"
1212
@echo "run - start application"
@@ -15,8 +15,8 @@ build: prepare
1515
@echo "Install jsonwire-grid"
1616
go install github.com/qa-dev/jsonwire-grid
1717

18-
fmt:
19-
go fmt
18+
lint:
19+
golangci-lint run --fix
2020

2121
gen:
2222
go-bindata -pkg mysql -o storage/migrations/mysql/bindata.go storage/migrations/mysql

config/config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ package config
33
import (
44
"encoding/json"
55
"errors"
6+
"os"
7+
68
log "github.com/sirupsen/logrus"
9+
710
"github.com/qa-dev/jsonwire-grid/pool/metrics"
8-
"os"
911
)
1012

1113
// Config - settings of application.

handlers/apiProxy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/url"
66

77
log "github.com/sirupsen/logrus"
8+
89
"github.com/qa-dev/jsonwire-grid/pool"
910
)
1011

handlers/createSession.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"io/ioutil"
9+
"net/http"
10+
"net/http/httputil"
11+
"net/url"
12+
813
log "github.com/sirupsen/logrus"
14+
915
"github.com/qa-dev/jsonwire-grid/jsonwire"
1016
"github.com/qa-dev/jsonwire-grid/pool"
1117
"github.com/qa-dev/jsonwire-grid/pool/capabilities"
1218
"github.com/qa-dev/jsonwire-grid/proxy"
13-
"io/ioutil"
14-
"net/http"
15-
"net/http/httputil"
16-
"net/url"
1719
)
1820

1921
// CreateSession - Receives requests to create session.

handlers/registerNode.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strconv"
88

99
log "github.com/sirupsen/logrus"
10+
1011
"github.com/qa-dev/jsonwire-grid/jsonwire"
1112
"github.com/qa-dev/jsonwire-grid/pool"
1213
"github.com/qa-dev/jsonwire-grid/pool/capabilities"

handlers/useSession.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"regexp"
88

99
log "github.com/sirupsen/logrus"
10+
1011
"github.com/qa-dev/jsonwire-grid/pool"
1112
)
1213

invoke.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package main
22

33
import (
44
_ "github.com/go-sql-driver/mysql"
5+
56
"github.com/qa-dev/jsonwire-grid/config"
67

78
"errors"
9+
810
"github.com/qa-dev/jsonwire-grid/jsonwire"
911
"github.com/qa-dev/jsonwire-grid/pool"
1012
"github.com/qa-dev/jsonwire-grid/pool/capabilities"

jsonwire/jsonwire.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,24 @@ type Register struct {
3333
Class json.RawMessage `json:"class,omitempty"`
3434
Configuration *Configuration `json:"configuration,omitempty"`
3535
CapabilitiesList []Capabilities `json:"capabilities,omitempty"` // selenium 3
36-
Description string `json:"description,omitempty"`
37-
Name string `json:"name,omitempty"`
36+
Description string `json:"description,omitempty"`
37+
Name string `json:"name,omitempty"`
3838
}
3939

4040
// Capabilities - structure of supported capabilities.
4141
type Capabilities map[string]interface{}
4242

4343
// Configuration - structure of node configuration.
4444
type Configuration struct {
45-
ID string `json:"id,omitempty"`
46-
Proxy string `json:"proxy,omitempty"`
47-
Role string `json:"role,omitempty"`
48-
Hub string `json:"hub,omitempty"`
49-
Port int `json:"port,omitempty"`
50-
RemoteHost string `json:"remoteHost,omitempty"`
51-
Host string `json:"host,omitempty"`
52-
MaxSession int `json:"maxSession,omitempty"`
53-
HubHost string `json:"hubHost,omitempty"`
45+
ID string `json:"id,omitempty"`
46+
Proxy string `json:"proxy,omitempty"`
47+
Role string `json:"role,omitempty"`
48+
Hub string `json:"hub,omitempty"`
49+
Port int `json:"port,omitempty"`
50+
RemoteHost string `json:"remoteHost,omitempty"`
51+
Host string `json:"host,omitempty"`
52+
MaxSession int `json:"maxSession,omitempty"`
53+
HubHost string `json:"hubHost,omitempty"`
5454
RegisterCycle int `json:"registerCycle,omitempty"`
5555
HubPort int `json:"hubPort,omitempty"`
5656
URL string `json:"url,omitempty"`

logger/logger.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/sirupsen/logrus"
55

66
"fmt"
7+
78
"github.com/qa-dev/jsonwire-grid/config"
89
)
910

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
func main() {
24-
stop := make(chan os.Signal)
24+
stop := make(chan os.Signal, 1)
2525
signal.Notify(stop, os.Interrupt)
2626

2727
cfg := config.New()

middleware/statsd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import (
55
"strings"
66

77
"fmt"
8+
"regexp"
9+
810
"github.com/sirupsen/logrus"
911
"gopkg.in/alexcesaro/statsd.v2"
10-
"regexp"
1112
)
1213

1314
// Statsd is statsd metrics middleware.

middleware/wrap.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package middleware
33
import (
44
"net/http"
55
"runtime/debug"
6+
67
"github.com/sirupsen/logrus"
78
)
89

middleware/wrap_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package middleware
22

33
import (
4+
"net/http"
45
"testing"
6+
57
"github.com/sirupsen/logrus"
6-
"net/http"
78
"github.com/stretchr/testify/assert"
89
)
910

pool/cache_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package pool
22

33
import (
4-
"github.com/stretchr/testify/assert"
54
"testing"
65
"time"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
func TestNewCache(t *testing.T) {

pool/capabilities/comparator_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package capabilities
22

33
import (
4-
"github.com/stretchr/testify/assert"
54
"strconv"
65
"testing"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
func TestNewComparator(t *testing.T) {

pool/metrics/metrics.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package metrics
22

33
import (
4+
"time"
5+
46
log "github.com/sirupsen/logrus"
7+
"gopkg.in/alexcesaro/statsd.v2"
8+
59
"github.com/qa-dev/jsonwire-grid/pool"
610
"github.com/qa-dev/jsonwire-grid/pool/capabilities"
7-
"gopkg.in/alexcesaro/statsd.v2"
8-
"time"
911
)
1012

1113
// Sender - metrics sender.

pool/mocks.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package pool
22

33
import (
4-
"github.com/qa-dev/jsonwire-grid/pool/capabilities"
54
"github.com/stretchr/testify/mock"
5+
6+
"github.com/qa-dev/jsonwire-grid/pool/capabilities"
67
)
78

89
type StorageMock struct {

pool/pool.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import (
55

66
"errors"
77
"fmt"
8+
89
log "github.com/sirupsen/logrus"
10+
911
"github.com/qa-dev/jsonwire-grid/pool/capabilities"
1012
)
1113

pool/pool_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package pool
22

33
import (
44
"errors"
5-
"github.com/qa-dev/jsonwire-grid/pool/capabilities"
6-
"github.com/qa-dev/jsonwire-grid/pool/strategy"
7-
"github.com/stretchr/testify/assert"
8-
"github.com/stretchr/testify/mock"
95
"testing"
106
"time"
7+
8+
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/mock"
10+
11+
"github.com/qa-dev/jsonwire-grid/pool/capabilities"
12+
"github.com/qa-dev/jsonwire-grid/pool/strategy"
1113
)
1214

1315
func TestNewPool(t *testing.T) {

pool/strategy/kubernetes/config.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@ package kubernetes
33
import (
44
"encoding/json"
55
"errors"
6-
"github.com/qa-dev/jsonwire-grid/config"
7-
"time"
86
"fmt"
7+
"time"
8+
9+
"github.com/qa-dev/jsonwire-grid/config"
910
)
1011

1112
type strategyParams struct {
12-
Namespace string
13+
Namespace string
1314
PodCreationTimeout time.Duration
1415
}
1516

1617
func (sp *strategyParams) UnmarshalJSON(b []byte) error {
17-
tempStruct := struct{
18-
Namespace string `json:"namespace"`
18+
tempStruct := struct {
19+
Namespace string `json:"namespace"`
1920
PodCreationTimeout string `json:"pod_creation_timeout"`
20-
} {
21+
}{
2122
"default",
2223
"1m",
2324
}

pool/strategy/kubernetes/factory.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package kubernetes
22

33
import (
44
"errors"
5+
6+
log "github.com/sirupsen/logrus"
7+
"k8s.io/client-go/kubernetes"
8+
"k8s.io/client-go/rest"
9+
510
"github.com/qa-dev/jsonwire-grid/config"
611
"github.com/qa-dev/jsonwire-grid/jsonwire"
712
"github.com/qa-dev/jsonwire-grid/pool"
813
"github.com/qa-dev/jsonwire-grid/pool/capabilities"
9-
"k8s.io/client-go/kubernetes"
10-
"k8s.io/client-go/rest"
11-
log "github.com/sirupsen/logrus"
1214
)
1315

1416
type StrategyFactory struct {
@@ -46,10 +48,10 @@ func (f *StrategyFactory) Create(
4648
}
4749

4850
provider := &kubDnsProvider{
49-
clientset: clientset,
50-
namespace: strategyConfig.Params.Namespace,
51+
clientset: clientset,
52+
namespace: strategyConfig.Params.Namespace,
5153
podCreationTimeout: strategyConfig.Params.PodCreationTimeout,
52-
clientFactory: clientFactory,
54+
clientFactory: clientFactory,
5355
}
5456

5557
return &Strategy{

0 commit comments

Comments
 (0)