-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redesigning the top-level Scorecard entrypoint #3717
Labels
Milestone
Comments
This issue is stale because it has been open for 60 days with no activity. |
This was referenced May 9, 2024
This was referenced Jul 2, 2024
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: still tweaking this, but happy to get any feedback.
Problem
Our current top-level entrypoint,
RunScorecard
, has a long list of parameters.There’s two problems with this:
Solution
We can use functional options to solve this problem. Functional options are a paradigm to pass an arbitrary number of options to a function to modify its behavior without changing its signature. At its core is the option type, which is unsurprisingly an alias for a function signature.
The first step is splitting our current arguments into required and optional values. I’m arguing that the only required values are the context and the repo to analyze (for rationale, see Appendix). Every other existing argument will use default values, unless modified by an option:
With this starting point, options are easily added. Let’s use commit SHA and depth as an example, we just add a new field to our unexported state, and an exported option to manipulate it:
Existing callers don’t need to change their signature, but those that want to customize the behavior can:
Appendix
A lot of the arguments either have default behavior built in already. Or the callers tend to provide the same arguments.
commitSHA string
,clients.HeadSHA
is the default, unless someone provides the--commit
optioncommitDepth int
checksToRun checker.CheckNameToFnMap
--checks
is provided, only those checks are run. However with structured results we're also seeing--probes
added (see 🌱 Add probes to main call #3688)all of the repo clients
clients.DefaultCIIBestPracticesClient()
checker.GetClients
, which indirectly creates the default clientschecker.GetClients
The text was updated successfully, but these errors were encountered: