From c2031d6516fc73babd30e7ca2690c8d165722a0d Mon Sep 17 00:00:00 2001 From: Eraxyso <130852025+Eraxyso@users.noreply.github.com> Date: Tue, 14 Jan 2025 02:00:52 +0000 Subject: [PATCH] fix: fix some lint issues --- controller/questionnaire.go | 12 +++++++----- controller/reminder.go | 9 ++++++--- controller/response.go | 2 ++ model/questionnaires_impl.go | 2 ++ model/questions_impl.go | 2 ++ model/respondents_impl.go | 2 ++ model/responses_impl.go | 2 ++ model/validations_impl.go | 9 ++++----- 8 files changed, 27 insertions(+), 13 deletions(-) diff --git a/controller/questionnaire.go b/controller/questionnaire.go index 2d9a62c1..e3bf266d 100644 --- a/controller/questionnaire.go +++ b/controller/questionnaire.go @@ -116,6 +116,8 @@ func (q Questionnaire) GetQuestionnaires(ctx echo.Context, userID string, params } func (q Questionnaire) PostQuestionnaire(c echo.Context, userID string, params openapi.PostQuestionnaireJSONRequestBody) (openapi.QuestionnaireDetail, error) { + _ = userID + responseDueDateTime := null.Time{} if params.ResponseDueDateTime != nil { responseDueDateTime.Valid = true @@ -576,31 +578,31 @@ func (q Questionnaire) EditQuestionnaire(c echo.Context, questionnaireID int, pa func (q Questionnaire) DeleteQuestionnaire(c echo.Context, questionnaireID int) error { err := q.ITransaction.Do(c.Request().Context(), nil, func(ctx context.Context) error { - err := q.IQuestionnaire.DeleteQuestionnaire(c.Request().Context(), questionnaireID) + err := q.IQuestionnaire.DeleteQuestionnaire(ctx, questionnaireID) if err != nil { c.Logger().Errorf("failed to delete questionnaire: %+v", err) return err } - err = q.DeleteTargets(c.Request().Context(), questionnaireID) + err = q.DeleteTargets(ctx, questionnaireID) if err != nil { c.Logger().Errorf("failed to delete targets: %+v", err) return err } - err = q.DeleteAdministrators(c.Request().Context(), questionnaireID) + err = q.DeleteAdministrators(ctx, questionnaireID) if err != nil { c.Logger().Errorf("failed to delete administrators: %+v", err) return err } - questions, err := q.GetQuestions(c.Request().Context(), questionnaireID) + questions, err := q.GetQuestions(ctx, questionnaireID) if err != nil { c.Logger().Errorf("failed to get questions: %+v", err) return err } for _, question := range questions { - err = q.DeleteQuestion(c.Request().Context(), question.ID) + err = q.DeleteQuestion(ctx, question.ID) if err != nil { c.Logger().Errorf("failed to delete administrators: %+v", err) return err diff --git a/controller/reminder.go b/controller/reminder.go index 35427121..b64dec3b 100644 --- a/controller/reminder.go +++ b/controller/reminder.go @@ -9,7 +9,7 @@ import ( "github.com/traPtitech/anke-to/model" "github.com/traPtitech/anke-to/traq" - "golang.org/x/sync/semaphore" + // "golang.org/x/sync/semaphore" ) type Job struct { @@ -24,7 +24,7 @@ type JobQueue struct { } var ( - sem = semaphore.NewWeighted(1) + // sem = semaphore.NewWeighted(1) Jq = &JobQueue{} Wg = &sync.WaitGroup{} reminderTimingMinutes = []int{5, 30, 60, 1440, 10080} @@ -60,7 +60,10 @@ func (jq *JobQueue) PushReminder(questionnaireID int, limit *time.Time) error { Timestamp: remindTimeStamp, QuestionnaireID: questionnaireID, Action: func() { - reminderAction(questionnaireID, reminderTimingStrings[i]) + err := reminderAction(questionnaireID, reminderTimingStrings[i]) + if err != nil { + panic(err) + } }, }) } diff --git a/controller/response.go b/controller/response.go index ff61d866..4c615ce1 100644 --- a/controller/response.go +++ b/controller/response.go @@ -123,6 +123,8 @@ func (r Response) GetResponse(ctx echo.Context, responseID openapi.ResponseIDInP } func (r Response) DeleteResponse(ctx echo.Context, responseID openapi.ResponseIDInPath, userID string) error { + _ = userID + limit, err := r.IQuestionnaire.GetQuestionnaireLimitByResponseID(ctx.Request().Context(), responseID) if err != nil { if errors.Is(err, model.ErrRecordNotFound) { diff --git a/model/questionnaires_impl.go b/model/questionnaires_impl.go index e0dbb922..18d77eac 100755 --- a/model/questionnaires_impl.go +++ b/model/questionnaires_impl.go @@ -42,6 +42,8 @@ type Questionnaires struct { // BeforeCreate Update時に自動でmodified_atを現在時刻に func (questionnaire *Questionnaires) BeforeCreate(tx *gorm.DB) error { + _ = tx + now := time.Now() questionnaire.ModifiedAt = now questionnaire.CreatedAt = now diff --git a/model/questions_impl.go b/model/questions_impl.go index 6b48077e..df0c84c0 100644 --- a/model/questions_impl.go +++ b/model/questions_impl.go @@ -36,6 +36,8 @@ type Questions struct { // BeforeCreate Update時に自動でmodified_atを現在時刻に func (questionnaire *Questions) BeforeCreate(tx *gorm.DB) error { + _ = tx + questionnaire.CreatedAt = time.Now() return nil diff --git a/model/respondents_impl.go b/model/respondents_impl.go index 249e0d09..4e597993 100755 --- a/model/respondents_impl.go +++ b/model/respondents_impl.go @@ -35,6 +35,8 @@ type Respondents struct { // BeforeCreate insert時に自動でmodifiedAt更新 func (r *Respondents) BeforeCreate(tx *gorm.DB) error { + _ = tx + r.ModifiedAt = time.Now() return nil diff --git a/model/responses_impl.go b/model/responses_impl.go index 93e070d4..8f79090d 100755 --- a/model/responses_impl.go +++ b/model/responses_impl.go @@ -28,6 +28,8 @@ type Responses struct { // BeforeCreate insert時に自動でmodifiedAt更新 func (r *Responses) BeforeCreate(tx *gorm.DB) error { + _ = tx + r.ModifiedAt = time.Now() return nil diff --git a/model/validations_impl.go b/model/validations_impl.go index 13cf699f..3de4daed 100644 --- a/model/validations_impl.go +++ b/model/validations_impl.go @@ -15,7 +15,7 @@ func NewValidation() *Validation { return new(Validation) } -//Validations validationsテーブルの構造体 +// Validations validationsテーブルの構造体 type Validations struct { QuestionID int `json:"questionID" gorm:"type:int(11);not null;primaryKey"` RegexPattern string `json:"regex_pattern" gorm:"type:text;default:NULL"` @@ -152,16 +152,15 @@ func (*Validation) CheckTextValidation(validation Validations, Response string) // CheckNumberValid MinBound,MaxBoundが指定されていれば,有効な入力か確認する func (*Validation) CheckNumberValid(MinBound, MaxBound string) error { var minBoundNum, maxBoundNum float64 + var err error if MinBound != "" { - min, err := strconv.ParseFloat(MinBound, 64) - minBoundNum = min + minBoundNum, err = strconv.ParseFloat(MinBound, 64) if err != nil { return fmt.Errorf("failed to check the boundary value. MinBound is not a numerical value: %w", ErrInvalidNumber) } } if MaxBound != "" { - max, err := strconv.ParseFloat(MaxBound, 64) - maxBoundNum = max + maxBoundNum, err = strconv.ParseFloat(MaxBound, 64) if err != nil { return fmt.Errorf("failed to check the boundary value. MaxBound is not a numerical value: %w", ErrInvalidNumber) }