fix: fix static code analysis
Some checks failed
Build Docker Image / Build-Docker-Image (push) Failing after 37s

This commit is contained in:
2024-11-29 20:29:10 +01:00
parent 81bff13edf
commit a2ca51afbf
4 changed files with 9 additions and 18 deletions

View File

@@ -36,7 +36,7 @@ func (handler IndexHandlerImpl) handle(router *http.ServeMux) {
func (handler IndexHandlerImpl) handleIndexAnd404() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
user, err := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
user, _ := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
var comp templ.Component = nil
userComp := service.UserInfoComp(user)
@@ -48,7 +48,7 @@ func (handler IndexHandlerImpl) handleIndexAnd404() http.HandlerFunc {
comp = template.Layout(template.Index(), userComp, handler.serverSettings.Environment)
}
err = comp.Render(r.Context(), w)
err := comp.Render(r.Context(), w)
if err != nil {
utils.LogError("Failed to render index", err)
http.Error(w, "Failed to render index", http.StatusInternalServerError)

View File

@@ -24,11 +24,11 @@ import (
)
var (
ErrInvaidCredentials = errors.New("Invalid email or password")
ErrInvalidPassword = errors.New("Password needs to be 8 characters long, contain at least one number, one special, one uppercase and one lowercase character")
ErrInvalidEmail = errors.New("Invalid email")
ErrAccountExists = errors.New("Account already exists")
ErrSessionIdInvalid = errors.New("Session ID is invalid")
ErrInvaidCredentials = errors.New("invalid email or password")
ErrInvalidPassword = errors.New("password needs to be 8 characters long, contain at least one number, one special, one uppercase and one lowercase character")
ErrInvalidEmail = errors.New("invalid email")
ErrAccountExists = errors.New("account already exists")
ErrSessionIdInvalid = errors.New("session ID is invalid")
)
type User struct {

View File

@@ -61,7 +61,7 @@ func NewWorkoutDto(rowId string, date string, workoutType string, sets string, r
}
var (
ErrInputValues = errors.New("Invalid input values")
ErrInputValues = errors.New("invalid input values")
)
func (service WorkoutServiceImpl) AddWorkout(user *User, workoutDto *WorkoutDto) (*WorkoutDto, error) {
@@ -125,15 +125,6 @@ func (service WorkoutServiceImpl) GetWorkouts(user *User) ([]*WorkoutDto, error)
return workoutsDto, nil
}
func renderDateStr(date string) (string, error) {
t, err := time.Parse("2006-01-02 15:04:05-07:00", date)
if err != nil {
return "", err
}
return renderDate(t), nil
}
func renderDate(date time.Time) string {
return date.Format("2006-01-02")
}

View File

@@ -5,5 +5,5 @@ import (
)
var (
ErrInternal = errors.New("Internal server error")
ErrInternal = errors.New("internal server error")
)