Skip to content

Commit

Permalink
Adapt .golangci.yml to latest version and fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Mar 20, 2024
1 parent 646f949 commit c5a4aae
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 31 deletions.
76 changes: 51 additions & 25 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ linters-settings:
simplify: true
goimports:
local-prefixes: github.com/iotaledger
golint:
min-confidence: 0.9
gocyclo:
min-complexity: 15
govet:
check-shadowing: false
disable:
- shadow
misspell:
locale: US
nlreturn:
# Size of the block (including return statement that is still "OK")
# so no return split required.
# Default: 1
block-size: 2
staticcheck:
checks: ["all"]
nlreturn:
block-size: 2
stylecheck:
initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"]
depguard:
Expand All @@ -39,74 +35,99 @@ linters:
disable-all: true
# Enable specific linter
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- varcheck
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
#- containedctx
#- contextcheck # this linter is buggy and renders all nolint rules useless
- copyloopvar
#- cyclop
- decorder
#- depguard
- depguard
- dogsled
- dupl
- dupword
- durationcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
#- exhaustive
#- exhaustruct
- exportloopref
#- forbidigo
- forcetypeassert
#- funlen
#- gci
- ginkgolinter
- gocheckcompilerdirectives
#- gochecknoglobals
#- gochecknoinits
#- gochecksumtype
#- gocognit
- goconst
- gocritic
#- gocyclo
- godot
- godox
#- goerr113
- goerr113
- gofmt
#- gofumpt
- goheader
- goimports
- golint
#- gomnd
- gomoddirectives
#- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosmopolitan
- grouper
- ifshort
- importas
- interfacer
- inamedparam
#- interfacebloat
- intrange
#- ireturn
#- lll
- loggercheck
#- maintidx
- makezero
- maligned
- mirror
- misspell
- musttag
- nakedret
#- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
#- nonamedreturns
- nosnakecase
- nosprintfhostport
- paralleltest
#- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- scopelint
- sloglint
- spancheck
- sqlclosecheck
- structcheck
- stylecheck
#- tagalign
- tagliatelle
- tenv
- testableexamples
- testifylint
- testpackage
- thelper
- tparallel
Expand All @@ -115,8 +136,14 @@ linters:
- usestdlibvars
#- varnamelen
- wastedassign
- whitespace
#- wrapcheck
#- wsl
- zerologlint

issues:
exclude-files:
- ".*_test.go$"
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
Expand Down Expand Up @@ -144,4 +171,3 @@ issues:
# - "blank-imports" # revive
# - "var-naming: don't use leading k in Go names;" #revive
# - 'shadow: declaration of "err"' # govet

5 changes: 1 addition & 4 deletions pkg/nodebridge/ledger.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//nolint:nosnakecase // grpc uses underscores
package nodebridge

import (
Expand Down Expand Up @@ -52,10 +51,8 @@ func (n *nodeBridge) ListenToLedgerUpdates(ctx context.Context, startSlot, endSl
var latestCommitmentID iotago.CommitmentID
if err := ListenToStream(ctx, stream.Recv, func(payload *inx.LedgerUpdate) error {
switch op := payload.GetOp().(type) {

case *inx.LedgerUpdate_BatchMarker:
switch op.BatchMarker.GetMarkerType() {

case inx.LedgerUpdate_Marker_BEGIN:
commitmentID := op.BatchMarker.GetCommitmentId().Unwrap()
n.LogDebugf("BEGIN batch: commitmentID: %s, consumed: %d, created: %d", commitmentID, op.BatchMarker.GetConsumedCount(), op.BatchMarker.GetCreatedCount())
Expand Down Expand Up @@ -169,7 +166,7 @@ func (n *nodeBridge) ListenToAcceptedTransactions(ctx context.Context, consumer
return consumer(&AcceptedTransaction{
API: n.apiProvider.APIForSlot(slot),
Slot: slot,
TransactionID: tx.TransactionId.Unwrap(),
TransactionID: tx.GetTransactionId().Unwrap(),
Consumed: consumed,
Created: created,
})
Expand Down
1 change: 0 additions & 1 deletion pkg/nodebridge/node_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ func (n *nodeBridge) getPluginClient(ctx context.Context, clientInitHook func(ct
}

return notAvailableError

}

// Management returns the ManagementClient.
Expand Down
1 change: 0 additions & 1 deletion pkg/nodebridge/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func (n *nodeBridge) listenToNodeStatus(ctx context.Context) error {
}

func (n *nodeBridge) processNodeStatus(nodeStatus *inx.NodeStatus) error {

var latestCommitment *Commitment
var latestCommitmentChanged bool

Expand Down

0 comments on commit c5a4aae

Please sign in to comment.