Skip to content

Commit 9379f9d

Browse files
authored
Make some more golang-ci improvements (#483)
1 parent da45ffe commit 9379f9d

File tree

5 files changed

+24
-25
lines changed

5 files changed

+24
-25
lines changed

.golangci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ linters-settings:
99
enable-all: true
1010
disable:
1111
- fieldalignment
12-
- composites # remove later
1312
- deepequalerrors # remove later
1413

1514
linters:
@@ -26,7 +25,7 @@ linters:
2625
- unconvert
2726
- unused
2827
- varcheck
29-
# - misspell add later
28+
- misspell
3029
- goimports
3130

3231
issues:

graphql_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4144,15 +4144,15 @@ func checkFieldTraces(t *testing.T, want, have []fieldTrace) {
41444144
t.Errorf("mismatched field traces: expected %d but got %d: %#v", len(want), len(have), have)
41454145
}
41464146

4147-
type comparsion struct {
4147+
type comparison struct {
41484148
want fieldTrace
41494149
have fieldTrace
41504150
}
41514151

4152-
m := map[string]comparsion{}
4152+
m := map[string]comparison{}
41534153

41544154
for _, ft := range want {
4155-
m[ft.fieldName] = comparsion{want: ft}
4155+
m[ft.fieldName] = comparison{want: ft}
41564156
}
41574157

41584158
for _, ft := range have {

internal/common/lexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (l *Lexer) ConsumeIdentWithLoc() types.Ident {
123123
loc := l.Location()
124124
name := l.sc.TokenText()
125125
l.ConsumeToken(scanner.Ident)
126-
return types.Ident{name, loc}
126+
return types.Ident{Name: name, Loc: loc}
127127
}
128128

129129
func (l *Lexer) ConsumeKeyword(keyword string) {

internal/common/literals.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ func ParseLiteral(l *Lexer, constOnly bool) types.Value {
1515
panic("unreachable")
1616
}
1717
l.ConsumeToken('$')
18-
return &types.Variable{l.ConsumeIdent(), loc}
18+
return &types.Variable{Name: l.ConsumeIdent(), Loc: loc}
1919

2020
case scanner.Int, scanner.Float, scanner.String, scanner.Ident:
2121
lit := l.ConsumeLiteral()
2222
if lit.Type == scanner.Ident && lit.Text == "null" {
23-
return &types.NullValue{loc}
23+
return &types.NullValue{Loc: loc}
2424
}
2525
lit.Loc = loc
2626
return lit
@@ -37,7 +37,7 @@ func ParseLiteral(l *Lexer, constOnly bool) types.Value {
3737
list = append(list, ParseLiteral(l, constOnly))
3838
}
3939
l.ConsumeToken(']')
40-
return &types.ListValue{list, loc}
40+
return &types.ListValue{Values: list, Loc: loc}
4141

4242
case '{':
4343
l.ConsumeToken('{')
@@ -46,10 +46,10 @@ func ParseLiteral(l *Lexer, constOnly bool) types.Value {
4646
name := l.ConsumeIdentWithLoc()
4747
l.ConsumeToken(':')
4848
value := ParseLiteral(l, constOnly)
49-
fields = append(fields, &types.ObjectField{name, value})
49+
fields = append(fields, &types.ObjectField{Name: name, Value: value})
5050
}
5151
l.ConsumeToken('}')
52-
return &types.ObjectValue{fields, loc}
52+
return &types.ObjectValue{Fields: fields, Loc: loc}
5353

5454
default:
5555
l.SyntaxError("invalid value")

internal/schema/schema_internal_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestParseInterfaceDef(t *testing.T) {
2222
definition: "Greeting { field: String }",
2323
expected: &types.InterfaceTypeDefinition{
2424
Name: "Greeting",
25-
Loc: errors.Location{1, 1},
25+
Loc: errors.Location{Line: 1, Column: 1},
2626
Fields: types.FieldsDefinition{&types.FieldDefinition{Name: "field"}}},
2727
}}
2828

@@ -53,19 +53,19 @@ func TestParseObjectDef(t *testing.T) {
5353
tests := []testCase{{
5454
description: "Parses type inheriting single interface",
5555
definition: "Hello implements World { field: String }",
56-
expected: &types.ObjectTypeDefinition{Name: "Hello", Loc: errors.Location{1, 1}, InterfaceNames: []string{"World"}},
56+
expected: &types.ObjectTypeDefinition{Name: "Hello", Loc: errors.Location{Line: 1, Column: 1}, InterfaceNames: []string{"World"}},
5757
}, {
5858
description: "Parses type inheriting multiple interfaces",
5959
definition: "Hello implements Wo & rld { field: String }",
60-
expected: &types.ObjectTypeDefinition{Name: "Hello", Loc: errors.Location{1, 1}, InterfaceNames: []string{"Wo", "rld"}},
60+
expected: &types.ObjectTypeDefinition{Name: "Hello", Loc: errors.Location{Line: 1, Column: 1}, InterfaceNames: []string{"Wo", "rld"}},
6161
}, {
6262
description: "Parses type inheriting multiple interfaces with leading ampersand",
6363
definition: "Hello implements & Wo & rld { field: String }",
64-
expected: &types.ObjectTypeDefinition{Name: "Hello", Loc: errors.Location{1, 1}, InterfaceNames: []string{"Wo", "rld"}},
64+
expected: &types.ObjectTypeDefinition{Name: "Hello", Loc: errors.Location{Line: 1, Column: 1}, InterfaceNames: []string{"Wo", "rld"}},
6565
}, {
6666
description: "Allows legacy SDL interfaces",
6767
definition: "Hello implements Wo, rld { field: String }",
68-
expected: &types.ObjectTypeDefinition{Name: "Hello", Loc: errors.Location{1, 1}, InterfaceNames: []string{"Wo", "rld"}},
68+
expected: &types.ObjectTypeDefinition{Name: "Hello", Loc: errors.Location{Line: 1, Column: 1}, InterfaceNames: []string{"Wo", "rld"}},
6969
}}
7070

7171
for _, test := range tests {
@@ -97,7 +97,7 @@ func TestParseUnionDef(t *testing.T) {
9797
expected: &types.Union{
9898
Name: "Foo",
9999
TypeNames: []string{"Bar", "Qux", "Quux"},
100-
Loc: errors.Location{1, 1},
100+
Loc: errors.Location{Line: 1, Column: 1},
101101
},
102102
},
103103
}
@@ -133,14 +133,14 @@ func TestParseEnumDef(t *testing.T) {
133133
EnumValuesDefinition: []*types.EnumValueDefinition{
134134
{
135135
EnumValue: "BAR",
136-
Loc: errors.Location{1, 7},
136+
Loc: errors.Location{Line: 1, Column: 7},
137137
},
138138
{
139139
EnumValue: "QUX",
140-
Loc: errors.Location{1, 11},
140+
Loc: errors.Location{Line: 1, Column: 11},
141141
},
142142
},
143-
Loc: errors.Location{1, 1},
143+
Loc: errors.Location{Line: 1, Column: 1},
144144
},
145145
},
146146
{
@@ -154,14 +154,14 @@ func TestParseEnumDef(t *testing.T) {
154154
EnumValuesDefinition: []*types.EnumValueDefinition{
155155
{
156156
EnumValue: "BAR",
157-
Loc: errors.Location{2, 5},
157+
Loc: errors.Location{Line: 2, Column: 5},
158158
},
159159
{
160160
EnumValue: "QUX",
161-
Loc: errors.Location{3, 5},
161+
Loc: errors.Location{Line: 3, Column: 5},
162162
},
163163
},
164-
Loc: errors.Location{1, 1},
164+
Loc: errors.Location{Line: 1, Column: 1},
165165
},
166166
},
167167
}
@@ -194,7 +194,7 @@ func TestParseDirectiveDef(t *testing.T) {
194194
definition: "@Foo on FIELD",
195195
expected: &types.DirectiveDefinition{
196196
Name: "Foo",
197-
Loc: errors.Location{1, 2},
197+
Loc: errors.Location{Line: 1, Column: 2},
198198
Locations: []string{"FIELD"},
199199
},
200200
},
@@ -229,7 +229,7 @@ func TestParseInputDef(t *testing.T) {
229229
expected: &types.InputObject{
230230
Name: "Foo",
231231
Values: nil,
232-
Loc: errors.Location{1, 1},
232+
Loc: errors.Location{Line: 1, Column: 1},
233233
},
234234
},
235235
}

0 commit comments

Comments
 (0)