rl404/go-malscraper

View on GitHub

Showing 20 of 389 total issues

File API.go has 1900 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Code generated by mockery v2.4.0-beta. DO NOT EDIT.

package mocks

import (
Severity: Major
Found in service/mocks/API.go - About 4 days to fix

    API has 79 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type API struct {
        mock.Mock
    }
    Severity: Major
    Found in service/mocks/API.go - About 1 day to fix

      Function StrToTime has 84 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func StrToTime(str string) (t time.Time, isValid bool) {
          str = strings.TrimSpace(str)
          if str == "" {
              return time.Time{}, false
          }
      Severity: Major
      Found in pkg/utils/time.go - About 2 hrs to fix

        Method Validator.isNewsTagValid has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
        Open

        func (v *Validator) isNewsTagValid(tag string) bool {
            if tag == "" {
                return true
            }
        
        
        Severity: Minor
        Found in internal/validator/validator.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

        detail has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type detail struct {
            area     *goquery.Selection
            cleanImg bool
            cleanVid bool
            data     model.Anime
        Severity: Minor
        Found in internal/parser/anime/anime_details.go - About 2 hrs to fix

          Function StrToTime has 22 return statements (exceeds 4 allowed).
          Open

          func StrToTime(str string) (t time.Time, isValid bool) {
              str = strings.TrimSpace(str)
              if str == "" {
                  return time.Time{}, false
              }
          Severity: Major
          Found in pkg/utils/time.go - About 2 hrs to fix

            Function StrToTime has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
            Open

            func StrToTime(str string) (t time.Time, isValid bool) {
                str = strings.TrimSpace(str)
                if str == "" {
                    return time.Time{}, false
                }
            Severity: Minor
            Found in pkg/utils/time.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 StrToDate has 61 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func StrToDate(str string) (y, m, d int) {
                str = strings.TrimSpace(str)
                if str == "" {
                    return 0, 0, 0
                }
            Severity: Minor
            Found in pkg/utils/time.go - About 1 hr to fix

              Function StrToDate has 13 return statements (exceeds 4 allowed).
              Open

              func StrToDate(str string) (y, m, d int) {
                  str = strings.TrimSpace(str)
                  if str == "" {
                      return 0, 0, 0
                  }
              Severity: Major
              Found in pkg/utils/time.go - About 1 hr to fix

                Method Validator.SearchAnime has 10 return statements (exceeds 4 allowed).
                Open

                func (v *Validator) SearchAnime(query model.Query) ([]model.AnimeSearch, int, error) {
                    if len(query.Title) < 3 {
                        return nil, http.StatusBadRequest, errors.Err3LettersSearch
                    }
                    if query.Page < 0 {
                Severity: Major
                Found in internal/validator/search.go - About 1 hr to fix

                  Method Validator.isNewsTagValid has 9 return statements (exceeds 4 allowed).
                  Open

                  func (v *Validator) isNewsTagValid(tag string) bool {
                      if tag == "" {
                          return true
                      }
                  
                  
                  Severity: Major
                  Found in internal/validator/validator.go - About 55 mins to fix

                    Method Validator.SearchManga has 9 return statements (exceeds 4 allowed).
                    Open

                    func (v *Validator) SearchManga(query model.Query) ([]model.MangaSearch, int, error) {
                        if len(query.Title) < 3 {
                            return nil, http.StatusBadRequest, errors.Err3LettersSearch
                        }
                        if query.Page < 0 {
                    Severity: Major
                    Found in internal/validator/search.go - About 55 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                          if match, _ := regexp.MatchString(`([a-z]+) ([0-9]{1,2})$`, str); match {
                              return 0, months[spltStr[0]], StrToNum(spltStr[1])
                          } else
                      
                          // 2021
                      Severity: Major
                      Found in pkg/utils/time.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                            if match, _ := regexp.MatchString(`Today, ([0-9]{1,2}):([0-9]{2}) (AM|PM)`, str); match {
                                today := now.Format("Jan 2, 2006")
                                str = strings.Replace(str, "Today,", today, -1)
                                return StrToTime(str)
                            } else
                        Severity: Major
                        Found in pkg/utils/time.go - About 45 mins to fix

                          Method Validator.GetUserAnime has 6 return statements (exceeds 4 allowed).
                          Open

                          func (v *Validator) GetUserAnime(query model.UserListQuery) ([]model.UserAnime, int, error) {
                              if len(query.Username) < 2 || len(query.Username) > 16 {
                                  return nil, http.StatusBadRequest, errors.ErrInvalidUsername
                              }
                              if query.Page == 0 {
                          Severity: Major
                          Found in internal/validator/user.go - About 40 mins to fix

                            Method Validator.GetUserManga has 6 return statements (exceeds 4 allowed).
                            Open

                            func (v *Validator) GetUserManga(query model.UserListQuery) ([]model.UserManga, int, error) {
                                if len(query.Username) < 2 || len(query.Username) > 16 {
                                    return nil, http.StatusBadRequest, errors.ErrInvalidUsername
                                }
                                if query.Page == 0 {
                            Severity: Major
                            Found in internal/validator/user.go - About 40 mins to fix

                              Method Validator.GetRecommendation has 5 return statements (exceeds 4 allowed).
                              Open

                              func (v *Validator) GetRecommendation(t string, id1, id2 int) (*model.Recommendation, int, error) {
                                  if t != AnimeType && t != MangaType {
                                      return nil, http.StatusBadRequest, errors.ErrInvalidType
                                  }
                                  if id1 <= 0 || id2 <= 0 {
                              Severity: Major
                              Found in internal/validator/recommendation.go - About 35 mins to fix

                                Method Validator.SearchUser has 5 return statements (exceeds 4 allowed).
                                Open

                                func (v *Validator) SearchUser(query model.UserQuery) ([]model.UserSearch, int, error) {
                                    if len(query.Username) < 3 {
                                        return nil, http.StatusBadRequest, errors.Err3LettersSearch
                                    }
                                    if query.Page < 0 {
                                Severity: Major
                                Found in internal/validator/search.go - About 35 mins to fix

                                  Method Validator.SearchClub has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (v *Validator) SearchClub(query model.ClubQuery) ([]model.ClubSearch, int, error) {
                                      if len(query.Name) < 3 {
                                          return nil, http.StatusBadRequest, errors.Err3LettersSearch
                                      }
                                      if query.Page < 0 {
                                  Severity: Major
                                  Found in internal/validator/search.go - About 35 mins to fix

                                    Function StrToDate has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                    func StrToDate(str string) (y, m, d int) {
                                        str = strings.TrimSpace(str)
                                        if str == "" {
                                            return 0, 0, 0
                                        }
                                    Severity: Minor
                                    Found in pkg/utils/time.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