Skip to content
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
5 changes: 1 addition & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:

permissions:
contents: read
pull-requests: read

jobs:
golangci:
Expand All @@ -21,6 +20,4 @@ jobs:
with:
go-version: 1.23.x
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
only-new-issues: ${{ github.event_name == 'pull_request' && 'true' || 'false' }}
uses: golangci/golangci-lint-action@v7
92 changes: 64 additions & 28 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,71 @@
issues:
exclude-dirs:
- docs
max-issues-per-linter: 0
max-same-issues: 0
version: "2"
run:
issues-exit-code: 1
tests: false
linters:
enable:
- asciicheck
- bidichk
- bodyclose
- contextcheck
- copyloopvar
- durationcheck
- errchkjson
- errorlint
- exhaustive
- fatcontext
- gocheckcompilerdirectives
- gochecksumtype
- gomodguard
- gosec
- gosmopolitan
- loggercheck
- makezero
- musttag
- nilerr
- nilnesserr
- noctx
- perfsprint
- prealloc
- protogetter
- reassign
- rowserrcheck
- spancheck
- sqlclosecheck
- testifylint
- usestdlibvars
- whitespace
- zerologlint
disable:
- asasalint
- depguard
- recvcheck
- unparam
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- docs
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
# Defaults above ours below
- copyloopvar
- usestdlibvars
- whitespace
presets:
- bugs
- format
- import
- performance
- unused
#linters-settings:
# errcheck:
# check-type-assertions: true
run:
issues-exit-code: 1
tests: false
timeout: 10m
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- docs
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion cbor/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (r *Rat) UnmarshalCBOR(cborData []byte) error {
}
// Create new big.Rat with num/denom set to big.Int values above
r.Rat = new(big.Rat)
r.Rat.SetFrac(tmpNum, tmpDenom)
r.SetFrac(tmpNum, tmpDenom)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/gouroboros/chainsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func chainSyncRollForwardHandler(
blockHash := v.Hash().Bytes()
var err error
if oConn == nil {
return errors.New("empty ouroboros connection, aborting!")
return errors.New("empty ouroboros connection, aborting")
}
block, err = oConn.BlockFetch().Client.GetBlock(common.NewPoint(blockSlot, blockHash))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (c *Connection) setupConnection() error {
// Check network magic value
if c.networkMagic == 0 {
return fmt.Errorf(
"invalid network magic value provided: %d\n",
"invalid network magic value provided: %d",
c.networkMagic,
)
}
Expand Down
8 changes: 4 additions & 4 deletions ledger/allegra/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,15 @@ func (t *AllegraTransaction) Cbor() []byte {
func NewAllegraBlockFromCbor(data []byte) (*AllegraBlock, error) {
var allegraBlock AllegraBlock
if _, err := cbor.Decode(data, &allegraBlock); err != nil {
return nil, fmt.Errorf("Allegra block decode error: %w", err)
return nil, fmt.Errorf("decode Allegra block error: %w", err)
}
return &allegraBlock, nil
}

func NewAllegraBlockHeaderFromCbor(data []byte) (*AllegraBlockHeader, error) {
var allegraBlockHeader AllegraBlockHeader
if _, err := cbor.Decode(data, &allegraBlockHeader); err != nil {
return nil, fmt.Errorf("Allegra block header decode error: %w", err)
return nil, fmt.Errorf("decode Allegra block header error: %w", err)
}
return &allegraBlockHeader, nil
}
Expand All @@ -344,15 +344,15 @@ func NewAllegraTransactionBodyFromCbor(
) (*AllegraTransactionBody, error) {
var allegraTx AllegraTransactionBody
if _, err := cbor.Decode(data, &allegraTx); err != nil {
return nil, fmt.Errorf("Allegra transaction body decode error: %w", err)
return nil, fmt.Errorf("decode Allegra transaction body error: %w", err)
}
return &allegraTx, nil
}

func NewAllegraTransactionFromCbor(data []byte) (*AllegraTransaction, error) {
var allegraTx AllegraTransaction
if _, err := cbor.Decode(data, &allegraTx); err != nil {
return nil, fmt.Errorf("Allegra transaction decode error: %w", err)
return nil, fmt.Errorf("decode Allegra transaction error: %w", err)
}
return &allegraTx, nil
}
10 changes: 5 additions & 5 deletions ledger/alonzo/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,15 @@ func (t *AlonzoTransaction) Utxorpc() *utxorpc.Tx {
func NewAlonzoBlockFromCbor(data []byte) (*AlonzoBlock, error) {
var alonzoBlock AlonzoBlock
if _, err := cbor.Decode(data, &alonzoBlock); err != nil {
return nil, fmt.Errorf("Alonzo block decode error: %w", err)
return nil, fmt.Errorf("decode Alonzo block error: %w", err)
}
return &alonzoBlock, nil
}

func NewAlonzoBlockHeaderFromCbor(data []byte) (*AlonzoBlockHeader, error) {
var alonzoBlockHeader AlonzoBlockHeader
if _, err := cbor.Decode(data, &alonzoBlockHeader); err != nil {
return nil, fmt.Errorf("Alonzo block header decode error: %w", err)
return nil, fmt.Errorf("decode Alonzo block header error: %w", err)
}
return &alonzoBlockHeader, nil
}
Expand All @@ -546,15 +546,15 @@ func NewAlonzoTransactionBodyFromCbor(
) (*AlonzoTransactionBody, error) {
var alonzoTx AlonzoTransactionBody
if _, err := cbor.Decode(data, &alonzoTx); err != nil {
return nil, fmt.Errorf("Alonzo transaction body decode error: %w", err)
return nil, fmt.Errorf("decode Alonzo transaction body error: %w", err)
}
return &alonzoTx, nil
}

func NewAlonzoTransactionFromCbor(data []byte) (*AlonzoTransaction, error) {
var alonzoTx AlonzoTransaction
if _, err := cbor.Decode(data, &alonzoTx); err != nil {
return nil, fmt.Errorf("Alonzo transaction decode error: %w", err)
return nil, fmt.Errorf("decode Alonzo transaction error: %w", err)
}
return &alonzoTx, nil
}
Expand All @@ -565,7 +565,7 @@ func NewAlonzoTransactionOutputFromCbor(
var alonzoTxOutput AlonzoTransactionOutput
if _, err := cbor.Decode(data, &alonzoTxOutput); err != nil {
return nil, fmt.Errorf(
"Alonzo transaction output decode error: %w",
"decode Alonzo transaction output error: %w",
err,
)
}
Expand Down
10 changes: 5 additions & 5 deletions ledger/babbage/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,15 +684,15 @@ func (t *BabbageTransaction) Utxorpc() *utxorpc.Tx {
func NewBabbageBlockFromCbor(data []byte) (*BabbageBlock, error) {
var babbageBlock BabbageBlock
if _, err := cbor.Decode(data, &babbageBlock); err != nil {
return nil, fmt.Errorf("Babbage block decode error: %w", err)
return nil, fmt.Errorf("decode Babbage block error: %w", err)
}
return &babbageBlock, nil
}

func NewBabbageBlockHeaderFromCbor(data []byte) (*BabbageBlockHeader, error) {
var babbageBlockHeader BabbageBlockHeader
if _, err := cbor.Decode(data, &babbageBlockHeader); err != nil {
return nil, fmt.Errorf("Babbage block header decode error: %w", err)
return nil, fmt.Errorf("decode Babbage block header error: %w", err)
}
return &babbageBlockHeader, nil
}
Expand All @@ -702,15 +702,15 @@ func NewBabbageTransactionBodyFromCbor(
) (*BabbageTransactionBody, error) {
var babbageTx BabbageTransactionBody
if _, err := cbor.Decode(data, &babbageTx); err != nil {
return nil, fmt.Errorf("Babbage transaction body decode error: %w", err)
return nil, fmt.Errorf("decode Babbage transaction body error: %w", err)
}
return &babbageTx, nil
}

func NewBabbageTransactionFromCbor(data []byte) (*BabbageTransaction, error) {
var babbageTx BabbageTransaction
if _, err := cbor.Decode(data, &babbageTx); err != nil {
return nil, fmt.Errorf("Babbage transaction decode error: %w", err)
return nil, fmt.Errorf("decode Babbage transaction error: %w", err)
}
return &babbageTx, nil
}
Expand All @@ -721,7 +721,7 @@ func NewBabbageTransactionOutputFromCbor(
var babbageTxOutput BabbageTransactionOutput
if _, err := cbor.Decode(data, &babbageTxOutput); err != nil {
return nil, fmt.Errorf(
"Babbage transaction output decode error: %w",
"decode Babbage transaction output error: %w",
err,
)
}
Expand Down
10 changes: 5 additions & 5 deletions ledger/byron/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ func NewByronEpochBoundaryBlockFromCbor(
) (*ByronEpochBoundaryBlock, error) {
var byronEbbBlock ByronEpochBoundaryBlock
if _, err := cbor.Decode(data, &byronEbbBlock); err != nil {
return nil, fmt.Errorf("Byron EBB block decode error: %w", err)
return nil, fmt.Errorf("decode Byron EBB block error: %w", err)
}
return &byronEbbBlock, nil
}
Expand All @@ -693,15 +693,15 @@ func NewByronEpochBoundaryBlockHeaderFromCbor(
) (*ByronEpochBoundaryBlockHeader, error) {
var byronEbbBlockHeader ByronEpochBoundaryBlockHeader
if _, err := cbor.Decode(data, &byronEbbBlockHeader); err != nil {
return nil, fmt.Errorf("Byron EBB block header decode error: %w", err)
return nil, fmt.Errorf("decode Byron EBB block header error: %w", err)
}
return &byronEbbBlockHeader, nil
}

func NewByronMainBlockFromCbor(data []byte) (*ByronMainBlock, error) {
var byronMainBlock ByronMainBlock
if _, err := cbor.Decode(data, &byronMainBlock); err != nil {
return nil, fmt.Errorf("Byron main block decode error: %w", err)
return nil, fmt.Errorf("decode Byron main block error: %w", err)
}
return &byronMainBlock, nil
}
Expand All @@ -711,15 +711,15 @@ func NewByronMainBlockHeaderFromCbor(
) (*ByronMainBlockHeader, error) {
var byronMainBlockHeader ByronMainBlockHeader
if _, err := cbor.Decode(data, &byronMainBlockHeader); err != nil {
return nil, fmt.Errorf("Byron main block header decode error: %w", err)
return nil, fmt.Errorf("decode Byron main block header error: %w", err)
}
return &byronMainBlockHeader, nil
}

func NewByronTransactionFromCbor(data []byte) (*ByronTransaction, error) {
var byronTx ByronTransaction
if _, err := cbor.Decode(data, &byronTx); err != nil {
return nil, fmt.Errorf("Byron transaction decode error: %w", err)
return nil, fmt.Errorf("decode Byron transaction error: %w", err)
}
return &byronTx, nil
}
19 changes: 8 additions & 11 deletions ledger/common/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,12 @@ func (a Address) ByronType() uint64 {
// PaymentAddress returns a new Address with only the payment address portion. This will return nil for anything other than payment and script addresses
func (a Address) PaymentAddress() *Address {
var addrType uint8
if a.addressType == AddressTypeKeyKey ||
a.addressType == AddressTypeKeyNone {
switch a.addressType {
case AddressTypeKeyKey, AddressTypeKeyNone:
addrType = AddressTypeKeyNone
} else if a.addressType == AddressTypeScriptKey ||
a.addressType == AddressTypeScriptNone ||
a.addressType == AddressTypeScriptScript {
case AddressTypeScriptKey, AddressTypeScriptNone, AddressTypeScriptScript:
addrType = AddressTypeScriptNone
} else {
default:
// Unsupported address type
return nil
}
Expand All @@ -332,13 +330,12 @@ func (a *Address) PaymentKeyHash() Blake2b224 {
// StakeAddress returns a new Address with only the stake key portion. This will return nil if the address is not a payment/staking key pair
func (a Address) StakeAddress() *Address {
var addrType uint8
if a.addressType == AddressTypeKeyKey ||
a.addressType == AddressTypeScriptKey {
switch a.addressType {
case AddressTypeKeyKey, AddressTypeScriptKey:
addrType = AddressTypeNoneKey
} else if a.addressType == AddressTypeScriptScript ||
a.addressType == AddressTypeNoneScript {
case AddressTypeScriptScript, AddressTypeNoneScript:
addrType = AddressTypeNoneScript
} else {
default:
// Unsupported address type
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion ledger/common/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type GenesisRat struct {

func (r *GenesisRat) UnmarshalJSON(data []byte) error {
r.Rat = new(big.Rat)
if _, ok := r.Rat.SetString(string(data)); !ok {
if _, ok := r.SetString(string(data)); !ok {
return fmt.Errorf("math/big: cannot unmarshal %q into a *big.Rat", data)
}
return nil
Expand Down
8 changes: 4 additions & 4 deletions ledger/conway/conway.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,15 @@ func (t *ConwayTransaction) Utxorpc() *utxorpc.Tx {
func NewConwayBlockFromCbor(data []byte) (*ConwayBlock, error) {
var conwayBlock ConwayBlock
if _, err := cbor.Decode(data, &conwayBlock); err != nil {
return nil, fmt.Errorf("Conway block decode error: %w", err)
return nil, fmt.Errorf("decode Conway block error: %w", err)
}
return &conwayBlock, nil
}

func NewConwayBlockHeaderFromCbor(data []byte) (*ConwayBlockHeader, error) {
var conwayBlockHeader ConwayBlockHeader
if _, err := cbor.Decode(data, &conwayBlockHeader); err != nil {
return nil, fmt.Errorf("Conway block header decode error: %w", err)
return nil, fmt.Errorf("decode Conway block header error: %w", err)
}
return &conwayBlockHeader, nil
}
Expand All @@ -508,15 +508,15 @@ func NewConwayTransactionBodyFromCbor(
) (*ConwayTransactionBody, error) {
var conwayTx ConwayTransactionBody
if _, err := cbor.Decode(data, &conwayTx); err != nil {
return nil, fmt.Errorf("Conway transaction body decode error: %w", err)
return nil, fmt.Errorf("decode Conway transaction body error: %w", err)
}
return &conwayTx, nil
}

func NewConwayTransactionFromCbor(data []byte) (*ConwayTransaction, error) {
var conwayTx ConwayTransaction
if _, err := cbor.Decode(data, &conwayTx); err != nil {
return nil, fmt.Errorf("Conway transaction decode error: %w", err)
return nil, fmt.Errorf("decode Conway transaction error: %w", err)
}
return &conwayTx, nil
}
Loading
Loading