Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix improper usage of Errorf #1434

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion locations/descriptor_locations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestDescriptorName(t *testing.T) {
for _, test := range tests {
t.Run(test.testName, func(t *testing.T) {
if diff := cmp.Diff(DescriptorName(test.d).Span, test.wantSpan); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
8 changes: 4 additions & 4 deletions locations/field_locations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestFieldLocations(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
l := FieldType(test.field)
if diff := cmp.Diff(l.GetSpan(), test.span); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand All @@ -66,7 +66,7 @@ func TestFieldLabel(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
l := FieldLabel(test.field)
if diff := cmp.Diff(l.GetSpan(), test.span); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand All @@ -84,7 +84,7 @@ func TestFieldResourceReference(t *testing.T) {
loc := FieldResourceReference(f.GetMessageTypes()[0].GetFields()[0])
// resource_reference annotation location is roughly line 4, column 19.
if diff := cmp.Diff(loc.GetSpan(), []int32{4, 19, 6, 3}); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}

Expand All @@ -99,6 +99,6 @@ func TestFieldOption(t *testing.T) {
`)
loc := FieldOption(f.GetMessageTypes()[0].GetFields()[0], apb.E_ResourceReference)
if diff := cmp.Diff(loc.GetSpan(), []int32{4, 19, 6, 3}); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}
4 changes: 2 additions & 2 deletions locations/file_locations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestLocations(t *testing.T) {
l = test.idxFx(f, test.idx)
}
if diff := cmp.Diff(l.Span, test.wantSpan); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestMissingLocations(t *testing.T) {
for _, test := range tests {
t.Run(test.testName, func(t *testing.T) {
if diff := cmp.Diff(test.fx(f).Span, []int32{0, 0, 0}); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion locations/message_locations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ func TestMessageResource(t *testing.T) {
`)
loc := MessageResource(f.GetMessageTypes()[0])
if diff := cmp.Diff(loc.GetSpan(), []int32{4, 2, 7, 4}); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}
10 changes: 5 additions & 5 deletions locations/method_locations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestMethodRequestType(t *testing.T) {
loc := MethodRequestType(f.GetServices()[0].GetMethods()[0])
// Three character span: line, start column, end column.
if diff := cmp.Diff(loc.GetSpan(), []int32{3, 14, 28}); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}

Expand All @@ -46,7 +46,7 @@ func TestMethodResponseType(t *testing.T) {
loc := MethodResponseType(f.GetServices()[0].GetMethods()[0])
// Three character span: line, start column, end column.
if diff := cmp.Diff(loc.GetSpan(), []int32{3, 39, 43}); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}

Expand All @@ -66,7 +66,7 @@ func TestMethodHTTPRule(t *testing.T) {
loc := MethodHTTPRule(f.GetServices()[0].GetMethods()[0])
// Four character span: start line, start column, end line, end column.
if diff := cmp.Diff(loc.GetSpan(), []int32{5, 4, 7, 6}); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}

Expand All @@ -86,7 +86,7 @@ func TestMethodOperationInfo(t *testing.T) {
loc := MethodOperationInfo(f.GetServices()[0].GetMethods()[0])
// Four character span: start line, start column, end line, end column.
if diff := cmp.Diff(loc.GetSpan(), []int32{5, 4, 8, 6}); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}

Expand All @@ -113,7 +113,7 @@ func TestMethodSignature(t *testing.T) {
loc := MethodSignature(f.GetServices()[0].GetMethods()[0], test.index)
// Four character span: start line, start column, end line, end column.
if diff := cmp.Diff(loc.GetSpan(), test.want); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0122/camel_case_uris_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestHttpUriField(t *testing.T) {
method := file.GetServices()[0].GetMethods()[0]
problems := httpURICase.Lint(file)
if diff := test.problems.SetDescriptor(method).Diff(problems); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions rules/aip0122/embedded_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestEmbeddedResource(t *testing.T) {
want[1].Descriptor = m.FindFieldByName("librarian")
}
if diff := want.Diff(embeddedResource.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestEmbeddedResource_Revisions(t *testing.T) {
`, test)
field := f.FindMessage("BookRevision").FindFieldByName("snapshot")
if diff := test.problems.SetDescriptor(field).Diff(embeddedResource.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0122/name_suffix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestNameSuffix(t *testing.T) {
`, test)
field := f.GetMessageTypes()[0].GetFields()[1]
if diff := test.problems.SetDescriptor(field).Diff(nameSuffix.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}
}
2 changes: 1 addition & 1 deletion rules/aip0122/no_self_links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestNoSelfLinks(t *testing.T) {
`, test)
field := f.GetMessageTypes()[0].GetFields()[1]
if diff := test.problems.SetDescriptor(field).Diff(noSelfLinks.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0122/resource_collection_identifiers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestResourceCollectionIdentifiers(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourceCollectionIdentifiers.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0122/resource_id_output_only_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestResourceIdOutputOnly(t *testing.T) {
`, test)
field := f.GetMessageTypes()[0].GetFields()[1]
if diff := test.problems.SetDescriptor(field).Diff(resourceIdOutputOnly.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}
}
2 changes: 1 addition & 1 deletion rules/aip0122/resource_reference_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestResourceReferenceType(t *testing.T) {
`, test)
field := f.GetMessageTypes()[0].GetFields()[0]
if diff := test.problems.SetDescriptor(field).Diff(resourceReferenceType.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0123/name_never_optional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestNameNeverOptional(t *testing.T) {
`, test)
field := f.GetMessageTypes()[0].GetFields()[0]
if diff := test.problems.SetDescriptor(field).Diff(nameNeverOptional.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions rules/aip0123/resource_annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestResourceAnnotation(t *testing.T) {
}
`)
if diff := (testutils.Problems{}).Diff(resourceAnnotation.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})

Expand All @@ -48,7 +48,7 @@ func TestResourceAnnotation(t *testing.T) {
}
`)
if diff := (testutils.Problems{}).Diff(resourceAnnotation.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})

Expand All @@ -73,7 +73,7 @@ func TestResourceAnnotation(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourceAnnotation.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0123/resource_definition_pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestResourceDefinitionPattern(t *testing.T) {
`, test)
got := resourceDefinitionPatterns.Lint(f)
if diff := test.problems.SetDescriptor(f).Diff(got); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0123/resource_definition_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestResourceDefinitionVariables(t *testing.T) {
`, test)
got := resourceDefinitionVariables.Lint(f)
if diff := test.problems.SetDescriptor(f).Diff(got); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0123/resource_name_components_alternate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestResourceNameComponentsAlternate(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourceNameComponentsAlternate.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions rules/aip0123/resource_pattern_plural_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestResourcePatternPluralSimple(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourcePatternPlural.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestResourcePatternPluralNested(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourcePatternPlural.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions rules/aip0123/resource_pattern_singular_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestResourcePatternSingularSimple(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourcePatternSingular.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestResourcePatternSingularMultiWord(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourcePatternSingular.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down Expand Up @@ -156,7 +156,7 @@ func TestResourcePatternSingularNested(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourcePatternSingular.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0123/resource_pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestResourcePattern(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourcePattern.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0123/resource_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestResourceVariables(t *testing.T) {
`, test)
m := f.GetMessageTypes()[0]
if diff := test.problems.SetDescriptor(m).Diff(resourceVariables.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions rules/aip0124/reference_same_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestReferenceSamePackage(t *testing.T) {
file := files["leaf.proto"]
field := file.GetMessageTypes()[0].GetFields()[0]
if diff := test.problems.SetDescriptor(field).Diff(referenceSamePackage.Lint(file)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})

Expand All @@ -83,7 +83,7 @@ func TestReferenceSamePackage(t *testing.T) {
file := files["leaf.proto"]
field := file.GetMessageTypes()[0].GetFields()[0]
if diff := test.problems.SetDescriptor(field).Diff(referenceSamePackage.Lint(file)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})

Expand Down Expand Up @@ -111,7 +111,7 @@ func TestReferenceSamePackage(t *testing.T) {
file := files["leaf.proto"]
field := file.GetMessageTypes()[0].GetFields()[0]
if diff := test.problems.SetDescriptor(field).Diff(referenceSamePackage.Lint(file)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
})
Expand Down
4 changes: 2 additions & 2 deletions rules/aip0126/unspecified_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestUnspecified(t *testing.T) {
// Run the lint rule and establish we get the correct problems.
problems := unspecified.Lint(f)
if diff := test.problems.SetDescriptor(f.GetEnumTypes()[0].GetValues()[0]).Diff(problems); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand All @@ -67,7 +67,7 @@ func TestUnspecified(t *testing.T) {
// Run the lint rule and establish we get the correct problems.
problems := unspecified.Lint(f)
if diff := test.problems.SetDescriptor(f.GetEnumTypes()[0].GetValues()[0]).Diff(problems); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0126/upper_snake_values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestUpperSnake(t *testing.T) {
// Run the lint rule, and establish that we got the correct problems.
problems := enumValueUpperSnakeCase.Lint(enum.GetFile())
if diff := test.problems.Diff(problems); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion rules/aip0127/http_annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestHasAnnotation(t *testing.T) {
`, "{{.Annotation}}", test.annotation), test)
m := f.GetServices()[0].GetMethods()[0]
if diff := test.problems.SetDescriptor(m).Diff(hasAnnotation.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions rules/aip0127/http_template_pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestHttpTemplatePattern_PatternMatching(t *testing.T) {
`, test)
m := f.GetServices()[0].GetMethods()[0]
if diff := test.problems.SetDescriptor(m).Diff(httpTemplatePattern.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestHttpTemplatePattern_MultiplePatterns(t *testing.T) {
`, test)
m := f.GetServices()[0].GetMethods()[0]
if diff := test.problems.SetDescriptor(m).Diff(httpTemplatePattern.Lint(f)); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
Loading
Loading