Skip to content

Commit ff7ab4d

Browse files
author
merge-queue-bot
committed
Merge PR #681: arch: add trivial-accessor exemption comments in workspace.go
2 parents f917212 + 49b71cb commit ff7ab4d

4 files changed

Lines changed: 67 additions & 14 deletions

File tree

PLAN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,5 @@ footer: |
221221
| 2606211907 || | [arch-fix: split internal/engine/runner.go](plan/2606211907_arch-fix-runner-srp-split.md) |
222222
| 2606211908 | 🔲 | | [arch-fix: split internal/lint/layer0.go](plan/2606211908_arch-fix-layer0-split.md) |
223223
| 2606211909 || | [arch-fix: split internal/lsp/server.go](plan/2606211909_arch-fix-lsp-server-split.md) |
224-
| 2606211910 | 🔲 | | [arch-fix: add trivial-accessor exemption comments in workspace.go](plan/2606211910_arch-fix-workspace-exemptions.md) |
224+
| 2606211910 | | | [arch-fix: add trivial-accessor exemption comments in workspace.go](plan/2606211910_arch-fix-workspace-exemptions.md) |
225225
<?/catalog?>

pkg/mdsmith/workspace.go

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ func (f *memFile) Read(p []byte) (int, error) {
319319
return n, nil
320320
}
321321

322-
func (f *memFile) Close() error { return nil }
322+
func (f *memFile) Close() error {
323+
// no test by design — trivial accessor
324+
return nil
325+
}
323326

324327
// memDir is an fs.ReadDirFile for in-memory directories.
325328
type memDir struct {
@@ -333,10 +336,14 @@ func (d *memDir) Stat() (fs.FileInfo, error) {
333336
}
334337

335338
func (d *memDir) Read([]byte) (int, error) {
339+
// no test by design — trivial accessor
336340
return 0, &fs.PathError{Op: "read", Path: d.name, Err: fs.ErrInvalid}
337341
}
338342

339-
func (d *memDir) Close() error { return nil }
343+
func (d *memDir) Close() error {
344+
// no test by design — trivial accessor
345+
return nil
346+
}
340347

341348
func (d *memDir) ReadDir(n int) ([]fs.DirEntry, error) {
342349
if n <= 0 {
@@ -363,15 +370,22 @@ type memDirEntry struct {
363370
dir bool
364371
}
365372

366-
func (e memDirEntry) Name() string { return e.name }
367-
func (e memDirEntry) IsDir() bool { return e.dir }
373+
func (e memDirEntry) Name() string {
374+
// no test by design — trivial accessor
375+
return e.name
376+
}
377+
func (e memDirEntry) IsDir() bool {
378+
// no test by design — trivial accessor
379+
return e.dir
380+
}
368381
func (e memDirEntry) Type() fs.FileMode {
369382
if e.dir {
370383
return fs.ModeDir
371384
}
372385
return 0
373386
}
374387
func (e memDirEntry) Info() (fs.FileInfo, error) {
388+
// no test by design — trivial accessor
375389
// memDirEntry and memFileInfo share an identical field layout, so
376390
// the conversion copies name/size/dir across one-for-one.
377391
return memFileInfo(e), nil
@@ -384,14 +398,29 @@ type memFileInfo struct {
384398
dir bool
385399
}
386400

387-
func (i memFileInfo) Name() string { return i.name }
388-
func (i memFileInfo) Size() int64 { return i.size }
401+
func (i memFileInfo) Name() string {
402+
// no test by design — trivial accessor
403+
return i.name
404+
}
405+
func (i memFileInfo) Size() int64 {
406+
// no test by design — trivial accessor
407+
return i.size
408+
}
389409
func (i memFileInfo) Mode() fs.FileMode {
390410
if i.dir {
391411
return fs.ModeDir | 0o555
392412
}
393413
return 0o444
394414
}
395-
func (i memFileInfo) ModTime() time.Time { return time.Time{} }
396-
func (i memFileInfo) IsDir() bool { return i.dir }
397-
func (i memFileInfo) Sys() any { return nil }
415+
func (i memFileInfo) ModTime() time.Time {
416+
// no test by design — trivial accessor
417+
return time.Time{}
418+
}
419+
func (i memFileInfo) IsDir() bool {
420+
// no test by design — trivial accessor
421+
return i.dir
422+
}
423+
func (i memFileInfo) Sys() any {
424+
// no test by design — trivial accessor
425+
return nil
426+
}

pkg/mdsmith/workspace_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,30 @@ func TestMemFSGlobDoublestar(t *testing.T) {
266266
}
267267
}
268268

269+
// TestMemDirEntry_Type covers both branches of the fs.DirEntry.Type() path.
270+
func TestMemDirEntry_Type(t *testing.T) {
271+
dir := memDirEntry{name: "docs", dir: true}
272+
if got := dir.Type(); got != fs.ModeDir {
273+
t.Errorf("Type() dir = %v, want %v", got, fs.ModeDir)
274+
}
275+
file := memDirEntry{name: "a.md", dir: false}
276+
if got := file.Type(); got != 0 {
277+
t.Errorf("Type() file = %v, want 0", got)
278+
}
279+
}
280+
281+
// TestMemFileInfo_Mode covers both branches of the fs.FileInfo.Mode() path.
282+
func TestMemFileInfo_Mode(t *testing.T) {
283+
dir := memFileInfo{name: "docs", dir: true}
284+
if got := dir.Mode(); got != fs.ModeDir|0o555 {
285+
t.Errorf("Mode() dir = %v, want %v", got, fs.ModeDir|0o555)
286+
}
287+
file := memFileInfo{name: "a.md", size: 10, dir: false}
288+
if got := file.Mode(); got != 0o444 {
289+
t.Errorf("Mode() file = %v, want 0o444", got)
290+
}
291+
}
292+
269293
// --- indexSlash ---
270294

271295
// TestIndexSlash covers the four boundary cases: no slash, slash at

plan/2606211910_arch-fix-workspace-exemptions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: 2606211910
33
title: >-
44
arch-fix: add trivial-accessor exemption
55
comments in workspace.go
6-
status: '🔲'
6+
status: ''
77
summary: >-
88
Add one-line "no test by design" comments
99
to the trivial one-liner methods in
@@ -55,9 +55,9 @@ Future audits pass without flagging them.
5555

5656
## Acceptance Criteria
5757

58-
- [ ] Every trivial one-liner method in
58+
- [x] Every trivial one-liner method in
5959
`pkg/mdsmith/workspace.go` carries an
6060
exemption comment.
61-
- [ ] `go build ./...` passes.
62-
- [ ] `mdsmith check pkg/mdsmith/workspace.go`
61+
- [x] `go build ./...` passes.
62+
- [x] `mdsmith check pkg/mdsmith/workspace.go`
6363
reports no new violations.

0 commit comments

Comments
 (0)