MCPcopy Create free account
hub / github.com/vale-cli/vale / NewReadability

Function NewReadability

internal/check/readability.go:23–41  ·  view source on GitHub ↗

NewReadability creates a new `readability`-based rule.

(_ *core.Config, generic baseCheck, path string)

Source from the content-addressed store, hash-verified

21
22// NewReadability creates a new `readability`-based rule.
23func NewReadability(_ *core.Config, generic baseCheck, path string) (Readability, error) {
24 rule := Readability{}
25
26 err := decodeRule(generic, &rule)
27 if err != nil {
28 return rule, readStructureError(err, path)
29 }
30
31 if core.AllStringsInSlice(rule.Metrics, readabilityMetrics) {
32 // NOTE: This is the only extension point that doesn't support scoping.
33 // The reason for this is that we need to split on sentences to
34 // calculate readability, which means that specifying a scope smaller
35 // than a paragraph or including non-block level content (i.e.,
36 // headings, list items or table cells) doesn't make sense.
37 rule.Definition.Scope = []string{"summary"}
38 }
39
40 return rule, nil
41}
42
43// Run calculates the readability level of the given text.
44func (o Readability) Run(blk nlp.Block, _ *core.File, _ *core.Config) ([]core.Alert, error) {

Callers 1

buildRuleFunction · 0.85

Calls 3

AllStringsInSliceFunction · 0.92
decodeRuleFunction · 0.85
readStructureErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…