MCPcopy Create free account
hub / github.com/cozystack/talm / buildModelineTemplatePaths

Function buildModelineTemplatePaths

pkg/commands/template.go:363–381  ·  view source on GitHub ↗

buildModelineTemplatePaths converts each template path into the forward-slash, root-relative form to be embedded in the generated modeline. Splits the per-path branching out of generateOutput so the outer function's cognitive complexity stays within the linter's gate.

(templateFiles []string, rootDir string)

Source from the content-addressed store, hash-verified

361// the outer function's cognitive complexity stays within the
362// linter's gate.
363func buildModelineTemplatePaths(templateFiles []string, rootDir string) []string {
364 out := make([]string, len(templateFiles))
365
366 absRootDir, err := filepath.Abs(rootDir)
367 if err != nil {
368 // If we can't get absolute root, normalize original paths for modeline
369 for i, p := range templateFiles {
370 out[i] = engine.NormalizeTemplatePath(p)
371 }
372
373 return out
374 }
375
376 for i, templatePath := range templateFiles {
377 out[i] = engine.NormalizeTemplatePath(modelinePathFor(templatePath, absRootDir))
378 }
379
380 return out
381}
382
383// modelinePathFor returns the path that should be embedded in the
384// modeline for a single template entry. Resolves the path relative

Callers 1

generateOutputFunction · 0.85

Calls 2

NormalizeTemplatePathFunction · 0.92
modelinePathForFunction · 0.85

Tested by

no test coverage detected