Skip to content

Commit 68eea8b

Browse files
donislawdevclaude
andcommitted
recipe: the depth switch says what it does about every other token
golangci-lint reads a switch on token.Type without a default as incomplete, and it is right about the shape while being wrong about this function: everything that is not a bracket or a brace leaves the nesting where it was, and listing the other thirty members would say less than one line saying so. Measured rather than assumed, because the natural conclusion was that flattening the function had introduced this. It had not. The version before the flattening, restored from 3a32c9d and run through the same pinned linter, reports the same thing at line 78 - the branch had simply never been through preflight, which is also how a shape cap sat one over its measurement for three commits. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 48ee1f0 commit 68eea8b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎internal/recipe/limits.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,18 @@ func flowDepth(src []byte) int {
9191
// the shape guard counts how many functions sit that deep as well as how deep
9292
// the deepest one is. Splitting is what that guard asks for and it costs
9393
// nothing here.
94+
// The default is not decoration. token.Type has thirty four members and a
95+
// switch on it without one is reported as incomplete, which is correct of the
96+
// linter and wrong about this function: everything that is not a bracket or a
97+
// brace leaves the nesting where it was, and listing thirty of them would say
98+
// less than one line saying so.
9499
func depthChange(t token.Type) int {
95100
switch t {
96101
case token.SequenceStartType, token.MappingStartType:
97102
return 1
98103
case token.SequenceEndType, token.MappingEndType:
99104
return -1
105+
default:
106+
return 0
100107
}
101-
return 0
102108
}

0 commit comments

Comments
 (0)