feat: run staticcheck during build and fix errors
All checks were successful
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 46s
Build Docker Image / Build-Docker-Image (push) Successful in 41s

This commit was merged in pull request #285.
This commit is contained in:
2024-11-29 20:23:02 +01:00
parent a62f0fb037
commit e201ac7b2c
6 changed files with 12 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
with-expecter: True
dir: mocks/
outpkg: mocks
issue-845-fix: True
packages:
me-fit/service:
interfaces:

View File

@@ -1,10 +1,10 @@
FROM golang:1.23.3@sha256:73f06be4578c9987ce560087e2e2ea6485fb605e3910542cadd8fa09fc5f3e31 AS builder_go
WORKDIR /me-fit
RUN go install github.com/a-h/templ/cmd/templ@latest && go install github.com/vektra/mockery/v2@latest
RUN go install github.com/a-h/templ/cmd/templ@latest && go install github.com/vektra/mockery/v2@latest && go install honnef.co/go/tools/cmd/staticcheck@latest
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN templ generate && mockery && go test ./... && go build -o /me-fit/me-fit .
RUN templ generate && mockery --log-level warn && staticcheck ./... && go test ./... && go build -o /me-fit/me-fit .
FROM node:22.11.0@sha256:5c76d05034644fa8ecc9c2aa84e0a83cd981d0ef13af5455b87b9adf5b216561 AS builder_node

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")
)