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

Function parse

internal/check/definition.go:217–235  ·  view source on GitHub ↗
(file []byte, path string)

Source from the content-addressed store, hash-verified

215}
216
217func parse(file []byte, path string) (map[string]interface{}, error) {
218 generic := map[string]interface{}{}
219
220 if err := yaml.Unmarshal(file, &generic); err != nil {
221 r := regexp.MustCompile(`yaml: line (\d+): (.+)`)
222 if r.MatchString(err.Error()) {
223 groups := r.FindStringSubmatch(err.Error())
224 i, erri := strconv.Atoi(groups[1])
225 if erri != nil {
226 return generic, core.NewE100("addCheck/Atoi", erri)
227 }
228 return generic, core.NewE201FromPosition(groups[2], path, i)
229 }
230 } else if err = validateDefinition(generic, path); err != nil {
231 return generic, err
232 }
233
234 return generic, nil
235}
236
237func validateDefinition(generic map[string]interface{}, path string) error {
238 if point, ok := generic["extends"]; !ok || point == nil {

Callers 1

addCheckMethod · 0.85

Calls 3

NewE100Function · 0.92
NewE201FromPositionFunction · 0.92
validateDefinitionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…