Skip to content

Commit

Permalink
chore: enable gci and fix ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ARR4N committed Sep 12, 2024
1 parent d47a4f8 commit 112be72
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 22 deletions.
30 changes: 20 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ linters:
# Every available linter at the time of writing was considered (quickly) and
# inclusion was liberal. Linters are good at detecting code smells, but if
# we find that a particular one causes too many false positives then we can
# first configure it better or, as a last resort, remove it..
# configure it better or, as a last resort, remove it.
- containedctx
- errcheck
- forcetypeassert
# TODO(arr4n) add and configure gci
- gci
- gocheckcompilerdirectives
- gofmt
- goimports
Expand Down Expand Up @@ -42,20 +42,29 @@ linters:
- whitespace

linters-settings:
gofmt:
simplify: true
revive:
rules:
- name: unused-parameter
# Method parameters may be equired by interfaces and forcing them to be
# named _ is of questionable benefit.
disabled: true
gci:
custom-order: true
sections:
- standard
- default
- localmodule
# The rest of these break developer expections, in increasing order of
# divergence, so are at the end to increase the chance of being seen.
- alias
- dot
- blank
gomodguard:
blocked:
modules:
- github.com/ava-labs/avalanchego:
- github.com/ava-labs/coreth:
- github.com/ava-labs/subnet-evm:
revive:
rules:
- name: unused-parameter
# Method parameters may be equired by interfaces and forcing them to be
# named _ is of questionable benefit.
disabled: true

issues:
exclude-dirs-use-default: false
Expand All @@ -67,6 +76,7 @@ issues:
- containedctx
- forcetypeassert
- errcheck
- gci
- gofmt
- gosec
- gosimple
Expand Down
3 changes: 2 additions & 1 deletion core/state_transition.libevm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/require"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/libevm"
"github.com/ethereum/go-ethereum/libevm/ethtest"
"github.com/ethereum/go-ethereum/libevm/hookstest"
"github.com/stretchr/testify/require"
)

func TestCanExecuteTransaction(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion core/vm/contracts.libevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package vm
import (
"fmt"

"github.com/holiman/uint256"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
"github.com/holiman/uint256"
)

// evmCallArgs mirrors the parameters of the [EVM] methods Call(), CallCode(),
Expand Down
9 changes: 5 additions & 4 deletions core/vm/contracts.libevm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import (
"fmt"
"testing"

"github.com/holiman/uint256"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/rand"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/libevm"
"github.com/ethereum/go-ethereum/libevm/ethtest"
"github.com/ethereum/go-ethereum/libevm/hookstest"
"github.com/ethereum/go-ethereum/params"
"github.com/holiman/uint256"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/rand"
)

type precompileStub struct {
Expand Down
3 changes: 2 additions & 1 deletion libevm/ethtest/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ package ethtest
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"
"github.com/stretchr/testify/require"
)

// NewZeroEVM returns a new EVM backed by a [rawdb.NewMemoryDatabase]; all other
Expand Down
3 changes: 2 additions & 1 deletion libevm/ethtest/rand.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package ethtest

import (
"github.com/ethereum/go-ethereum/common"
"golang.org/x/exp/rand"

"github.com/ethereum/go-ethereum/common"
)

// PseudoRand extends [rand.Rand] (*not* crypto/rand).
Expand Down
3 changes: 2 additions & 1 deletion libevm/libevm.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package libevm

import (
"github.com/ethereum/go-ethereum/common"
"github.com/holiman/uint256"

"github.com/ethereum/go-ethereum/common"
)

// PrecompiledContract is an exact copy of vm.PrecompiledContract, mirrored here
Expand Down
3 changes: 2 additions & 1 deletion params/config.libevm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/libevm/pseudo"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/ethereum/go-ethereum/libevm/pseudo"
)

type rawJSON struct {
Expand Down
2 changes: 1 addition & 1 deletion params/example.libevm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (r RulesExtra) PrecompileOverride(addr common.Address) (_ libevm.Precompile
// to state allows it to be configured on-chain however this is an optional
// implementation detail.
func (r RulesExtra) CanCreateContract(*libevm.AddressContext, libevm.StateReader) error {
if time.Unix(int64(r.timestamp), 0).UTC().Day() != int(time.Tuesday) { //nolint:gosec // triggering G115 overflow
if time.Unix(int64(r.timestamp), 0).UTC().Day() != int(time.Tuesday) { //nolint:gosec // G115 timestamp won't overflow int64 for millions of years so this is someone else's problem
return errors.New("uh oh")
}
return nil
Expand Down
3 changes: 2 additions & 1 deletion params/json.libevm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/libevm/pseudo"
"github.com/stretchr/testify/require"

"github.com/ethereum/go-ethereum/libevm/pseudo"
)

type nestedChainConfigExtra struct {
Expand Down

0 comments on commit 112be72

Please sign in to comment.