3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00

fix some issues found with staticcheck.io

This commit is contained in:
Shivaram Lingamneni 2019-05-10 01:44:14 -04:00
parent ce6a3e42df
commit c193def606
9 changed files with 12 additions and 63 deletions

View File

@ -5,7 +5,6 @@ package irc
import (
"encoding/json"
"errors"
"fmt"
"net/smtp"
"strconv"
@ -480,7 +479,7 @@ func (am *AccountManager) dispatchCallback(client *Client, casefoldedAccount str
} else if callbackNamespace == "mailto" {
return am.dispatchMailtoCallback(client, casefoldedAccount, callbackValue)
} else {
return "", errors.New(fmt.Sprintf("Callback not implemented: %s", callbackNamespace))
return "", fmt.Errorf("Callback not implemented: %s", callbackNamespace)
}
}
@ -1262,7 +1261,6 @@ func (am *AccountManager) Logout(client *Client) {
}
}
am.accountToClients[casefoldedAccount] = remainingClients
return
}
var (

View File

@ -1043,34 +1043,6 @@ func (channel *Channel) ShowMaskList(client *Client, mode modes.Mode, rb *Respon
rb.Add(nil, client.server.name, rplendoflist, nick, channel.name, client.t("End of list"))
}
func (channel *Channel) applyModeMask(client *Client, mode modes.Mode, op modes.ModeOp, mask string, rb *ResponseBuffer) bool {
list := channel.lists[mode]
if list == nil {
// This should never happen, but better safe than panicky.
return false
}
if (op == modes.List) || (mask == "") {
channel.ShowMaskList(client, mode, rb)
return false
}
if !channel.ClientIsAtLeast(client, modes.ChannelOperator) {
rb.Add(nil, client.server.name, ERR_CHANOPRIVSNEEDED, client.Nick(), channel.Name(), client.t("You're not a channel operator"))
return false
}
if op == modes.Add {
return list.Add(mask)
}
if op == modes.Remove {
return list.Remove(mask)
}
return false
}
// Quit removes the given client from the channel
func (channel *Channel) Quit(client *Client) {
channelEmpty := func() bool {

View File

@ -538,14 +538,12 @@ func (client *Client) tryResume() (success bool) {
func (client *Client) tryResumeChannels() {
details := client.resumeDetails
channels := make([]*Channel, len(details.Channels))
for _, name := range details.Channels {
channel := client.server.channels.Get(name)
if channel == nil {
continue
}
channel.Resume(client, details.OldClient, details.Timestamp)
channels = append(channels, channel)
}
// replay direct PRIVSMG history

View File

@ -393,7 +393,7 @@ func (conf *Config) OperatorClasses() (map[string]*OperClass, error) {
// get inhereted info from other operclasses
if len(info.Extends) > 0 {
einfo, _ := ocs[info.Extends]
einfo := ocs[info.Extends]
for capab := range einfo.Capabilities {
oc.Capabilities[capab] = true

View File

@ -1184,20 +1184,14 @@ func inviteHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
func isonHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
var nicks = msg.Params
var err error
var casefoldedNick string
ison := make([]string, 0)
ison := make([]string, 0, len(msg.Params))
for _, nick := range nicks {
casefoldedNick, err = CasefoldName(nick)
if err != nil {
continue
}
if iclient := server.clients.Get(casefoldedNick); iclient != nil {
ison = append(ison, iclient.nick)
if iclient := server.clients.Get(nick); iclient != nil {
ison = append(ison, iclient.Nick())
}
}
rb.Add(nil, server.name, RPL_ISON, client.nick, strings.Join(nicks, " "))
rb.Add(nil, server.name, RPL_ISON, client.nick, strings.Join(ison, " "))
return false
}
@ -2099,7 +2093,7 @@ func npcaHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
// OPER <name> <password>
func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
if client.HasMode(modes.Operator) == true {
if client.HasMode(modes.Operator) {
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), "OPER", client.t("You're already opered-up!"))
return false
}

View File

@ -170,7 +170,7 @@ func SplitChannelMembershipPrefixes(target string) (prefixes string, name string
prefixes = target[:i+1]
name = target[i+1:]
default:
break
return
}
}

View File

@ -36,5 +36,4 @@ func (serversem *ServerSemaphores) Initialize() {
capacity = MaxServerSemaphoreCapacity
}
serversem.ClientDestroy.Initialize(capacity)
return
}

View File

@ -24,7 +24,6 @@ import (
"github.com/goshuirc/irc-go/ircfmt"
"github.com/oragono/oragono/irc/caps"
"github.com/oragono/oragono/irc/connection_limits"
"github.com/oragono/oragono/irc/isupport"
"github.com/oragono/oragono/irc/logger"
"github.com/oragono/oragono/irc/modes"
"github.com/oragono/oragono/irc/sno"
@ -73,12 +72,10 @@ type Server struct {
ctime time.Time
dlines *DLineManager
helpIndexManager HelpIndexManager
isupport *isupport.List
klines *KLineManager
listeners map[string]*ListenerWrapper
logger *logger.Manager
monitorManager *MonitorManager
motdLines []string
name string
nameCasefolded string
rehashMutex sync.Mutex // tier 4
@ -176,13 +173,6 @@ func (config *Config) generateISupport() (err error) {
return
}
func loadChannelList(channel *Channel, list string, maskMode modes.Mode) {
if list == "" {
return
}
channel.lists[maskMode].AddAll(strings.Split(list, " "))
}
// Shutdown shuts down the server.
func (server *Server) Shutdown() {
//TODO(dan): Make sure we disallow new nicks
@ -518,9 +508,7 @@ func (client *Client) getWhoisOf(target *Client, rb *ResponseBuffer) {
tLanguages := target.Languages()
if 0 < len(tLanguages) {
params := []string{cnick, tnick}
for _, str := range client.server.Languages().Codes(tLanguages) {
params = append(params, str)
}
params = append(params, client.server.Languages().Codes(tLanguages)...)
params = append(params, client.t("can speak these languages"))
rb.Add(nil, client.server.name, RPL_WHOISLANGUAGE, params...)
}

View File

@ -52,7 +52,7 @@ func (m *SnoManager) RemoveMasks(client *Client, masks ...sno.Mask) {
for _, mask := range masks {
currentClientList := m.sendLists[mask]
if currentClientList == nil || len(currentClientList) == 0 {
if len(currentClientList) == 0 {
continue
}
@ -70,7 +70,7 @@ func (m *SnoManager) RemoveClient(client *Client) {
for mask := range m.sendLists {
currentClientList := m.sendLists[mask]
if currentClientList == nil || len(currentClientList) == 0 {
if len(currentClientList) == 0 {
continue
}
@ -87,7 +87,7 @@ func (m *SnoManager) Send(mask sno.Mask, content string) {
currentClientList := m.sendLists[mask]
if currentClientList == nil || len(currentClientList) == 0 {
if len(currentClientList) == 0 {
return
}