42wim/matterbridge

View on GitHub

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]
Severity: Minor
Found in bridge/matrix/matrix.go - About 1 hr to fix

    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
    Severity: Minor
    Found in bridge/api/api.go - About 1 hr to fix

      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 {
      Severity: Minor
      Found in bridge/telegram/handlers.go - About 1 hr to fix

      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 {
      Severity: Minor
      Found in bridge/discord/discord.go - About 1 hr to fix

        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}
        
        
        Severity: Minor
        Found in bridge/rocketchat/rocketchat.go - About 1 hr to fix

          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
              }
          Severity: Minor
          Found in bridge/irc/irc.go - About 1 hr to fix

            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
            Severity: Minor
            Found in bridge/whatsappmulti/whatsapp.go - About 1 hr to fix

              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
                  }
              
              
              Severity: Minor
              Found in bridge/telegram/handlers.go - About 1 hr to fix

                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 {
                Severity: Minor
                Found in bridge/zulip/zulip.go - About 1 hr to fix

                  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
                      }
                  Severity: Minor
                  Found in bridge/slack/slack.go - About 1 hr to fix

                    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:
                    Severity: Minor
                    Found in bridge/telegram/handlers.go - About 1 hr to fix

                      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
                          }
                      Severity: Minor
                      Found in bridge/discord/handlers.go - About 55 mins to fix

                      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)
                      Severity: Minor
                      Found in bridge/mattermost/mattermost.go - About 55 mins to fix

                      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) {
                      Severity: Minor
                      Found in bridge/mattermost/handlers.go - About 45 mins to fix

                      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")
                          }
                      Severity: Minor
                      Found in gateway/router.go - About 45 mins to fix

                      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)
                                      }
                      Severity: Major
                      Found in bridge/xmpp/xmpp.go - About 45 mins to fix

                        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)
                                            }
                        Severity: Major
                        Found in bridge/zulip/zulip.go - About 45 mins to fix

                          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 {
                          Severity: Minor
                          Found in bridge/zulip/zulip.go - About 45 mins to fix

                          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) {
                          Severity: Minor
                          Found in bridge/telegram/telegram.go - About 35 mins to fix

                            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) {
                            Severity: Minor
                            Found in bridge/helper/helper.go - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language