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

Update golangci-lint to 1.44.2 #256

Merged
merged 1 commit into from
Mar 11, 2022
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/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v2
with:
version: v1.43.0
version: v1.44.2

docker:
name: Docker
Expand Down
2 changes: 1 addition & 1 deletion .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ format = "colored-line-number"

[linters]
enable-all = true
disable = ["ireturn", "varnamelen", "gochecknoglobals", "gas", "goerr113", "exhaustivestruct"]
disable = ["ireturn", "varnamelen", "gochecknoglobals", "gas", "goerr113", "exhaustivestruct", "containedctx"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
IMAGE_NAME := mtg
APP_NAME := $(IMAGE_NAME)

GOLANGCI_LINT_VERSION := v1.43.0
GOLANGCI_LINT_VERSION := v1.44.2

VERSION_GO := $(shell go version)
VERSION_DATE := $(shell date -Ru)
Expand Down
6 changes: 3 additions & 3 deletions internal/testlib/mtglib_network_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ type MtglibNetworkMock struct {
func (m *MtglibNetworkMock) Dial(network, address string) (essentials.Conn, error) {
args := m.Called(network, address)

return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
}

func (m *MtglibNetworkMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
args := m.Called(ctx, network, address)

return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
}

func (m *MtglibNetworkMock) MakeHTTPClient(dialFunc func(ctx context.Context,
network, address string) (essentials.Conn, error)) *http.Client {
return m.Called(dialFunc).Get(0).(*http.Client)
return m.Called(dialFunc).Get(0).(*http.Client) // nolint: forcetypeassert
}
4 changes: 2 additions & 2 deletions internal/testlib/net_conn_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func (n *EssentialsConnMock) CloseWrite() error {
}

func (n *EssentialsConnMock) LocalAddr() net.Addr {
return n.Called().Get(0).(net.Addr)
return n.Called().Get(0).(net.Addr) // nolint: forcetypeassert
}

func (n *EssentialsConnMock) RemoteAddr() net.Addr {
return n.Called().Get(0).(net.Addr)
return n.Called().Get(0).(net.Addr) // nolint: forcetypeassert
}

func (n *EssentialsConnMock) SetDeadline(t time.Time) error {
Expand Down
2 changes: 1 addition & 1 deletion mtglib/internal/faketls/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var bytesBufferPool = sync.Pool{
}

func acquireBytesBuffer() *bytes.Buffer {
return bytesBufferPool.Get().(*bytes.Buffer)
return bytesBufferPool.Get().(*bytes.Buffer) // nolint: forcetypeassert
}

func releaseBytesBuffer(b *bytes.Buffer) {
Expand Down
2 changes: 1 addition & 1 deletion mtglib/internal/faketls/record/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var recordPool = sync.Pool{
}

func AcquireRecord() *Record {
return recordPool.Get().(*Record)
return recordPool.Get().(*Record) // nolint: forcetypeassert
}

func ReleaseRecord(r *Record) {
Expand Down
4 changes: 2 additions & 2 deletions mtglib/internal/obfuscated2/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
)

func acquireSha256Hasher() hash.Hash {
return sha256HasherPool.Get().(hash.Hash)
return sha256HasherPool.Get().(hash.Hash) // nolint: forcetypeassert
}

func releaseSha256Hasher(h hash.Hash) {
Expand All @@ -30,7 +30,7 @@ func releaseSha256Hasher(h hash.Hash) {
}

func acquireBytesBuffer() *bytes.Buffer {
return bytesBufferPool.Get().(*bytes.Buffer)
return bytesBufferPool.Get().(*bytes.Buffer) // nolint: forcetypeassert
}

func releaseBytesBuffer(buf *bytes.Buffer) {
Expand Down
4 changes: 2 additions & 2 deletions mtglib/internal/obfuscated2/server_handshake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (suite *ServerHandshakeTestSuite) TestSendToTelegram() {
Once().
Run(func(args mock.Arguments) {
message := make([]byte, len(messageToTelegram))
suite.decryptor.XORKeyStream(message, args.Get(0).([]byte))
suite.decryptor.XORKeyStream(message, args.Get(0).([]byte)) // nolint: forcetypeassert
suite.Equal(messageToTelegram, message)
})

Expand All @@ -89,7 +89,7 @@ func (suite *ServerHandshakeTestSuite) TestRecieveFromTelegram() {
Run(func(args mock.Arguments) {
message := make([]byte, len(messageFromTelegram))
suite.encryptor.XORKeyStream(message, messageFromTelegram)
copy(args.Get(0).([]byte), message)
copy(args.Get(0).([]byte), message) // nolint: forcetypeassert
})

n, err := suite.proxyConn.Read(buffer)
Expand Down
2 changes: 1 addition & 1 deletion mtglib/internal/relay/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var copyBufferPool = sync.Pool{
}

func acquireCopyBuffer() *[]byte {
return copyBufferPool.Get().(*[]byte)
return copyBufferPool.Get().(*[]byte) // nolint: forcetypeassert
}

func releaseCopyBuffer(buf *[]byte) {
Expand Down
9 changes: 6 additions & 3 deletions mtglib/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (p *Proxy) Serve(listener net.Listener) error { // nolint: cyclop
}
}

ipAddr := conn.RemoteAddr().(*net.TCPAddr).IP
ipAddr := conn.RemoteAddr().(*net.TCPAddr).IP // nolint: forcetypeassert
logger := p.logger.BindStr("ip", ipAddr.String())

if p.whitelist != nil && !p.whitelist.Contains(ipAddr) {
Expand Down Expand Up @@ -255,7 +255,10 @@ func (p *Proxy) doTelegramCall(ctx *streamContext) error {
}

p.eventStream.Send(ctx,
NewEventConnectedToDC(ctx.streamID, conn.RemoteAddr().(*net.TCPAddr).IP, ctx.dc))
NewEventConnectedToDC(ctx.streamID,
conn.RemoteAddr().(*net.TCPAddr).IP, // nolint: forcetypeassert
ctx.dc),
)

return nil
}
Expand Down Expand Up @@ -316,7 +319,7 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) {

pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
func(arg interface{}) {
proxy.ServeConn(arg.(essentials.Conn))
proxy.ServeConn(arg.(essentials.Conn)) // nolint: forcetypeassert
},
ants.WithLogger(opts.getLogger("ants")),
ants.WithNonblocking(true))
Expand Down
2 changes: 1 addition & 1 deletion mtglib/stream_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (s *streamContext) Close() {
}

func (s *streamContext) ClientIP() net.IP {
return s.clientConn.RemoteAddr().(*net.TCPAddr).IP
return s.clientConn.RemoteAddr().(*net.TCPAddr).IP // nolint: forcetypeassert
}

func newStreamContext(ctx context.Context, logger Logger, clientConn essentials.Conn) *streamContext {
Expand Down
2 changes: 1 addition & 1 deletion network/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (d *defaultDialer) DialContext(ctx context.Context, network, address string
return nil, fmt.Errorf("cannot set socket options: %w", err)
}

return conn.(essentials.Conn), nil
return conn.(essentials.Conn), nil // nolint: forcetypeassert
}

// NewDefaultDialer build a new dialer which dials bypassing proxies
Expand Down
4 changes: 2 additions & 2 deletions network/init_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ type DialerMock struct {
func (d *DialerMock) Dial(network, address string) (essentials.Conn, error) {
args := d.Called(network, address)

return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
}

func (d *DialerMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
args := d.Called(ctx, network, address)

return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
}
4 changes: 2 additions & 2 deletions network/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ type DialerMock struct {
func (d *DialerMock) Dial(network, address string) (essentials.Conn, error) {
args := d.Called(network, address)

return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
}

func (d *DialerMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
args := d.Called(ctx, network, address)

return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
}

type HTTPServerTestSuite struct {
Expand Down
4 changes: 2 additions & 2 deletions network/sockopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
//
// bufferSize setting is deprecated and ignored.
func SetClientSocketOptions(conn net.Conn, bufferSize int) error {
return setCommonSocketOptions(conn.(*net.TCPConn))
return setCommonSocketOptions(conn.(*net.TCPConn)) // nolint: forcetypeassert
}

// SetServerSocketOptions tunes a TCP socket that represents a connection to
// remote server like Telegram or fronting domain (but not end user).
func SetServerSocketOptions(conn net.Conn, bufferSize int) error {
return setCommonSocketOptions(conn.(*net.TCPConn))
return setCommonSocketOptions(conn.(*net.TCPConn)) // nolint: forcetypeassert
}

func setCommonSocketOptions(conn *net.TCPConn) error {
Expand Down
2 changes: 1 addition & 1 deletion stats/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var streamInfoPool = sync.Pool{
}

func acquireStreamInfo() *streamInfo {
return streamInfoPool.Get().(*streamInfo)
return streamInfoPool.Get().(*streamInfo) // nolint: forcetypeassert
}

func releaseStreamInfo(info *streamInfo) {
Expand Down