Skip to content

Commit

Permalink
Revert "Fix lint"
Browse files Browse the repository at this point in the history
This reverts commit 5b68e15.

Signed-off-by: Edward McFarlane <[email protected]>
  • Loading branch information
emcfarlane committed Jan 16, 2025
1 parent b030c6c commit 6f92562
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 9 deletions.
4 changes: 2 additions & 2 deletions buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ modules:
- path: internal/examples/pets/internal/proto
lint:
use:
- STANDARD
- DEFAULT
except:
- ENUM_VALUE_PREFIX
- ENUM_VALUE_UPPER_SNAKE_CASE
Expand All @@ -16,7 +16,7 @@ deps:
- buf.build/googleapis/googleapis
lint:
use:
- STANDARD
- DEFAULT
except:
- RPC_REQUEST_RESPONSE_UNIQUE
- RPC_RESPONSE_STANDARD_NAME
Expand Down
5 changes: 4 additions & 1 deletion codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func TestJSONStabilize(t *testing.T) {
},
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
result, err := jsonStabilize(([]byte)(testCase.input))
Expand Down Expand Up @@ -408,7 +409,7 @@ func TestJSONCodec_MarshalField(t *testing.T) {
target := msg.NewField(field)
listVal := target.List()
source := reflect.ValueOf(val)
for i := range source.Len() {
for i := 0; i < source.Len(); i++ {
listVal.Append(asSingularValue(source.Index(i).Interface()))
}
return target
Expand Down Expand Up @@ -463,7 +464,9 @@ func TestJSONCodec_MarshalField(t *testing.T) {
t.Run(marshalOpt.name, func(t *testing.T) {
t.Parallel()
for _, testCase := range testCases {
testCase := testCase
for _, fieldName := range testCase.fieldNames {
fieldName := fieldName
t.Run(fieldName, func(t *testing.T) {
t.Parallel()
msg := (&testv1.AllTypes{}).ProtoReflect()
Expand Down
4 changes: 2 additions & 2 deletions params.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func isWKTWithScalarJSONMapping(field protoreflect.FieldDescriptor) bool {
func setParameter(msg protoreflect.Message, fields []protoreflect.FieldDescriptor, param string) error {
// Traverse the message to the last field.
leaf := msg
for i := range len(fields) - 1 {
for i := 0; i < len(fields)-1; i++ {
leaf = leaf.Mutable(fields[i]).Message()
}
field := fields[len(fields)-1]
Expand Down Expand Up @@ -255,7 +255,7 @@ func isNullValue(field protoreflect.FieldDescriptor) bool {
func getParameter(msg protoreflect.Message, fields []protoreflect.FieldDescriptor, index int) (string, error) {
// Traverse the message to the last field.
leaf := msg
for i := range len(fields) - 1 {
for i := 0; i < len(fields)-1; i++ {
leaf = leaf.Mutable(fields[i]).Message()
}
field := fields[len(fields)-1]
Expand Down
3 changes: 3 additions & 0 deletions params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func TestIsParameter(t *testing.T) {
isParam: false,
}}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.fieldPath, func(t *testing.T) {
t.Parallel()
fields, err := resolvePathToFieldDescriptors(desc, testCase.fieldPath, true)
Expand Down Expand Up @@ -400,6 +401,7 @@ func TestSetParameter(t *testing.T) {
wantErr: "unknown field in field path \"unknownField\": element \"unknownField\" does not correspond to any field of type vanguard.test.v1.ParameterValues",
}}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.fields+"="+testCase.value, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -699,6 +701,7 @@ func TestGetParameter(t *testing.T) {
want: "2021-01-01T00:00:00Z",
}}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.fields+"="+testCase.want, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion path_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func pathIsHexSlash(input string) bool {
func pathEscape(input string, mode pathEncoding) string {
// Count the number of characters that possibly escaping.
hexCount := 0
for i := range len(input) {
for i := 0; i < len(input); i++ {
if pathShouldEscape(input[i], mode) {
hexCount++
}
Expand Down
2 changes: 2 additions & 0 deletions path_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func TestPath_ParsePathTemplate(t *testing.T) {
},
}}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.tmpl, func(t *testing.T) {
t.Parallel()
segments, variables, err := parsePathTemplate(testCase.tmpl)
Expand Down Expand Up @@ -291,6 +292,7 @@ func TestPath_Escaping(t *testing.T) {
wantEscaped: "foo%2Fbar",
}}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.input, func(t *testing.T) {
t.Parallel()
dec, err := pathUnescape(testCase.input, testCase.mode)
Expand Down
4 changes: 2 additions & 2 deletions protocol_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func grpcStatusFromError(err *connect.Error) *status.Status {
// https://datatracker.ietf.org/doc/html/rfc3986#section-2.1
func grpcPercentEncode(msg string) string {
var hexCount int
for i := range len(msg) {
for i := 0; i < len(msg); i++ {
if grpcShouldEscape(msg[i]) {
hexCount++
}
Expand All @@ -434,7 +434,7 @@ func grpcPercentEncode(msg string) string {
// We need to escape some characters, so we'll need to allocate a new string.
var out strings.Builder
out.Grow(len(msg) + 2*hexCount)
for i := range len(msg) {
for i := 0; i < len(msg); i++ {
switch char := msg[i]; {
case grpcShouldEscape(char):
out.WriteByte('%')
Expand Down
1 change: 1 addition & 0 deletions protocol_grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func TestGRPCPercentEncoding(t *testing.T) {
`foo%bar`,
"fiancée",
} {
input := input
t.Run(input, func(t *testing.T) {
t.Parallel()
assert.True(t, utf8.ValidString(input), "input invalid UTF-8")
Expand Down
1 change: 1 addition & 0 deletions protocol_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ func TestHTTPEncodePathValues(t *testing.T) {
wantErr: "unknown field in field path \"unknownQueryParam\": element \"unknownQueryParam\" does not correspond to any field of type vanguard.test.v1.ParameterValues",
}}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.tmpl, func(t *testing.T) {
t.Parallel()
segments, variables, err := parsePathTemplate(testCase.tmpl)
Expand Down
1 change: 1 addition & 0 deletions protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func TestParseMultiHeader(t *testing.T) {
},
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
result := parseMultiHeader(testCase.input)
Expand Down
1 change: 1 addition & 0 deletions regress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestIssue148(t *testing.T) {
"json": {connect.WithGRPC(), connect.WithProtoJSON()},
}
for caseName := range clientCases {
caseName := caseName
clientOpts := clientCases[caseName]
t.Run(caseName, func(t *testing.T) {
t.Parallel()
Expand Down
3 changes: 3 additions & 0 deletions router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func TestRouteTrie_FindTarget(t *testing.T) {
trie := initTrie(t)

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.path, func(t *testing.T) {
t.Parallel()
var present, absent []string
Expand All @@ -156,6 +157,7 @@ func TestRouteTrie_FindTarget(t *testing.T) {
absent = []string{http.MethodGet, http.MethodPost, http.MethodDelete, http.MethodPut}
}
for _, method := range present {
method := method
t.Run(method, func(t *testing.T) {
t.Parallel()
target, vars, _ := trie.match(testCase.path, method)
Expand All @@ -175,6 +177,7 @@ func TestRouteTrie_FindTarget(t *testing.T) {
})
}
for _, method := range absent {
method := method
t.Run(method, func(t *testing.T) {
t.Parallel()
target, _, _ := trie.match(testCase.path, method)
Expand Down
11 changes: 11 additions & 0 deletions transcoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,15 @@ func TestTranscoder_BufferTooLargeFails(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
for i := range testCase.reqs {
testReq := &testCase.reqs[i]
t.Run(testReq.name, func(t *testing.T) {
t.Parallel()
for _, mode := range muxTestModes {
mode := mode
t.Run(mode.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -596,6 +598,7 @@ func TestTranscoder_ConnectGetUsesPostIfRequestTooLarge(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -984,6 +987,7 @@ func TestTranscoder_Errors(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1312,15 +1316,19 @@ func TestTranscoder_PassThrough(t *testing.T) {
}

for _, protocolCase := range protocolOptions {
protocolCase := protocolCase
t.Run(protocolCase.name, func(t *testing.T) {
t.Parallel()
for _, encodingCase := range encodingOptions {
encodingCase := encodingCase
t.Run(encodingCase.name, func(t *testing.T) {
t.Parallel()
for _, compressionCase := range compressionOptions {
compressionCase := compressionCase
t.Run(compressionCase.name, func(t *testing.T) {
t.Parallel()
for _, testReq := range testRequests {
testReq := testReq
t.Run(testReq.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1491,12 +1499,15 @@ func TestMessage_AdvanceStage(t *testing.T) {
}

for _, compressed := range []bool{true, false} {
compressed := compressed
t.Run(fmt.Sprintf("compressed:%v", compressed), func(t *testing.T) {
t.Parallel()
for _, isRequest := range []bool{true, false} {
isRequest := isRequest
t.Run(fmt.Sprintf("request:%v", isRequest), func(t *testing.T) {
t.Parallel()
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 2 additions & 0 deletions vanguard_restxrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,11 @@ func TestMux_RESTxRPC(t *testing.T) {
}
codec := NewJSONCodec(protoregistry.GlobalTypes)
for _, opts := range testOpts {
opts := opts
t.Run(opts.name, func(t *testing.T) {
t.Parallel()
for _, testCase := range testRequests {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 2 additions & 0 deletions vanguard_rpcxrest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ func TestMux_RPCxREST(t *testing.T) {
}}

for _, opts := range testOpts {
opts := opts
clients := testClients{
libClient: testv1connect.NewLibraryServiceClient(
opts.server.Client(), opts.server.URL, opts.opts...,
Expand All @@ -431,6 +432,7 @@ func TestMux_RPCxREST(t *testing.T) {
t.Run(opts.name, func(t *testing.T) {
t.Parallel()
for _, req := range testRequests {
req := req
t.Run(req.name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 3 additions & 1 deletion vanguard_rpcxrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ func TestMux_RPCxRPC(t *testing.T) {
},
}
for _, opts := range testOpts {
opts := opts
clients := testClients{
libClient: testv1connect.NewLibraryServiceClient(
opts.server.Client(), opts.server.URL, opts.opts...,
Expand All @@ -405,7 +406,8 @@ func TestMux_RPCxRPC(t *testing.T) {
}
t.Run(opts.name, func(t *testing.T) {
t.Parallel()
for _, testCase := range testRequests {
for _, testReq := range testRequests {
testCase := testReq
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
runRPCTestCase(t, &interceptor, clients, testCase.invoke, testCase.stream)
Expand Down

0 comments on commit 6f92562

Please sign in to comment.