Skip to content

Commit

Permalink
Merge pull request #377 from alsm/master
Browse files Browse the repository at this point in the history
Fixing linting issues
  • Loading branch information
Al S-M committed Oct 28, 2019
2 parents 90c9a58 + 046d366 commit 825e8b3
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 57 deletions.
2 changes: 1 addition & 1 deletion client.go
Expand Up @@ -799,7 +799,7 @@ func (c *client) reserveStoredPublishIDs() {
// The resume function sets the stored id for publish packets only (some other packets
// will get new ids in net code). This means that the only keys we need to ensure are
// unique are the publish ones (and these will completed/replaced in resume() )
if c.options.CleanSession == false {
if !c.options.CleanSession {
storedKeys := c.persist.All()
for _, key := range storedKeys {
packet := c.persist.Get(key)
Expand Down
5 changes: 1 addition & 4 deletions packets/connack.go
Expand Up @@ -15,10 +15,7 @@ type ConnackPacket struct {
}

func (ca *ConnackPacket) String() string {
str := fmt.Sprintf("%s", ca.FixedHeader)
str += " "
str += fmt.Sprintf("sessionpresent: %t returncode: %d", ca.SessionPresent, ca.ReturnCode)
return str
return fmt.Sprintf("%s sessionpresent: %t returncode: %d", ca.FixedHeader, ca.SessionPresent, ca.ReturnCode)
}

func (ca *ConnackPacket) Write(w io.Writer) error {
Expand Down
5 changes: 1 addition & 4 deletions packets/connect.go
Expand Up @@ -29,10 +29,7 @@ type ConnectPacket struct {
}

func (c *ConnectPacket) String() string {
str := fmt.Sprintf("%s", c.FixedHeader)
str += " "
str += fmt.Sprintf("protocolversion: %d protocolname: %s cleansession: %t willflag: %t WillQos: %d WillRetain: %t Usernameflag: %t Passwordflag: %t keepalive: %d clientId: %s willtopic: %s willmessage: %s Username: %s Password: %s", c.ProtocolVersion, c.ProtocolName, c.CleanSession, c.WillFlag, c.WillQos, c.WillRetain, c.UsernameFlag, c.PasswordFlag, c.Keepalive, c.ClientIdentifier, c.WillTopic, c.WillMessage, c.Username, c.Password)
return str
return fmt.Sprintf("%s protocolversion: %d protocolname: %s cleansession: %t willflag: %t WillQos: %d WillRetain: %t Usernameflag: %t Passwordflag: %t keepalive: %d clientId: %s willtopic: %s willmessage: %s Username: %s Password: %s", c.FixedHeader, c.ProtocolVersion, c.ProtocolName, c.CleanSession, c.WillFlag, c.WillQos, c.WillRetain, c.UsernameFlag, c.PasswordFlag, c.Keepalive, c.ClientIdentifier, c.WillTopic, c.WillMessage, c.Username, c.Password)
}

func (c *ConnectPacket) Write(w io.Writer) error {
Expand Down
4 changes: 1 addition & 3 deletions packets/disconnect.go
@@ -1,7 +1,6 @@
package packets

import (
"fmt"
"io"
)

Expand All @@ -12,8 +11,7 @@ type DisconnectPacket struct {
}

func (d *DisconnectPacket) String() string {
str := fmt.Sprintf("%s", d.FixedHeader)
return str
return d.FixedHeader.String()
}

func (d *DisconnectPacket) Write(w io.Writer) error {
Expand Down
4 changes: 1 addition & 3 deletions packets/pingreq.go
@@ -1,7 +1,6 @@
package packets

import (
"fmt"
"io"
)

Expand All @@ -12,8 +11,7 @@ type PingreqPacket struct {
}

func (pr *PingreqPacket) String() string {
str := fmt.Sprintf("%s", pr.FixedHeader)
return str
return pr.FixedHeader.String()
}

func (pr *PingreqPacket) Write(w io.Writer) error {
Expand Down
4 changes: 1 addition & 3 deletions packets/pingresp.go
@@ -1,7 +1,6 @@
package packets

import (
"fmt"
"io"
)

Expand All @@ -12,8 +11,7 @@ type PingrespPacket struct {
}

func (pr *PingrespPacket) String() string {
str := fmt.Sprintf("%s", pr.FixedHeader)
return str
return pr.FixedHeader.String()
}

func (pr *PingrespPacket) Write(w io.Writer) error {
Expand Down
5 changes: 1 addition & 4 deletions packets/puback.go
Expand Up @@ -13,10 +13,7 @@ type PubackPacket struct {
}

func (pa *PubackPacket) String() string {
str := fmt.Sprintf("%s", pa.FixedHeader)
str += " "
str += fmt.Sprintf("MessageID: %d", pa.MessageID)
return str
return fmt.Sprintf("%s MessageID: %d", pa.FixedHeader, pa.MessageID)
}

func (pa *PubackPacket) Write(w io.Writer) error {
Expand Down
5 changes: 1 addition & 4 deletions packets/pubcomp.go
Expand Up @@ -13,10 +13,7 @@ type PubcompPacket struct {
}

func (pc *PubcompPacket) String() string {
str := fmt.Sprintf("%s", pc.FixedHeader)
str += " "
str += fmt.Sprintf("MessageID: %d", pc.MessageID)
return str
return fmt.Sprintf("%s MessageID: %d", pc.FixedHeader, pc.MessageID)
}

func (pc *PubcompPacket) Write(w io.Writer) error {
Expand Down
7 changes: 1 addition & 6 deletions packets/publish.go
Expand Up @@ -16,12 +16,7 @@ type PublishPacket struct {
}

func (p *PublishPacket) String() string {
str := fmt.Sprintf("%s", p.FixedHeader)
str += " "
str += fmt.Sprintf("topicName: %s MessageID: %d", p.TopicName, p.MessageID)
str += " "
str += fmt.Sprintf("payload: %s", string(p.Payload))
return str
return fmt.Sprintf("%s topicName: %s MessageID: %d payload: %s", p.FixedHeader, p.TopicName, p.MessageID, string(p.Payload))
}

func (p *PublishPacket) Write(w io.Writer) error {
Expand Down
5 changes: 1 addition & 4 deletions packets/pubrec.go
Expand Up @@ -13,10 +13,7 @@ type PubrecPacket struct {
}

func (pr *PubrecPacket) String() string {
str := fmt.Sprintf("%s", pr.FixedHeader)
str += " "
str += fmt.Sprintf("MessageID: %d", pr.MessageID)
return str
return fmt.Sprintf("%s MessageID: %d", pr.FixedHeader, pr.MessageID)
}

func (pr *PubrecPacket) Write(w io.Writer) error {
Expand Down
5 changes: 1 addition & 4 deletions packets/pubrel.go
Expand Up @@ -13,10 +13,7 @@ type PubrelPacket struct {
}

func (pr *PubrelPacket) String() string {
str := fmt.Sprintf("%s", pr.FixedHeader)
str += " "
str += fmt.Sprintf("MessageID: %d", pr.MessageID)
return str
return fmt.Sprintf("%s MessageID: %d", pr.FixedHeader, pr.MessageID)
}

func (pr *PubrelPacket) Write(w io.Writer) error {
Expand Down
5 changes: 1 addition & 4 deletions packets/suback.go
Expand Up @@ -15,10 +15,7 @@ type SubackPacket struct {
}

func (sa *SubackPacket) String() string {
str := fmt.Sprintf("%s", sa.FixedHeader)
str += " "
str += fmt.Sprintf("MessageID: %d", sa.MessageID)
return str
return fmt.Sprintf("%s MessageID: %d", sa.FixedHeader, sa.MessageID)
}

func (sa *SubackPacket) Write(w io.Writer) error {
Expand Down
5 changes: 1 addition & 4 deletions packets/subscribe.go
Expand Up @@ -16,10 +16,7 @@ type SubscribePacket struct {
}

func (s *SubscribePacket) String() string {
str := fmt.Sprintf("%s", s.FixedHeader)
str += " "
str += fmt.Sprintf("MessageID: %d topics: %s", s.MessageID, s.Topics)
return str
return fmt.Sprintf("%s MessageID: %d topics: %s", s.FixedHeader, s.MessageID, s.Topics)
}

func (s *SubscribePacket) Write(w io.Writer) error {
Expand Down
5 changes: 1 addition & 4 deletions packets/unsuback.go
Expand Up @@ -13,10 +13,7 @@ type UnsubackPacket struct {
}

func (ua *UnsubackPacket) String() string {
str := fmt.Sprintf("%s", ua.FixedHeader)
str += " "
str += fmt.Sprintf("MessageID: %d", ua.MessageID)
return str
return fmt.Sprintf("%s MessageID: %d", ua.FixedHeader, ua.MessageID)
}

func (ua *UnsubackPacket) Write(w io.Writer) error {
Expand Down
5 changes: 1 addition & 4 deletions packets/unsubscribe.go
Expand Up @@ -15,10 +15,7 @@ type UnsubscribePacket struct {
}

func (u *UnsubscribePacket) String() string {
str := fmt.Sprintf("%s", u.FixedHeader)
str += " "
str += fmt.Sprintf("MessageID: %d", u.MessageID)
return str
return fmt.Sprintf("%s MessageID: %d", u.FixedHeader, u.MessageID)
}

func (u *UnsubscribePacket) Write(w io.Writer) error {
Expand Down
2 changes: 1 addition & 1 deletion ping.go
Expand Up @@ -59,7 +59,7 @@ func keepalive(c *client) {
pingSent = time.Now()
}
}
if atomic.LoadInt32(&c.pingOutstanding) > 0 && time.Now().Sub(pingSent) >= c.options.PingTimeout {
if atomic.LoadInt32(&c.pingOutstanding) > 0 && time.Since(pingSent) >= c.options.PingTimeout {
CRITICAL.Println(PNG, "pingresp not received, disconnecting")
c.errors <- errors.New("pingresp not received, disconnecting")
return
Expand Down

0 comments on commit 825e8b3

Please sign in to comment.