stan
stan copied to clipboard
[RFC] Design API for specifying custom inspections
Users may want to introduce their own inspections (e.g. forbidding their partial functions). It would be nice to be able to support this API as well.
My first thoughts (not a final proposal): add a new enum field in the Check data type, like:
data InspectionSource
= Stan -- Default, when missing
| Custom
So users can write:
[[check]]
type = "Include"
source = "Custom"
...
What users can include for now:
- Custom
NameMetas to forbid custom functions- Question: How can they specify
PatternType? We need some custom format and parser forPatternType, sounds like something that requires thinking... But if we can come up with that, we can also support customPatternAst.
- Question: How can they specify
Yes, we definitely need to start designing this feature. @chshersh , what do you think if we would support the creation of custom inspections through the other list in TOML config?
[[inspections]]
type = ForbidExtension
name = "NamedPunFields"
id = "123" # optional, we can use the same tactic we already have, but without a number
# e.g. USER-DE-hash1234
# ^ DE is the code for the type of ins
...
# I don'r know yet what else we need and how to name it
[[check]]
...
# what we had before
What do you think?
@vrom911 :egg:cellent proposal :+1: That makes more sense to me. And we can easily extend these possibilities further.
I will try to share my thoughts of how :egg:zample of the custom inspection specifying can look like on something like STAN-0001 (partial head):
[[inspection]]
type = "ForbidName"
id = "MYAPP-0001" # will become USER-MYAPP-0001
name = "Usage of partial 'head'"
description = "..."
solution = [ "...", "..." ]
category = [ "List", "Partial" ]
severity = "PossibleBug"
nameMeta = { package = "base", module = "GHC.OldList", name = "head" }
patternType = { fun = { arg = { nameMeta = { "..." }, vars = { "..." } }, res = "?" } }