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)
| 361 | // the outer function's cognitive complexity stays within the |
| 362 | // linter's gate. |
| 363 | func 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 |
no test coverage detected