42wim/matterbridge

View on GitHub

Showing 74 of 74 total issues

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

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

        } else if b.GetString(tokenConfig) != "" {
            b.Log.Info("Connecting using token (sending and receiving)")
            b.sc = slack.New(b.GetString(tokenConfig), slack.OptionDebug(b.GetBool("debug")))
            b.channels = newChannelManager(b.Log, b.sc)
            b.users = newUserManager(b.Log, b.sc)
    Severity: Major
    Found in bridge/slack/legacy.go and 1 other location - About 1 hr to fix
    bridge/slack/legacy.go on lines 58..66

    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 160.

    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

            if b.GetString(tokenConfig) != "" {
                b.Log.Info("Connecting using token (receiving)")
                b.sc = slack.New(b.GetString(tokenConfig), slack.OptionDebug(b.GetBool("debug")))
                b.channels = newChannelManager(b.Log, b.sc)
                b.users = newUserManager(b.Log, b.sc)
    Severity: Major
    Found in bridge/slack/legacy.go and 1 other location - About 1 hr to fix
    bridge/slack/legacy.go on lines 67..75

    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 160.

    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

    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

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

              func (b *Bwhatsapp) handleUserLeave(event *events.GroupInfo) {
                  for _, leftJid := range event.Leave {
                      senderName := b.getSenderNameFromJID(leftJid)
              
                      rmsg := config.Message{
              Severity: Major
              Found in bridge/whatsappmulti/handlers.go and 1 other location - About 1 hr to fix
              bridge/whatsappmulti/handlers.go on lines 43..59

              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 143.

              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) handleUserJoin(event *events.GroupInfo) {
                  for _, joinedJid := range event.Join {
                      senderName := b.getSenderNameFromJID(joinedJid)
              
                      rmsg := config.Message{
              Severity: Major
              Found in bridge/whatsappmulti/handlers.go and 1 other location - About 1 hr to fix
              bridge/whatsappmulti/handlers.go on lines 60..76

              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 143.

              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

              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
                                Severity
                                Category
                                Status
                                Source
                                Language