main.go
Function processMessage
has a Cognitive Complexity of 279 (exceeds 20 allowed). Consider refactoring. Open
Open
func processMessage(update tgbotapi.Update) error {
chatID, err := helpers.GetChatID(update)
if err != nil {
return err
}
- Read upRead up
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
Open
func processMessage(update tgbotapi.Update) error {
chatID, err := helpers.GetChatID(update)
if err != nil {
return err
}
File main.go
has 809 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package main
import (
"database/sql"
"encoding/base64"
Function checkUniqueness
has 117 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func checkUniqueness(message tgbotapi.Message, text string, voteModel models.Vote) {
token := config.TextRuToken
if len(config.TextRuToken) == 0 {
return
}
Function processMessage
has 31 return statements (exceeds 4 allowed). Open
Open
func processMessage(update tgbotapi.Update) error {
chatID, err := helpers.GetChatID(update)
if err != nil {
return err
}
Function checkUniqueness
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
Open
func checkUniqueness(message tgbotapi.Message, text string, voteModel models.Vote) {
token := config.TextRuToken
if len(config.TextRuToken) == 0 {
return
}
- Read upRead up
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
Open
func checkUniqueness(message tgbotapi.Message, text string, voteModel models.Vote) {
token := config.TextRuToken
if len(config.TextRuToken) == 0 {
return
}
Function verifyVotes
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func verifyVotes(voteModel models.Vote, update tgbotapi.Update) error {
chatID, err := helpers.GetChatID(update)
if err != nil {
return err
}
Function verifyVotes
has 8 return statements (exceeds 4 allowed). Open
Open
func verifyVotes(voteModel models.Vote, update tgbotapi.Update) error {
chatID, err := helpers.GetChatID(update)
if err != nil {
return err
}
Function sendReferralFee
has 5 return statements (exceeds 4 allowed). Open
Open
func sendReferralFee(referrer string, referral string) {
if referrer == referral {
log.Printf("Пригласивший и приглашенный %s совпадают", referral)
return
}