42wim/matterbridge

View on GitHub

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)
Severity: Major
Found in bridge/matrix/matrix.go - About 6 hrs to fix

    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 ") {
    Severity: Major
    Found in bridge/discord/discord.go - About 4 hrs to fix

      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)
      Severity: Minor
      Found in bridge/matrix/matrix.go - About 3 hrs 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

      File matrix.go has 573 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package bmatrix
      
      import (
          "bytes"
          "fmt"
      Severity: Minor
      Found in bridge/matrix/matrix.go - About 3 hrs to fix

        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
        Severity: Minor
        Found in bridge/telegram/handlers.go - About 3 hrs 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

        File gateway.go has 560 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        package gateway
        
        import (
            "fmt"
            "io/ioutil"
        Severity: Minor
        Found in gateway/gateway.go - About 3 hrs to fix

          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 ") {
          Severity: Minor
          Found in bridge/discord/discord.go - About 3 hrs 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

          File handlers.go has 528 lines of code (exceeds 500 allowed). Consider refactoring.
          Open

          package btelegram
          
          import (
              "fmt"
              "html"
          Severity: Minor
          Found in bridge/telegram/handlers.go - About 2 hrs to fix

            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)
            Severity: Minor
            Found in bridge/xmpp/xmpp.go - About 2 hrs 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

            Gateway has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type Gateway struct {
                config.Config
            
                Router         *Router
                MyConfig       *config.Gateway
            Severity: Minor
            Found in gateway/gateway.go - About 2 hrs to fix

              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])
              Severity: Major
              Found in bridge/matrix/matrix.go - About 2 hrs to fix

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

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

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

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

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

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

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