Merge pull request #256 from 9seconds/golangcilint-1.44.2

Update golangci-lint to 1.44.2
This commit is contained in:
Sergey Arkhipov
2022-03-11 17:13:58 +03:00
committed by GitHub
17 changed files with 30 additions and 27 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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"]
+1 -1
View File
@@ -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)
+3 -3
View File
@@ -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
}
+2 -2
View File
@@ -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 {
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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) {
+2 -2
View File
@@ -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) {
@@ -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) {
@@ -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)
})
@@ -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)
+1 -1
View File
@@ -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) {
+6 -3
View File
@@ -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) {
@@ -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
}
@@ -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))
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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
}
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+1 -1
View File
@@ -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) {