Skip to content

Commit

Permalink
Fix/ignore lint violations
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Nov 27, 2023
1 parent 062ab07 commit e2684ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions client/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (b *clientFactory) SDKClient(c *cli.Context, namespace string) sdkclient.Cl

func newPayloadCodecGRPCClientInterceptor(c *cli.Context, codecEndpoint string) (grpc.UnaryClientInterceptor, error) {
namespace := c.String(common.FlagNamespace)
auth := c.String(common.FlagCodecAuth)
codecAuth := c.String(common.FlagCodecAuth)
codecEndpoint = strings.ReplaceAll(codecEndpoint, "{namespace}", namespace)

payloadCodec := converter.NewRemoteDataConverter(
Expand All @@ -163,8 +163,8 @@ func newPayloadCodecGRPCClientInterceptor(c *cli.Context, codecEndpoint string)
Endpoint: codecEndpoint,
ModifyRequest: func(req *http.Request) error {
req.Header.Set("X-Namespace", namespace)
if auth != "" {
req.Header.Set("Authorization", auth)
if codecAuth != "" {
req.Header.Set("Authorization", codecAuth)
}

return nil
Expand Down
7 changes: 5 additions & 2 deletions common/stringify/stringify.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (
maxWordLength = 120 // if text length is larger than maxWordLength, it will be inserted spaces
)

//revive:disable:cognitive-complexity
//revive:disable:cyclomatic
func AnyToString(val interface{}, printFully bool, maxFieldLength int) string {

Check failure on line 25 in common/stringify/stringify.go

View workflow job for this annotation

GitHub Actions / golangci-lint

flag-parameter: parameter 'printFully' seems to be a control flag, avoid control coupling (revive)
dc := converter.GetDefaultDataConverter()
v := reflect.ValueOf(val)
Expand Down Expand Up @@ -169,17 +171,18 @@ func AnyToString(val interface{}, printFully bool, maxFieldLength int) string {
}
}

//revive:disable:flag-parameter
func sliceToString(slice reflect.Value, printFully bool, maxFieldLength int) string {
var b strings.Builder
b.WriteRune('[')
for i := 0; i < slice.Len(); i++ {
if i == 0 || printFully {
b.WriteString(AnyToString(slice.Index(i).Interface(), printFully, maxFieldLength))
_, _ = b.WriteString(AnyToString(slice.Index(i).Interface(), printFully, maxFieldLength))
if i < slice.Len()-1 {
b.WriteRune(',')
}
if !printFully && slice.Len() > 1 {
b.WriteString(fmt.Sprintf("...%d more]", slice.Len()-1))
_, _ = b.WriteString(fmt.Sprintf("...%d more]", slice.Len()-1))
return b.String()
}
}
Expand Down

0 comments on commit e2684ff

Please sign in to comment.