Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
fix linting as muchlinting errors as possible;
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitomir2 committed Feb 13, 2024
1 parent 5ab6afe commit 5271bcd
Show file tree
Hide file tree
Showing 311 changed files with 886 additions and 330 deletions.
134 changes: 68 additions & 66 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,79 @@
# This file configures github.com/golangci/golangci-lint.

run:
timeout: 3m
tests: true
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
skip-dirs:
- tests
timeout: 3m
tests: true
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
skip-dirs:
- tests
- e2e
- e2e-polybft

service:
golangci-lint-version: 1.49.0
golangci-lint-version: 1.49.0

linters:
disable-all: true
enable:
- whitespace # Tool for detection of leading and trailing whitespace
- wsl # Forces you to use empty lines
- wastedassign # Finds wasted assignment statements
- unconvert # Unnecessary type conversions
- tparallel # Detects inappropriate usage of t.Parallel() method in your Go test codes
- thelper # Detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- stylecheck # Stylecheck is a replacement for golint
- prealloc # Finds slice declarations that could potentially be pre-allocated
- predeclared # Finds code that shadows one of Go's predeclared identifiers
- nolintlint # Ill-formed or insufficient nolint directives
- nlreturn # Checks for a new line before return and branch statements to increase code clarity
- misspell # Misspelled English words in comments
- makezero # Finds slice declarations with non-zero initial length
- lll # Long lines
- importas # Enforces consistent import aliases
- gosec # Security problems
- gofmt # Whether the code was gofmt-ed
- goimports # Unused imports
- goconst # Repeated strings that could be replaced by a constant
- forcetypeassert # Finds forced type assertions
- dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
- dupl # Code clone detection
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13
- gocritic
- errcheck # Errcheck is a go lint rule for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- godox # Godox is a linter for TODOs and FIXMEs left in the code
disable-all: true
enable:
- whitespace # Tool for detection of leading and trailing whitespace
- wsl # Forces you to use empty lines
- wastedassign # Finds wasted assignment statements
- unconvert # Unnecessary type conversions
- tparallel # Detects inappropriate usage of t.Parallel() method in your Go test codes
- thelper # Detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- stylecheck # Stylecheck is a replacement for golint
- prealloc # Finds slice declarations that could potentially be pre-allocated
- predeclared # Finds code that shadows one of Go's predeclared identifiers
- nolintlint # Ill-formed or insufficient nolint directives
- nlreturn # Checks for a new line before return and branch statements to increase code clarity
- misspell # Misspelled English words in comments
- makezero # Finds slice declarations with non-zero initial length
- lll # Long lines
- importas # Enforces consistent import aliases
- gosec # Security problems
- gofmt # Whether the code was gofmt-ed
- goimports # Unused imports
- goconst # Repeated strings that could be replaced by a constant
- forcetypeassert # Finds forced type assertions
- dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
- dupl # Code clone detection
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13
- gocritic
- errcheck # Errcheck is a go lint rule for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- godox # Godox is a linter for TODOs and FIXMEs left in the code

linters-settings:
gofmt:
simplify: true
goconst:
min-len: 3
min-occurrences: 3
gocritic:
enabled-checks:
- ruleguard
settings:
ruleguard:
rules: "./gorules/rules.go"
gofmt:
simplify: true
goconst:
min-len: 3
min-occurrences: 3
gocritic:
enabled-checks:
- ruleguard
settings:
ruleguard:
rules: "./gorules/rules.go"

issues:
new-from-rev: origin/develop # report only new issues with reference to develop branch
whole-files: true
exclude-rules:
- path: _test\.go
linters:
- gosec
- unparam
- lll
- path: gen_sc_data\.go
linters:
- wsl
- lll
- stylecheck
include:
- EXC0012 # Exported (.+) should have comment( \(or a comment on this block\))? or be unexported
- EXC0013 # Package comment should be of the form "(.+)...
- EXC0014 # Comment on exported (.+) should be of the form "(.+)..."
- EXC0015 # Should have a package comment
new-from-rev: origin/develop # report only new issues with reference to develop branch
whole-files: true
exclude-rules:
- path: _test\.go
linters:
- gosec
- unparam
- lll
- path: gen_sc_data\.go
linters:
- wsl
- lll
- stylecheck
include:
- EXC0012 # Exported (.+) should have comment( \(or a comment on this block\))? or be unexported
- EXC0013 # Package comment should be of the form "(.+)...
- EXC0014 # Comment on exported (.+) should be of the form "(.+)..."
- EXC0015 # Should have a package comment
3 changes: 2 additions & 1 deletion archive/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package archive
import (
"context"
"errors"
"fmt"
"io"
"os"

"fmt"

"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/server/proto"
"github.com/0xPolygon/polygon-edge/types"
Expand Down
3 changes: 2 additions & 1 deletion archive/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package archive

import (
"errors"
"fmt"
"io"
"math/big"
"os"

"fmt"

"github.com/0xPolygon/polygon-edge/blockchain"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/helper/progress"
Expand Down
3 changes: 2 additions & 1 deletion archive/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package archive
import (
"bytes"
"errors"
"fmt"
"io"
"os"
"testing"

"fmt"

"github.com/0xPolygon/polygon-edge/blockchain"
"github.com/0xPolygon/polygon-edge/helper/progress"
"github.com/0xPolygon/polygon-edge/types"
Expand Down
3 changes: 2 additions & 1 deletion blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package blockchain

import (
"errors"
"fmt"
"math/big"
"sync"
"sync/atomic"

"fmt"

"github.com/0xPolygon/polygon-edge/blockchain/storage"
"github.com/0xPolygon/polygon-edge/chain"
"github.com/0xPolygon/polygon-edge/helper/common"
Expand Down
4 changes: 3 additions & 1 deletion blockchain/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package blockchain

import (
"errors"
"fmt"
"math/big"
"reflect"
"testing"

"fmt"

"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/helper/hex"
"github.com/0xPolygon/polygon-edge/state"
Expand Down Expand Up @@ -450,6 +451,7 @@ func TestInsertHeaders(t *testing.T) {
if len(a) != len(b) {
t.Fatal("bad size")
}

for indx := range a {
if chain.headers[a[indx].hash].Hash != b[indx].Hash {
t.Fatal("bad")
Expand Down
3 changes: 2 additions & 1 deletion blockchain/storage/keyvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
package storage

import (
"fmt"
"math/big"

"fmt"

"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/types"
"github.com/hashicorp/go-hclog"
Expand Down
1 change: 1 addition & 0 deletions blockchain/storage/leveldb/leveldb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func dirSize(t *testing.T, path string) int64 {
if err != nil {
t.Fail()
}

if !info.IsDir() {
size += info.Size()
}
Expand Down
3 changes: 2 additions & 1 deletion blockchain/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package blockchain

import (
"errors"
"fmt"
"math/big"
"testing"

"fmt"

"github.com/0xPolygon/polygon-edge/blockchain/storage"
"github.com/0xPolygon/polygon-edge/blockchain/storage/memory"

Expand Down
3 changes: 2 additions & 1 deletion chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package chain
import (
"encoding/binary"
"encoding/json"
"fmt"
"math/big"
"os"

"fmt"

"github.com/hashicorp/go-multierror"
"github.com/umbracle/ethgo"

Expand Down
1 change: 1 addition & 0 deletions command/backup/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package backup

import (
"bytes"

"fmt"

"github.com/0xPolygon/polygon-edge/command/helper"
Expand Down
3 changes: 2 additions & 1 deletion command/bridge/common/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package common
import (
"bytes"
"errors"
"fmt"
"math/big"
"strings"

"fmt"

"github.com/spf13/cobra"
"github.com/umbracle/ethgo"

Expand Down
3 changes: 2 additions & 1 deletion command/bridge/deposit/erc1155/deposit_erc1155.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package erc1155

import (
"fmt"
"math/big"
"strings"

"fmt"

"github.com/spf13/cobra"
"github.com/umbracle/ethgo"

Expand Down
3 changes: 2 additions & 1 deletion command/bridge/deposit/erc20/deposit_erc20.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package erc20

import (
"fmt"
"math/big"

"fmt"

"github.com/spf13/cobra"
"github.com/umbracle/ethgo"
"golang.org/x/sync/errgroup"
Expand Down
3 changes: 2 additions & 1 deletion command/bridge/deposit/erc721/deposit_erc721.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package deposit

import (
"fmt"
"math/big"
"strings"

"fmt"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/bridge/common"
"github.com/0xPolygon/polygon-edge/command/rootchain/helper"
Expand Down
3 changes: 2 additions & 1 deletion command/bridge/exit/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"bytes"
"encoding/hex"
"errors"
"fmt"
"math/big"
"strconv"

"fmt"

"github.com/spf13/cobra"
"github.com/umbracle/ethgo"
"github.com/umbracle/ethgo/jsonrpc"
Expand Down
3 changes: 2 additions & 1 deletion command/bridge/withdraw/erc1155/withdraw_erc1155.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package erc1155

import (
"encoding/hex"
"fmt"
"math/big"
"strings"

"fmt"

"github.com/spf13/cobra"
"github.com/umbracle/ethgo"
"github.com/umbracle/ethgo/wallet"
Expand Down
3 changes: 2 additions & 1 deletion command/bridge/withdraw/erc20/withdraw_erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package erc20

import (
"encoding/hex"
"fmt"
"math/big"

"fmt"

"github.com/spf13/cobra"
"github.com/umbracle/ethgo"
"github.com/umbracle/ethgo/wallet"
Expand Down
3 changes: 2 additions & 1 deletion command/bridge/withdraw/erc721/withdraw_erc721.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package withdraw

import (
"encoding/hex"
"fmt"
"math/big"
"strings"

"fmt"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/bridge/common"
"github.com/0xPolygon/polygon-edge/command/rootchain/helper"
Expand Down
3 changes: 2 additions & 1 deletion command/cli_output.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package command

import (
"fmt"
"os"

"fmt"
)

// cliOutput implements OutputFormatter interface by printing the output into std out
Expand Down
Loading

0 comments on commit 5271bcd

Please sign in to comment.