Skip to content

Commit 00063c8

Browse files
ccejannotti
andauthored
CI: add dupword linter and fix issues (#6474)
Co-authored-by: John Jannotti <jannotti@gmail.com>
1 parent efffb9d commit 00063c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+126
-96
lines changed

.github/workflows/reviewdog.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "ReviewDog workflow"
22
env:
3-
GOLANGCI_LINT_VERSION: "v2.5.0"
3+
GOLANGCI_LINT_VERSION: "v2.5.1-0.20251021235302-b99da877a247"
44
on:
55
push:
66
branches:
@@ -23,17 +23,39 @@ jobs:
2323
# move go out of the way temporarily to avoid "go list ./..." from installing modules
2424
- name: Make libsodium.a
2525
run: sudo mv /usr/bin/go /usr/bin/go.bak && make libsodium && sudo mv /usr/bin/go.bak /usr/bin/go
26-
- name: reviewdog-golangci-lint
27-
uses: reviewdog/action-golangci-lint@v2.8.0
28-
with:
29-
go_version_file: go.mod
30-
golangci_lint_version: ${{ env.GOLANGCI_LINT_VERSION }}
31-
golangci_lint_flags: "-c .golangci.yml --allow-parallel-runners"
32-
reporter: "github-pr-check"
33-
tool_name: "Lint Errors"
34-
level: "error"
35-
fail_level: any
36-
filter_mode: "nofilter"
26+
- name: Add bin to PATH
27+
run: |
28+
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
29+
echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/bin" >> $GITHUB_PATH
30+
- name: Set up Go
31+
uses: ./.github/actions/setup-go
32+
- name: Install golangci-lint
33+
run: |
34+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${{ env.GOLANGCI_LINT_VERSION }}
35+
golangci-lint --version
36+
- name: Install reviewdog
37+
run: |
38+
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/v0.21.0/install.sh | sh -s -- v0.21.0
39+
reviewdog --version
40+
- name: Run golangci-lint with reviewdog
41+
env:
42+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
set -e
45+
46+
golangci-lint run \
47+
--output.text.path stdout \
48+
-c .golangci.yml \
49+
--issues-exit-code 0 \
50+
--allow-parallel-runners > temp_golangci-lint-errors.txt
51+
52+
cat temp_golangci-lint-errors.txt | reviewdog \
53+
-f=golangci-lint \
54+
-name="Lint Errors" \
55+
-reporter=github-pr-check \
56+
-filter-mode=nofilter \
57+
-fail-level=any \
58+
-level=error
3759
# Non-Blocking Warnings Section
3860
reviewdog-warnings:
3961
runs-on: ubuntu-latest

.golangci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ linters:
66
default: none
77
enable:
88
- copyloopvar
9+
- dupword
910
- errcheck
1011
- govet
1112
- ineffassign
@@ -18,6 +19,10 @@ linters:
1819
- unused
1920

2021
settings:
22+
dupword:
23+
comments-only: true
24+
ignore:
25+
- long # "long long" is OK
2126
errcheck:
2227
exclude-functions:
2328
# We do this 121 times and never check the error.
@@ -28,6 +33,8 @@ linters:
2833
# Enables these linters in addition to the default ones.
2934
enable:
3035
- shadow
36+
disable:
37+
- buildtag
3138
settings:
3239
printf:
3340
# Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`).
@@ -89,7 +96,6 @@ linters:
8996
linters:
9097
- errcheck
9198
- ineffassign
92-
- misspell
9399
- nolintlint
94100
- staticcheck
95101
- unused

agreement/state_machine_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func (blackhole) Write(data []byte) (int, error) {
391391
return len(data), nil
392392
}
393393

394-
// deterministicTraceTestCase encapsulates a traditional unit test test case.
394+
// deterministicTraceTestCase encapsulates a traditional unit test case.
395395
type determisticTraceTestCase struct {
396396
inputs []event
397397
expectedOutputs []event

catchup/service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ func TestServiceLedgerUnavailable(t *testing.T) {
10881088
require.Less(t, local.LastRound(), remote.LastRound())
10891089
}
10901090

1091-
// TestServiceNoBlockForRound checks if fetchAndWrite does not repeats 500 times if a block not avaialble
1091+
// TestServiceNoBlockForRound checks if fetchAndWrite does not repeats 500 times if a block not available
10921092
func TestServiceNoBlockForRound(t *testing.T) {
10931093
partitiontest.PartitionTest(t)
10941094

config/localTemplate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ type Local struct {
326326
// determining the source of a connection. If used, it should be set to the string "X-Forwarded-For", unless the
327327
// proxy vendor provides another header field. In the case of CloudFlare proxy, the "CF-Connecting-IP" header
328328
// field can be used.
329-
// This setting does not support multiple X-Forwarded-For HTTP headers or multiple values in in the header and always uses the last value
329+
// This setting does not support multiple X-Forwarded-For HTTP headers or multiple values in the header and always uses the last value
330330
// from the last X-Forwarded-For HTTP header that corresponds to a single reverse proxy (even if it received the request from another reverse proxy or adversary node).
331331
//
332332
// WARNING: By enabling this option, you are trusting peers to provide accurate forwarding addresses.

crypto/merklearray/merkle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ func TestSizeLimitsMerkle(t *testing.T) {
485485
for depth := uint64(0); depth < uint64(18); depth = depth + increment {
486486
size := uint64(1) << depth
487487

488-
// eltCoefficient is the coefficent to determine how many elements are in the proof.
488+
// eltCoefficient is the coefficient to determine how many elements are in the proof.
489489
// There will be 1/eltCoefficient elements of all possible element (2^treeDepth)
490490
// numElts = 2^(depth-eltCoefficient)
491491

crypto/multisig_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func TestMoreThanMaxSigsInMultisig(t *testing.T) {
310310
}
311311

312312
msig, err := MultisigAssemble(sigs)
313-
require.NoError(t, err, "Multisig: error assmeble multisig")
313+
require.NoError(t, err, "Multisig: error assemble multisig")
314314
err = MultisigVerify(txid, addr, msig)
315315
require.Error(t, err, "Multisig: did not return error as expected")
316316
br := MakeBatchVerifier()
@@ -346,7 +346,7 @@ func TestOneSignatureIsEmpty(t *testing.T) {
346346
}
347347

348348
msig, err := MultisigAssemble(sigs)
349-
require.NoError(t, err, "Multisig: error assmeble multisig")
349+
require.NoError(t, err, "Multisig: error assemble multisig")
350350
msig.Subsigs[0].Sig = Signature{}
351351
err = MultisigVerify(txid, addr, msig)
352352
require.Error(t, err, "Multisig: did not return error as expected")
@@ -386,7 +386,7 @@ func TestOneSignatureIsInvalid(t *testing.T) {
386386

387387
sigs[1].Subsigs[1].Sig[5] = sigs[1].Subsigs[1].Sig[5] + 1
388388
msig, err := MultisigAssemble(sigs)
389-
require.NoError(t, err, "Multisig: error assmeble multisig")
389+
require.NoError(t, err, "Multisig: error assemble multisig")
390390
err = MultisigVerify(txid, addr, msig)
391391
require.Error(t, err, "Multisig: did not return error as expected")
392392
br := MakeBatchVerifier()

daemon/algod/api/server/v1/routes/routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
// V1Routes contains all routes for v1
25-
// v1 algod paths will route to the sunset message, resulting in a 410 Gone response.
25+
// These algod paths will route to the sunset message, resulting in a 410 Gone response.
2626
var V1Routes = lib.Routes{
2727
lib.Route{
2828
Name: "status",

daemon/kmd/api/v1/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type reqContext struct {
3838
sm *session.Manager
3939
}
4040

41-
// errorResponse sets the specified status code (should != 200), and fills in the
41+
// errorResponse sets the specified status code (should != 200), and fills in
4242
// the response envelope by setting Error to true and a Message to the passed
4343
// user-readable error message.
4444
func errorResponse(w http.ResponseWriter, status int, err error) {

daemon/kmd/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (k KMDConfig) Validate() error {
104104
return nil
105105
}
106106

107-
// LoadKMDConfig tries to read the the kmd configuration from disk, merging the
107+
// LoadKMDConfig tries to read the kmd configuration from disk, merging the
108108
// default kmd configuration with what it finds
109109
func LoadKMDConfig(dataDir string) (cfg KMDConfig, err error) {
110110
cfg = defaultConfig(dataDir)

0 commit comments

Comments
 (0)