Skip to content
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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ clean: ## Delete intermediate build artifacts
.PHONY: test
test: build ## Run unit tests
go test -vet=off -race -cover ./...
@# Also run against the Go Opaque API, which the protoopaque build tag selects
@# for the hybrid-generated Protobuf packages we depend on.
go test -vet=off -race -cover -tags protoopaque ./...

.PHONY: build
build: generate ## Build all packages
Expand Down
4 changes: 2 additions & 2 deletions check/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ func (a *annotation) toProto() *checkv1.Annotation {
if a.againstFileLocation != nil {
protoAgainstFileLocation = a.againstFileLocation.ToProto()
}
return &checkv1.Annotation{
return checkv1.Annotation_builder{
RuleId: a.RuleID(),
Message: a.Message(),
FileLocation: protoFileLocation,
AgainstFileLocation: protoAgainstFileLocation,
}
}.Build()
}

func (*annotation) isAnnotation() {}
Expand Down
4 changes: 2 additions & 2 deletions check/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ func (r *category) toProto() *checkv1.Category {
if r == nil {
return nil
}
return &checkv1.Category{
return checkv1.Category_builder{
Id: r.id,
Purpose: r.purpose,
Deprecated: r.deprecated,
ReplacementIds: r.replacementIDs,
}
}.Build()
}

func (*category) isCategory() {}
Expand Down
8 changes: 4 additions & 4 deletions check/check_service_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ func (c *checkServiceHandler) ListRules(_ context.Context, listRulesRequest *che
if err != nil {
return nil, err
}
listRulesResponse := &checkv1.ListRulesResponse{
listRulesResponse := checkv1.ListRulesResponse_builder{
NextPageToken: nextPageToken,
Rules: xslices.Map(rules, Rule.toProto),
}
}.Build()
if err := c.validator.Validate(listRulesResponse); err != nil {
return nil, err
}
Expand All @@ -242,10 +242,10 @@ func (c *checkServiceHandler) ListCategories(_ context.Context, listCategoriesRe
if err != nil {
return nil, err
}
listCategoriesResponse := &checkv1.ListCategoriesResponse{
listCategoriesResponse := checkv1.ListCategoriesResponse_builder{
NextPageToken: nextPageToken,
Categories: xslices.Map(categories, Category.toProto),
}
}.Build()
if err := c.validator.Validate(listCategoriesResponse); err != nil {
return nil, err
}
Expand Down
52 changes: 26 additions & 26 deletions check/check_service_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,76 +39,76 @@ func TestCheckServiceHandlerUniqueFiles(t *testing.T) {

_, err = checkServiceHandler.Check(
t.Context(),
&checkv1.CheckRequest{
checkv1.CheckRequest_builder{
FileDescriptors: []*descriptorv1.FileDescriptor{
{
descriptorv1.FileDescriptor_builder{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
Name: proto.String("foo.proto"),
SourceCodeInfo: &descriptorpb.SourceCodeInfo{},
},
},
}.Build(),
},
AgainstFileDescriptors: []*descriptorv1.FileDescriptor{
{
descriptorv1.FileDescriptor_builder{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
Name: proto.String("foo.proto"),
SourceCodeInfo: &descriptorpb.SourceCodeInfo{},
},
},
}.Build(),
},
},
}.Build(),
)
require.NoError(t, err)

_, err = checkServiceHandler.Check(
t.Context(),
&checkv1.CheckRequest{
checkv1.CheckRequest_builder{
FileDescriptors: []*descriptorv1.FileDescriptor{
{
descriptorv1.FileDescriptor_builder{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
Name: proto.String("foo.proto"),
SourceCodeInfo: &descriptorpb.SourceCodeInfo{},
},
},
{
}.Build(),
descriptorv1.FileDescriptor_builder{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
Name: proto.String("foo.proto"),
SourceCodeInfo: &descriptorpb.SourceCodeInfo{},
},
},
}.Build(),
},
},
}.Build(),
)
pluginrpcError := &pluginrpc.Error{}
require.ErrorAs(t, err, &pluginrpcError)
require.Equal(t, pluginrpc.CodeInvalidArgument, pluginrpcError.Code())

_, err = checkServiceHandler.Check(
t.Context(),
&checkv1.CheckRequest{
checkv1.CheckRequest_builder{
FileDescriptors: []*descriptorv1.FileDescriptor{
{
descriptorv1.FileDescriptor_builder{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
Name: proto.String("foo.proto"),
SourceCodeInfo: &descriptorpb.SourceCodeInfo{},
},
},
}.Build(),
},
AgainstFileDescriptors: []*descriptorv1.FileDescriptor{
{
descriptorv1.FileDescriptor_builder{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
Name: proto.String("bar.proto"),
SourceCodeInfo: &descriptorpb.SourceCodeInfo{},
},
},
{
}.Build(),
descriptorv1.FileDescriptor_builder{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
Name: proto.String("bar.proto"),
SourceCodeInfo: &descriptorpb.SourceCodeInfo{},
},
},
}.Build(),
},
},
}.Build(),
)
pluginrpcError = &pluginrpc.Error{}
require.ErrorAs(t, err, &pluginrpcError)
Expand All @@ -129,22 +129,22 @@ func TestCheckServiceHandlerNoSourceCodeInfo(t *testing.T) {

_, err = checkServiceHandler.Check(
t.Context(),
&checkv1.CheckRequest{
checkv1.CheckRequest_builder{
FileDescriptors: []*descriptorv1.FileDescriptor{
{
descriptorv1.FileDescriptor_builder{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
Name: proto.String("foo.proto"),
},
},
}.Build(),
},
AgainstFileDescriptors: []*descriptorv1.FileDescriptor{
{
descriptorv1.FileDescriptor_builder{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
Name: proto.String("foo.proto"),
},
},
}.Build(),
},
},
}.Build(),
)
require.NoError(t, err)
}
4 changes: 2 additions & 2 deletions check/checktest/checktest.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,12 @@ func compile(ctx context.Context, dirPaths []string, filePaths []string) ([]desc
fileDescriptorProto,
filePathToUnusedDependencyFilePaths[fileDescriptorProto.GetName()],
)
protoFileDescriptors[i] = &descriptorv1.FileDescriptor{
protoFileDescriptors[i] = descriptorv1.FileDescriptor_builder{
FileDescriptorProto: fileDescriptorProto,
IsImport: !isNotImport,
IsSyntaxUnspecified: isSyntaxUnspecified,
UnusedDependency: unusedDependencyIndexes,
}
}.Build()
}
return descriptor.FileDescriptorsForProtoFileDescriptors(protoFileDescriptors)
}
Expand Down
8 changes: 4 additions & 4 deletions check/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ func (c *client) listRulesUncached(ctx context.Context) ([]Rule, error) {
for {
response, err := checkServiceClient.ListRules(
ctx,
&checkv1.ListRulesRequest{
checkv1.ListRulesRequest_builder{
PageSize: listRulesPageSize,
PageToken: pageToken,
},
}.Build(),
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -259,10 +259,10 @@ func (c *client) listCategoriesUncached(ctx context.Context) ([]Category, error)
for {
response, err := checkServiceClient.ListCategories(
ctx,
&checkv1.ListCategoriesRequest{
checkv1.ListCategoriesRequest_builder{
PageSize: listCategoriesPageSize,
PageToken: pageToken,
},
}.Build(),
)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions check/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ func (r *request) toProtos() ([]*checkv1.CheckRequest, error) {
}
if len(r.ruleIDs) == 0 {
return []*checkv1.CheckRequest{
{
checkv1.CheckRequest_builder{
FileDescriptors: protoFileDescriptors,
AgainstFileDescriptors: protoAgainstFileDescriptors,
Options: protoOptions,
},
}.Build(),
}, nil
}
var checkRequests []*checkv1.CheckRequest
Expand All @@ -207,12 +207,12 @@ func (r *request) toProtos() ([]*checkv1.CheckRequest, error) {
end := min(start+checkRuleIDPageSize, len(r.ruleIDs))
checkRequests = append(
checkRequests,
&checkv1.CheckRequest{
checkv1.CheckRequest_builder{
FileDescriptors: protoFileDescriptors,
AgainstFileDescriptors: protoAgainstFileDescriptors,
Options: protoOptions,
RuleIds: r.ruleIDs[start:end],
},
}.Build(),
)
}
return checkRequests, nil
Expand Down
4 changes: 2 additions & 2 deletions check/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func (r *response) Annotations() []Annotation {
}

func (r *response) toProto() *checkv1.CheckResponse {
return &checkv1.CheckResponse{
return checkv1.CheckResponse_builder{
Annotations: xslices.Map(r.annotations, Annotation.toProto),
}
}.Build()
}

func (*response) isResponse() {}
4 changes: 2 additions & 2 deletions check/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ func (r *rule) toProto() *checkv1.Rule {
return nil
}
protoRuleType := ruleTypeToProtoRuleType[r.ruleType]
return &checkv1.Rule{
return checkv1.Rule_builder{
Id: r.id,
CategoryIds: xslices.Map(r.categories, Category.ID),
Default: r.isDefault,
Purpose: r.purpose,
Type: protoRuleType,
Deprecated: r.deprecated,
ReplacementIds: r.replacementIDs,
}
}.Build()
}

func (*rule) isRule() {}
Expand Down
4 changes: 2 additions & 2 deletions descriptor/file_descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ func (f *fileDescriptor) ToProto() *descriptorv1.FileDescriptor {
if f == nil {
return nil
}
return &descriptorv1.FileDescriptor{
return descriptorv1.FileDescriptor_builder{
FileDescriptorProto: f.fileDescriptorProto,
IsImport: f.isImport,
IsSyntaxUnspecified: f.isSyntaxUnspecified,
UnusedDependency: f.unusedDependencyIndexes,
}
}.Build()
}

func (*fileDescriptor) isFileDescriptor() {}
4 changes: 2 additions & 2 deletions descriptor/file_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ func (l *fileLocation) ToProto() *descriptorv1.FileLocation {
if l == nil {
return nil
}
return &descriptorv1.FileLocation{
return descriptorv1.FileLocation_builder{
FileName: l.fileDescriptor.ProtoreflectFileDescriptor().Path(),
SourcePath: l.sourceLocation.Path,
}
}.Build()
}

func (l *fileLocation) unclonedSourcePath() protoreflect.SourcePath {
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ require (
buf.build/go/spdx v0.2.0
github.com/bufbuild/protocompile v0.14.1
github.com/stretchr/testify v1.11.1
google.golang.org/protobuf v1.36.11
pluginrpc.com/pluginrpc v0.5.0
google.golang.org/protobuf v1.36.12
pluginrpc.com/pluginrpc v0.5.1-0.20260825152034-473fc805d0d1
)

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260209202127-80ab13bee0bf.1 // indirect
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.11-20241007202033-cf42259fcbfc.1 // indirect
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.1 // indirect
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.12-20241007202033-cf42259fcbfc.1 // indirect
cel.dev/expr v0.25.1 // indirect
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/cel-go v0.29.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/pflag v1.0.10 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp v0.0.0-20250813145105-42675adae3e6 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.28.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a // indirect
Expand Down
Loading
Loading