Fix linter issues

This commit is contained in:
Christian Schaible 2024-07-15 12:16:44 +02:00
parent a509aae2a6
commit 85f07ec14a
5 changed files with 12 additions and 19 deletions

View file

@ -144,7 +144,7 @@ buf generate --include-imports
##### Build library
```bash
go mod download && go mod tidy && go get ./... && go fmt ./... && go vet ./... && go build ./... && go test ./...
go mod download && go mod tidy && go get ./... && go fmt ./... && go vet ./... && golangci-lint run && go build ./... && go test ./...
```
#### Register buf validation schema in IntelliJ / Goland

View file

@ -229,11 +229,9 @@ func (a *LegacyAuditApi) convertAndSerializeIntoLegacyFormat(
} else {
return nil, ErrUnsupportedObjectIdentifierType
}
break
case *auditV1.RoutableAuditEvent_ObjectName:
eventType = "SYSTEM_EVENT"
messageContext = nil
break
default:
return nil, ErrUnsupportedResourceReferenceType
}

View file

@ -410,15 +410,12 @@ func validateProtobufMessagePayload(
if objectIdentifier.Type == auditV1.ObjectType_OBJECT_TYPE_ORGANIZATION {
assert.Equal(t, routingIdentifier.Identifier.String(), reference.ObjectIdentifier.Identifier)
}
break
case RoutingIdentifierTypeProject:
assert.Equal(t, routingIdentifier.Identifier.String(), reference.ObjectIdentifier.Identifier)
assert.Equal(t, auditV1.ObjectType_OBJECT_TYPE_PROJECT, reference.ObjectIdentifier.Type)
break
default:
assert.Fail(t, "Routing identifier type not expected")
}
break
case *auditV1.RoutableAuditEvent_ObjectName:
assert.Nil(t, objectIdentifier)
assert.Nil(t, routingIdentifier)
@ -431,7 +428,6 @@ func validateProtobufMessagePayload(
switch data := routableAuditEvent.Data.(type) {
case *auditV1.RoutableAuditEvent_UnencryptedData:
assert.NoError(t, proto.Unmarshal(data.UnencryptedData.Data, &auditEvent))
break
default:
assert.Fail(t, "Encrypted data not expected")
}

View file

@ -131,7 +131,7 @@ func (a *AmqpMessagingApi) Send(ctx context.Context, topic string, data []byte,
}
// Drop the current sender, as it cannot connect to the broker anymore
slog.Error("message sender error, recreating", err)
slog.Error("message sender error, recreating", slog.Any("error", err))
err = a.resetConnection(ctx)
if err != nil {
@ -182,7 +182,7 @@ func (a *AmqpMessagingApi) resetConnection(ctx context.Context) error {
_ = (*a.session).Close(ctx)
err := a.connection.Close()
if err != nil {
slog.Error("failed to close message connection", err)
slog.Error("failed to close message connection", slog.Any("error", err))
}
return a.connect()

View file

@ -125,7 +125,8 @@ func (c SolaceContainer) QueueCreate(ctx context.Context, queueName string) erro
_, err := c.sempClient.RequestWithBody(
ctx,
"POST",
fmt.Sprintf("/config/msgVpns/default/queues"), queueConfig)
"/config/msgVpns/default/queues",
queueConfig)
return err
}
@ -220,7 +221,7 @@ func (c SolaceContainer) ValidateTopicName(topicSubscriptionTopicPattern string,
}
// Check topic name
allowedTopicCharacters, err := regexp.Compile("[0-9A-Za-z-.]+(?:/[0-9A-Za-z-.]+)+|[0-9A-Za-z-.]+")
allowedTopicCharacters, err := regexp.Compile(`[0-9A-Za-z-.]+(?:/[0-9A-Za-z-.]+)+|[0-9A-Za-z-.]+`)
if err != nil {
return err
}
@ -230,7 +231,7 @@ func (c SolaceContainer) ValidateTopicName(topicSubscriptionTopicPattern string,
// Check topic subscription topic pattern
allowedTopicSubscriptionCharacters, err := regexp.Compile(
"(?:(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\\*)(?:/(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\\*))+|(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\\*)|/>)|>")
`(?:(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\*)(?:/(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\*))+|(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\*)|/>)|>`)
if err != nil {
return err
}
@ -257,27 +258,25 @@ func (c SolaceContainer) ValidateTopicName(topicSubscriptionTopicPattern string,
case '*':
if name[i] == '/' {
expectedNextCharacter = '/'
nextError = errors.New(fmt.Sprintf("Invalid character '/' at index %d", i))
nextError = fmt.Errorf("invalid character '/' at index %d", i)
subscriptionIndex++
}
break
case '/':
if name[i] != '/' {
return errors.New(fmt.Sprintf("Expected character '/', got %c at index %d", name[i], i))
return fmt.Errorf("expected character '/', got %c at index %d", name[i], i)
}
subscriptionIndex++
break
case '>':
// everything is allowed
break
default:
if name[i] != topicSubscriptionTopicPattern[subscriptionIndex] {
return errors.New(fmt.Sprintf(
"Expected character %c, got %c at index %d",
return fmt.Errorf(
"expected character %c, got %c at index %d",
topicSubscriptionTopicPattern[subscriptionIndex],
name[i],
i,
))
)
} else {
subscriptionIndex++
}