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
39 changes: 37 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,41 @@ linters-settings:
- (*github.com/algorand/go-algorand/data/transactions/logic.OpStream).error
- (*github.com/algorand/go-algorand/data/transactions/logic.OpStream).warnf
- (*github.com/algorand/go-algorand/data/transactions/logic.OpStream).warn
govet:
settings:
printf:
# Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`).
# Default: []
funcs:
- (github.com/algorand/go-algorand/logging.Logger).Debugf
- (github.com/algorand/go-algorand/logging.Logger).Infof
- (github.com/algorand/go-algorand/logging.Logger).Warnf
- (github.com/algorand/go-algorand/logging.Logger).Errorf
- (github.com/algorand/go-algorand/logging.Logger).Fatalf
- (github.com/algorand/go-algorand/logging.Logger).Panicf
- (github.com/algorand/go-algorand/logging.Logger).Debugln
- (github.com/algorand/go-algorand/logging.Logger).Infoln
- (github.com/algorand/go-algorand/logging.Logger).Warnln
- (github.com/algorand/go-algorand/logging.Logger).Errorln
- (github.com/algorand/go-algorand/logging.Logger).Fatalln
- (github.com/algorand/go-algorand/logging.Logger).Panicln
- (github.com/algorand/go-algorand/logging.Logger).Debug
- (github.com/algorand/go-algorand/logging.Logger).Info
- (github.com/algorand/go-algorand/logging.Logger).Warn
- (github.com/algorand/go-algorand/logging.Logger).Error
- (github.com/algorand/go-algorand/logging.Logger).Fatal
- (github.com/algorand/go-algorand/logging.Logger).Panic
- (github.com/algorand/go-algorand/data/transactions/logic.OpStream).warnf
- (github.com/algorand/go-algorand/data/transactions/logic.OpStream).errorf
- (github.com/algorand/go-algorand/data/transactions/logic.OpStream).lineErrorf
- (github.com/algorand/go-algorand/cmd/goal/main).reportInfof
- (github.com/algorand/go-algorand/cmd/goal/main).reportInfoln
- (github.com/algorand/go-algorand/cmd/goal/main).reportWarnf
- (github.com/algorand/go-algorand/cmd/goal/main).reportWarnln
- (github.com/algorand/go-algorand/cmd/goal/main).reportWarnRawf
- (github.com/algorand/go-algorand/cmd/goal/main).reportWarnRawln
- (github.com/algorand/go-algorand/cmd/goal/main).reportErrorf
- (github.com/algorand/go-algorand/cmd/goal/main).reportErrorln

issues:
# Work our way back over time to be clean against all these
Expand Down Expand Up @@ -69,9 +104,9 @@ issues:
- path: _test\.go
linters:
- errcheck
- gofmt
# - gofmt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why disabled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they're actually being enabled.. this is an exclude list, so the linters being commented out here are the only ones that will run on test code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why comment them out instead of removing them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe @algojack set it up that way so it was more clear what linters were being run on tests — this way you can see that gofmt, govet, and revive are the linters we want to run on tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm ok with deleting comments, just wanted to make sure that we didn't accidentally forget to ignore that excluded path on any linters. If we keep comments we can see that we enabled them there on purpose vs just forgetting to exclude them. Doesn't matter much.

- gosimple
- govet
# - govet
- ineffassign
- misspell
- nolintlint
Expand Down
2 changes: 1 addition & 1 deletion agreement/cadaver.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (c *cadaver) trySetup() bool {
if c.out.bytesWritten >= c.fileSizeTarget {
err := c.out.Close()
if err != nil {
logging.Base().Warn("unable to close cadaver file : %v", err)
logging.Base().Warnf("unable to close cadaver file : %v", err)
}
err = os.Rename(c.filename(), c.filename()+".archive")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion daemon/algod/api/server/v2/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func (v2 *Handlers) AccountInformation(ctx echo.Context, address string, params
}
totalResults := record.TotalAssets + record.TotalAssetParams + record.TotalAppLocalStates + record.TotalAppParams
if totalResults > maxResults {
v2.Log.Info("MaxAccountAPIResults limit %d exceeded, total results %d", maxResults, totalResults)
v2.Log.Infof("MaxAccountAPIResults limit %d exceeded, total results %d", maxResults, totalResults)
extraData := map[string]interface{}{
"max-results": maxResults,
"total-assets-opted-in": record.TotalAssets,
Expand Down
2 changes: 1 addition & 1 deletion data/account/participationRegistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ func (db *participationDB) Flush(timeout time.Duration) error {
// Close attempts to flush with db.flushTimeout, then waits for the write queue for another db.flushTimeout.
func (db *participationDB) Close() {
if err := db.Flush(db.flushTimeout); err != nil {
db.log.Warnf("participationDB unhandled error during Close/Flush: %w", err)
db.log.Warnf("participationDB unhandled error during Close/Flush: %v", err)
}

db.store.Close()
Expand Down
2 changes: 1 addition & 1 deletion data/account/registeryDbOps.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (d deleteStateProofKeysOp) apply(db *participationDB) error {
})

if err != nil {
db.log.Warnf("participationDB unable to delete stateProof key: %w", err)
db.log.Warnf("participationDB unable to delete stateProof key: %v", err)
}
return err
}
Expand Down
6 changes: 3 additions & 3 deletions data/accountManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (manager *AccountManager) Keys(rnd basics.Round) (out []account.Participati
if part.OverlapsInterval(rnd, rnd) {
partRndSecrets, err := manager.registry.GetForRound(part.ParticipationID, rnd)
if err != nil {
manager.log.Warnf("error while loading round secrets from participation registry: %w", err)
manager.log.Warnf("error while loading round secrets from participation registry: %v", err)
continue
}
out = append(out, partRndSecrets)
Expand Down Expand Up @@ -198,7 +198,7 @@ func (manager *AccountManager) DeleteOldKeys(latestHdr bookkeeping.BlockHeader,

// Delete expired records from participation registry.
if err := manager.registry.DeleteExpired(latestHdr.Round, agreementProto); err != nil {
manager.log.Warnf("error while deleting expired records from participation registry: %w", err)
manager.log.Warnf("error while deleting expired records from participation registry: %v", err)
}
}

Expand All @@ -212,6 +212,6 @@ func (manager *AccountManager) Record(account basics.Address, round basics.Round
// This function updates a cache in the ParticipationRegistry, we must call Flush to persist the changes.
err := manager.registry.Record(account, round, participationType)
if err != nil {
manager.log.Warnf("node.Record: Account %v not able to record participation (%d) on round %d: %w", account, participationType, round, err)
manager.log.Warnf("node.Record: Account %v not able to record participation (%d) on round %d: %v", account, participationType, round, err)
}
}
2 changes: 1 addition & 1 deletion data/transactions/logic/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ func eval(program []byte, cx *EvalContext) (pass bool, err error) {
errstr += cx.Trace.String()
}
err = PanicError{x, errstr}
cx.EvalParams.log().Errorf("recovered panic in Eval: %w", err)
cx.EvalParams.log().Errorf("recovered panic in Eval: %v", err)
}
}()

Expand Down
2 changes: 1 addition & 1 deletion ledger/acctonline.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func (ao *onlineAccounts) onlineTotalsEx(rnd basics.Round) (basics.MicroAlgos, e

var roundOffsetError *RoundOffsetError
if !errors.As(err, &roundOffsetError) {
ao.log.Errorf("onlineTotalsImpl error: %w", err)
ao.log.Errorf("onlineTotalsImpl error: %v", err)
}

totalsOnline, err = ao.accountsq.lookupOnlineTotalsHistory(rnd)
Expand Down
2 changes: 1 addition & 1 deletion ledger/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (tr *trackerRegistry) commitSyncer(deferredCommits chan *deferredCommitCont
}
err := tr.commitRound(commit)
if err != nil {
tr.log.Warnf("Could not commit round: %w", err)
tr.log.Warnf("Could not commit round: %v", err)
}
case <-tr.ctx.Done():
// drain the pending commits queue:
Expand Down
2 changes: 1 addition & 1 deletion network/wsNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ func (wn *WebsocketNetwork) checkIncomingConnectionVariables(response http.Respo
response.WriteHeader(http.StatusPreconditionFailed)
n, err := response.Write([]byte("mismatching genesis ID"))
if err != nil {
wn.log.Warnf("ws failed to write mismatching genesis ID response '%s' : n = %d err = %v", n, err)
wn.log.Warnf("ws failed to write mismatching genesis ID response '%s' : n = %d err = %v", otherGenesisID, n, err)
}
return http.StatusPreconditionFailed
}
Expand Down
2 changes: 1 addition & 1 deletion network/wsPeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ func (wp *wsPeer) readLoop() {
case channel <- &Response{Topics: topics}:
// do nothing. writing was successful.
default:
wp.net.log.Warnf("wsPeer readLoop: channel blocked. Could not pass the response to the requester", wp.conn.RemoteAddr().String())
wp.net.log.Warn("wsPeer readLoop: channel blocked. Could not pass the response to the requester", wp.conn.RemoteAddr().String())
}
continue
case protocol.MsgDigestSkipTag:
Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ func (node *AlgorandFullNode) loadParticipationKeys() error {
renamedFileName := filepath.Join(fullname, ".old")
err = os.Rename(fullname, renamedFileName)
if err != nil {
node.log.Warn("loadParticipationKeys: failed to rename unsupported participation key file '%s' to '%s': %v", fullname, renamedFileName, err)
node.log.Warnf("loadParticipationKeys: failed to rename unsupported participation key file '%s' to '%s': %v", fullname, renamedFileName, err)
}
} else {
return fmt.Errorf("AlgorandFullNode.loadParticipationKeys: cannot load account at %v: %v", info.Name(), err)
Expand Down Expand Up @@ -1070,7 +1070,7 @@ func (node *AlgorandFullNode) oldKeyDeletionThread(done <-chan struct{}) {
// Persist participation registry updates to last-used round and voting key changes.
err = node.accountManager.Registry().Flush(participationRegistryFlushMaxWaitDuration)
if err != nil {
node.log.Warnf("error while flushing the registry: %w", err)
node.log.Warnf("error while flushing the registry: %v", err)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs/txService.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (txs *TxService) ServeHTTP(response http.ResponseWriter, request *http.Requ
response.WriteHeader(http.StatusOK)
_, err = response.Write(txblob)
if err != nil {
txs.log.Warnf("http block write failed ", err)
txs.log.Warn("http block write failed", err)
}
}

Expand Down
8 changes: 4 additions & 4 deletions stateproof/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (spw *Worker) initBuilders() {
return
})
if err != nil {
spw.log.Warnf("initBuilders: getPendingSigs: %w", err)
spw.log.Warnf("initBuilders: getPendingSigs: %v", err)
return
}

Expand Down Expand Up @@ -128,7 +128,7 @@ func (spw *Worker) addSigsToBuilder(sigs []pendingSig, rnd basics.Round) {

isPresent, err := builderForRound.Present(pos)
if err != nil {
spw.log.Warnf("addSigsToBuilder: failed to invoke builderForRound.Present on pos %d - %w ", pos, err)
spw.log.Warnf("addSigsToBuilder: failed to invoke builderForRound.Present on pos %d - %v", pos, err)
continue
}
if isPresent {
Expand All @@ -141,7 +141,7 @@ func (spw *Worker) addSigsToBuilder(sigs []pendingSig, rnd basics.Round) {
continue
}
if err := builderForRound.Add(pos, sig.sig); err != nil {
spw.log.Warnf("addSigsToBuilder: error while adding sig. inner error: %w", err)
spw.log.Warnf("addSigsToBuilder: error while adding sig. inner error: %v", err)
continue
}
}
Expand Down Expand Up @@ -407,7 +407,7 @@ func (spw *Worker) tryBroadcast() {

sp, err := b.Build()
if err != nil {
spw.log.Warnf("spw.tryBroadcast: building state proof for %d failed: %w", rnd, err)
spw.log.Warnf("spw.tryBroadcast: building state proof for %d failed: %v", rnd, err)
continue
}

Expand Down
6 changes: 3 additions & 3 deletions test/commandandcontrol/cc_agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func main() {

serverWs, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
if err != nil {
log.Errorf("dial:", err)
log.Error("dial:", err)
}
serverWs.Unsafe = true
defer func() {
Expand Down Expand Up @@ -168,7 +168,7 @@ func main() {
case t := <-ticker.C:
err := serverWs.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("heartbeat from agent %s with time %s", component.GetHostAgent().Host.Name, t.String())))
if err != nil {
log.Errorf("write:", err)
log.Error("write:", err)
return
}
case <-interrupt:
Expand All @@ -177,7 +177,7 @@ func main() {
// waiting (with timeout) for the server to close the connection.
err := serverWs.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
if err != nil {
log.Errorf("write close:", err)
log.Error("write close:", err)
return
}
select {
Expand Down
2 changes: 1 addition & 1 deletion test/commandandcontrol/cc_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func main() {
func closeServiceConnection(serverWs *websocket.Conn) {
err := serverWs.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
if err != nil {
log.Errorf("write close:", err)
log.Error("write close:", err)
return
}
}
4 changes: 2 additions & 2 deletions test/commandandcontrol/cc_service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
func handleClientConnections(w http.ResponseWriter, r *http.Request) {
ws, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Errorf("upgrade:", err)
log.Error("upgrade:", err)
return
}
ws.Unsafe = true
Expand All @@ -72,7 +72,7 @@ func handleAgentConnections(w http.ResponseWriter, r *http.Request) {
// Upgrade initial GET request to a websocket
ws, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Errorf("problem initializing agent web socket", err)
log.Error("problem initializing agent web socket", err)
return
}
ws.Unsafe = true
Expand Down