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

Method Apply

internal/core/view.go:86–112  ·  view source on GitHub ↗
(f *File)

Source from the content-addressed store, hash-verified

84}
85
86func (b *View) Apply(f *File) ([]ScopedValues, error) {
87 value, scalars, err := fileToValue(f)
88 if err != nil {
89 return nil, err
90 }
91
92 resolver := newScalarResolver(scalars)
93 found := make([]ScopedValues, 0, len(b.Scopes))
94 for _, s := range b.Scopes {
95 strs, serr := selectStrings(value, s.Expr)
96 if serr != nil {
97 return nil, fmt.Errorf("processing scope %q: %w", s.Name, serr)
98 }
99 values := make([]ScopedValue, 0, len(strs))
100 for _, str := range strs {
101 line, col := resolver.locate(str)
102 values = append(values, ScopedValue{Text: str, Line: line, Column: col})
103 }
104 found = append(found, ScopedValues{
105 Scope: s.Name,
106 Values: values,
107 Format: s.Type,
108 })
109 }
110
111 return found, nil
112}
113
114func selectStrings(value DaselValue, expr string) ([]string, error) {
115 selected, _, err := dasel.Select(context.Background(), value, expr)

Callers 1

lintDataMethod · 0.80

Calls 4

fileToValueFunction · 0.85
newScalarResolverFunction · 0.85
selectStringsFunction · 0.85
locateMethod · 0.80

Tested by

no test coverage detected