Skip to content

Commit

Permalink
fix all linting except unimplemented daily job
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRoesler committed Oct 28, 2023
1 parent d9d5791 commit 088db15
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
4 changes: 2 additions & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/google/uuid"
"github.com/jonboulle/clockwork"

. "github.com/go-co-op/gocron/v2"
. "github.com/go-co-op/gocron/v2" // nolint:revive
)

func ExampleAfterJobRuns() {
Expand Down Expand Up @@ -160,7 +160,7 @@ func ExampleScheduler_NewJob() {
),
)
if err != nil {
// handle error
panic(err)
}
fmt.Println(j.ID())
}
Expand Down
13 changes: 5 additions & 8 deletions job.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type internalJob struct {
timer clockwork.Timer
singletonMode bool
limitRunsTo *limitRunsTo
lockerKey string
startTime time.Time
startImmediately bool
// event listeners
Expand Down Expand Up @@ -209,7 +208,7 @@ func (d durationRandomJobDefinition) setup(j *internalJob, _ *time.Location) err
j.jobSchedule = &durationRandomJob{
min: d.min,
max: d.max,
rand: rand.New(rand.NewSource(time.Now().UnixNano())),
rand: rand.New(rand.NewSource(time.Now().UnixNano())), // nolint:gosec
}
return nil
}
Expand Down Expand Up @@ -247,7 +246,7 @@ func (d dailyJobDefinition) options() []JobOption {
}

func (d dailyJobDefinition) setup(i *internalJob, location *time.Location) error {

Check warning on line 248 in job.go

View workflow job for this annotation

GitHub Actions / lint and test (1.20)

unused-parameter: parameter 'i' seems to be unused, consider removing or renaming it as _ (revive)
//TODO implement me
// TODO implement me
panic("implement me")
}

Expand Down Expand Up @@ -280,10 +279,8 @@ func (w weeklyJobDefinition) setup(j *internalJob, location *time.Location) erro
return ErrWeeklyJobAtTimesNil
}

var daysOfTheWeek []time.Weekday
for _, wd := range w.daysOfTheWeek() {
daysOfTheWeek = append(daysOfTheWeek, wd)
}
daysOfTheWeek := w.daysOfTheWeek()

slices.Sort(daysOfTheWeek)

atTimesDate, err := convertAtTimesToDateTime(w.atTimes, location)
Expand Down Expand Up @@ -641,7 +638,7 @@ type dailyJob struct {
}

func (d dailyJob) next(lastRun time.Time) time.Time {

Check warning on line 640 in job.go

View workflow job for this annotation

GitHub Actions / lint and test (1.20)

unused-parameter: parameter 'lastRun' seems to be unused, consider removing or renaming it as _ (revive)
//TODO implement me
// TODO implement me
panic("implement me")
}

Expand Down
4 changes: 2 additions & 2 deletions job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/stretchr/testify/require"
)

func TestDurationJob_next(t *testing.T) {
}
//func TestDurationJob_next(t *testing.T) {
//}

func TestWeeklyJob_next(t *testing.T) {
tests := []struct {
Expand Down
9 changes: 3 additions & 6 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ func (s *scheduler) stopScheduler() {
s.started = false
for id, j := range s.jobs {
j.stop()
select {
case <-j.ctx.Done():
}
<-j.ctx.Done()

j.ctx, j.cancel = context.WithCancel(s.shutdownCtx)
s.jobs[id] = j
}
Expand Down Expand Up @@ -318,9 +317,7 @@ func (s *scheduler) addOrUpdateJob(id uuid.UUID, definition JobDefinition) (Job,
} else {
currentJob := requestJob(s.shutdownCtx, id, s.jobOutRequestCh)
s.removeJobCh <- id
select {
case <-currentJob.ctx.Done():
}
<-currentJob.ctx.Done()

j.id = id
}
Expand Down

0 comments on commit 088db15

Please sign in to comment.