omarperezr/SmarttyBot

View on GitHub

Showing 3 of 3 total issues

Method EmailClient.CheckMessagesForDiscord has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
Open

func (client *EmailClient) CheckMessagesForDiscord(messages chan *imap.Message) {
    var channel string
    var subject string
    var sender string

Severity: Minor
Found in Platforms/Email/EmailClient.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

Avoid deeply nested control flow statements.
Open

                if message_fields[0] == "-m" || message_fields[0] == "-mention" {
                    mention_user_cmd(client, update, message_fields)
                } else if message_fields[0] == "-p" || message_fields[0] == "-parse" {
                    natural_language_cmd(client, update, message_fields)
                } else if message_fields[0] == "-r" || message_fields[0] == "-register" {
Severity: Major
Found in Platforms/Telegram/TelegramClient.go - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

        } else if amount_parameters > 2 && (message_parameters[0] == "-m" || message_parameters[0] == "-send-email") {
            to := message_parameters[1]
            subject := message_parameters[2]
            body := strings.Join(message_parameters[3:], " ")
            client.SendEmail(to, subject, body)
    Severity: Major
    Found in Platforms/Discord/DiscordClient.go - About 45 mins to fix
      Severity
      Category
      Status
      Source
      Language