update golangci lint linter list
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
// Package ctrladmin provides HTTP handlers for admin UI
|
||||
package ctrladmin
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
@@ -150,7 +152,6 @@ type (
|
||||
handlerAdminRaw func(w http.ResponseWriter, r *http.Request)
|
||||
)
|
||||
|
||||
//nolint:gocognit
|
||||
func (c *Controller) H(h handlerAdmin) http.Handler {
|
||||
// TODO: break this up a bit
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -272,26 +273,33 @@ func sessLogSave(s *sessions.Session, w http.ResponseWriter, r *http.Request) {
|
||||
// ## begin validation
|
||||
// ## begin validation
|
||||
|
||||
var (
|
||||
errValiNoUsername = errors.New("please enter the password twice")
|
||||
errValiPasswordAllFields = errors.New("please enter the password twice")
|
||||
errValiPasswordsNotSame = errors.New("passwords entered were not the same")
|
||||
errValiKeysAllFields = errors.New("please enter the api key and secret")
|
||||
)
|
||||
|
||||
func validateUsername(username string) error {
|
||||
if username == "" {
|
||||
return fmt.Errorf("please enter the username")
|
||||
return errValiNoUsername
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validatePasswords(pOne, pTwo string) error {
|
||||
if pOne == "" || pTwo == "" {
|
||||
return fmt.Errorf("please enter the password twice")
|
||||
return errValiPasswordAllFields
|
||||
}
|
||||
if !(pOne == pTwo) {
|
||||
return fmt.Errorf("the two passwords entered were not the same")
|
||||
return errValiPasswordsNotSame
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateAPIKey(apiKey, secret string) error {
|
||||
if apiKey == "" || secret == "" {
|
||||
return fmt.Errorf("please enter both the api key and secret")
|
||||
return errValiKeysAllFields
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package ctrladmin
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
@@ -12,6 +13,10 @@ import (
|
||||
"go.senan.xyz/gonic/server/db"
|
||||
)
|
||||
|
||||
var (
|
||||
errPlaylistNoMatch = errors.New("couldn't match track")
|
||||
)
|
||||
|
||||
func playlistParseLine(c *Controller, path string) (int, error) {
|
||||
if strings.HasPrefix(path, "#") || strings.TrimSpace(path) == "" {
|
||||
return 0, nil
|
||||
@@ -25,7 +30,7 @@ func playlistParseLine(c *Controller, path string) (int, error) {
|
||||
err := query.First(&track).Error
|
||||
switch {
|
||||
case gorm.IsRecordNotFoundError(err):
|
||||
return 0, fmt.Errorf("couldn't match track %q", path)
|
||||
return 0, fmt.Errorf("%v: %w", err, errPlaylistNoMatch)
|
||||
case err != nil:
|
||||
return 0, fmt.Errorf("while matching: %w", err)
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user