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

unused parameter should be replaced by underscore #3334

Merged
merged 1 commit into from
Aug 29, 2023
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 cmd/goa/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func NewGenerator(cmd string, path, output string) *Generator {
}

// Write writes the main file.
func (g *Generator) Write(debug bool) error {
func (g *Generator) Write(_ bool) error {
var tmpDir string
{
wd := "."
Expand Down
2 changes: 1 addition & 1 deletion codegen/example/example_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func CLIFiles(genpkg string, root *expr.RootExpr) []*codegen.File {

// exampleCLIMain returns an example client tool main implementation for the
// given server expression.
func exampleCLIMain(genpkg string, root *expr.RootExpr, svr *expr.ServerExpr) *codegen.File {
func exampleCLIMain(_ string, root *expr.RootExpr, svr *expr.ServerExpr) *codegen.File {
svrdata := Servers.Get(svr)

path := filepath.Join("cmd", svrdata.Dir+"-cli", "main.go")
Expand Down
2 changes: 1 addition & 1 deletion codegen/service/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
)

// ClientFile returns the client file for the given service.
func ClientFile(genpkg string, service *expr.ServiceExpr) *codegen.File {
func ClientFile(_ string, service *expr.ServiceExpr) *codegen.File {
svc := Services.Get(service.Name)
data := endpointData(service)
path := filepath.Join(codegen.Gendir, svc.PathName, "client.go")
Expand Down
2 changes: 1 addition & 1 deletion codegen/service/example_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func ExampleServiceFiles(genpkg string, root *expr.RootExpr) []*codegen.File {
}

// exampleServiceFile returns a basic implementation of the given service.
func exampleServiceFile(genpkg string, root *expr.RootExpr, svc *expr.ServiceExpr, apipkg string) *codegen.File {
func exampleServiceFile(genpkg string, _ *expr.RootExpr, svc *expr.ServiceExpr, apipkg string) *codegen.File {
data := Services.Get(svc.Name)
svcName := data.PathName
fpath := svcName + ".go"
Expand Down
2 changes: 1 addition & 1 deletion codegen/service/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type viewedType struct {

// ViewsFile returns the views file for the given service which contains
// logic to render result types using the defined views.
func ViewsFile(genpkg string, service *expr.ServiceExpr) *codegen.File {
func ViewsFile(_ string, service *expr.ServiceExpr) *codegen.File {
svc := Services.Get(service.Name)
if len(svc.projectedTypes) == 0 {
return nil
Expand Down
2 changes: 1 addition & 1 deletion codegen/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func GoNativeTypeName(t expr.DataType) string {
}

// AttributeTags computes the struct field tags from its metadata if any.
func AttributeTags(parent, att *expr.AttributeExpr) string {
func AttributeTags(_, att *expr.AttributeExpr) string {
var elems []string
keys := make([]string, len(att.Meta))
i := 0
Expand Down
6 changes: 3 additions & 3 deletions grpc/codegen/client_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
// ClientTypeFiles returns the types file for every gRPC service that contain
// constructors to transform:
//
// * service payload types into protocol buffer request message types
// * protocol buffer response message types into service result types
// - service payload types into protocol buffer request message types
// - protocol buffer response message types into service result types
func ClientTypeFiles(genpkg string, root *expr.RootExpr) []*codegen.File {
fw := make([]*codegen.File, len(root.API.GRPC.Services))
seen := make(map[string]struct{})
Expand All @@ -28,7 +28,7 @@ func ClientTypeFiles(genpkg string, root *expr.RootExpr) []*codegen.File {
//
// seen keeps track of the constructor names that have already been generated
// to prevent duplicate code generation.
func clientType(genpkg string, svc *expr.GRPCServiceExpr, seen map[string]struct{}) *codegen.File {
func clientType(genpkg string, svc *expr.GRPCServiceExpr, _ map[string]struct{}) *codegen.File {
var (
initData []*InitData

Expand Down
2 changes: 1 addition & 1 deletion grpc/codegen/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type (
)

// Name returns the protocol buffer type name.
func (p *protoBufScope) Name(att *expr.AttributeExpr, pkg string, ptr, useDefault bool) string {
func (p *protoBufScope) Name(att *expr.AttributeExpr, pkg string, _, _ bool) string {
return protoBufGoFullTypeName(att, pkg, p.scope)
}

Expand Down
4 changes: 2 additions & 2 deletions grpc/codegen/protobuf_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,15 +638,15 @@ func convertType(src, tgt *expr.AttributeExpr, srcPtr bool, tgtPtr bool, srcVar
// representation to another.
// NOTE: For Int and UInt kinds, protocol buffer Go compiler generates
// int32 and uint32 respectively whereas Goa generates int and uint.
func convertPrimitiveToProto(src, tgt *expr.AttributeExpr, srcPtr, tgtPtr bool, srcVar string, ta *transformAttrs) string {
func convertPrimitiveToProto(_, tgt *expr.AttributeExpr, srcPtr, _ bool, srcVar string, _ *transformAttrs) string {
tgtType := protoBufNativeGoTypeName(tgt.Type)
if srcPtr {
srcVar = "*" + srcVar
}
return fmt.Sprintf("%s(%s)", tgtType, srcVar)
}

func convertPrimitiveFromProto(src, tgt *expr.AttributeExpr, srcPtr, tgtPtr bool, srcVar string, ta *transformAttrs) string {
func convertPrimitiveFromProto(_, tgt *expr.AttributeExpr, srcPtr, _ bool, srcVar string, ta *transformAttrs) string {
tgtType, _ := codegen.GetMetaType(tgt)
if tgtType == "" {
tgtType = ta.TargetCtx.Scope.Ref(tgt, ta.TargetCtx.Pkg(tgt))
Expand Down
6 changes: 3 additions & 3 deletions grpc/codegen/server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
// ServerTypeFiles returns the types file for every gRPC service that contain
// constructors to transform:
//
// * protocol buffer request message types into service payload types
// * service result types into protocol buffer response message types
// - protocol buffer request message types into service payload types
// - service result types into protocol buffer response message types
func ServerTypeFiles(genpkg string, root *expr.RootExpr) []*codegen.File {
fw := make([]*codegen.File, len(root.API.GRPC.Services))
seen := make(map[string]struct{})
Expand All @@ -28,7 +28,7 @@ func ServerTypeFiles(genpkg string, root *expr.RootExpr) []*codegen.File {
//
// seen keeps track of the constructor names that have already been generated
// to prevent duplicate code generation.
func serverType(genpkg string, svc *expr.GRPCServiceExpr, seen map[string]struct{}) *codegen.File {
func serverType(genpkg string, svc *expr.GRPCServiceExpr, _ map[string]struct{}) *codegen.File {
var (
initData []*InitData

Expand Down
2 changes: 1 addition & 1 deletion grpc/codegen/service_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ func buildResponseConvertData(response, result *expr.AttributeExpr, svcCtx *code
// svcCtx is the attribute context for service type
// proto if true indicates the target type is a protocol buffer type
// svr if true indicates the code is generated for conversion server side
func buildInitData(source, target *expr.AttributeExpr, sourceVar, targetVar string, svcCtx *codegen.AttributeContext, proto, svr, usesrc bool, sd *ServiceData) *InitData {
func buildInitData(source, target *expr.AttributeExpr, sourceVar, targetVar string, svcCtx *codegen.AttributeContext, proto, _, usesrc bool, sd *ServiceData) *InitData {
var (
name string
isStruct bool
Expand Down
4 changes: 2 additions & 2 deletions grpc/middleware/xray/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,15 @@ func (cs *mockClientStream) Header() (metadata.MD, error) {
return nil, cs.err
}

func (cs *mockClientStream) SendMsg(m any) error {
func (cs *mockClientStream) SendMsg(_ any) error {
return cs.err
}

func (cs *mockClientStream) CloseSend() error {
return cs.err
}

func (cs *mockClientStream) RecvMsg(m any) error {
func (cs *mockClientStream) RecvMsg(_ any) error {
return cs.err
}

Expand Down
2 changes: 1 addition & 1 deletion http/codegen/openapi/v2/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func itemsFromExpr(at *expr.AttributeExpr) *Items {
return items
}

func responseSpecFromExpr(s *V2, root *expr.RootExpr, r *expr.HTTPResponseExpr, typeNamePrefix string) *Response {
func responseSpecFromExpr(_ *V2, root *expr.RootExpr, r *expr.HTTPResponseExpr, typeNamePrefix string) *Response {
var schema *openapi.Schema
if mt, ok := r.Body.Type.(*expr.ResultTypeExpr); ok {
view := expr.DefaultView
Expand Down
13 changes: 6 additions & 7 deletions http/codegen/server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,22 @@ func ServerTypeFiles(genpkg string, root *expr.RootExpr) []*codegen.File {
// slices, maps or objects always use pointers either implicitly - slices and
// maps - or explicitly - objects.
//
// * The payload struct fields (if a struct) hold pointers when not required
// - The payload struct fields (if a struct) hold pointers when not required
// and have no default value.
//
// * Request body fields (if the body is a struct) always hold pointers to
// - Request body fields (if the body is a struct) always hold pointers to
// allow for explicit validation.
//
// * Request header, path and query string parameter variables hold pointers
// - Request header, path and query string parameter variables hold pointers
// when not required. Request header, body fields and param variables that
// have default values are never required (enforced by DSL engine).
//
// * The result struct fields (if a struct) hold pointers when not required
// - The result struct fields (if a struct) hold pointers when not required
// or have a default value (so generated code can set when null)
//
// * Response body fields (if the body is a struct) and header variables hold
// - Response body fields (if the body is a struct) and header variables hold
// pointers when not required and have no default value.
//
func serverType(genpkg string, svc *expr.HTTPServiceExpr, seen map[string]struct{}) *codegen.File {
func serverType(genpkg string, svc *expr.HTTPServiceExpr, _ map[string]struct{}) *codegen.File {
var (
path string
data = HTTPServices.Get(svc.Name())
Expand Down
Loading