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
4 changes: 4 additions & 0 deletions .golangci-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ linters:
disable-all: true
enable:
- deadcode
- gosec
- partitiontest
- structcheck
- varcheck
- unused

linters-settings:
gosec: # we are mostly only interested in G601
excludes: [G101, G103, G104, G107, G202, G301, G302, G303, G304, G306, G307, G404]
custom:
partitiontest:
path: cmd/partitiontest_linter/plugin.so
Expand Down Expand Up @@ -51,6 +54,7 @@ issues:
- path: _test\.go
linters:
- deadcode
- gosec
- structcheck
- varcheck
- unused
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ linters:
disable-all: true
enable:
- errcheck
- exportloopref
- gofmt
- gosimple
- govet
Expand Down Expand Up @@ -107,6 +108,7 @@ issues:
- path: _test\.go
linters:
- errcheck
# - exportloopref
# - gofmt
- gosimple
# - govet
Expand Down
4 changes: 2 additions & 2 deletions cmd/goal/clerk.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ func createSignedTransaction(client libgoal.Client, signTx bool, dataDir string,

func writeSignedTxnsToFile(stxns []transactions.SignedTxn, filename string) error {
var outData []byte
for _, stxn := range stxns {
outData = append(outData, protocol.Encode(&stxn)...)
for i := range stxns {
outData = append(outData, protocol.Encode(&stxns[i])...)
}

return writeFile(filename, outData, 0600)
Expand Down
4 changes: 2 additions & 2 deletions cmd/opdoc/opdoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ func opsToMarkdown(out io.Writer) (err error) {
out.Write([]byte("# Opcodes\n\nOps have a 'cost' of 1 unless otherwise specified.\n\n"))
opSpecs := logic.OpcodesByVersion(uint64(docVersion))
written := make(map[string]bool)
for _, spec := range opSpecs {
err = opToMarkdown(out, &spec, written)
for i := range opSpecs {
err = opToMarkdown(out, &opSpecs[i], written)
if err != nil {
return
}
Expand Down
4 changes: 2 additions & 2 deletions daemon/algod/api/server/v2/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ func convertLogs(txn node.TxnWithStatus) *[][]byte {

func convertInners(txn *node.TxnWithStatus) *[]PreEncodedTxInfo {
inner := make([]PreEncodedTxInfo, len(txn.ApplyData.EvalDelta.InnerTxns))
for i, itxn := range txn.ApplyData.EvalDelta.InnerTxns {
inner[i] = convertInnerTxn(&itxn)
for i := range txn.ApplyData.EvalDelta.InnerTxns {
inner[i] = convertInnerTxn(&txn.ApplyData.EvalDelta.InnerTxns[i])
}
return &inner
}
Expand Down
2 changes: 1 addition & 1 deletion data/pools/transactionPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ func (pool *TransactionPool) AssembleBlock(round basics.Round, deadline time.Tim
}
stats.TotalLength += uint64(encodedLen)
if txib.Txn.Type == protocol.StateProofTx {
stats.StateProofStats = pool.getStateProofStats(&txib, encodedLen)
stats.StateProofStats = pool.getStateProofStats(&payset[i], encodedLen)
}
}
stats.AverageFee = totalFees / uint64(stats.IncludedCount)
Expand Down
6 changes: 3 additions & 3 deletions data/transactions/logic/assembler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,9 @@ func testProg(t testing.TB, source string, ver uint64, expected ...Expect) *OpSt
}
} else {
var found *lineError
for _, err := range errors {
if err.Line == exp.l {
found = &err
for i := range errors {
if errors[i].Line == exp.l {
found = &errors[i]
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion data/transactions/verify/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func txnGroupBatchPrep(stxs []transactions.SignedTxn, contextHdr *bookkeeping.Bl
minFeeCount := uint64(0)
feesPaid := uint64(0)
for i, stxn := range stxs {
prepErr := txnBatchPrep(&stxn, i, groupCtx, verifier, evalTracer)
prepErr := txnBatchPrep(&stxs[i], i, groupCtx, verifier, evalTracer)
if prepErr != nil {
// re-wrap the error with more details
prepErr.err = fmt.Errorf("transaction %+v invalid : %w", stxn, prepErr.err)
Expand Down
4 changes: 2 additions & 2 deletions ledger/store/accountsV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ func (w *accountsV2Writer) AccountsPutOnlineRoundParams(onlineRoundParamsData []
return err
}

for i, onlineRoundParams := range onlineRoundParamsData {
_, err = insertStmt.Exec(startRound+basics.Round(i), protocol.Encode(&onlineRoundParams))
for i := range onlineRoundParamsData {
_, err = insertStmt.Exec(startRound+basics.Round(i), protocol.Encode(&onlineRoundParamsData[i]))
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion ledger/store/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func accountsInit(tx *sql.Tx, initAccounts map[basics.Address]basics.AccountData

for addr, data := range initAccounts {
_, err = tx.Exec("INSERT INTO accountbase (address, data) VALUES (?, ?)",
addr[:], protocol.Encode(&data))
addr[:], protocol.Encode(&data)) //nolint:gosec // Encode does not hold on to reference
Comment thread
jannotti marked this conversation as resolved.
if err != nil {
return true, err
}
Expand Down
29 changes: 23 additions & 6 deletions scripts/check_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,36 @@ missing_dep() {
}

GO_DEPS=(
"$GO_BIN/stringer"
"$GO_BIN/msgp"
"$GO_BIN/golangci-lint"
"msgp"
"golangci-lint"
Comment thread
cce marked this conversation as resolved.
"oapi-codegen"
"swagger"
)

check_go_binary_version() {
binary_name=$1
expected_version=$(grep "$binary_name" scripts/buildtools/versions | awk '{print $2}')
actual_version=$(go version -m "$GO_BIN/$binary_name" | awk 'NR==3 {print $3}')

if [ "$expected_version" != "$actual_version" ]; then
Comment thread
cce marked this conversation as resolved.
echo "$YELLOW_FG[WARNING]$END_FG_COLOR $binary_name version mismatch, expected $expected_version, but got $actual_version"
fi
}

check_deps() {
for path in ${GO_DEPS[*]}
for dep in ${GO_DEPS[*]}
do
if [ ! -f "$path" ]
if [ ! -f "$GO_BIN/$dep" ]
then
# Parameter expansion is faster than invoking another process.
# https://www.linuxjournal.com/content/bash-parameter-expansion
missing_dep "${path##*/}"
missing_dep "${dep##*/}"
fi

# go 1.17 on arm64 macs has an issue checking binaries with "go version", skip version check
if [[ "$(uname)" != "Darwin" ]] || [[ "$(uname -m)" != "arm64" ]] || ! [[ "$(go version | awk '{print $3}')" < "go1.17" ]]
then
check_go_binary_version "$dep"
fi
done

Expand Down