diff --git a/.golangci-warnings.yml b/.golangci-warnings.yml index 769ea9ddbd..f0f2eee48e 100644 --- a/.golangci-warnings.yml +++ b/.golangci-warnings.yml @@ -39,8 +39,6 @@ issues: exclude: # ignore govet false positive fixed in https://github.com/golang/go/issues/45043 - "sigchanyzer: misuse of unbuffered os.Signal channel as argument to signal.Notify" - # ignore golint false positive fixed in https://github.com/golang/lint/pull/487 - - "exported method (.*).Unwrap` should have comment or be unexported" # ignore issues about the way we use _struct fields to define encoding settings - "`_struct` is unused" diff --git a/.golangci.yml b/.golangci.yml index 8af53cf27f..271c682e50 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ run: timeout: 5m - tests: false + tests: true linters: # default: deadcode, errcheck, gosimple, govet, ineffassign, staticcheck, typecheck, unused, varcheck @@ -66,12 +66,24 @@ issues: - "var-naming: don't use leading k in Go names" exclude-rules: + - path: _test\.go + linters: + - errcheck + - gofmt + - gosimple + - govet + - ineffassign + - misspell + - nolintlint + # - revive + - staticcheck + - typecheck # Add all linters here -- Comment this block out for testing linters - path: test/linttest/lintissues\.go linters: - errcheck - gofmt - - golint + - revive - govet - ineffassign - misspell diff --git a/ledger/internal/apptxn_test.go b/ledger/internal/apptxn_test.go index b0d082324f..86a4a7feab 100644 --- a/ledger/internal/apptxn_test.go +++ b/ledger/internal/apptxn_test.go @@ -2479,7 +2479,7 @@ func TestInnerClearState(t *testing.T) { eval := nextBlock(t, l) txn(t, l, eval, &inner) vb := endBlock(t, l, eval) - innerId := vb.Block().Payset[0].ApplicationID + innerID := vb.Block().Payset[0].ApplicationID // Outer is a simple app that will invoke the given app (in ForeignApps[0]) // with the given OnCompletion (in ApplicationArgs[0]). Goal is to use it @@ -2498,33 +2498,33 @@ itxn_begin itxn_field OnCompletion itxn_submit `), - ForeignApps: []basics.AppIndex{innerId}, + ForeignApps: []basics.AppIndex{innerID}, } eval = nextBlock(t, l) txn(t, l, eval, &outer) vb = endBlock(t, l, eval) - outerId := vb.Block().Payset[0].ApplicationID + outerID := vb.Block().Payset[0].ApplicationID fund := txntest.Txn{ Type: "pay", Sender: addrs[0], - Receiver: outerId.Address(), + Receiver: outerID.Address(), Amount: 1_000_000, } call := txntest.Txn{ Type: "appl", Sender: addrs[0], - ApplicationID: outerId, + ApplicationID: outerID, ApplicationArgs: [][]byte{{byte(transactions.OptInOC)}}, - ForeignApps: []basics.AppIndex{innerId}, + ForeignApps: []basics.AppIndex{innerID}, } eval = nextBlock(t, l) txns(t, l, eval, &fund, &call) endBlock(t, l, eval) - outerAcct := lookup(t, l, outerId.Address()) + outerAcct := lookup(t, l, outerID.Address()) require.Len(t, outerAcct.AppLocalStates, 1) require.Equal(t, outerAcct.TotalAppSchema, basics.StateSchema{ NumUint: 2, @@ -2536,7 +2536,7 @@ itxn_submit txn(t, l, eval, &call) endBlock(t, l, eval) - outerAcct = lookup(t, l, outerId.Address()) + outerAcct = lookup(t, l, outerID.Address()) require.Empty(t, outerAcct.AppLocalStates) require.Empty(t, outerAcct.TotalAppSchema) @@ -2567,7 +2567,7 @@ b top eval := nextBlock(t, l) txn(t, l, eval, &badCallee) vb := endBlock(t, l, eval) - badId := vb.Block().Payset[0].ApplicationID + badID := vb.Block().Payset[0].ApplicationID // Outer is a simple app that will invoke the given app (in ForeignApps[0]) // with the given OnCompletion (in ApplicationArgs[0]). Goal is to use it @@ -2603,33 +2603,33 @@ bnz skip // Don't do budget checking during optin assert skip: `), - ForeignApps: []basics.AppIndex{badId}, + ForeignApps: []basics.AppIndex{badID}, } eval = nextBlock(t, l) txn(t, l, eval, &outer) vb = endBlock(t, l, eval) - outerId := vb.Block().Payset[0].ApplicationID + outerID := vb.Block().Payset[0].ApplicationID fund := txntest.Txn{ Type: "pay", Sender: addrs[0], - Receiver: outerId.Address(), + Receiver: outerID.Address(), Amount: 1_000_000, } call := txntest.Txn{ Type: "appl", Sender: addrs[0], - ApplicationID: outerId, + ApplicationID: outerID, ApplicationArgs: [][]byte{{byte(transactions.OptInOC)}}, - ForeignApps: []basics.AppIndex{badId}, + ForeignApps: []basics.AppIndex{badID}, } eval = nextBlock(t, l) txns(t, l, eval, &fund, &call) endBlock(t, l, eval) - outerAcct := lookup(t, l, outerId.Address()) + outerAcct := lookup(t, l, outerID.Address()) require.Len(t, outerAcct.AppLocalStates, 1) // When doing a clear state, `call` checks that budget wasn't stolen @@ -2639,7 +2639,7 @@ skip: endBlock(t, l, eval) // Clearstate took effect, despite failure from infinite loop - outerAcct = lookup(t, l, outerId.Address()) + outerAcct = lookup(t, l, outerID.Address()) require.Empty(t, outerAcct.AppLocalStates) } @@ -2697,8 +2697,8 @@ log eval := nextBlock(t, l) txns(t, l, eval, &inner, &waster) vb := endBlock(t, l, eval) - innerId := vb.Block().Payset[0].ApplicationID - wasterId := vb.Block().Payset[1].ApplicationID + innerID := vb.Block().Payset[0].ApplicationID + wasterID := vb.Block().Payset[1].ApplicationID // Grouper is a simple app that will invoke the given apps (in // ForeignApps[0,1]) as a group, with the given OnCompletion (in @@ -2730,27 +2730,27 @@ itxn_submit eval = nextBlock(t, l) txn(t, l, eval, &grouper) vb = endBlock(t, l, eval) - grouperId := vb.Block().Payset[0].ApplicationID + grouperID := vb.Block().Payset[0].ApplicationID fund := txntest.Txn{ Type: "pay", Sender: addrs[0], - Receiver: grouperId.Address(), + Receiver: grouperID.Address(), Amount: 1_000_000, } call := txntest.Txn{ Type: "appl", Sender: addrs[0], - ApplicationID: grouperId, + ApplicationID: grouperID, ApplicationArgs: [][]byte{{byte(transactions.OptInOC)}, {byte(transactions.OptInOC)}}, - ForeignApps: []basics.AppIndex{wasterId, innerId}, + ForeignApps: []basics.AppIndex{wasterID, innerID}, } eval = nextBlock(t, l) txns(t, l, eval, &fund, &call) endBlock(t, l, eval) - gAcct := lookup(t, l, grouperId.Address()) + gAcct := lookup(t, l, grouperID.Address()) require.Len(t, gAcct.AppLocalStates, 2) call.ApplicationArgs = [][]byte{{byte(transactions.CloseOutOC)}, {byte(transactions.ClearStateOC)}} @@ -2760,7 +2760,7 @@ itxn_submit require.Len(t, vb.Block().Payset, 0) // Clearstate did not take effect, since the caller tried to shortchange the CSP - gAcct = lookup(t, l, grouperId.Address()) + gAcct = lookup(t, l, grouperID.Address()) require.Len(t, gAcct.AppLocalStates, 2) } diff --git a/ledger/internal/eval_blackbox_test.go b/ledger/internal/eval_blackbox_test.go index 8f8f7f1a35..b6eb6b9c16 100644 --- a/ledger/internal/eval_blackbox_test.go +++ b/ledger/internal/eval_blackbox_test.go @@ -1047,13 +1047,13 @@ func TestLogsInBlock(t *testing.T) { } vb := dl.fullBlock(&createTxn) createInBlock := vb.Block().Payset[0] - appId := createInBlock.ApplyData.ApplicationID + appID := createInBlock.ApplyData.ApplicationID require.Equal(t, "APP", createInBlock.ApplyData.EvalDelta.Logs[0]) optInTxn := txntest.Txn{ Type: protocol.ApplicationCallTx, Sender: addrs[1], - ApplicationID: appId, + ApplicationID: appID, OnCompletion: transactions.OptInOC, } vb = dl.fullBlock(&optInTxn) @@ -1063,7 +1063,7 @@ func TestLogsInBlock(t *testing.T) { clearTxn := txntest.Txn{ Type: protocol.ApplicationCallTx, Sender: addrs[1], - ApplicationID: appId, + ApplicationID: appID, OnCompletion: transactions.ClearStateOC, } vb = dl.fullBlock(&clearTxn) @@ -1102,7 +1102,7 @@ func TestUnfundedSenders(t *testing.T) { ghost := basics.Address{0x01} - asa_create := txntest.Txn{ + asaCreate := txntest.Txn{ Type: "acfg", Sender: addrs[0], AssetParams: basics.AssetParams{ @@ -1113,12 +1113,12 @@ func TestUnfundedSenders(t *testing.T) { }, } - app_create := txntest.Txn{ + appCreate := txntest.Txn{ Type: "appl", Sender: addrs[0], } - dl.fullBlock(&asa_create, &app_create) + dl.fullBlock(&asaCreate, &appCreate) // Advance so that rewardsLevel increases for i := 1; i < 10; i++ { @@ -1230,7 +1230,7 @@ func TestAppCallAppDuringInit(t *testing.T) { dl.fullBlock() } - call_in_init := txntest.Txn{ + callInInit := txntest.Txn{ Type: "appl", Sender: addrs[0], ApprovalProgram: ` @@ -1251,6 +1251,6 @@ func TestAppCallAppDuringInit(t *testing.T) { // In the old days, balances.Move would try to increase the rewardsState on the unfunded account problem = "balance 0 below min" } - dl.txn(&call_in_init, problem) + dl.txn(&callInInit, problem) }) } diff --git a/scripts/travis/codegen_verification.sh b/scripts/travis/codegen_verification.sh index f442959c45..8ba594d7b1 100755 --- a/scripts/travis/codegen_verification.sh +++ b/scripts/travis/codegen_verification.sh @@ -27,40 +27,6 @@ eval "$(~/gimme "${GOLANG_VERSION}")" make gen SHORT_PART_PERIOD=1 -function runGoFmt() { - unformatted=$(gofmt -l .) - [ -z "$unformatted" ] && return 0 - - # Some files are not gofmt'd. Print message and fail. - - echo >&2 "Go files must be formatted with gofmt. Please run:" - for fn in $unformatted; do - echo >&2 " gofmt -w $PWD/$fn" - done - - return 1 -} - -function runGoLint() { - warningCount=$("$GOPATH"/bin/golangci-lint -c .golangci.yml | wc -l | tr -d ' ') - if [ "${warningCount}" = "0" ]; then - return 0 - fi - - echo >&2 "golangci-lint must be clean. Please run the following to list issues(${warningCount}):" - echo >&2 " make lint" - - # run the linter again to output the actual issues - "$GOPATH"/bin/golangci-lint -c .golangci.yml >&2 - return 1 -} - -echo "Running gofmt..." -runGoFmt - -echo "Running golangci-lint..." -runGoLint - echo "Running check_license..." ./scripts/check_license.sh