From f6c83a3142ac4243219eede0d24586c66f1f4609 Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Fri, 21 Feb 2025 09:09:02 -0500 Subject: [PATCH] chore: configuration for golangci-lint Signed-off-by: Chris Gianelloni --- .golangci.yml | 18 ++++++++++++++++++ cmd/gouroboros/chainsync.go | 6 +++--- cmd/gouroboros/localtxsubmission.go | 4 ++-- cmd/gouroboros/mem_usage.go | 8 ++++++-- cmd/gouroboros/query.go | 2 +- cmd/gouroboros/server.go | 2 +- cmd/tx-submission/main.go | 6 +++--- ledger/conway/conway.go | 2 +- 8 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..b2552e04 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,18 @@ +issues: + exclude-dirs: + - docs + max-issues-per-linter: 0 + max-same-issues: 0 +linters: + enable: + - errcheck + - gosec + - gosimple + - govet + - ineffassign + - staticcheck + - unused +run: + issues-exit-code: 1 + tests: false + timeout: 10m diff --git a/cmd/gouroboros/chainsync.go b/cmd/gouroboros/chainsync.go index c7368f07..33f91153 100644 --- a/cmd/gouroboros/chainsync.go +++ b/cmd/gouroboros/chainsync.go @@ -1,4 +1,4 @@ -// Copyright 2024 Blink Labs Software +// Copyright 2025 Blink Labs Software // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -172,7 +172,7 @@ func testChainSync(f *globalFlags) { }() o, err := ouroboros.New( ouroboros.WithConnection(conn), - ouroboros.WithNetworkMagic(uint32(f.networkMagic)), + ouroboros.WithNetworkMagic(uint32(f.networkMagic)), // #nosec G115 ouroboros.WithErrorChan(errorChan), ouroboros.WithNodeToNode(f.ntnProto), ouroboros.WithKeepAlive(true), @@ -199,7 +199,7 @@ func testChainSync(f *globalFlags) { point = tip.Point } else if len(intersectPoint) > 0 { // Slot - slot := uint64(intersectPoint[0].(int)) + slot := uint64(intersectPoint[0].(int)) // #nosec G115 // Block hash hash, _ := hex.DecodeString(intersectPoint[1].(string)) point = common.NewPoint(slot, hash) diff --git a/cmd/gouroboros/localtxsubmission.go b/cmd/gouroboros/localtxsubmission.go index 591dc61c..c608e5f8 100644 --- a/cmd/gouroboros/localtxsubmission.go +++ b/cmd/gouroboros/localtxsubmission.go @@ -1,4 +1,4 @@ -// Copyright 2023 Blink Labs Software +// Copyright 2025 Blink Labs Software // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ func testLocalTxSubmission(f *globalFlags) { }() o, err := ouroboros.New( ouroboros.WithConnection(conn), - ouroboros.WithNetworkMagic(uint32(f.networkMagic)), + ouroboros.WithNetworkMagic(uint32(f.networkMagic)), // #nosec G115 ouroboros.WithErrorChan(errorChan), ouroboros.WithNodeToNode(f.ntnProto), ouroboros.WithKeepAlive(true), diff --git a/cmd/gouroboros/mem_usage.go b/cmd/gouroboros/mem_usage.go index 7bb760ca..e415cf8e 100644 --- a/cmd/gouroboros/mem_usage.go +++ b/cmd/gouroboros/mem_usage.go @@ -19,12 +19,14 @@ import ( "fmt" "log" "net/http" - _ "net/http/pprof" "os" "runtime" "runtime/pprof" "time" + // #nosec G108 + _ "net/http/pprof" + ouroboros "github.com/blinklabs-io/gouroboros" ) @@ -70,6 +72,8 @@ func testMemUsage(f *globalFlags) { ) go func() { log.Println( + // This is a test program, no timeouts + // #nosec G114 http.ListenAndServe( fmt.Sprintf(":%d", memUsageFlags.debugPort), nil, @@ -94,7 +98,7 @@ func testMemUsage(f *globalFlags) { }() o, err := ouroboros.New( ouroboros.WithConnection(conn), - ouroboros.WithNetworkMagic(uint32(f.networkMagic)), + ouroboros.WithNetworkMagic(uint32(f.networkMagic)), // #nosec G115 ouroboros.WithErrorChan(errorChan), ouroboros.WithNodeToNode(f.ntnProto), ouroboros.WithKeepAlive(true), diff --git a/cmd/gouroboros/query.go b/cmd/gouroboros/query.go index e61c3b01..7c980b10 100644 --- a/cmd/gouroboros/query.go +++ b/cmd/gouroboros/query.go @@ -66,7 +66,7 @@ func testQuery(f *globalFlags) { }() o, err := ouroboros.New( ouroboros.WithConnection(conn), - ouroboros.WithNetworkMagic(uint32(f.networkMagic)), + ouroboros.WithNetworkMagic(uint32(f.networkMagic)), // #nosec G115 ouroboros.WithErrorChan(errorChan), ouroboros.WithNodeToNode(f.ntnProto), ouroboros.WithKeepAlive(true), diff --git a/cmd/gouroboros/server.go b/cmd/gouroboros/server.go index cc6d20f0..2ca4b5b4 100644 --- a/cmd/gouroboros/server.go +++ b/cmd/gouroboros/server.go @@ -90,7 +90,7 @@ func testServer(f *globalFlags) { }() _, err = ouroboros.New( ouroboros.WithConnection(conn), - ouroboros.WithNetworkMagic(uint32(f.networkMagic)), + ouroboros.WithNetworkMagic(uint32(f.networkMagic)), // #nosec G115 ouroboros.WithErrorChan(errorChan), ouroboros.WithNodeToNode(f.ntnProto), ouroboros.WithServer(true), diff --git a/cmd/tx-submission/main.go b/cmd/tx-submission/main.go index 0fcc3887..000d5d9d 100644 --- a/cmd/tx-submission/main.go +++ b/cmd/tx-submission/main.go @@ -1,4 +1,4 @@ -// Copyright 2024 Blink Labs Software +// Copyright 2025 Blink Labs Software // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ func main() { }() o, err := ouroboros.New( ouroboros.WithConnection(conn), - ouroboros.WithNetworkMagic(uint32(f.NetworkMagic)), + ouroboros.WithNetworkMagic(uint32(f.NetworkMagic)), // #nosec G115 ouroboros.WithErrorChan(errorChan), ouroboros.WithNodeToNode(f.NtnProto), ouroboros.WithKeepAlive(true), @@ -164,7 +164,7 @@ func handleRequestTxIds( EraId: 5, TxId: txHash, }, - Size: uint32(len(txBytes)), + Size: uint32(len(txBytes)), // #nosec G115 }, } return ret, nil diff --git a/ledger/conway/conway.go b/ledger/conway/conway.go index 52c584d5..b5100ee9 100644 --- a/ledger/conway/conway.go +++ b/ledger/conway/conway.go @@ -203,7 +203,7 @@ func (r ConwayRedeemers) Indexes(tag common.RedeemerTag) []uint { func (r ConwayRedeemers) Value(index uint, tag common.RedeemerTag) (cbor.LazyValue, common.RedeemerExUnits) { redeemer, ok := r.Redeemers[ConwayRedeemerKey{ Tag: tag, - Index: uint32(index), + Index: uint32(index), // #nosec G115 }] if ok { return redeemer.Data, redeemer.ExUnits