Add linter checks to GHA & Fix code to pass lints

Add linter checks to GHA & Fix code to pass lints.
The linters added are:
- whitespace: Tool for detection of leading and trailing whitespace
- gosec: Inspects source code for security problems
- gci: Gci control golang package import order and make it always deterministic
- misspell: Finds commonly misspelled English words in comments
- gomnd: An analyzer to detect magic numbers

The file utils/utils.go is excluded from the checks of gomnd, as uses magic numbers through the code
This commit is contained in:
arnaucube
2020-08-27 18:10:05 +02:00
parent fe8431edfa
commit fd1e9c25ee
27 changed files with 95 additions and 75 deletions

View File

@@ -7,7 +7,9 @@ import (
"github.com/hermeznetwork/hermez-node/common"
"github.com/hermeznetwork/hermez-node/db"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq" // driver for postgres DB
//nolint:errcheck // driver for postgres DB
_ "github.com/lib/pq"
migrate "github.com/rubenv/sql-migrate"
"github.com/russross/meddler"
)

View File

@@ -49,8 +49,8 @@ func TestBlocks(t *testing.T) {
// Generate fake blocks
blocks := genBlocks(fromBlock, toBlock)
// Insert blocks into DB
for _, block := range blocks {
err := historyDB.AddBlock(&block)
for i := 0; i < len(blocks); i++ {
err := historyDB.AddBlock(&blocks[i])
assert.NoError(t, err)
}
// Get all blocks from DB