forked from quic-go/quic-go
Merge pull request #1798 from lucas-clemente/linter-fixes
use GolangCI-Lint instead of gometalinter
This commit is contained in:
24
.golangci.yml
Normal file
24
.golangci.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
run:
|
||||
skip-files:
|
||||
- h2quic/response_writer_closenotifier.go
|
||||
|
||||
linters-settings:
|
||||
misspell:
|
||||
ignore-words:
|
||||
- ect
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- deadcode
|
||||
- goconst
|
||||
- goimports
|
||||
- gosimple
|
||||
- ineffassign
|
||||
- misspell
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- unconvert
|
||||
- unused
|
||||
- varcheck
|
||||
- vet
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"DisableAll": true,
|
||||
"Exclude": [
|
||||
"vendor",
|
||||
"streams_map_incoming_generic.go",
|
||||
"streams_map_outgoing_generic.go"
|
||||
],
|
||||
"Enable": [
|
||||
"deadcode",
|
||||
"goimports",
|
||||
"ineffassign",
|
||||
"misspell",
|
||||
"staticcheck",
|
||||
"structcheck",
|
||||
"unconvert",
|
||||
"varcheck",
|
||||
"vet"
|
||||
],
|
||||
"Linters": {
|
||||
"vet": "go tool vet -printfuncs=Infof,Debugf,Warningf,Errorf:PATH:LINE:MESSAGE",
|
||||
"misspell": "misspell -i ect:PATH:LINE:COL:MESSAGE",
|
||||
"staticcheck": "staticcheck -ignore github.com/lucas-clemente/quic-go/h2quic/response_writer_closenotifier.go:SA1019:PATH:LINE:COL:MESSAGE"
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,9 @@
|
||||
set -ex
|
||||
|
||||
go get -t ./...
|
||||
if [ ${TESTMODE} == "lint" ]; then
|
||||
go get github.com/alecthomas/gometalinter
|
||||
gometalinter --install
|
||||
gometalinter --deadline=300s --tests ./...
|
||||
if [ ${TESTMODE} == "lint" ]; then
|
||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.15.0
|
||||
./bin/golangci-lint run ./...
|
||||
fi
|
||||
|
||||
if [ ${TESTMODE} == "unit" ]; then
|
||||
|
||||
@@ -62,10 +62,10 @@ var _ = Describe("Stream Framer", func() {
|
||||
for i := 0; i < numFrames+1; i++ {
|
||||
framer.QueueControlFrame(bf)
|
||||
}
|
||||
frames, length := framer.AppendControlFrames(nil, protocol.ByteCount(maxSize))
|
||||
frames, length := framer.AppendControlFrames(nil, maxSize)
|
||||
Expect(frames).To(HaveLen(numFrames))
|
||||
Expect(length).To(BeNumerically(">", maxSize-bfLen))
|
||||
frames, length = framer.AppendControlFrames(nil, protocol.ByteCount(maxSize))
|
||||
frames, length = framer.AppendControlFrames(nil, maxSize)
|
||||
Expect(frames).To(HaveLen(1))
|
||||
Expect(length).To(Equal(bfLen))
|
||||
})
|
||||
|
||||
@@ -70,7 +70,7 @@ var _ = Describe("PRR sender", func() {
|
||||
})
|
||||
|
||||
It("burst loss results in slow start", func() {
|
||||
bytesInFlight := protocol.ByteCount(20 * protocol.DefaultTCPMSS)
|
||||
bytesInFlight := 20 * protocol.DefaultTCPMSS
|
||||
const numPacketsLost = 13
|
||||
const ssthreshAfterLoss = 10
|
||||
const congestionWindow = ssthreshAfterLoss * protocol.DefaultTCPMSS
|
||||
|
||||
@@ -167,7 +167,7 @@ var _ = Describe("Base Flow controller", func() {
|
||||
newWindowSize := controller.receiveWindowSize
|
||||
Expect(newWindowSize).To(Equal(2 * oldWindowSize))
|
||||
// check that the new window size was used to increase the offset
|
||||
Expect(offset).To(Equal(protocol.ByteCount(bytesRead + dataRead + newWindowSize)))
|
||||
Expect(offset).To(Equal(bytesRead + dataRead + newWindowSize))
|
||||
})
|
||||
|
||||
It("doesn't increase the window size if data is read so fast that the window would be consumed in less than 4 RTTs, but less than half the window has been read", func() {
|
||||
@@ -188,7 +188,7 @@ var _ = Describe("Base Flow controller", func() {
|
||||
newWindowSize := controller.receiveWindowSize
|
||||
Expect(newWindowSize).To(Equal(oldWindowSize))
|
||||
// check that the new window size was used to increase the offset
|
||||
Expect(offset).To(Equal(protocol.ByteCount(bytesRead + dataRead + newWindowSize)))
|
||||
Expect(offset).To(Equal(bytesRead + dataRead + newWindowSize))
|
||||
})
|
||||
|
||||
It("doesn't increase the window size if read too slowly", func() {
|
||||
@@ -206,7 +206,7 @@ var _ = Describe("Base Flow controller", func() {
|
||||
// check that the window size was not increased
|
||||
Expect(controller.receiveWindowSize).To(Equal(oldWindowSize))
|
||||
// check that the new window size was used to increase the offset
|
||||
Expect(offset).To(Equal(protocol.ByteCount(bytesRead + dataRead + oldWindowSize)))
|
||||
Expect(offset).To(Equal(bytesRead + dataRead + oldWindowSize))
|
||||
})
|
||||
|
||||
It("doesn't increase the window size to a value higher than the maxReceiveWindowSize", func() {
|
||||
|
||||
@@ -75,7 +75,7 @@ var _ = Describe("Connection Flow controller", func() {
|
||||
dataRead := windowSize/2 - 1 // make sure not to trigger auto-tuning
|
||||
controller.AddBytesRead(dataRead)
|
||||
offset := controller.GetWindowUpdate()
|
||||
Expect(offset).To(Equal(protocol.ByteCount(oldOffset + dataRead + 60)))
|
||||
Expect(offset).To(Equal(oldOffset + dataRead + 60))
|
||||
})
|
||||
|
||||
It("autotunes the window", func() {
|
||||
@@ -90,7 +90,7 @@ var _ = Describe("Connection Flow controller", func() {
|
||||
offset := controller.GetWindowUpdate()
|
||||
newWindowSize := controller.receiveWindowSize
|
||||
Expect(newWindowSize).To(Equal(2 * oldWindowSize))
|
||||
Expect(offset).To(Equal(protocol.ByteCount(oldOffset + dataRead + newWindowSize)))
|
||||
Expect(offset).To(Equal(oldOffset + dataRead + newWindowSize))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -183,7 +183,7 @@ var _ = Describe("Stream Flow controller", func() {
|
||||
controller.epochStartTime = time.Now().Add(-time.Millisecond)
|
||||
controller.AddBytesRead(55)
|
||||
offset := controller.GetWindowUpdate()
|
||||
Expect(offset).To(Equal(protocol.ByteCount(oldOffset + 55 + 2*oldWindowSize)))
|
||||
Expect(offset).To(Equal(oldOffset + 55 + 2*oldWindowSize))
|
||||
Expect(controller.receiveWindowSize).To(Equal(2 * oldWindowSize))
|
||||
Expect(controller.connection.(*connectionFlowController).receiveWindowSize).To(Equal(protocol.ByteCount(float64(controller.receiveWindowSize) * protocol.ConnectionFlowControlMultiplier)))
|
||||
})
|
||||
|
||||
@@ -80,7 +80,7 @@ var _ = Describe("Log", func() {
|
||||
DefaultLogger.SetLogTimeFormat(format)
|
||||
DefaultLogger.SetLogLevel(LogLevelInfo)
|
||||
DefaultLogger.Infof("info")
|
||||
t, err := time.Parse(format, string(b.String()[:b.Len()-6]))
|
||||
t, err := time.Parse(format, b.String()[:b.Len()-6])
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(t).To(BeTemporally("~", time.Now(), 25*time.Hour))
|
||||
})
|
||||
|
||||
@@ -323,10 +323,6 @@ func (s *sendStream) closeForShutdown(err error) {
|
||||
s.ctxCancel()
|
||||
}
|
||||
|
||||
func (s *sendStream) getWriteOffset() protocol.ByteCount {
|
||||
return s.writeOffset
|
||||
}
|
||||
|
||||
// signalWrite performs a non-blocking send on the writeChan
|
||||
func (s *sendStream) signalWrite() {
|
||||
select {
|
||||
|
||||
@@ -62,11 +62,6 @@ func areSessionsRunning() bool {
|
||||
return strings.Contains(b.String(), "quic-go.(*session).run")
|
||||
}
|
||||
|
||||
func insertPacketBuffer(p *receivedPacket) *receivedPacket {
|
||||
p.buffer = getPacketBuffer()
|
||||
return p
|
||||
}
|
||||
|
||||
var _ = Describe("Session", func() {
|
||||
var (
|
||||
sess *session
|
||||
@@ -678,7 +673,7 @@ var _ = Describe("Session", func() {
|
||||
It("cuts packets to the right length", func() {
|
||||
hdrLen, packet := getPacketWithLength(sess.srcConnID, 456)
|
||||
unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any()).DoAndReturn(func(_ *wire.Header, data []byte) (*unpackedPacket, error) {
|
||||
Expect(data).To(HaveLen(int(hdrLen + 456 - 3)))
|
||||
Expect(data).To(HaveLen(hdrLen + 456 - 3))
|
||||
return &unpackedPacket{
|
||||
encryptionLevel: protocol.EncryptionHandshake,
|
||||
data: []byte{0},
|
||||
@@ -690,7 +685,7 @@ var _ = Describe("Session", func() {
|
||||
It("handles coalesced packets", func() {
|
||||
hdrLen1, packet1 := getPacketWithLength(sess.srcConnID, 456)
|
||||
unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any()).DoAndReturn(func(_ *wire.Header, data []byte) (*unpackedPacket, error) {
|
||||
Expect(data).To(HaveLen(int(hdrLen1 + 456 - 3)))
|
||||
Expect(data).To(HaveLen(hdrLen1 + 456 - 3))
|
||||
return &unpackedPacket{
|
||||
encryptionLevel: protocol.EncryptionHandshake,
|
||||
data: []byte{0},
|
||||
@@ -698,7 +693,7 @@ var _ = Describe("Session", func() {
|
||||
})
|
||||
hdrLen2, packet2 := getPacketWithLength(sess.srcConnID, 123)
|
||||
unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any()).DoAndReturn(func(_ *wire.Header, data []byte) (*unpackedPacket, error) {
|
||||
Expect(data).To(HaveLen(int(hdrLen2 + 123 - 3)))
|
||||
Expect(data).To(HaveLen(hdrLen2 + 123 - 3))
|
||||
return &unpackedPacket{
|
||||
encryptionLevel: protocol.EncryptionHandshake,
|
||||
data: []byte{0},
|
||||
@@ -713,7 +708,7 @@ var _ = Describe("Session", func() {
|
||||
Expect(sess.srcConnID).ToNot(Equal(wrongConnID))
|
||||
hdrLen1, packet1 := getPacketWithLength(sess.srcConnID, 456)
|
||||
unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any()).DoAndReturn(func(_ *wire.Header, data []byte) (*unpackedPacket, error) {
|
||||
Expect(data).To(HaveLen(int(hdrLen1 + 456 - 3)))
|
||||
Expect(data).To(HaveLen(hdrLen1 + 456 - 3))
|
||||
return &unpackedPacket{
|
||||
encryptionLevel: protocol.EncryptionHandshake,
|
||||
data: []byte{0},
|
||||
|
||||
Reference in New Issue
Block a user