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

Function buildRule

internal/check/definition.go:122–166  ·  view source on GitHub ↗
(cfg *core.Config, generic baseCheck)

Source from the content-addressed store, hash-verified

120type baseCheck map[string]interface{}
121
122func buildRule(cfg *core.Config, generic baseCheck) (Rule, error) {
123 path, ok := generic["path"].(string)
124 if !ok {
125 msg := fmt.Errorf("'%v' is not valid", generic)
126 return Existence{}, core.NewE100("buildRule: path", msg)
127 }
128
129 name, ok := generic["extends"].(string)
130 if !ok {
131 name = "unknown"
132 }
133
134 delete(generic, "path")
135 switch name {
136 case "existence":
137 return NewExistence(cfg, generic, path)
138 case "substitution":
139 return NewSubstitution(cfg, generic, path)
140 case "capitalization":
141 return NewCapitalization(cfg, generic, path)
142 case "occurrence":
143 return NewOccurrence(cfg, generic, path)
144 case "spelling":
145 return NewSpelling(cfg, generic, path)
146 case "repetition":
147 return NewRepetition(cfg, generic, path)
148 case "readability":
149 return NewReadability(cfg, generic, path)
150 case "conditional":
151 return NewConditional(cfg, generic, path)
152 case "consistency":
153 return NewConsistency(cfg, generic, path)
154 case "sequence":
155 return NewSequence(cfg, generic, path)
156 case "metric":
157 return NewMetric(cfg, generic, path)
158 case "script":
159 return NewScript(cfg, generic, path)
160 default:
161 return Existence{}, core.NewE201FromTarget(
162 fmt.Sprintf("'extends' key must be one of %v.", extensionPoints),
163 name,
164 path)
165 }
166}
167
168func formatMessages(msg string, desc string, subs ...string) (string, string) {
169 return core.FormatMessage(msg, subs...), core.FormatMessage(desc, subs...)

Callers 3

addCheckMethod · 0.85
loadDefaultRulesMethod · 0.85
loadVocabRulesMethod · 0.85

Calls 14

NewE100Function · 0.92
NewE201FromTargetFunction · 0.92
NewExistenceFunction · 0.85
NewSubstitutionFunction · 0.85
NewCapitalizationFunction · 0.85
NewOccurrenceFunction · 0.85
NewSpellingFunction · 0.85
NewRepetitionFunction · 0.85
NewReadabilityFunction · 0.85
NewConditionalFunction · 0.85
NewConsistencyFunction · 0.85
NewSequenceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…