Skip to content

Commit

Permalink
chore: enable gomoddirectives, unparam (cometbft#2290)
Browse files Browse the repository at this point in the history
- enable typecheck linter, fix a copylocks issue
- enable gomoddirectives
- gomoddirectives

This PR goes directly against main, since these linters don't produce
changes. Cherry picked from one of the revive forks.


---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
  • Loading branch information
faddat authored Feb 14, 2024
1 parent 01a3ad4 commit ac0fb28
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ linters:
- goerr113
- golint
- gomnd
- gomoddirectives
- ifshort
- interfacebloat
- interfacer
Expand All @@ -46,9 +45,6 @@ linters:
- structcheck
- tagliatelle
- testifylint
- typecheck
# Prefer unparam over revive's unused param. It is more thorough in its checking.
- unparam
- varcheck
- varnamelen
- wrapcheck
Expand Down
5 changes: 4 additions & 1 deletion internal/bits/bit_array.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,10 @@ func (bA *BitArray) UnmarshalJSON(bz []byte) error {
bA2.SetIndex(i, true)
}
}
*bA = *bA2 //nolint:govet
// Instead of *bA = *bA2
bA.Bits = bA2.Bits
bA.Elems = make([]uint64, len(bA2.Elems))
copy(bA.Elems, bA2.Elems)
return nil
}

Expand Down
14 changes: 7 additions & 7 deletions light/store/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (s *dbs) LastLightBlockHeight() (int64, error) {

for itr.Valid() {
key := itr.Key()
_, height, ok := parseLbKey(key)
height, ok := parseLbKey(key)
if ok {
return height, nil
}
Expand All @@ -171,7 +171,7 @@ func (s *dbs) FirstLightBlockHeight() (int64, error) {

for itr.Valid() {
key := itr.Key()
_, height, ok := parseLbKey(key)
height, ok := parseLbKey(key)
if ok {
return height, nil
}
Expand Down Expand Up @@ -201,7 +201,7 @@ func (s *dbs) LightBlockBefore(height int64) (*types.LightBlock, error) {

for itr.Valid() {
key := itr.Key()
_, existingHeight, ok := parseLbKey(key)
existingHeight, ok := parseLbKey(key)
if ok {
return s.LightBlock(existingHeight)
}
Expand Down Expand Up @@ -245,7 +245,7 @@ func (s *dbs) Prune(size uint16) error {
pruned := 0
for itr.Valid() && numToPrune > 0 {
key := itr.Key()
_, height, ok := parseLbKey(key)
height, ok := parseLbKey(key)
if ok {
if err = b.Delete(s.lbKey(height)); err != nil {
return err
Expand Down Expand Up @@ -307,11 +307,11 @@ func parseKey(key []byte) (part string, prefix string, height int64, ok bool) {
return
}

func parseLbKey(key []byte) (prefix string, height int64, ok bool) {
func parseLbKey(key []byte) (height int64, ok bool) {
var part string
part, prefix, height, ok = parseKey(key)
part, _, height, ok = parseKey(key)
if part != "lb" {
return "", 0, false
return 0, false
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pkg/infra/digitalocean/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func ansiblePerturbConnectionBytes(disconnect bool) string {
}

// ExecCompose runs a Docker Compose command for a testnet.
func execAnsible(ctx context.Context, dir, playbook string, nodeIPs []string, args ...string) error {
func execAnsible(ctx context.Context, dir, playbook string, nodeIPs []string, args ...string) error { //nolint:unparam
playbook = filepath.Join(dir, playbook)
return exec.CommandVerbose(ctx, append(
[]string{"ansible-playbook", playbook, "-f", "50", "-u", "root", "--inventory", strings.Join(nodeIPs, ",") + ","},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func testNode(t *testing.T, testFunc func(*testing.T, e2e.Node)) {
//
// If maxNodes is set to 0 or below, all full nodes and validators will be
// tested.
func testFullNodesOrValidators(t *testing.T, maxNodes int, testFunc func(*testing.T, e2e.Node)) {
func testFullNodesOrValidators(t *testing.T, maxNodes int, testFunc func(*testing.T, e2e.Node)) { //nolint:unparam // maxNodes could be used in future tests
t.Helper()

testnet := loadTestnet(t)
Expand Down

0 comments on commit ac0fb28

Please sign in to comment.