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 (
API
has 79 methods (exceeds 20 allowed). Consider refactoring. Open
type API struct {
mock.Mock
}
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
}
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
}
- 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
detail
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
type detail struct {
area *goquery.Selection
cleanImg bool
cleanVid bool
data model.Anime
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
}
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
}
- 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 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
}
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
}
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 {
Method Validator.isNewsTagValid
has 9 return statements (exceeds 4 allowed). Open
func (v *Validator) isNewsTagValid(tag string) bool {
if tag == "" {
return true
}
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 {
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
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
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 {
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 {
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 {
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 {
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 {
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
}
- 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"