fuzzyworld

template / files / IMPROVEMENTS.md

IMPROVEMENTS.md

Blame: the commit that last changed each line · file · history

6e0dbce3 2026-05-01 Pavel Safronov1# Improvement Plan
2
3Ordered roughly by effort, lowest first. Each section lists the concrete changes needed.
4
5---
6
37160b89 2026-05-01 Pavel Safronov7## ✅ 1. Drop `golang.org/x/exp` dependency
6e0dbce3 2026-05-01 Pavel Safronov8
37160b89 2026-05-01 Pavel Safronov9Replaced `golang.org/x/exp/slices` with the stdlib `slices` package in
10[config.go](internal/core/config.go), [profile.go](internal/core/profile.go), and
11[name_pattern_test.go](internal/core/name_pattern_test.go). Removed the dependency
12from [go.mod](go.mod) via `go mod tidy`.
6e0dbce3 2026-05-01 Pavel Safronov13
14---
15
37160b89 2026-05-01 Pavel Safronov16## ✅ 2. Upgrade Go version
6e0dbce3 2026-05-01 Pavel Safronov17
37160b89 2026-05-01 Pavel Safronov18[go.mod](go.mod) now declares `go 1.25.0`, driven by the project's actual transitive
19deps. The GitLab CI image (`golang:1.25`) is aligned.
6e0dbce3 2026-05-01 Pavel Safronov20
21---
22
37160b89 2026-05-01 Pavel Safronov23## ✅ 3. Reorganize source files into a nested directory
6e0dbce3 2026-05-01 Pavel Safronov24
37160b89 2026-05-01 Pavel Safronov25All source files moved out of the repo root into:
6e0dbce3 2026-05-01 Pavel Safronov26
27```text
28cmd/
29 template/
37160b89 2026-05-01 Pavel Safronov30 main.go ← 14-line entry point; sets Version, calls core.Run()
6e0dbce3 2026-05-01 Pavel Safronov31internal/
37160b89 2026-05-01 Pavel Safronov32 core/
33 app.go ← CLI wiring + all orchestration logic
6e0dbce3 2026-05-01 Pavel Safronov34 config.go
37160b89 2026-05-01 Pavel Safronov35 profile.go
36 ... (all other files)
6e0dbce3 2026-05-01 Pavel Safronov37```
38
37160b89 2026-05-01 Pavel Safronov39[Makefile](Makefile) build and install targets updated to `./cmd/template/`.
40[.goreleaser.yaml](.goreleaser.yaml) updated with `main: ./cmd/template/`.
6e0dbce3 2026-05-01 Pavel Safronov41
37160b89 2026-05-01 Pavel Safronov42---
43
44## ✅ 4. Tool management via separate module
6e0dbce3 2026-05-01 Pavel Safronov45
37160b89 2026-05-01 Pavel Safronov46Dev tools (golangci-lint, gomarklint, goreleaser) are now version-pinned in
47[tools/go.mod](tools/go.mod), keeping their hundreds of transitive dependencies
48out of the main [go.mod](go.mod). The [Makefile](Makefile) installs them via
49`cd tools && go install ...` and exposes `make lint` and `make lint-docs` targets.
6e0dbce3 2026-05-01 Pavel Safronov50
51---
52
37160b89 2026-05-01 Pavel Safronov53## ✅ 5. Reduce `main.go` size
6e0dbce3 2026-05-01 Pavel Safronov54
37160b89 2026-05-01 Pavel Safronov55[cmd/template/main.go](cmd/template/main.go) is now 14 lines. All CLI wiring,
56settings construction (`createSettings`), profile resolution (`findProfile`), and
57orchestration (`runMain`) live in [internal/core/app.go](internal/core/app.go)
58where they are reachable by tests without going through the CLI layer.
59
60---
6e0dbce3 2026-05-01 Pavel Safronov61
ecad2935 2026-05-01 Pavel Safronov62## ✅ 6. Improve test coverage
63
64Coverage raised from ~56% to 67.7%. Threshold gate in [Makefile](Makefile) raised
65to 65%.
66
67New tests added across:
68
69- **[app_test.go](internal/core/app_test.go)** — `readEnvVars` (all env var
70 branches), `loadAndMergeUserConfig` (file not found, valid merge, invalid YAML,
71 merge error from invalid global config), `findProfile` (named profile, default
72 profile, no-profile error)
73- **[file_test.go](internal/core/file_test.go)** — `createFile` error paths
74 (`OSCreate` failure, `OSWriteFile` failure in template and empty-template paths),
75 `readFile` (happy path and missing file)
76- **[profile_test.go](internal/core/profile_test.go)** — `createEntity` error
77 paths (mkdir failure, chdir failure, invalid file-name pattern inside folder,
78 subdir mkdir failure, `createFile` failure for both `FolderType` and `FileType`),
79 `processProfile` edge cases (target-dir mkdir/chdir failures, `createEntity`
80 error with and without `RunPostscriptOnFailure` swallow, invalid post-script
81 template, post script with no output, post script that exits non-zero),
82 `ScriptType` profile
83- **[profile_test.go](internal/core/profile_test.go)** — new
84 `TestCreateNewNameForPatternsGetVersionError`: `getVersion` used in a non-last
85 pattern returns an error
86
87Remaining uncovered paths are inherently untestable in unit tests: CLI wiring
88(`Run`, `createSettings`, `runMain`), the Windows branch of `shellCommandAndArgs`,
89and error branches in `yaml.Marshal` / `bufio.Writer` that the library panics on
90rather than returning errors.
6e0dbce3 2026-05-01 Pavel Safronov91
92---
93
51fece6b 2026-05-01 Pavel Safronov94## ✅ 7. Clean up `default_config.go`
6e0dbce3 2026-05-01 Pavel Safronov95
51fece6b 2026-05-01 Pavel Safronov96[default_config.go](internal/core/default_config.go) shrunk from 396 lines to 18
97by switching to `//go:embed defaults.yaml`. All 14 profiles now live in
98[defaults.yaml](internal/core/defaults.yaml) as plain YAML, editable without
99touching Go code.
6e0dbce3 2026-05-01 Pavel Safronov100
51fece6b 2026-05-01 Pavel Safronov101Added `omitempty` to the `IsDefault` and `IsDisabled` bool fields in `Profile`
102so marshaling produces clean output (zero values omitted).
6e0dbce3 2026-05-01 Pavel Safronov103
104---
105
51fece6b 2026-05-01 Pavel Safronov106## ✅ 8. Minor housekeeping
37160b89 2026-05-01 Pavel Safronov107
51fece6b 2026-05-01 Pavel Safronov108- **Empty `src/` directory** — removed.
109- **`.DS_Store`** — `**/.DS_Store` added to [.gitignore](.gitignore).
98e28fa3 2026-10-27 Pavel Safronov110- **CI image pinning** — [.fw-ci.yml](.fw-ci.yml) pinned to
51fece6b 2026-05-01 Pavel Safronov111 `golang:1.25.4`.