Skip to content

Commit

Permalink
Golangci lint up, step2 (#68)
Browse files Browse the repository at this point in the history
* golangci-lint v1.57.2

* save

* save

* save

* save

* save

* save

* save

* save

* save

* save

* save

* save

* save

* save

* save

* save
  • Loading branch information
AskAlexSharov authored Apr 18, 2024
1 parent 12190a8 commit a45f9b5
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ yarn.lock
node_modules

logs/

golangci-lint
build
43 changes: 13 additions & 30 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,49 +34,32 @@ linters:
# - stylecheck

linters-settings:
gocritic:
# Which checks should be enabled; can't be combined with 'disabled-checks';
# See https://go-critic.github.io/overview#checks-overview
# To check which checks are enabled run `GL_DEBUG=gocritic ./build/bin/golangci-lint run`
# By default list of stable checks is used.
enabled-checks:
# - ruleguard
# - defaultCaseOrder

# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
gocritic: # see https://golangci-lint.run/usage/linters/#gocritic and https://go-critic.github.io/overview#checks-overview
enabled-tags:
- performance
- diagnostic
- style
disabled-checks:
- regexpMust
- appendAssign
# - hugeParam
- rangeValCopy
- exitAfterDefer
- elseif
- dupBranchBody
- assignOp
- singleCaseSwitch
- unlambda
- captLocal
- commentFormatting
- ifElseChain
- sprintfQuotedString
- commentedOutCode
- preferFprint

# style tag
- importShadow
- emptyStringTest
- paramTypeCombine
- builtinShadow
- typeUnparen
- unnamedResult

# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
enabled-tags:
- performance
- diagnostic
- opinionated
disabled-tags:
- experimental
settings:
# ruleguard:
# rules: "rules.go"
hugeParam:
# size in bytes that makes the warning trigger (default 80)
sizeThreshold: 1000
rangeExprCopy:
# size in bytes that makes the warning trigger (default 512)
sizeThreshold: 512
Expand All @@ -96,7 +79,7 @@ linters-settings:
min-len: 2
min-occurrences: 2
gofmt:
auto-fix: false
simplify: false

issues:
exclude-rules:
Expand Down
Binary file modified build/bin/golangci-lint
Binary file not shown.
4 changes: 0 additions & 4 deletions internal/erigon_node/bodies_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import (
)

func (c *NodeClient) BodiesDownload(ctx context.Context, w http.ResponseWriter) {
/*snapshot := btree.NewG(16, func(a, b SnapshotItem) bool {
return a.Id < b.Id
})*/

var tick int64
sendEvery := time.NewTicker(1000 * time.Millisecond)
defer sendEvery.Stop()
Expand Down
6 changes: 3 additions & 3 deletions internal/erigon_node/erigon_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
var _ Client = &NodeClient{}

type NodeClient struct {
sync.Mutex
lock sync.Mutex
requestId uint64
requestChannel chan *NodeRequest
nodeId string
Expand All @@ -27,10 +27,10 @@ func NewClient(nodeId string, requestChannel chan *NodeRequest) Client {
}

func (c *NodeClient) nextRequestId() string {
c.Lock()
c.lock.Lock()
id := c.requestId
c.requestId++
c.Unlock()
c.lock.Unlock()
return strconv.FormatUint(id, 10)
}

Expand Down
4 changes: 0 additions & 4 deletions internal/erigon_node/headers_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import (
)

func (c *NodeClient) HeadersDownload(ctx context.Context, w http.ResponseWriter) {
/*
snapshot := btree.NewG(16, func(a, b SnapshotItem) bool {
return a.Id < b.Id
})*/
var tick int64
sendEvery := time.NewTicker(1000 * time.Millisecond)
defer sendEvery.Stop()
Expand Down
5 changes: 2 additions & 3 deletions internal/erigon_node/remote_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func (r *results) UnmarshalJSON(json []byte) (err error) {

switch json[i] {
case byte('"'):
len, value := tostr(json[i:])
length, value := tostr(json[i:])

i += len
i += length

if result[ri], err = base64.URLEncoding.DecodeString(value); err != nil {
return err
Expand Down Expand Up @@ -161,7 +161,6 @@ func (rc *RemoteCursor) findFullDbPath(ctx context.Context, db string) (string,
if err != nil {
return "", err
}
// fmt.Println("lines: ", lines)

var dbPath string

Expand Down
10 changes: 5 additions & 5 deletions internal/sessions/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type NodeInfo struct {

// NodeSession corresponds to one Erigon node connected via "erigon support" bridge to an operator
type NodeSession struct {
sync.Mutex
lock sync.Mutex
Connected bool
RemoteAddr string
Client erigon_node.Client
Expand All @@ -39,15 +39,15 @@ type NodeSession struct {
}

func (ns *NodeSession) Connect(remoteAddr string) {
ns.Lock()
defer ns.Unlock()
ns.lock.Lock()
defer ns.lock.Unlock()
ns.Connected = true
ns.RemoteAddr = remoteAddr
}

func (ns *NodeSession) Disconnect() {
ns.Lock()
defer ns.Unlock()
ns.lock.Lock()
defer ns.lock.Unlock()
ns.Connected = false
}

Expand Down

0 comments on commit a45f9b5

Please sign in to comment.