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 warnings #5047

Merged
merged 2 commits into from
Jan 24, 2023
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
3 changes: 1 addition & 2 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ jobs:
-c .golangci-warnings.yml \
--issues-exit-code 0 \
--allow-parallel-runners > temp_golangci-lint-cgo.txt
cat temp_golangci-lint-cgo.txt

cat temp_golangci-lint-cgo.txt | reviewdog \
-f=golangci-lint \
Expand All @@ -102,4 +101,4 @@ jobs:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
run: |
curl -X POST --data-urlencode "payload={\"text\": \"Reviewdog failed. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} \"}" $SLACK_WEBHOOK
if: ${{ failure() && (contains(github.ref_name, 'rel/nightly') || contains(github.ref_name, 'rel/beta') || contains(github.ref_name, 'rel/stable') || contains(github.ref_name, 'master')) }}
if: ${{ failure() && (contains(github.ref_name, 'rel/nightly') || contains(github.ref_name, 'rel/beta') || contains(github.ref_name, 'rel/stable') || contains(github.ref_name, 'master')) }}
4 changes: 0 additions & 4 deletions .golangci-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ linters:
- partitiontest
- structcheck
- varcheck
- unconvert
cce marked this conversation as resolved.
Show resolved Hide resolved
- unused


linters-settings:
custom:
partitiontest:
Expand Down Expand Up @@ -55,15 +53,13 @@ issues:
- deadcode
- structcheck
- varcheck
- unconvert
- unused
# Add all linters here -- Comment this block out for testing linters
- path: test/linttest/lintissues\.go
linters:
- deadcode
- structcheck
- varcheck
- unconvert
- unused
- path: crypto/secp256k1/secp256_test\.go
linters:
Expand Down
2 changes: 2 additions & 0 deletions agreement/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ import (
"testing"

"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)

// TestSerializableErrorBackwardCompatible ensures Err field of type serializableError can be
// properly decoded from ConsensusVersionView.
// This test is only needed for agreement state serialization switch from reflection to msgp.
func TestSerializableErrorBackwardCompatibility(t *testing.T) {
partitiontest.PartitionTest(t)

encodedEmpty, err := base64.StdEncoding.DecodeString("gqNFcnLAp1ZlcnNpb26jdjEw")
require.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions agreement/persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func TestEmptyMapDeserialization(t *testing.T) {
}

func TestDecodeFailures(t *testing.T) {
partitiontest.PartitionTest(t)
clock := timers.MakeMonotonicClock(time.Date(2015, 1, 2, 5, 6, 7, 8, time.UTC))
ce := clock.Encode()
log := makeServiceLogger(logging.Base())
Expand Down
1 change: 1 addition & 0 deletions cmd/goal/formatting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func TestNewBoxRef(t *testing.T) {
}

func TestStringsToBoxRefs(t *testing.T) {
partitiontest.PartitionTest(t)
brs := stringsToBoxRefs([]string{"77,str:hello", "55,int:6", "int:88"})
require.EqualValues(t, 77, brs[0].appID)
require.EqualValues(t, 55, brs[1].appID)
Expand Down
17 changes: 0 additions & 17 deletions cmd/tealdbg/dryrunRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,6 @@ func ddrFromParams(dp *DebugParams) (ddr v2.DryrunRequest, err error) {
return
}

func convertAccounts(accounts []model.Account) (records []basics.BalanceRecord, err error) {
for _, a := range accounts {
var addr basics.Address
addr, err = basics.UnmarshalChecksumAddress(a.Address)
if err != nil {
return
}
var ad basics.AccountData
ad, err = v2.AccountToAccountData(&a)
if err != nil {
return
}
records = append(records, basics.BalanceRecord{Addr: addr, AccountData: ad})
}
return
}

func balanceRecordsFromDdr(ddr *v2.DryrunRequest) (records []basics.BalanceRecord, err error) {
accounts := make(map[basics.Address]basics.AccountData)
for _, a := range ddr.Accounts {
Expand Down
1 change: 1 addition & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ func TestGetNonDefaultConfigValues(t *testing.T) {
}

func TestLocal_TxFiltering(t *testing.T) {
partitiontest.PartitionTest(t)
cfg := GetDefaultLocal()

// ensure the default
Expand Down
2 changes: 0 additions & 2 deletions daemon/algod/api/server/v2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ var (
errFailedRetrievingLatestBlockHeaderStatus = "failed retrieving latests block header"
errFailedRetrievingSyncRound = "failed retrieving sync round from ledger"
errFailedSettingSyncRound = "failed to set sync round on the ledger"
errSyncModeNotEnabled = "sync mode must be enabled"
errFailedParsingFormatOption = "failed to parse the format option"
errFailedToParseAddress = "failed to parse the address"
errFailedToParseExclude = "failed to parse exclude"
errFailedToParseTransaction = "failed to parse transaction"
errFailedToParseBlock = "failed to parse block"
errFailedToParseCert = "failed to parse cert"
errFailedToParseSourcemap = "failed to parse sourcemap"
errFailedToEncodeResponse = "failed to encode response"
errInternalFailure = "internal failure"
errNoValidTxnSpecified = "no valid transaction ID was specified"
Expand Down
2 changes: 2 additions & 0 deletions logging/telemetryspec/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func TestTransactionProcessingTimeDistributionFormatting(t *testing.T) {
}

func TestTransactionProcessingTimeDistributionPrint(t *testing.T) {
partitiontest.PartitionTest(t)

var decPT transactionProcessingTimeDistribution
expected := "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38]"
require.NoError(t, json.Unmarshal([]byte(expected), &decPT))
Expand Down
3 changes: 3 additions & 0 deletions shared/pingpong/pingpong.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

// Package pingpong provides a transaction generating utility for performance testing.
//
//nolint:unused,structcheck,deadcode,varcheck // ignore unused pingpong code
package pingpong

import (
Expand Down
5 changes: 2 additions & 3 deletions util/rateLimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ type capacityQueue chan capacity
// ErlCapacityGuard is the structure returned to clients so they can release the capacity when needed
// they also inform the congestion manager of events
type ErlCapacityGuard struct {
client ErlClient
cq capacityQueue
cm CongestionManager
cq capacityQueue
cm CongestionManager
}

// Release will put capacity back into the queue attached to this capacity guard
Expand Down
1 change: 1 addition & 0 deletions util/tcpinfo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func getConnTCPInfo(raw syscall.RawConn) (*TCPInfo, error) {

// linuxTCPInfo is based on linux include/uapi/linux/tcp.h struct tcp_info
//revive:disable:var-naming
//nolint:structcheck // complains about unused fields that are rqeuired to match C tcp_info struct
type linuxTCPInfo struct {
state uint8
ca_state uint8
Expand Down