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

linting: add gofumpt #105

Merged
merged 8 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
tag: '1.21'
steps:
- checkout
- run: golangci-lint run superchain validation
- run: golangci-lint run superchain/... validation/...
golang-modules-tidy:
executor:
name: go/default # is based on cimg/go
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ run:
linters:
# also see https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- goimports
- gofumpt
trianglesphere marked this conversation as resolved.
Show resolved Hide resolved
- bodyclose
- asciicheck
- misspell
Expand Down
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
mds1 marked this conversation as resolved.
Show resolved Hide resolved
"go.formatTool": "gofumpt",
"go.lintTool": "golangci-lint",
"go.lintOnSave": "workspace",
"gopls": {
"formatting.gofumpt": true,
},
}
2 changes: 0 additions & 2 deletions superchain/superchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ func unMarshalSuperchainConfig(data []byte, s *SuperchainConfig) error {
}

return yaml.Unmarshal(data, temp)

}

type Superchain struct {
Expand Down Expand Up @@ -529,7 +528,6 @@ func isConfigFile(c fs.DirEntry) bool {
strings.HasSuffix(c.Name(), ".yaml") &&
c.Name() != "superchain.yaml" &&
c.Name() != "semver.yaml")

}

func init() {
Expand Down
14 changes: 7 additions & 7 deletions superchain/superchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestVersionFor(t *testing.T) {
_, err = cl.VersionFor("Garbage")
require.Error(t, err)
}

func TestChainIds(t *testing.T) {
chainIDs := map[uint64]bool{}

Expand Down Expand Up @@ -159,7 +160,6 @@ func TestContractVersionsCheck(t *testing.T) {
t.Fatal(err)
}
}

}

// TestContractVersionsResolve will test that the high lever interface used works.
Expand Down Expand Up @@ -432,16 +432,17 @@ fjord_time:
}

func TestHardForkOverridesAndDefaults(t *testing.T) {

defaultCanyonTime := uint64(3)
defaultSuperchainConfig := SuperchainConfig{
hardForkDefaults: HardForkConfiguration{
CanyonTime: &defaultCanyonTime,
}}
},
}
nilDefaultSuperchainConfig := SuperchainConfig{
hardForkDefaults: HardForkConfiguration{
CanyonTime: nil,
}}
},
}

overridenCanyonTime := uint64Ptr(uint64(8))
override := []byte(`canyon_time: 8`)
Expand Down Expand Up @@ -478,16 +479,15 @@ func TestHardForkOverridesAndDefaults(t *testing.T) {
for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) { executeTestCase(t, tt) })
}

}

func TestHardForkOverridesAndDefaults2(t *testing.T) {

defaultSuperchainConfig := SuperchainConfig{
hardForkDefaults: HardForkConfiguration{
CanyonTime: uint64Ptr(0),
DeltaTime: uint64Ptr(1),
}}
},
}

c := ChainConfig{}

Expand Down
4 changes: 0 additions & 4 deletions validation/gpo-params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestGasPriceOracleParams(t *testing.T) {
gasPriceOraclAddr := predeploys.GasPriceOracleAddr

checkPreEcotoneResourceConfig := func(t *testing.T, chain *ChainConfig, client *ethclient.Client) {

desiredParamsOuter, ok := GasPriceOracleParams[chain.Superchain]

if !ok {
Expand All @@ -56,11 +55,9 @@ func TestGasPriceOracleParams(t *testing.T) {
"scalar parameter %d out of bounds %d", actualParams.Scalar, desiredParams.Scalar.Bounds)

t.Logf("gas price oracle params are acceptable")

}

checkEcotoneResourceConfig := func(t *testing.T, chain *ChainConfig, client *ethclient.Client) {

desiredParamsOuter, ok := GasPriceOracleParams[chain.Superchain]

if !ok {
Expand All @@ -83,7 +80,6 @@ func TestGasPriceOracleParams(t *testing.T) {
"baseFeeScalar parameter %d out of bounds %d", actualParams.BaseFeeScalar, desiredParams.BaseFeeScalar.Bounds)

t.Logf("gas price oracle params are acceptable")

}

checkResourceConfig := func(t *testing.T, chain *ChainConfig, client *ethclient.Client) {
Expand Down
3 changes: 0 additions & 3 deletions validation/l2oo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
)

func TestL2OOParams(t *testing.T) {

isExcluded := map[uint64]bool{
10: true, // mainnet/op (old version of L2OutputOracle, no submissionInterval method)
291: true, // mainnet/orderly (old version of L2OutputOracle, no submissionInterval method)
Expand All @@ -42,7 +41,6 @@ func TestL2OOParams(t *testing.T) {

incorrectMsg := func(name string, want, got *big.Int) string {
return fmt.Sprintf("Incorrect %s, wanted %d got %d", name, want, got)

}

requireEqualParams := func(t *testing.T, desired, actual L2OOParams) {
Expand Down Expand Up @@ -90,7 +88,6 @@ func TestL2OOParams(t *testing.T) {
requireEqualParams(t, desiredParams, actualParams)

t.Logf("L2OutputOracle config params acceptable")

}

for chainID, chain := range OPChains {
Expand Down
1 change: 0 additions & 1 deletion validation/resource-config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func TestResourceConfig(t *testing.T) {
require.Equal(t, bindings.ResourceMeteringResourceConfig(OPMainnetResourceConfig), actualResourceConfig, "resource config unacceptable")

t.Logf("resource metering acceptable")

}

for chainID, chain := range OPChains {
Expand Down
3 changes: 0 additions & 3 deletions validation/superchain-version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ var isSemverAcceptable = func(desired, actual string) bool {
}

func TestSuperchainWideContractVersions(t *testing.T) {

checkSuperchainTargetSatisfiesSemver := func(t *testing.T, superchain *Superchain) {

rpcEndpoint := superchain.Config.L1.PublicRPC
require.NotEmpty(t, rpcEndpoint)

Expand Down Expand Up @@ -53,7 +51,6 @@ func TestSuperchainWideContractVersions(t *testing.T) {
for superchainName, superchain := range Superchains {
t.Run(superchainName, func(t *testing.T) { checkSuperchainTargetSatisfiesSemver(t, superchain) })
}

}

func TestContractVersions(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion validation/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var isWithinBounds = func(actual uint32, bounds [2]uint32) bool {
panic("bounds are in wrong order")
}
return (actual >= bounds[0] && actual <= bounds[1])

}

func TestAreCloseInts(t *testing.T) {
Expand Down
Loading