Skip to content

Commit d839d6f

Browse files
committed
replace fallthrough statements with case clause lists
Found using https://go-critic.github.io/overview#emptyFallthrough-ref
1 parent cd6ef8d commit d839d6f

File tree

3 files changed

+7
-31
lines changed

3 files changed

+7
-31
lines changed

language/parser/parser.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,7 @@ func parseValueLiteral(parser *Parser, isConst bool) (ast.Value, error) {
601601
Value: token.Value,
602602
Loc: loc(parser, token.Start),
603603
}), nil
604-
case lexer.TokenKind[lexer.BLOCK_STRING]:
605-
fallthrough
606-
case lexer.TokenKind[lexer.STRING]:
604+
case lexer.TokenKind[lexer.BLOCK_STRING], lexer.TokenKind[lexer.STRING]:
607605
return parseStringLiteral(parser)
608606
case lexer.TokenKind[lexer.NAME]:
609607
if token.Value == "true" || token.Value == "false" {

type_info.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,7 @@ func (ti *TypeInfo) Leave(node ast.Node) {
206206
}
207207
case kinds.Directive:
208208
ti.directive = nil
209-
case kinds.OperationDefinition:
210-
fallthrough
211-
case kinds.InlineFragment:
212-
fallthrough
213-
case kinds.FragmentDefinition:
209+
case kinds.OperationDefinition, kinds.InlineFragment, kinds.FragmentDefinition:
214210
// pop ti.typeStack
215211
if len(ti.typeStack) > 0 {
216212
_, ti.typeStack = ti.typeStack[len(ti.typeStack)-1], ti.typeStack[:len(ti.typeStack)-1]
@@ -226,9 +222,7 @@ func (ti *TypeInfo) Leave(node ast.Node) {
226222
if len(ti.inputTypeStack) > 0 {
227223
_, ti.inputTypeStack = ti.inputTypeStack[len(ti.inputTypeStack)-1], ti.inputTypeStack[:len(ti.inputTypeStack)-1]
228224
}
229-
case kinds.ListValue:
230-
fallthrough
231-
case kinds.ObjectField:
225+
case kinds.ListValue, kinds.ObjectField:
232226
// pop ti.inputTypeStack
233227
if len(ti.inputTypeStack) > 0 {
234228
_, ti.inputTypeStack = ti.inputTypeStack[len(ti.inputTypeStack)-1], ti.inputTypeStack[:len(ti.inputTypeStack)-1]

util.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,9 @@ func getGraphType(tipe reflect.Type) Output {
7575
switch kind {
7676
case reflect.String:
7777
return String
78-
case reflect.Int:
79-
fallthrough
80-
case reflect.Int8:
81-
fallthrough
82-
case reflect.Int32:
83-
fallthrough
84-
case reflect.Int64:
78+
case reflect.Int, reflect.Int8, reflect.Int32, reflect.Int64:
8579
return Int
86-
case reflect.Float32:
87-
fallthrough
88-
case reflect.Float64:
80+
case reflect.Float32, reflect.Float64:
8981
return Float
9082
case reflect.Bool:
9183
return Boolean
@@ -98,19 +90,11 @@ func getGraphType(tipe reflect.Type) Output {
9890
func getGraphList(tipe reflect.Type) *List {
9991
if tipe.Kind() == reflect.Slice {
10092
switch tipe.Elem().Kind() {
101-
case reflect.Int:
102-
fallthrough
103-
case reflect.Int8:
104-
fallthrough
105-
case reflect.Int32:
106-
fallthrough
107-
case reflect.Int64:
93+
case reflect.Int, reflect.Int8, reflect.Int32, reflect.Int64:
10894
return NewList(Int)
10995
case reflect.Bool:
11096
return NewList(Boolean)
111-
case reflect.Float32:
112-
fallthrough
113-
case reflect.Float64:
97+
case reflect.Float32, reflect.Float64:
11498
return NewList(Float)
11599
case reflect.String:
116100
return NewList(String)

0 commit comments

Comments
 (0)