telegram-go-bot/go_bot

View on GitHub

Showing 25 of 69 total issues

Method Impl.OnCommand has a Cognitive Complexity of 36 (exceeds 6 allowed). Consider refactoring.
Open

func (p Impl) OnCommand(item raw.Activity) (bool, error) {

    _, isThisCommand := helpers.IsOnCommand(item.Text, []string{"ковид", "covid", "корона", "corona", "насморк"})
    if !isThisCommand {
        return false, nil
Severity: Minor
Found in app/activity_handlers/covid/covid.go - About 5 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

Method Impl.OnCommand has 60 lines of code (exceeds 30 allowed). Consider refactoring.
Open

func (p Impl) OnCommand(item raw.Activity) (bool, error) {

    _, isThisCommand := helpers.IsOnCommand(item.Text, []string{"ковид", "covid", "корона", "corona", "насморк"})
    if !isThisCommand {
        return false, nil
Severity: Minor
Found in app/activity_handlers/covid/covid.go - About 2 hrs to fix

    Method zagadka.onZagadka has 41 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

    func (p zagadka) onZagadka(item raw.Activity) {
    
        SendMsg := func(message string) (int, error) {
            return p.presenter.ShowMessage(output.ShowMessageData{ChatID: item.ChatID, Text: message})
        }
    Severity: Minor
    Found in app/activity_handlers/zagadka/zagadka.go - About 1 hr to fix

      Function isGoodChar has a Cognitive Complexity of 12 (exceeds 6 allowed). Consider refactoring.
      Open

      func isGoodChar(ch rune) bool {
          if ch >= '0' && ch <= '9' {
              return true
          }
      
      Severity: Minor
      Found in app/activity_handlers/otpetushi/otpetushi.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 wordToKoKo has 33 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

      func wordToKoKo(word string) string {
          var res strings.Builder
      
          wordLen := utf8.RuneCountInString(word)
      
      Severity: Minor
      Found in app/activity_handlers/otpetushi/otpetushi.go - About 1 hr to fix

        Method impl.OnCommand has 33 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

        func (p impl) OnCommand(item domain.Activity) (bool, error) {
        
            msg, isThisCommand := helpers.IsOnCommand(item.Text, []string{"голосом", "голос", "гг"})
            if !isThisCommand {
                return false, nil
        Severity: Minor
        Found in app/activity_handlers/ivona_maxim_text_to_speech/ivona.go - About 1 hr to fix

          Method Impl.OnCommand has 33 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

          func (p Impl) OnCommand(item raw.Activity) (bool, error) {
              command, isThisCommand := helpers.IsOnCommand(item.Text, []string{"add_magic"})
              if isThisCommand {
                  // here we should process internal add_magic\update_magic etc. commands
                  err := p.onAddMagic(command)
          Severity: Minor
          Found in app/activity_handlers/magic_query/magic_query.go - About 1 hr to fix

            Function delectLang has a Cognitive Complexity of 11 (exceeds 6 allowed). Consider refactoring.
            Open

            func delectLang(message string) (bool, bool) {
                // lets assume we are on qwerty keyboard
            
                rus := 0
                eng := 0
            Severity: Minor
            Found in app/activity_handlers/fix_layout/fix_layout.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 Search.SearchImage has 31 lines of code (exceeds 30 allowed). Consider refactoring.
            Open

            func (s Search) SearchImage(query string, searchDepth int) []string {
            
                log.Printf("Searching for: %s\n", query)
            
                hc := &http.Client{Transport: &transport.APIKey{Key: s.apiKey}}
            Severity: Minor
            Found in app/common/web_search/google/google.go - About 1 hr to fix

              Function GetTopComment has a Cognitive Complexity of 10 (exceeds 6 allowed). Consider refactoring.
              Open

              func GetTopComment(messageID int, ownerID int, commentsCount int, minLikes int) string {
                  offset := 0
                  const blockSize = 100
              
                  if commentsCount == 0 {
              Severity: Minor
              Found in app/common/vk/comments.go - About 55 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

              Function wordToKoKo has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring.
              Open

              func wordToKoKo(word string) string {
                  var res strings.Builder
              
                  wordLen := utf8.RuneCountInString(word)
              
              Severity: Minor
              Found in app/activity_handlers/otpetushi/otpetushi.go - About 45 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 Search.SearchImage has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring.
              Open

              func (s Search) SearchImage(query string, searchDepth int) []string {
              
                  log.Printf("Searching for: %s\n", query)
              
                  hc := &http.Client{Transport: &transport.APIKey{Key: s.apiKey}}
              Severity: Minor
              Found in app/common/web_search/google/google.go - About 45 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

              Function wordToKoKo has 8 return statements (exceeds 6 allowed).
              Open

              func wordToKoKo(word string) string {
                  var res strings.Builder
              
                  wordLen := utf8.RuneCountInString(word)
              
              Severity: Major
              Found in app/activity_handlers/otpetushi/otpetushi.go - About 40 mins to fix

                Method MessageReader.activitiesProducer has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring.
                Open

                func (r *MessageReader) activitiesProducer() error {
                    u := tgbotapi.NewUpdate(0)
                    u.Timeout = 60
                
                    updates, err := r.bot.GetUpdatesChan(u)
                Severity: Minor
                Found in app/input/activities/telegram/telegram_message_reader.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

                Function getLoopaAndPoopaNews has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring.
                Open

                func getLoopaAndPoopaNews(depth string) (string, error) {
                    parameters := make(map[string]string)
                    parameters["count"] = depth // message
                    parameters["domain"] = "pupa_and_lupa"
                
                
                Severity: Minor
                Found in app/activity_handlers/loopa_poopa/loopa_poopa.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 zagadka.onZagadka has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring.
                Open

                func (p zagadka) onZagadka(item raw.Activity) {
                
                    SendMsg := func(message string) (int, error) {
                        return p.presenter.ShowMessage(output.ShowMessageData{ChatID: item.ChatID, Text: message})
                    }
                Severity: Minor
                Found in app/activity_handlers/zagadka/zagadka.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 impl.OnCommand has 7 return statements (exceeds 6 allowed).
                Open

                func (p impl) OnCommand(item raw.Activity) (bool, error) {
                
                    _, isThisCommand := helpers.IsOnCommand(item.Text, []string{"отпетуши", "петуши", "petushi", "otpetushi"})
                    if !isThisCommand || item.RepliedTo == nil {
                        return false, nil
                Severity: Major
                Found in app/activity_handlers/otpetushi/otpetushi.go - About 35 mins to fix

                  Function textToSpeech has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                  Open

                  func textToSpeech(msg string) (string, error) {
                  
                      convID := os.Getenv("IVONA_TEXT_TO_SPEECH_CONVERSATION_ID")
                      if len(convID) == 0 {
                          return "", fmt.Errorf("IVONA_TEXT_TO_SPEECH_CONVERSATION_ID env var is EMPTY!!!")
                  Severity: Minor
                  Found in app/activity_handlers/ivona_maxim_text_to_speech/ivona.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

                  Function toString has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                  Open

                  func toString(num int64) string {
                      s := strconv.FormatInt(num, 10)
                      const devider int = 3
                      if len(s) <= devider {
                          return s
                  Severity: Minor
                  Found in app/activity_handlers/covid/covid.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

                  Method ActivityHandlerFacade.ProcessActivities has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                  Open

                  func (h *ActivityHandlerFacade) ProcessActivities(reader activities.IActivityReader) error {
                      for {
                          activity, err := reader.GetActivity()
                          if err != nil {
                              return err
                  Severity: Minor
                  Found in app/activity_handlers/activity_handler_facade.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