From 29f9cd8d24aa46759114316779e2914896405c15 Mon Sep 17 00:00:00 2001 From: Stephen Augustus Date: Tue, 15 Feb 2022 20:37:41 -0500 Subject: [PATCH] checker: Add `NewRunner` constructor for `Runner` Signed-off-by: Stephen Augustus --- checker/check_runner.go | 20 ++++++++++++++++++++ pkg/scorecard.go | 11 ++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/checker/check_runner.go b/checker/check_runner.go index 49195dd9359b..d52eaffb5b88 100644 --- a/checker/check_runner.go +++ b/checker/check_runner.go @@ -36,6 +36,26 @@ type Runner struct { CheckRequest CheckRequest } +func NewRunner(checkName, repo string, checkReq CheckRequest) *Runner { + return &Runner{ + CheckName: checkName, + Repo: repo, + CheckRequest: checkReq, + } +} + +func (r *Runner) WithCheckName(check string) { + r.CheckName = check +} + +func (r *Runner) WithRepo(repo string) { + r.Repo = repo +} + +func (r *Runner) WithCheckRequest(checkReq CheckRequest) { + r.CheckRequest = checkReq +} + // CheckFn defined for convenience. type CheckFn func(*CheckRequest) CheckResult diff --git a/pkg/scorecard.go b/pkg/scorecard.go index 42e2decbf0c7..b30b49155bca 100644 --- a/pkg/scorecard.go +++ b/pkg/scorecard.go @@ -48,11 +48,12 @@ func runEnabledChecks(ctx context.Context, wg.Add(1) go func() { defer wg.Done() - runner := checker.Runner{ - Repo: repo.URI(), - CheckName: checkName, - CheckRequest: request, - } + runner := checker.NewRunner( + checkName, + repo.URI(), + request, + ) + resultsCh <- runner.Run(ctx, checkFn) }() }