Skip to content

Commit

Permalink
refactor: fix linter warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@paral.in>
  • Loading branch information
paralin committed Mar 23, 2023
1 parent 10336ed commit 2f48989
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 42 deletions.
2 changes: 1 addition & 1 deletion apigen/api_generate.go
Expand Up @@ -260,7 +260,7 @@ func GenerateAPI(ctx context.Context, clientOutput, eventsOutput io.Writer) erro

for _, eventHandler := range eventHandlersOrdered {
fmt.Fprintf(eventsOutput, "\n")
fmt.Fprintf(eventsOutput, eventHandler.generateComment())
fmt.Fprint(eventsOutput, eventHandler.generateComment())
fmt.Fprintf(eventsOutput, "type %s struct {\n", eventHandler.eventName)
fmt.Fprintf(eventsOutput, "\t")
if err := printFieldType(eventsOutput, eventHandler.eventType.Obj.Type()); err != nil {
Expand Down
11 changes: 6 additions & 5 deletions apigen/cmd_generate.go
Expand Up @@ -3,9 +3,10 @@ package main
import (
"bytes"
"context"
"github.com/urfave/cli/v2"
gofmt "go/format"
"io/ioutil"
"os"

"github.com/urfave/cli/v2"
)

var clientOutFile string
Expand Down Expand Up @@ -37,7 +38,7 @@ func init() {
return err
}

if err := ioutil.WriteFile(clientOutFile, clientFileBuf.Bytes(), 0655); err != nil {
if err := os.WriteFile(clientOutFile, clientFileBuf.Bytes(), 0655); err != nil {
return err
}

Expand All @@ -46,7 +47,7 @@ func init() {
clientFileDat = clientFileBuf.Bytes()
}

if err := ioutil.WriteFile(clientOutFile, clientFileDat, 0655); err != nil {
if err := os.WriteFile(clientOutFile, clientFileDat, 0655); err != nil {
return err
}

Expand All @@ -59,7 +60,7 @@ func init() {
eventsFileDat = eventsFileBuf.Bytes()
}

if err := ioutil.WriteFile(eventsOutFile, eventsFileDat, 0655); err != nil {
if err := os.WriteFile(eventsOutFile, eventsFileDat, 0655); err != nil {
return err
}

Expand Down
8 changes: 1 addition & 7 deletions apigen/msg_func.go
Expand Up @@ -15,10 +15,7 @@ func GetMessageFuncName(msg dota_gcmessages_msgid.EDOTAGCMsg) string {

msgName := msg.String()
msgName = strings.TrimPrefix(msgName, "k_EMsg")

if strings.HasPrefix(msgName, "DOTA") {
msgName = msgName[4:]
}
msgName = strings.TrimPrefix(msgName, "DOTA")

switch {
case strings.HasPrefix(msgName, "ClientToGC"):
Expand All @@ -43,9 +40,6 @@ func GetMessageFuncName(msg dota_gcmessages_msgid.EDOTAGCMsg) string {
if !IsWordVerb(words[0]) && IsWordVerb(words[1]) {
words[0], words[1] = words[1], words[0]
}
break
case IsWordVerb(words[0]):
break
}

switch {
Expand Down
5 changes: 1 addition & 4 deletions apigen/msg_sender.go
Expand Up @@ -29,10 +29,7 @@ func GetMessageSender(msg protocol.EDOTAGCMsg) MsgSender {

msgName := msg.String()
msgName = msgName[6:]

if strings.HasPrefix(msgName, "DOTA") {
msgName = msgName[4:]
}
msgName = strings.TrimPrefix(msgName, "DOTA")

switch {
case strings.HasPrefix(msgName, "SQL"):
Expand Down
17 changes: 0 additions & 17 deletions client_match.go

This file was deleted.

8 changes: 0 additions & 8 deletions socache/socache_container.go
Expand Up @@ -4,7 +4,6 @@ import (
"math/rand"
"sync"

"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -53,13 +52,6 @@ func (c *SOCacheContainer) parseObject(obj *gcsdkm.CMsgSOCacheSubscribed_Subscri
return so, nil
}

// stringifyObject converts an object to a json string.
func (c *SOCacheContainer) stringifyObject(obj proto.Message) string {
m := &jsonpb.Marshaler{}
str, _ := m.MarshalToString(obj)
return str
}

// emitEvent emits an event to all listeners.
func (c *SOCacheContainer) emitEvent(event *CacheEvent) {
c.subscriptions.Range(func(key interface{}, value interface{}) bool {
Expand Down

0 comments on commit 2f48989

Please sign in to comment.