Skip to content

Commit

Permalink
fix: lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryQW committed Apr 20, 2024
1 parent b95ce9b commit bc62849
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ linters-settings:
- shadow
- fieldalignment
gocognit:
min-complexity: 30
min-complexity: 20
gocyclo:
min-complexity: 30
min-complexity: 20
gocritic:
disabled-tags: ["opinionated", "experimental"]
4 changes: 3 additions & 1 deletion internal/database/dialer/cockroachdb/client_billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ func (c *client) PrepareBillingCollectTokens(ctx context.Context, nowTime time.T
err = tx.Where("consumption_date = ? AND key_id = ?", nowTime, k.ID).
First(&possibleExistLog).
Error

if err != nil {
// nolint: gocritic
if errors.Is(err, gorm.ErrRecordNotFound) {
// Fine, let's create it
err = tx.Create(&table.GatewayConsumptionLog{
Expand All @@ -81,7 +83,7 @@ func (c *client) PrepareBillingCollectTokens(ctx context.Context, nowTime time.T
APICalls: k.APICallsCurrent,
}).Error
} else {
// Error happens, but we don't know what's this, create a new record for now.
// TODO: Error happens, but we don't know what's this, create a new record for now.
err = tx.Create(&table.GatewayConsumptionLog{
KeyID: k.ID,
ConsumptionDate: nowTime,
Expand Down
4 changes: 2 additions & 2 deletions internal/service/hub/model/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func KeyCreate(ctx context.Context, accountAddress common.Address, keyName strin
return &Key{k, databaseClient, controlClient}, nil
}

func KeyGetByID(ctx context.Context, KeyID uint64, activeOnly bool, databaseClient *gorm.DB, controlClient *control.StateClientWriter) (*Key, bool, error) {
func KeyGetByID(ctx context.Context, keyID uint64, activeOnly bool, databaseClient *gorm.DB, controlClient *control.StateClientWriter) (*Key, bool, error) {
queryBase := databaseClient.WithContext(ctx).Model(&table.GatewayKey{})

if activeOnly {
Expand All @@ -59,7 +59,7 @@ func KeyGetByID(ctx context.Context, KeyID uint64, activeOnly bool, databaseClie

var k table.GatewayKey

if err := queryBase.Where("id = ?", KeyID).First(&k).Error; err != nil {
if err := queryBase.Where("id = ?", keyID).First(&k).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, false, nil
}
Expand Down
6 changes: 3 additions & 3 deletions internal/service/hub/swagger/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ import (

type Opts func(*config)

//func SetSwaggerHost(host string) Opts {
// func SetSwaggerHost(host string) Opts {
// return func(o *config) {
// o.SwaggerHost = host
// }
//}
//
//func SetSwaggerAuthorizer(f func(*http.Request) bool) Opts {
// func SetSwaggerAuthorizer(f func(*http.Request) bool) Opts {
// return func(o *config) {
// o.Authorizer = f
// }
//}
//
//func SetSwaggerIsHTTPS(b bool) Opts {
// func SetSwaggerIsHTTPS(b bool) Opts {
// return func(o *config) {
// o.IsHTTPS = b
// }
Expand Down
7 changes: 4 additions & 3 deletions internal/service/indexer/l2/report_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ func (s *server) sendNotificationMessage(txErr error, txHash string, txFunc stri
// Send base information
var errReason string

if errors.Is(txErr, errors.New("transaction failed")) {
switch {
case errors.Is(txErr, errors.New("transaction failed")):
errReason = "Failed"
} else if errors.Is(txErr, context.DeadlineExceeded) {
case errors.Is(txErr, context.DeadlineExceeded):
errReason = "Timeout (/!\\ doesn't mean it failed)"
} else {
default:
// Unknown error
errReason = txErr.Error()
}
Expand Down

0 comments on commit bc62849

Please sign in to comment.