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

Daniil/linter-update #1957

Merged
merged 7 commits into from
Jul 17, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/juno-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.56.2
version: v1.59.1
24 changes: 12 additions & 12 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ linters-settings:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
mnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
ignored-numbers:
- '0'
- '1'
- '2'
- '3'
- "0"
- "1"
- "2"
- "3"
ignored-functions:
- strings.SplitN

govet:
check-shadowing: true
shadow: true
settings:
printf:
funcs:
Expand Down Expand Up @@ -82,7 +82,7 @@ linters:
- gocritic
- gocyclo
- gofumpt
- gomnd
- mnd
- goprintffuncname
- gosec
- gosimple
Expand Down Expand Up @@ -127,7 +127,7 @@ issues:
exclude-rules:
- path: _test\.go
linters:
- gomnd
- mnd
- funlen
- lll
- gosec
Expand Down Expand Up @@ -156,11 +156,11 @@ issues:
text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead."
- path: pkg/golinters/unused.go
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"

run:
timeout: 5m
kirugan marked this conversation as resolved.
Show resolved Hide resolved
skip-dirs:
exclude-dirs:
- test/testdata_etc # test files
- internal/cache # extracted from Go code
- internal/renameio # extracted from Go code
- internal/robustio # extracted from Go code

run:
timeout: 5m
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ install-mockgen:
go install go.uber.org/mock/mockgen@latest

install-golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1

lint:
@which golangci-lint || make install-golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion core/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type ResourceBounds struct {
}

func (rb ResourceBounds) Bytes(resource Resource) []byte {
maxAmountBytes := make([]byte, 8) //nolint:gomnd
maxAmountBytes := make([]byte, 8) //nolint:mnd
binary.BigEndian.PutUint64(maxAmountBytes, rb.MaxAmount)
maxPriceBytes := rb.MaxPricePerUnit.Bytes()
return slices.Concat(
Expand Down
2 changes: 1 addition & 1 deletion core/trie/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (k *Key) SubKey(n uint8) (*Key, error) {
}

newKey := &Key{len: n}
copy(newKey.bitset[:], k.bitset[len(k.bitset)-int((k.len+7)/8):]) //nolint:gomnd
copy(newKey.bitset[:], k.bitset[len(k.bitset)-int((k.len+7)/8):]) //nolint:mnd

// Shift right by the number of bits that are not needed
shift := k.len - n
Expand Down
8 changes: 4 additions & 4 deletions core/trie/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func VerifyProof(root *felt.Felt, key *Key, value *felt.Felt, proofs []ProofNode
return false
}
expectedHash = proofNode.Edge.Child
remainingPath.Truncate(251 - proofNode.Edge.Path.Len()) //nolint:gomnd
remainingPath.Truncate(251 - proofNode.Edge.Path.Len()) //nolint:mnd
}
}

Expand Down Expand Up @@ -369,7 +369,7 @@ func ProofToPath(proofNodes []ProofNode, leafKey *Key, hashF hashFunc) ([]Storag
}

// Don't store leafs along proof paths
if parentKey.len == 251 { //nolint:gomnd
if parentKey.len == 251 { //nolint:mnd
break
}

Expand Down Expand Up @@ -458,7 +458,7 @@ func getChildKey(childIdx int, crntKey, leafKey, nilKey *Key, proofNodes []Proof
return nil, err
}

if crntKey.len+uint8(compressChild)+compressChildOffset == 251 { //nolint:gomnd
if crntKey.len+uint8(compressChild)+compressChildOffset == 251 { //nolint:mnd
return nilKey, nil
}

Expand All @@ -467,7 +467,7 @@ func getChildKey(childIdx int, crntKey, leafKey, nilKey *Key, proofNodes []Proof

// BuildTrie builds a trie using the proof paths (including inner nodes), and then sets all the keys-values (leaves)
func BuildTrie(leftProofPath, rightProofPath []StorageNode, keys, values []*felt.Felt) (*Trie, error) { //nolint:gocyclo
tempTrie, err := NewTriePedersen(newMemStorage(), 251) //nolint:gomnd
tempTrie, err := NewTriePedersen(newMemStorage(), 251) //nolint:mnd
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ var defaultMigrations = []Migration{
NewBucketMigrator(db.ContractStorage, migrateTrieNodesFromBitsetToTrieKey(db.ContractStorage)).
WithKeyFilter(nodesFilter(db.ContractStorage)),
NewBucketMover(db.Temporary, db.ContractStorage),
NewBucketMigrator(db.StateUpdatesByBlockNumber, changeStateDiffStruct).WithBatchSize(100), //nolint:gomnd
NewBucketMigrator(db.Class, migrateCairo1CompiledClass).WithBatchSize(1_000), //nolint:gomnd
NewBucketMigrator(db.StateUpdatesByBlockNumber, changeStateDiffStruct).WithBatchSize(100), //nolint:mnd
NewBucketMigrator(db.Class, migrateCairo1CompiledClass).WithBatchSize(1_000), //nolint:mnd
}

var ErrCallWithNewTransaction = errors.New("call with new transaction")
Expand Down
2 changes: 1 addition & 1 deletion utils/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var levelStrings = map[utils.LogLevel]string{

func TestLogLevelString(t *testing.T) {
for level, str := range levelStrings {
t.Run("level "+str, func(t *testing.T) { //nolint:goconst
t.Run("level "+str, func(t *testing.T) {
assert.Equal(t, str, level.String())
})
}
Expand Down
10 changes: 5 additions & 5 deletions utils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var (
FeederURL: "https://alpha4.starknet.io/feeder_gateway/",
GatewayURL: "https://alpha4.starknet.io/gateway/",
L2ChainID: "SN_GOERLI",
//nolint:gomnd
//nolint:mnd
L1ChainID: big.NewInt(5),
CoreContractAddress: common.HexToAddress("0xde29d060D45901Fb19ED6C6e959EB22d8626708e"),
BlockHashMetaInfo: &BlockHashMetaInfo{
Expand All @@ -73,7 +73,7 @@ var (
FeederURL: "https://alpha4-2.starknet.io/feeder_gateway/",
GatewayURL: "https://alpha4-2.starknet.io/gateway/",
L2ChainID: "SN_GOERLI2",
//nolint:gomnd
//nolint:mnd
L1ChainID: big.NewInt(5),
CoreContractAddress: common.HexToAddress("0xa4eD3aD27c294565cB0DCc993BDdCC75432D498c"),
BlockHashMetaInfo: &BlockHashMetaInfo{
Expand All @@ -86,7 +86,7 @@ var (
FeederURL: "https://external.integration.starknet.io/feeder_gateway/",
GatewayURL: "https://external.integration.starknet.io/gateway/",
L2ChainID: "SN_GOERLI",
//nolint:gomnd
//nolint:mnd
L1ChainID: big.NewInt(5),
CoreContractAddress: common.HexToAddress("0xd5c325D183C592C94998000C5e0EED9e6655c020"),
BlockHashMetaInfo: &BlockHashMetaInfo{
Expand All @@ -100,7 +100,7 @@ var (
FeederURL: "https://alpha-sepolia.starknet.io/feeder_gateway/",
GatewayURL: "https://alpha-sepolia.starknet.io/gateway/",
L2ChainID: "SN_SEPOLIA",
//nolint:gomnd
//nolint:mnd
L1ChainID: big.NewInt(11155111),
CoreContractAddress: common.HexToAddress("0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057"),
BlockHashMetaInfo: &BlockHashMetaInfo{
Expand All @@ -113,7 +113,7 @@ var (
FeederURL: "https://integration-sepolia.starknet.io/feeder_gateway/",
GatewayURL: "https://integration-sepolia.starknet.io/gateway/",
L2ChainID: "SN_INTEGRATION_SEPOLIA",
//nolint:gomnd
//nolint:mnd
L1ChainID: big.NewInt(11155111),
CoreContractAddress: common.HexToAddress("0x4737c0c1B4D5b1A687B42610DdabEE781152359c"),
BlockHashMetaInfo: &BlockHashMetaInfo{
Expand Down
2 changes: 1 addition & 1 deletion utils/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestNetwork(t *testing.T) {
//nolint:dupl // see comment in utils/log_test.go
func TestNetworkSet(t *testing.T) {
for network, str := range networkStrings {
t.Run("network "+str, func(t *testing.T) { //nolint:goconst
t.Run("network "+str, func(t *testing.T) {
n := new(utils.Network)
require.NoError(t, n.Set(str))
assert.Equal(t, network, *n)
Expand Down
Loading