From 4a5ebf5d80b0858d21faad8a4a4d947a5ed2a51d Mon Sep 17 00:00:00 2001 From: John Roesler Date: Thu, 1 Jun 2023 16:18:29 -0500 Subject: [PATCH 1/3] upgrade to golangci lint 1.53 --- .github/workflows/go_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml index 836d41e9..91880d3b 100644 --- a/.github/workflows/go_test.yml +++ b/.github/workflows/go_test.yml @@ -25,7 +25,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3.4.0 with: - version: v1.51.2 + version: v1.53.0 - name: Install Go uses: actions/setup-go@v4 with: From 0b57721a8946f62368137f0adfa6531394d15dcb Mon Sep 17 00:00:00 2001 From: John Roesler Date: Fri, 2 Jun 2023 06:56:06 -0500 Subject: [PATCH 2/3] 1.53.0 -> 1.53.1 --- .github/workflows/go_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml index 91880d3b..982caa8f 100644 --- a/.github/workflows/go_test.yml +++ b/.github/workflows/go_test.yml @@ -25,7 +25,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3.4.0 with: - version: v1.53.0 + version: v1.53.1 - name: Install Go uses: actions/setup-go@v4 with: From 938fedea457855866909b04ecabb87b8a667b573 Mon Sep 17 00:00:00 2001 From: John Roesler Date: Fri, 2 Jun 2023 07:12:32 -0500 Subject: [PATCH 3/3] address lint findings --- scheduler.go | 3 +-- scheduler_test.go | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/scheduler.go b/scheduler.go index 11199966..e66ae499 100644 --- a/scheduler.go +++ b/scheduler.go @@ -1175,9 +1175,8 @@ func (s *Scheduler) Months(daysOfTheMonth ...int) *Scheduler { if _, ok := repeatMap[dayOfMonth]; ok { job.error = wrapOrError(job.error, ErrInvalidDaysOfMonthDuplicateValue) break - } else { - repeatMap[dayOfMonth]++ } + repeatMap[dayOfMonth]++ } } if job.daysOfTheMonth == nil { diff --git a/scheduler_test.go b/scheduler_test.go index f7580223..d9698e75 100644 --- a/scheduler_test.go +++ b/scheduler_test.go @@ -23,8 +23,8 @@ func (f fakeTime) Now(loc *time.Location) time.Time { return f.onNow(loc) } -func (f fakeTime) Unix(i int64, i2 int64) time.Time { - panic("implement me") +func (f fakeTime) Unix(sec int64, nsec int64) time.Time { + return time.Unix(sec, nsec) } func (f fakeTime) Sleep(d time.Duration) { @@ -148,7 +148,8 @@ func TestScheduler_Every(t *testing.T) { } } s.Stop() - assert.Equal(t, 2, counter) + assert.GreaterOrEqual(t, counter, 2) + assert.LessOrEqual(t, counter, 3) }) t.Run("string duration", func(t *testing.T) { @@ -2355,7 +2356,8 @@ func TestScheduler_CheckCalculateDaysOfMonth(t *testing.T) { func TestScheduler_CheckSetBehaviourBeforeJobCreated(t *testing.T) { s := NewScheduler(time.UTC) - s.Month(1, 2).Every(1).Do(func() {}) + _, err := s.Month(1, 2).Every(1).Do(func() {}) + assert.NoError(t, err) } func TestScheduler_MonthLastDayAtTime(t *testing.T) {