GolosTools/golos-vote-bot

View on GitHub
main.go

Summary

Maintainability
F
1 wk
Test Coverage

Function processMessage has a Cognitive Complexity of 279 (exceeds 20 allowed). Consider refactoring.
Open

func processMessage(update tgbotapi.Update) error {
    chatID, err := helpers.GetChatID(update)
    if err != nil {
        return err
    }
Severity: Minor
Found in main.go - About 5 days 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

Function processMessage has 419 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func processMessage(update tgbotapi.Update) error {
    chatID, err := helpers.GetChatID(update)
    if err != nil {
        return err
    }
Severity: Major
Found in main.go - About 1 day to fix

    File main.go has 809 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package main
    
    import (
        "database/sql"
        "encoding/base64"
    Severity: Major
    Found in main.go - About 1 day to fix

      Function checkUniqueness has 117 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func checkUniqueness(message tgbotapi.Message, text string, voteModel models.Vote) {
          token := config.TextRuToken
          if len(config.TextRuToken) == 0 {
              return
          }
      Severity: Major
      Found in main.go - About 3 hrs to fix

        Function processMessage has 31 return statements (exceeds 4 allowed).
        Open

        func processMessage(update tgbotapi.Update) error {
            chatID, err := helpers.GetChatID(update)
            if err != nil {
                return err
            }
        Severity: Major
        Found in main.go - About 2 hrs to fix

          Function checkUniqueness has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
          Open

          func checkUniqueness(message tgbotapi.Message, text string, voteModel models.Vote) {
              token := config.TextRuToken
              if len(config.TextRuToken) == 0 {
                  return
              }
          Severity: Minor
          Found in main.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

          Function checkUniqueness has 12 return statements (exceeds 4 allowed).
          Open

          func checkUniqueness(message tgbotapi.Message, text string, voteModel models.Vote) {
              token := config.TextRuToken
              if len(config.TextRuToken) == 0 {
                  return
              }
          Severity: Major
          Found in main.go - About 1 hr to fix

            Function verifyVotes has 52 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func verifyVotes(voteModel models.Vote, update tgbotapi.Update) error {
                chatID, err := helpers.GetChatID(update)
                if err != nil {
                    return err
                }
            Severity: Minor
            Found in main.go - About 1 hr to fix

              Function verifyVotes has 8 return statements (exceeds 4 allowed).
              Open

              func verifyVotes(voteModel models.Vote, update tgbotapi.Update) error {
                  chatID, err := helpers.GetChatID(update)
                  if err != nil {
                      return err
                  }
              Severity: Major
              Found in main.go - About 50 mins to fix

                Function sendReferralFee has 5 return statements (exceeds 4 allowed).
                Open

                func sendReferralFee(referrer string, referral string) {
                    if referrer == referral {
                        log.Printf("Пригласивший и приглашенный %s совпадают", referral)
                        return
                    }
                Severity: Major
                Found in main.go - About 35 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status