Skip to content

Commit

Permalink
chore: fix linters warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <[email protected]>
  • Loading branch information
rustatian committed Sep 6, 2024
1 parent bedb596 commit b1d3900
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Linters
on: [push, pull_request]

jobs:
golangci-lint:
linters:
name: Golang-CI (lint)
runs-on: ubuntu-latest
steps:
Expand All @@ -18,5 +18,5 @@ jobs:
- name: Run linter
uses: golangci/[email protected] # Action page: <https://github.com/golangci/golangci-lint-action>
with:
version: v1.60 # without patch version
version: v1 # without patch version
only-new-issues: false # show only new issues if it's a pull request
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Linux
on: [push, pull_request]

jobs:
build:
testing:
name: Tests [Go ${{ matrix.go }} OS ${{ matrix.os }}]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ linters: # All available linters list: <https://golangci-lint.run/usage/linters/
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- errorlint # find code that will cause problems with the error wrapping scheme introduced in Go 1.13
- exhaustive # check exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- copyloopvar # checks for pointers to enclosing loop variables
- gochecknoinits # Checks that no init functions are present in Go code
- goconst # Finds repeated strings that could be replaced by a constant
- gocritic # The most opinionated Go source code linter
Expand Down
4 changes: 2 additions & 2 deletions pkg/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ func (c *ClientCodec) WriteRequest(r *rpc.Request, body any) error {
}

// SEQ_ID + METHOD_NAME_LEN
fr.WriteOptions(fr.HeaderPtr(), uint32(r.Seq), uint32(len(r.ServiceMethod)))
fr.WriteOptions(fr.HeaderPtr(), uint32(r.Seq), uint32(len(r.ServiceMethod))) //nolint:gosec
fr.WriteVersion(fr.Header(), frame.Version1)

fr.WritePayloadLen(fr.Header(), uint32(buf.Len()))
fr.WritePayloadLen(fr.Header(), uint32(buf.Len())) //nolint:gosec
fr.WritePayload(buf.Bytes())
fr.WriteCRC(fr.Header())

Expand Down
18 changes: 9 additions & 9 deletions pkg/rpc/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ func (c *Codec) putFrame(f *frame.Frame) {
c.fPool.Put(f)
}

// WriteResponse marshals response, byte slice or error to remote party.
// WriteResponse marshals response, byte slice or error to remote.
func (c *Codec) WriteResponse(r *rpc.Response, body any) error { //nolint:funlen
const op = errors.Op("goridge_write_response")
fr := c.getFrame()
defer c.putFrame(fr)

// SEQ_ID + METHOD_NAME_LEN
fr.WriteOptions(fr.HeaderPtr(), uint32(r.Seq), uint32(len(r.ServiceMethod)))
fr.WriteOptions(fr.HeaderPtr(), uint32(r.Seq), uint32(len(r.ServiceMethod))) //nolint:gosec
// Write protocol version
fr.WriteVersion(fr.Header(), frame.Version1)

Expand Down Expand Up @@ -110,7 +110,7 @@ func (c *Codec) WriteResponse(r *rpc.Response, body any) error { //nolint:funlen
buf.WriteString(r.ServiceMethod)
buf.Write(d)

fr.WritePayloadLen(fr.Header(), uint32(buf.Len()))
fr.WritePayloadLen(fr.Header(), uint32(buf.Len())) //nolint:gosec
// copy inside
fr.WritePayload(buf.Bytes())
fr.WriteCRC(fr.Header())
Expand All @@ -128,15 +128,15 @@ func (c *Codec) WriteResponse(r *rpc.Response, body any) error { //nolint:funlen
buf.WriteString(r.ServiceMethod)
buf.Write(data)

fr.WritePayloadLen(fr.Header(), uint32(buf.Len()))
fr.WritePayloadLen(fr.Header(), uint32(buf.Len())) //nolint:gosec
fr.WritePayload(buf.Bytes())
case *[]byte:
buf.Grow(len(*data) + len(r.ServiceMethod))
// writeServiceMethod to the buffer
buf.WriteString(r.ServiceMethod)
buf.Write(*data)

fr.WritePayloadLen(fr.Header(), uint32(buf.Len()))
fr.WritePayloadLen(fr.Header(), uint32(buf.Len())) //nolint:gosec
fr.WritePayload(buf.Bytes())
default:
return c.handleError(r, fr, "unknown Raw payload type")
Expand All @@ -161,7 +161,7 @@ func (c *Codec) WriteResponse(r *rpc.Response, body any) error { //nolint:funlen
buf.WriteString(r.ServiceMethod)
buf.Write(data)

fr.WritePayloadLen(fr.Header(), uint32(buf.Len()))
fr.WritePayloadLen(fr.Header(), uint32(buf.Len())) //nolint:gosec
// copy inside
fr.WritePayload(buf.Bytes())
fr.WriteCRC(fr.Header())
Expand All @@ -182,7 +182,7 @@ func (c *Codec) WriteResponse(r *rpc.Response, body any) error { //nolint:funlen
buf.WriteString(r.ServiceMethod)
buf.Write(b)

fr.WritePayloadLen(fr.Header(), uint32(buf.Len()))
fr.WritePayloadLen(fr.Header(), uint32(buf.Len())) //nolint:gosec
// copy inside
fr.WritePayload(buf.Bytes())
fr.WriteCRC(fr.Header())
Expand All @@ -202,7 +202,7 @@ func (c *Codec) WriteResponse(r *rpc.Response, body any) error { //nolint:funlen
return errors.E(op, err)
}

fr.WritePayloadLen(fr.Header(), uint32(buf.Len()))
fr.WritePayloadLen(fr.Header(), uint32(buf.Len())) //nolint:gosec
// copy inside
fr.WritePayload(buf.Bytes())
fr.WriteCRC(fr.Header())
Expand All @@ -226,7 +226,7 @@ func (c *Codec) handleError(r *rpc.Response, fr *frame.Frame, err string) error
if err != "" {
buf.WriteString(err)
}
fr.WritePayloadLen(fr.Header(), uint32(buf.Len()))
fr.WritePayloadLen(fr.Header(), uint32(buf.Len())) //nolint:gosec
fr.WritePayload(buf.Bytes())

fr.WriteCRC(fr.Header())
Expand Down
4 changes: 2 additions & 2 deletions pkg/socket/socket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestSocketRelay(t *testing.T) {
nf := frame.NewFrame()
nf.WriteVersion(nf.Header(), frame.Version1)
nf.WriteFlags(nf.Header(), frame.CONTROL, frame.CodecGob, frame.CodecJSON)
nf.WritePayloadLen(nf.Header(), uint32(len([]byte(TestPayload))))
nf.WritePayloadLen(nf.Header(), uint32(len([]byte(TestPayload)))) //nolint:gosec
nf.WritePayload([]byte(TestPayload))
nf.WriteCRC(nf.Header())
assert.Equal(t, true, nf.VerifyCRC(nf.Header()))
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestSocketRelayOptions(t *testing.T) {
nf := frame.NewFrame()
nf.WriteVersion(nf.Header(), frame.Version1)
nf.WriteFlags(nf.Header(), frame.CONTROL, frame.CodecGob, frame.CodecJSON)
nf.WritePayloadLen(nf.Header(), uint32(len([]byte(TestPayload))))
nf.WritePayloadLen(nf.Header(), uint32(len([]byte(TestPayload)))) //nolint:gosec
nf.WritePayload([]byte(TestPayload))
nf.WriteOptions(nf.HeaderPtr(), 100, 10000, 100000)
nf.WriteCRC(nf.Header())
Expand Down

0 comments on commit b1d3900

Please sign in to comment.