Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: fix linter errors and update CI to require passing #4241

Merged
merged 20 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
tool_name: "Lint Errors"
level: "error"
fail_on_error: true
filter_mode: "nofilter"
# Non-Blocking Warnings Section
reviewdog-warnings:
runs-on: ubuntu-latest
Expand Down
13 changes: 11 additions & 2 deletions cmd/catchpointdump/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,24 @@ func deleteLedgerFiles(deleteTracker bool) error {

func loadAndDump(addr string, tarFile string, genesisInitState ledgercore.InitState) error {
// delete current ledger files.
deleteLedgerFiles(true)
err := deleteLedgerFiles(true)
if err != nil {
reportErrorf("Unable to delete ledger files : %v", err)
cce marked this conversation as resolved.
Show resolved Hide resolved
return err
}
cfg := config.GetDefaultLocal()
l, err := ledger.OpenLedger(logging.Base(), "./ledger", false, genesisInitState, cfg)
if err != nil {
reportErrorf("Unable to open ledger : %v", err)
return err
}

defer deleteLedgerFiles(!loadOnly)
defer func() {
err := deleteLedgerFiles(!loadOnly)
if err != nil {
reportErrorf("Unable to delete ledger files : %v", err)
}
}()
defer l.Close()

catchupAccessor := ledger.MakeCatchpointCatchupAccessor(l, logging.Base())
Expand Down
4 changes: 2 additions & 2 deletions data/transactions/logic/assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ func (ops *OpStream) trace(format string, args ...interface{}) {

func (ops *OpStream) typeError(err error) {
if ops.typeTracking {
ops.error(err)
_ = ops.error(err)
}
}

Expand Down Expand Up @@ -1413,7 +1413,7 @@ func (ops *OpStream) assemble(text string) error {
// bail out on the assembly as a whole.
spec, ok = OpsByName[AssemblerMaxVersion][opstring]
if ok {
ops.errorf("%s opcode was introduced in TEAL v%d", opstring, spec.Version)
_ = ops.errorf("%s opcode was introduced in TEAL v%d", opstring, spec.Version)
} else {
spec, ok = keywords[opstring]
}
Expand Down
6 changes: 3 additions & 3 deletions data/transactions/logic/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1310,17 +1310,17 @@ func opLt(cx *EvalContext) error {
// opSwap, opLt, and opNot always succeed (return nil). So error checking elided in Gt,Le,Ge

func opGt(cx *EvalContext) error {
opSwap(cx)
_ = opSwap(cx)
return opLt(cx)
}

func opLe(cx *EvalContext) error {
opGt(cx)
_ = opGt(cx)
return opNot(cx)
}

func opGe(cx *EvalContext) error {
opLt(cx)
_ = opLt(cx)
return opNot(cx)
}

Expand Down
2 changes: 1 addition & 1 deletion ledger/accountdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ type compactAccountDeltas struct {
}

// onlineAccountDelta track all changes of account state within a range,
// used in conjunction wih compactOnlineAccountDeltas to group and represent per-account changes.
// used in conjunction with compactOnlineAccountDeltas to group and represent per-account changes.
// oldAcct represents the "old" state of the account in the DB, and compared against newAcct[0]
// to determine if the acct became online or went offline.
type onlineAccountDelta struct {
Expand Down
2 changes: 0 additions & 2 deletions ledger/acctonline.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ func (ao *onlineAccounts) lookupOnlineAccountData(rnd basics.Round, addr basics.
}
// the round number cannot be found in deltas, it is in history
inHistory = true
err = nil
}
paramsOffset, err = ao.roundParamsOffset(rnd)
if err != nil {
Expand Down Expand Up @@ -744,7 +743,6 @@ func (ao *onlineAccounts) onlineTop(rnd basics.Round, voteRnd basics.Round, n ui
}
// the round number cannot be found in deltas, it is in history
inMemory = false
err = nil
}

modifiedAccounts := make(map[basics.Address]*ledgercore.OnlineAccount)
Expand Down
5 changes: 4 additions & 1 deletion ledger/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,10 @@ func (tr *trackerRegistry) commitSyncer(deferredCommits chan *deferredCommitCont
if !ok {
return
}
tr.commitRound(commit)
err := tr.commitRound(commit)
if err != nil {
tr.log.Errorf("commitSyncer: commitRound error %s", err.Error())
}
case <-tr.ctx.Done():
// drain the pending commits queue:
drained := false
Expand Down
10 changes: 5 additions & 5 deletions network/wsNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ type GossipNode interface {
// this node to send corresponding MsgOfInterest notifications to any
// newly connecting peers. This should be called before the network
// is started.
RegisterMessageInterest(protocol.Tag) error
RegisterMessageInterest(protocol.Tag)

// SubstituteGenesisID substitutes the "{genesisID}" with their network-specific genesisID.
SubstituteGenesisID(rawURL string) string
Expand Down Expand Up @@ -2308,7 +2308,7 @@ func SetUserAgentHeader(header http.Header) {
// this node to send corresponding MsgOfInterest notifications to any
// newly connecting peers. This should be called before the network
// is started.
func (wn *WebsocketNetwork) RegisterMessageInterest(t protocol.Tag) error {
func (wn *WebsocketNetwork) RegisterMessageInterest(t protocol.Tag) {
wn.messagesOfInterestMu.Lock()
defer wn.messagesOfInterestMu.Unlock()

Expand All @@ -2321,11 +2321,11 @@ func (wn *WebsocketNetwork) RegisterMessageInterest(t protocol.Tag) error {

wn.messagesOfInterest[t] = true
wn.updateMessagesOfInterestEnc()
return nil
return
cce marked this conversation as resolved.
Show resolved Hide resolved
}

// DeregisterMessageInterest will tell peers to no longer send us traffic with a protocol Tag
func (wn *WebsocketNetwork) DeregisterMessageInterest(t protocol.Tag) error {
func (wn *WebsocketNetwork) DeregisterMessageInterest(t protocol.Tag) {
wn.messagesOfInterestMu.Lock()
defer wn.messagesOfInterestMu.Unlock()

Expand All @@ -2338,7 +2338,7 @@ func (wn *WebsocketNetwork) DeregisterMessageInterest(t protocol.Tag) error {

delete(wn.messagesOfInterest, t)
wn.updateMessagesOfInterestEnc()
return nil
return
}

func (wn *WebsocketNetwork) updateMessagesOfInterestEnc() {
Expand Down
4 changes: 2 additions & 2 deletions network/wsNetwork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1839,8 +1839,8 @@ func TestWebsocketNetworkMessageOfInterest(t *testing.T) {
waitReady(t, netB, readyTimeout.C)

// have netB asking netA to send it only AgreementVoteTag and ProposalPayloadTag
require.NoError(t, netB.RegisterMessageInterest(ft1))
require.NoError(t, netB.RegisterMessageInterest(ft2))
netB.RegisterMessageInterest(ft1)
netB.RegisterMessageInterest(ft2)
// send another message which we can track, so that we'll know that the first message was delivered.
netB.Broadcast(context.Background(), protocol.VoteBundleTag, []byte{0, 1, 2, 3, 4}, true, nil)
messageFilterArriveWg.Wait()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func main() {
mu.Unlock()
// prevent requests for block #2 to go through.
if strings.HasSuffix(request.URL.String(), "/block/2") {
response.Write([]byte("webProxy prevents block 2 from serving"))
response.WriteHeader(http.StatusBadRequest)
_, _ = response.Write([]byte("webProxy prevents block 2 from serving"))
return
}
if *webProxyLogFile != "" {
Expand Down