42wim/matterbridge

View on GitHub

Showing 74 of 74 total issues

Identical blocks of code found in 4 locations. Consider refactoring.
Open

    rmsg := config.Message{
        UserID:   senderJID.String(),
        Username: senderName,
        Channel:  msg.Info.Chat.String(),
        Account:  b.Account,
Severity: Major
Found in bridge/whatsappmulti/handlers.go and 3 other locations - About 40 mins to fix
bridge/whatsappmulti/handlers.go on lines 208..217
bridge/whatsappmulti/handlers.go on lines 338..347
bridge/whatsappmulti/handlers.go on lines 396..405

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

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

    rmsg := config.Message{
        UserID:   senderJID.String(),
        Username: senderName,
        Channel:  msg.Info.Chat.String(),
        Account:  b.Account,
Severity: Major
Found in bridge/whatsappmulti/handlers.go and 3 other locations - About 40 mins to fix
bridge/whatsappmulti/handlers.go on lines 208..217
bridge/whatsappmulti/handlers.go on lines 272..281
bridge/whatsappmulti/handlers.go on lines 338..347

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

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

    rmsg := config.Message{
        UserID:   senderJID.String(),
        Username: senderName,
        Channel:  msg.Info.Chat.String(),
        Account:  b.Account,
Severity: Major
Found in bridge/whatsappmulti/handlers.go and 3 other locations - About 40 mins to fix
bridge/whatsappmulti/handlers.go on lines 208..217
bridge/whatsappmulti/handlers.go on lines 272..281
bridge/whatsappmulti/handlers.go on lines 396..405

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

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

      Function HandleDownloadSize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func HandleDownloadSize(logger *logrus.Entry, msg *config.Message, name string, size int64, general *config.Protocol) error {
      Severity: Minor
      Found in bridge/helper/helper.go - About 35 mins to fix

        Function HandleDownloadData2 has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func HandleDownloadData2(logger *logrus.Entry, msg *config.Message, name, id, comment, url string, data *[]byte, general *config.Protocol) {
        Severity: Minor
        Found in bridge/helper/helper.go - About 35 mins to fix

          Method Bslack.handleSlackClient has a Cognitive Complexity of 22 (exceeds 20 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 35 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 Bmatrix.handleEvent has a Cognitive Complexity of 22 (exceeds 20 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 35 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.handleRecv has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
          Open

          func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
              for update := range updates {
                  b.Log.Debugf("== Receiving event: %#v", update.Message)
          
                  if update.Message == nil && update.ChannelPost == nil &&
          Severity: Minor
          Found in bridge/telegram/handlers.go - About 35 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.handleEntities has a Cognitive Complexity of 22 (exceeds 20 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 35 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

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

              for _, outer := range br.GetStringSlice2D("ReplaceMessages") {
                  search := outer[0]
                  replace := outer[1]
                  // TODO move compile to bridge init somewhere
                  re, err := regexp.Compile(search)
          Severity: Minor
          Found in gateway/gateway.go and 1 other location - About 35 mins to fix
          gateway/gateway.go on lines 335..345

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

          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

              for _, outer := range br.GetStringSlice2D("ReplaceNicks") {
                  search := outer[0]
                  replace := outer[1]
                  // TODO move compile to bridge init somewhere
                  re, err := regexp.Compile(search)
          Severity: Minor
          Found in gateway/gateway.go and 1 other location - About 35 mins to fix
          gateway/gateway.go on lines 411..421

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

          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 Bxmpp.Send has a Cognitive Complexity of 21 (exceeds 20 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 25 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

          Severity
          Category
          Status
          Source
          Language