Skip to content

Commit 3778137

Browse files
Lint config changes (#3926)
* Lint config changes Signed-off-by: Steve Coffman <[email protected]> * Remove outdated nolint comments Signed-off-by: Steve Coffman <[email protected]> * Exclude generated resolvers from formatters Signed-off-by: Steve Coffman <[email protected]> * Further lint Signed-off-by: Steve Coffman <[email protected]> * More lints Signed-off-by: Steve Coffman <[email protected]> * Format Signed-off-by: Steve Coffman <[email protected]> * More Lint Signed-off-by: Steve Coffman <[email protected]> * Remove t.Helper() * Minor tweak Signed-off-by: Steve Coffman <[email protected]> * Regenerate Signed-off-by: Steve Coffman <[email protected]> --------- Signed-off-by: Steve Coffman <[email protected]>
1 parent c442432 commit 3778137

File tree

265 files changed

+4927
-1893
lines changed

Some content is hidden

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

265 files changed

+4927
-1893
lines changed

.golangci.yml

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,50 @@
1+
# All settings can be found here https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
12
version: "2"
23
run:
4+
concurrency: 8
5+
modules-download-mode: readonly
6+
issues-exit-code: 1
37
tests: true
8+
allow-parallel-runners: false
9+
issues:
10+
# Maximum count of issues with the same text.
11+
# Set to 0 to disable.
12+
# Default: 3
13+
max-issues-per-linter: 0
14+
max-same-issues: 0
15+
new: false
16+
formatters:
17+
exclusions:
18+
paths:
19+
- codegen/testserver/followschema/resolver.go
20+
- codegen/testserver/singlefile/resolver.go
21+
- codegen/testserver/usefunctionsyntaxforexecutioncontext/resolver.go
22+
- generated
23+
enable:
24+
- golines
25+
- gofumpt
26+
- gci
27+
settings:
28+
gci:
29+
sections:
30+
- standard
31+
- default
32+
- prefix(github.com/99designs/gqlgen)
33+
golines:
34+
# Target maximum line length.
35+
# Default: 100
36+
max-len: 100
437
linters:
538
default: none
639
enable:
40+
- asasalint
41+
- asciicheck
42+
- bidichk
743
- bodyclose
844
- copyloopvar
945
- dupl
1046
- dupword
47+
- durationcheck
1148
- errcheck
1249
- gocritic
1350
- govet
@@ -17,17 +54,28 @@ linters:
1754
- nolintlint
1855
- perfsprint
1956
- prealloc
57+
- reassign
2058
- revive
2159
- staticcheck
60+
- testableexamples
2261
- testifylint
2362
- unconvert
63+
- unparam
2464
- unused
65+
- usestdlibvars
66+
- usetesting
67+
- wastedassign
2568
settings:
2669
errcheck:
2770
exclude-functions:
2871
- (io.Writer).Write
72+
- (http.ResponseWriter).Write
73+
- (*bytes.Buffer).WriteByte
74+
- (*strings.Builder).WriteByte
75+
- (*strings.Builder).WriteString
2976
- io.Copy
3077
- io.WriteString
78+
- fmt.Fprintln
3179
gocritic:
3280
enabled-checks:
3381
- emptyStringTest
@@ -136,17 +184,4 @@ linters:
136184
- third_party$
137185
- builtin$
138186
- examples$
139-
formatters:
140-
enable:
141-
- gofmt
142-
- goimports
143-
exclusions:
144-
generated: lax
145-
paths:
146-
- bin
147-
- third_party$
148-
- builtin$
149-
- examples$
150-
issues:
151-
max-issues-per-linter: 0
152-
max-same-issues: 0
187+
- generated$

_examples/chat/chat_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/99designs/gqlgen/graphql/handler/transport"
1110
"github.com/stretchr/testify/assert"
1211
"github.com/stretchr/testify/require"
1312

1413
"github.com/99designs/gqlgen/client"
1514
"github.com/99designs/gqlgen/graphql/handler"
15+
"github.com/99designs/gqlgen/graphql/handler/transport"
1616
)
1717

1818
func TestChatSubscriptions(t *testing.T) {
@@ -83,7 +83,8 @@ func TestChatSubscriptions(t *testing.T) {
8383
}
8484
wg.Wait()
8585

86-
// 1 for the main thread, 1 for the testing package and remainder is reserved for the HTTP server threads
86+
// 1 for the main thread, 1 for the testing package and remainder is reserved for the HTTP
87+
// server threads
8788
// TODO: use something like runtime.Stack to filter out HTTP server threads,
8889
// TODO: which is required for proper concurrency and leaks testing
8990
require.Less(t, runtime.NumGoroutine(), 1+1+batchSize*2, "goroutine leak")

_examples/chat/resolvers.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ type Chatroom struct {
6262

6363
type mutationResolver struct{ *resolver }
6464

65-
func (r *mutationResolver) Post(ctx context.Context, text, username, roomName string) (*Message, error) {
65+
func (r *mutationResolver) Post(
66+
ctx context.Context,
67+
text, username, roomName string,
68+
) (*Message, error) {
6669
room := r.getRoom(roomName)
6770

6871
message := &Message{
@@ -99,7 +102,10 @@ func (r *queryResolver) Room(ctx context.Context, name string) (*Chatroom, error
99102

100103
type subscriptionResolver struct{ *resolver }
101104

102-
func (r *subscriptionResolver) MessageAdded(ctx context.Context, roomName string) (<-chan *Message, error) {
105+
func (r *subscriptionResolver) MessageAdded(
106+
ctx context.Context,
107+
roomName string,
108+
) (<-chan *Message, error) {
103109
room := r.getRoom(roomName)
104110

105111
id := randString(8)

_examples/config/schema.resolvers.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_examples/config/todo.resolvers.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_examples/config/user.resolvers.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_examples/contextpropagation/todo.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ func New() Config {
2727
return c
2828
}
2929

30-
type Resolver struct {
31-
}
30+
type Resolver struct{}
3231

3332
func (r *Resolver) Query() QueryResolver {
3433
return r

_examples/dataloader/dataloader_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package dataloader
33
import (
44
"testing"
55

6-
"github.com/99designs/gqlgen/graphql/handler/extension"
7-
"github.com/99designs/gqlgen/graphql/handler/transport"
86
"github.com/stretchr/testify/require"
97

108
"github.com/99designs/gqlgen/client"
119
"github.com/99designs/gqlgen/graphql/handler"
10+
"github.com/99designs/gqlgen/graphql/handler/extension"
11+
"github.com/99designs/gqlgen/graphql/handler/transport"
1212
"github.com/99designs/gqlgen/graphql/introspection"
1313
)
1414

@@ -50,7 +50,8 @@ func TestTodo(t *testing.T) {
5050
}, resp.Torture2d)
5151
})
5252

53-
// Input coercion on arrays should convert non array values into an array of the appropriate depth
53+
// Input coercion on arrays should convert non array values into an array of the appropriate
54+
// depth
5455
// http://facebook.github.io/graphql/June2018/#sec-Type-System.List
5556
t.Run("array coercion", func(t *testing.T) {
5657
t.Run("1d", func(t *testing.T) {
@@ -88,6 +89,10 @@ func TestTodo(t *testing.T) {
8889
}
8990
err := c.Post(`{ torture2d(customerIds:{}) { id name } }`, &resp)
9091

91-
require.EqualError(t, err, "[{\"message\":\"map[string]interface {} is not an int\",\"path\":[\"torture2d\",\"customerIds\",0,0]}]")
92+
require.EqualError(
93+
t,
94+
err,
95+
"[{\"message\":\"map[string]interface {} is not an int\",\"path\":[\"torture2d\",\"customerIds\",0,0]}]",
96+
)
9297
})
9398
}

_examples/dataloader/dataloaders.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ func LoaderMiddleware(next http.Handler) http.Handler {
4848
addresses := make([]*Address, len(keys))
4949
errors := make([]error, len(keys))
5050
for i, key := range keys {
51-
addresses[i] = &Address{Street: "home street", Country: "hometon " + strconv.Itoa(key)}
51+
addresses[i] = &Address{
52+
Street: "home street",
53+
Country: "hometon " + strconv.Itoa(key),
54+
}
5255
}
5356
return addresses, errors
5457
},
@@ -64,16 +67,27 @@ func LoaderMiddleware(next http.Handler) http.Handler {
6467
keySql = append(keySql, strconv.Itoa(key))
6568
}
6669

67-
fmt.Printf("SELECT * FROM orders WHERE customer_id IN (%s)\n", strings.Join(keySql, ","))
70+
fmt.Printf(
71+
"SELECT * FROM orders WHERE customer_id IN (%s)\n",
72+
strings.Join(keySql, ","),
73+
)
6874
time.Sleep(5 * time.Millisecond)
6975

7076
orders := make([][]*Order, len(keys))
7177
errors := make([]error, len(keys))
7278
for i, key := range keys {
7379
id := 10 + rand.Int()%3
7480
orders[i] = []*Order{
75-
{ID: id, Amount: rand.Float64(), Date: time.Now().Add(-time.Duration(key) * time.Hour)},
76-
{ID: id + 1, Amount: rand.Float64(), Date: time.Now().Add(-time.Duration(key) * time.Hour)},
81+
{
82+
ID: id,
83+
Amount: rand.Float64(),
84+
Date: time.Now().Add(-time.Duration(key) * time.Hour),
85+
},
86+
{
87+
ID: id + 1,
88+
Amount: rand.Float64(),
89+
Date: time.Now().Add(-time.Duration(key) * time.Hour),
90+
},
7791
}
7892

7993
// if you had another customer loader you would prime its cache here
@@ -94,7 +108,10 @@ func LoaderMiddleware(next http.Handler) http.Handler {
94108
keySql = append(keySql, strconv.Itoa(key))
95109
}
96110

97-
fmt.Printf("SELECT * FROM items JOIN item_order WHERE item_order.order_id IN (%s)\n", strings.Join(keySql, ","))
111+
fmt.Printf(
112+
"SELECT * FROM items JOIN item_order WHERE item_order.order_id IN (%s)\n",
113+
strings.Join(keySql, ","),
114+
)
98115
time.Sleep(5 * time.Millisecond)
99116

100117
items := make([][]*Item, len(keys))

_examples/dataloader/resolvers.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ func (r *queryResolver) Torture2d(ctx context.Context, customerIds [][]int) ([][
8585
for i := range customerIds {
8686
inner := make([]*Customer, len(customerIds[i]))
8787
for j := range customerIds[i] {
88-
inner[j] = &Customer{ID: customerIds[i][j], Name: fmt.Sprintf("%d %d", i, j), AddressID: rand.Int() % 10}
88+
inner[j] = &Customer{
89+
ID: customerIds[i][j],
90+
Name: fmt.Sprintf("%d %d", i, j),
91+
AddressID: rand.Int() % 10,
92+
}
8993
}
9094
result[i] = inner
9195
}

0 commit comments

Comments
 (0)