Skip to content

Commit 6d2a112

Browse files
authored
chore(golangci-lint): enable format, import, and unused presets; disable depguard (#950)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent fb666cf commit 6d2a112

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+238
-213
lines changed

.golangci.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ issues:
44
max-issues-per-linter: 0
55
max-same-issues: 0
66
linters:
7+
disable:
8+
- asasalint
9+
- depguard
10+
- recvcheck
11+
- unparam
712
enable:
813
- errcheck
914
- gosimple
@@ -12,12 +17,15 @@ linters:
1217
- staticcheck
1318
- unused
1419
# Defaults above ours below
15-
disable:
16-
- asasalint
17-
- recvcheck
20+
- copyloopvar
21+
- usestdlibvars
22+
- whitespace
1823
presets:
1924
- bugs
25+
- format
26+
- import
2027
- performance
28+
- unused
2129
#linters-settings:
2230
# errcheck:
2331
# check-type-assertions: true

cbor/cbor.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ const (
3636
type RawMessage = _cbor.RawMessage
3737

3838
// Alias for Tag for convenience
39-
type Tag = _cbor.Tag
40-
type RawTag = _cbor.RawTag
39+
type (
40+
Tag = _cbor.Tag
41+
RawTag = _cbor.RawTag
42+
)
4143

4244
// Useful for embedding and easier to remember
4345
type StructAsArray struct {

cbor/decode.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ func DecodeById(
115115
return ret, nil
116116
}
117117

118-
var decodeGenericTypeCache = map[reflect.Type]reflect.Type{}
119-
var decodeGenericTypeCacheMutex sync.RWMutex
118+
var (
119+
decodeGenericTypeCache = map[reflect.Type]reflect.Type{}
120+
decodeGenericTypeCacheMutex sync.RWMutex
121+
)
120122

121123
// DecodeGeneric decodes the specified CBOR into the destination object without using the
122124
// destination object's UnmarshalCBOR() function

cbor/encode.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ func Encode(data interface{}) ([]byte, error) {
3939
return buf.Bytes(), err
4040
}
4141

42-
var encodeGenericTypeCache = map[reflect.Type]reflect.Type{}
43-
var encodeGenericTypeCacheMutex sync.RWMutex
42+
var (
43+
encodeGenericTypeCache = map[reflect.Type]reflect.Type{}
44+
encodeGenericTypeCacheMutex sync.RWMutex
45+
)
4446

4547
// EncodeGeneric encodes the specified object to CBOR without using the source object's
4648
// MarshalCBOR() function

cbor/value.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ func generateAstJsonMap[T map[any]any | Map](v T) ([]byte, error) {
248248
strings.Join(tmpItems, ","),
249249
)
250250
return []byte(tmpJson), nil
251-
252251
}
253252

254253
type Constructor struct {

cmd/gouroboros/mem_usage.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ import (
1919
"fmt"
2020
"log"
2121
"net/http"
22+
// #nosec G108
23+
_ "net/http/pprof"
2224
"os"
2325
"runtime"
2426
"runtime/pprof"
2527
"time"
2628

27-
// #nosec G108
28-
_ "net/http/pprof"
29-
3029
ouroboros "github.com/blinklabs-io/gouroboros"
3130
)
3231

cmd/gouroboros/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ import (
2626

2727
type serverFlags struct {
2828
flagset *flag.FlagSet
29-
//txFile string
29+
// txFile string
3030
}
3131

3232
func newServerFlags() *serverFlags {
3333
f := &serverFlags{
3434
flagset: flag.NewFlagSet("server", flag.ExitOnError),
3535
}
36-
//f.flagset.StringVar(&f.txFile, "tx-file", "", "path to the transaction file to submit")
36+
// f.flagset.StringVar(&f.txFile, "tx-file", "", "path to the transaction file to submit")
3737
return f
3838
}
3939

cmd/tx-submission/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ type txSubmissionFlags struct {
3333
rawTxFile string
3434
}
3535

36-
var txBytes []byte
37-
var txHash [32]byte
38-
var sentTx bool
39-
var doneChan chan any
36+
var (
37+
txBytes []byte
38+
txHash [32]byte
39+
sentTx bool
40+
doneChan chan any
41+
)
4042

4143
func main() {
4244
// Parse commandline

ledger/allegra.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ import "github.com/blinklabs-io/gouroboros/ledger/allegra"
2020
// to keep existing code working after a refactor of the ledger package
2121

2222
// Allegra types
23-
type AllegraBlock = allegra.AllegraBlock
24-
type AllegraTransaction = allegra.AllegraTransaction
25-
type AllegraTransactionBody = allegra.AllegraTransactionBody
26-
type AllegraProtocolParameters = allegra.AllegraProtocolParameters
27-
type AllegraProtocolParameterUpdate = allegra.AllegraProtocolParameterUpdate
23+
type (
24+
AllegraBlock = allegra.AllegraBlock
25+
AllegraTransaction = allegra.AllegraTransaction
26+
AllegraTransactionBody = allegra.AllegraTransactionBody
27+
AllegraProtocolParameters = allegra.AllegraProtocolParameters
28+
AllegraProtocolParameterUpdate = allegra.AllegraProtocolParameterUpdate
29+
)
2830

2931
// Allegra constants
3032
const (

ledger/allegra/allegra.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/blinklabs-io/gouroboros/cbor"
2222
"github.com/blinklabs-io/gouroboros/ledger/common"
2323
"github.com/blinklabs-io/gouroboros/ledger/shelley"
24-
2524
utxorpc "github.com/utxorpc/go-codegen/utxorpc/v1alpha/cardano"
2625
)
2726

@@ -36,12 +35,10 @@ const (
3635
TxTypeAllegra = 2
3736
)
3837

39-
var (
40-
EraAllegra = common.Era{
41-
Id: EraIdAllegra,
42-
Name: EraNameAllegra,
43-
}
44-
)
38+
var EraAllegra = common.Era{
39+
Id: EraIdAllegra,
40+
Name: EraNameAllegra,
41+
}
4542

4643
func init() {
4744
common.RegisterEra(EraAllegra)

0 commit comments

Comments
 (0)