42wim/matterbridge

View on GitHub

Showing 74 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        func (b *Bwhatsapp) PostVideoMessage(msg config.Message, filetype string) (string, error) {
            fi := msg.Extra["file"][0].(config.FileInfo)
        
            caption := msg.Username + fi.Comment
        
        
        Severity: Major
        Found in bridge/whatsappmulti/whatsapp.go and 1 other location - About 3 hrs to fix
        bridge/whatsappmulti/whatsapp.go on lines 260..291

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 288.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        func (b *Bwhatsapp) PostImageMessage(msg config.Message, filetype string) (string, error) {
            fi := msg.Extra["file"][0].(config.FileInfo)
        
            caption := msg.Username + fi.Comment
        
        
        Severity: Major
        Found in bridge/whatsappmulti/whatsapp.go and 1 other location - About 3 hrs to fix
        bridge/whatsappmulti/whatsapp.go on lines 294..325

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 288.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          func (b *Bdiscord) memberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) {
              if m.GuildID != b.guildID {
                  b.Log.Debugf("Ignoring memberAdd because it originates from a different guild")
                  return
              }
          Severity: Major
          Found in bridge/discord/handlers.go and 1 other location - About 3 hrs to fix
          bridge/discord/handlers.go on lines 225..251

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 260.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          func (b *Bdiscord) memberRemove(s *discordgo.Session, m *discordgo.GuildMemberRemove) {
              if m.GuildID != b.guildID {
                  b.Log.Debugf("Ignoring memberRemove because it originates from a different guild")
                  return
              }
          Severity: Major
          Found in bridge/discord/handlers.go and 1 other location - About 3 hrs to fix
          bridge/discord/handlers.go on lines 197..223

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 260.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      default:
                          b.Log.Debugf("sendFile %s", res.ContentURI)
                          err = b.retry(func() error {
                              _, err = b.mc.SendMessageEvent(channel, "m.room.message", matrix.FileMessage{
                                  MsgType: "m.file",
                  Severity: Major
                  Found in bridge/matrix/matrix.go and 1 other location - About 1 hr to fix
                  bridge/matrix/matrix.go on lines 680..697

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 162.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      case strings.Contains(mtype, "audio"):
                          b.Log.Debugf("sendAudio %s", res.ContentURI)
                          err = b.retry(func() error {
                              _, err = b.mc.SendMessageEvent(channel, "m.room.message", matrix.AudioMessage{
                                  MsgType: "m.audio",
                  Severity: Major
                  Found in bridge/matrix/matrix.go and 1 other location - About 1 hr to fix
                  bridge/matrix/matrix.go on lines 698..715

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 162.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language