Showing 47 of 74 total issues
Method Bmatrix.Send
has 190 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bmatrix) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Receiving %#v", msg)
channel := b.getRoomID(msg.Channel)
b.Log.Debugf("Channel %s maps to channel id %s", msg.Channel, channel)
Method Bdiscord.Connect
has 129 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bdiscord) Connect() error {
var err error
token := b.GetString("Token")
b.Log.Info("Connecting")
if !strings.HasPrefix(b.GetString("Token"), "Bot ") {
Method Bmatrix.Send
has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring. Open
func (b *Bmatrix) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Receiving %#v", msg)
channel := b.getRoomID(msg.Channel)
b.Log.Debugf("Channel %s maps to channel id %s", msg.Channel, channel)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File matrix.go
has 573 lines of code (exceeds 500 allowed). Consider refactoring. Open
package bmatrix
import (
"bytes"
"fmt"
Method Btelegram.handleUsername
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
func (b *Btelegram) handleUsername(rmsg *config.Message, message *tgbotapi.Message) {
if message.From != nil {
rmsg.UserID = strconv.FormatInt(message.From.ID, 10)
if b.GetBool("UseFirstName") {
rmsg.Username = message.From.FirstName
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File gateway.go
has 560 lines of code (exceeds 500 allowed). Consider refactoring. Open
package gateway
import (
"fmt"
"io/ioutil"
Method Bdiscord.Connect
has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring. Open
func (b *Bdiscord) Connect() error {
var err error
token := b.GetString("Token")
b.Log.Info("Connecting")
if !strings.HasPrefix(b.GetString("Token"), "Bot ") {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File handlers.go
has 528 lines of code (exceeds 500 allowed). Consider refactoring. Open
package btelegram
import (
"fmt"
"html"
Method Bxmpp.handleXMPP
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. Open
func (b *Bxmpp) handleXMPP() error {
b.startTime = time.Now()
done := b.xmppKeepAlive()
defer close(done)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Gateway
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
type Gateway struct {
config.Config
Router *Router
MyConfig *config.Gateway
Method Bmatrix.handleUploadFile
has 76 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *config.FileInfo) {
username := newMatrixUsername(msg.Username)
content := bytes.NewReader(*fi.Data)
sp := strings.Split(fi.Name, ".")
mtype := mime.TypeByExtension("." + sp[len(sp)-1])
Method Bwhatsapp.Connect
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (b *Bwhatsapp) Connect() error {
device, err := b.getDevice()
if err != nil {
return err
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Bwhatsapp.Connect
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bwhatsapp) Connect() error {
device, err := b.getDevice()
if err != nil {
return err
}
Method Gateway.getDestChannel
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (gw *Gateway) getDestChannel(msg *config.Message, dest bridge.Bridge) []config.ChannelInfo {
var channels []config.ChannelInfo
// for messages received from the api check that the gateway is the specified one
if msg.Protocol == apiProtocol && gw.Name != msg.Gateway {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Bxmpp.handleXMPP
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bxmpp) handleXMPP() error {
b.startTime = time.Now()
done := b.xmppKeepAlive()
defer close(done)
Method Gateway.SendMessage
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (gw *Gateway) SendMessage(
rmsg *config.Message,
dest *bridge.Bridge,
channel *config.ChannelInfo,
canonicalParentMsgID string,
Method Bxmpp.Send
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bxmpp) Send(msg config.Message) (string, error) {
// should be fixed by using a cache instead of dropping
if !b.Connected() {
return "", fmt.Errorf("bridge %s not connected, dropping message %#v to bridge", b.Account, msg)
}
Method BLegacy.Connect
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *BLegacy) Connect() error {
b.RLock()
defer b.RUnlock()
if b.GetString(incomingWebhookConfig) != "" {
switch {
Method Bslack.handleSlackClient
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bslack) handleSlackClient(messages chan *config.Message) {
for msg := range b.rtm.IncomingEvents {
if msg.Type != sUserTyping && msg.Type != sHello && msg.Type != sLatencyReport {
b.Log.Debugf("== Receiving event %#v", msg.Data)
}
Method Bdiscord.messageCreate
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { //nolint:unparam
if m.GuildID != b.guildID {
b.Log.Debugf("Ignoring messageCreate because it originates from a different guild")
return
}