-
Notifications
You must be signed in to change notification settings - Fork 509
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
Avoiding probe explosion and boilerplate #3824
Comments
Big fan of this idea. Moving from ints to strings is a huge improvement, for sure. As we briefly discussed in #3816 (comment), I'd love if it were possible to make the map more generic (literally!), but after spending much of Friday learning how generics and interfaces actually work in Go, I've come to realize it simply isn't possible in this situation. So using strings seems reasonable. The evaluation logic for many checks will need to convert back into other types (i.e. ints) to make comparisons, but that should be simple enough. |
I like these two changes (reframing the probes and changing the Having a string (instead of an interface or generic) is preferred IMO, but I may have a bit of bias from dealing with a map of interfaces in the past: It tends to often get messy and increase maintainability. A On the question of reframing the probes, I can't see a negative impact from this. Scorecards own evaluation would be able to process the probes more or less in the same manner, and other users that write their own evaluation should not see increased complexity from structuring the probes in the way that @spencerschrock suggests. @spencerschrock 's suggestion will definitely reduce Scorecards LoC and a fair bit of repeated code. |
Background
When evaluating a repository, it’s common for Scorecard to detect different tools when scoring checks or probes. The heuristic has to do with the usage of tools from certain categories, not the usage of an exact tool. This applies to many checks (and their underlying probes):
Proposal
We frame probes as answers to various questions about a repository, so this proposal boils down to figuring out what the question is:
I’m going to argue we should favor the first question. Specifically, there should be a single probe per tool category, not per tool.
Pros
Cons
E.g. check out our [link to some markdown] for instructions for specific tools for your language.
Example
Current
Proposed
Why aren’t things like this already?
Short answer: a limitation in the Finding struct.
Specifically, let’s take a look at the
Values
map. It maps some property/label to an integer value. This typing was chosen with a small subset of probes in mind, and was always subject to change.But the integer type also provides limitations, and probes converted after the Values map was typed have to resort to workarounds
Enabling Change
One option is making the
Values
typemap[string]string
, as strings are more flexible. Integers can be represented as a string so we don’t lose anything. Note: this does introduce an extra step for probes which want int values.Examples
CII-Best-Practices
Before:
After:
Maintained:
Before:
After:
The text was updated successfully, but these errors were encountered: