Showing 47 of 74 total issues
Method Bmatrix.handleEvent
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bmatrix) handleEvent(ev *matrix.Event) {
b.Log.Debugf("== Receiving event: %#v", ev)
if ev.Sender != b.UserID {
b.RLock()
channel, ok := b.RoomMap[ev.RoomID]
Function New
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func New(cfg *bridge.Config) bridge.Bridger {
b := &API{Config: cfg}
e := echo.New()
e.HideBanner = true
e.HidePort = true
Method Btelegram.handleQuoting
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func (b *Btelegram) handleQuoting(rmsg *config.Message, message *tgbotapi.Message) {
// Used to check if the message was a reply to the root topic
if message.ReplyToMessage != nil && (!message.IsTopicMessage || message.ReplyToMessage.MessageID != message.MessageThreadID) { //nolint:nestif
usernameReply := ""
if message.ReplyToMessage.From != nil {
- 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 Bdiscord.handleEventBotUser
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bdiscord) handleEventBotUser(msg *config.Message, channelID string) (string, error) {
b.Log.Debugf("Broadcasting using token (API)")
// Delete message
if msg.Event == config.EventMsgDelete {
Method Brocketchat.Send
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Brocketchat) Send(msg config.Message) (string, error) {
// strip the # if people has set this
msg.Channel = strings.TrimPrefix(msg.Channel, "#")
channel := &models.Channel{ID: b.getChannelID(msg.Channel), Name: msg.Channel}
Method Birc.getClient
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Birc) getClient() (*girc.Client, error) {
server, portstr, err := net.SplitHostPort(b.GetString("Server"))
if err != nil {
return nil, err
}
Method Bwhatsapp.Send
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bwhatsapp) Send(msg config.Message) (string, error) {
groupJID, _ := types.ParseJID(msg.Channel)
extendedMsgID, _ := b.parseMessageID(msg.ID)
msg.ID = extendedMsgID.MessageID
Method Btelegram.handleEntities
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Btelegram) handleEntities(rmsg *config.Message, message *tgbotapi.Message) {
if message.Entities == nil {
return
}
Method Bzulip.handleQueue
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bzulip) handleQueue() error {
for {
messages, err := b.q.GetEvents()
if err != nil {
switch err {
Method Bslack.sendWebhook
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Bslack) sendWebhook(msg config.Message) error {
// Skip events.
if msg.Event != "" {
return nil
}
Method Btelegram.handleDownload
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *Btelegram) handleDownload(rmsg *config.Message, message *tgbotapi.Message) error {
size := int64(0)
var url, name, text string
switch {
case message.Sticker != nil:
Method Bdiscord.messageCreate
has a Cognitive Complexity of 24 (exceeds 20 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
}
- 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 Bmattermost.Send
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (b *Bmattermost) Send(msg config.Message) (string, error) {
if b.Account == mattermostPlugin {
return "", nil
}
b.Log.Debugf("=> Receiving %#v", msg)
- 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 Bmattermost.handleMatterClient
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (b *Bmattermost) handleMatterClient(messages chan *config.Message) {
for message := range b.mc.MessageChan {
b.Log.Debugf("%#v %#v", message.Raw.GetData(), message.Raw.EventType())
if b.skipMessage(message) {
- 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 Router.Start
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (r *Router) Start() error {
m := make(map[string]*bridge.Bridge)
if len(r.Gateways) == 0 {
return fmt.Errorf("no [[gateway]] configured. See https://github.com/42wim/matterbridge/wiki/How-to-create-your-config for more info")
}
- 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
Avoid deeply nested control flow statements. Open
} else if available {
avatar = getAvatar(b.avatarMap, v.Remote, b.General)
}
Avoid deeply nested control flow statements. Open
if err != nil {
b.Log.Errorf("reconnecting failed: %s. Sleeping 10 seconds", err)
time.Sleep(time.Second * 10)
}
Method Bzulip.handleQueue
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (b *Bzulip) handleQueue() error {
for {
messages, err := b.q.GetEvents()
if err != nil {
switch 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 Btelegram.sendMediaFiles
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (b *Btelegram) sendMediaFiles(msg *config.Message, chatid int64, threadid int, parentID int, media []interface{}) (string, error) {
Function HandleDownloadData
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func HandleDownloadData(logger *logrus.Entry, msg *config.Message, name, comment, url string, data *[]byte, general *config.Protocol) {