Showing 11 of 13 total issues
Function apiEndpointHandler
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func apiEndpointHandler(w http.ResponseWriter, r *http.Request) {
errLog("Error when parsing query values: ", r.ParseForm())
if r.FormValue("q") != "" || r.FormValue("url") != "" {
err := apiEndpointQuery(w, r)
- Create a ticketCreate a ticket
Function ParseRegistryTwtxt
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func ParseRegistryTwtxt(twtxt []byte) ([]*User, error) {
var erz []byte
if len(twtxt) == 0 {
return nil, fmt.Errorf("received no data")
}
- Create a ticketCreate a ticket
Method Registry.UpdateUser
has 7 return statements (exceeds 4 allowed). Open
Open
func (registry *Registry) UpdateUser(urlKey string) error {
if urlKey == "" || !strings.HasPrefix(urlKey, "http") {
return fmt.Errorf("invalid URL: %v", urlKey)
}
- Create a ticketCreate a ticket
Function GetTwtxt
has 7 return statements (exceeds 4 allowed). Open
Open
func GetTwtxt(urlKey string, client *http.Client) ([]byte, bool, error) {
if !strings.HasPrefix(urlKey, "http://") && !strings.HasPrefix(urlKey, "https://") {
return nil, false, fmt.Errorf("invalid URL: %v", urlKey)
}
- Create a ticketCreate a ticket
Method Registry.CrawlRemoteRegistry
has 5 return statements (exceeds 4 allowed). Open
Open
func (registry *Registry) CrawlRemoteRegistry(urlKey string) error {
if urlKey == "" || !strings.HasPrefix(urlKey, "http") {
return fmt.Errorf("invalid URL: %v", urlKey)
}
- Create a ticketCreate a ticket
Method Registry.DiffTwtxt
has 5 return statements (exceeds 4 allowed). Open
Open
func (registry *Registry) DiffTwtxt(urlKey string) (bool, error) {
if !strings.HasPrefix(urlKey, "http://") && !strings.HasPrefix(urlKey, "https://") {
return false, fmt.Errorf("invalid URL: %v", urlKey)
}
- Create a ticketCreate a ticket
Method Registry.AddUser
has 5 return statements (exceeds 4 allowed). Open
Open
func (registry *Registry) AddUser(nickname, urlKey string, ipAddress net.IP, statuses TimeMap) error {
if registry == nil {
return fmt.Errorf("can't add user to uninitialized registry")
- Create a ticketCreate a ticket
Method Registry.DelUser
has 5 return statements (exceeds 4 allowed). Open
Open
func (registry *Registry) DelUser(urlKey string) error {
if registry == nil {
return fmt.Errorf("can't delete user from empty registry")
- Create a ticketCreate a ticket
Function handleUserDelete
has 5 return statements (exceeds 4 allowed). Open
Open
func handleUserDelete(w http.ResponseWriter, r *http.Request) {
pass := r.Header.Get("X-Auth")
if pass == "" {
errHTTP(w, r, errors.New("unauthorized"), http.StatusUnauthorized)
return
- Create a ticketCreate a ticket
Function ParseUserTwtxt
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func ParseUserTwtxt(twtxt []byte, nickname, urlKey string) (TimeMap, error) {
var erz []byte
if len(twtxt) == 0 {
return nil, fmt.Errorf("no data to parse in twtxt file")
}
- Read upRead up
- Create a ticketCreate a ticket
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 ParseRegistryTwtxt
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func ParseRegistryTwtxt(twtxt []byte) ([]*User, error) {
var erz []byte
if len(twtxt) == 0 {
return nil, fmt.Errorf("received no data")
}
- Read upRead up
- Create a ticketCreate a ticket
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"