Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,5 @@ footer: |
| 2606211907 | ✅ | | [arch-fix: split internal/engine/runner.go](plan/2606211907_arch-fix-runner-srp-split.md) |
| 2606211908 | 🔲 | | [arch-fix: split internal/lint/layer0.go](plan/2606211908_arch-fix-layer0-split.md) |
| 2606211909 | 🔲 | | [arch-fix: split internal/lsp/server.go](plan/2606211909_arch-fix-lsp-server-split.md) |
| 2606211910 | 🔲 | | [arch-fix: add trivial-accessor exemption comments in workspace.go](plan/2606211910_arch-fix-workspace-exemptions.md) |
| 2606211910 | | | [arch-fix: add trivial-accessor exemption comments in workspace.go](plan/2606211910_arch-fix-workspace-exemptions.md) |
<?/catalog?>
47 changes: 38 additions & 9 deletions pkg/mdsmith/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ func (f *memFile) Read(p []byte) (int, error) {
return n, nil
}

func (f *memFile) Close() error { return nil }
func (f *memFile) Close() error {
// no test by design — trivial accessor
return nil
}

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

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

func (d *memDir) Close() error { return nil }
func (d *memDir) Close() error {
// no test by design — trivial accessor
return nil
}

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

func (e memDirEntry) Name() string { return e.name }
func (e memDirEntry) IsDir() bool { return e.dir }
func (e memDirEntry) Name() string {
// no test by design — trivial accessor
return e.name
}
func (e memDirEntry) IsDir() bool {
// no test by design — trivial accessor
return e.dir
}
func (e memDirEntry) Type() fs.FileMode {
if e.dir {
return fs.ModeDir
}
return 0
}
func (e memDirEntry) Info() (fs.FileInfo, error) {
// no test by design — trivial accessor
// memDirEntry and memFileInfo share an identical field layout, so
// the conversion copies name/size/dir across one-for-one.
return memFileInfo(e), nil
Expand All @@ -384,14 +398,29 @@ type memFileInfo struct {
dir bool
}

func (i memFileInfo) Name() string { return i.name }
func (i memFileInfo) Size() int64 { return i.size }
func (i memFileInfo) Name() string {
// no test by design — trivial accessor
return i.name
}
func (i memFileInfo) Size() int64 {
// no test by design — trivial accessor
return i.size
}
func (i memFileInfo) Mode() fs.FileMode {
if i.dir {
return fs.ModeDir | 0o555
}
return 0o444
}
func (i memFileInfo) ModTime() time.Time { return time.Time{} }
func (i memFileInfo) IsDir() bool { return i.dir }
func (i memFileInfo) Sys() any { return nil }
func (i memFileInfo) ModTime() time.Time {
// no test by design — trivial accessor
return time.Time{}
}
func (i memFileInfo) IsDir() bool {
// no test by design — trivial accessor
return i.dir
}
func (i memFileInfo) Sys() any {
// no test by design — trivial accessor
return nil
}
24 changes: 24 additions & 0 deletions pkg/mdsmith/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,30 @@ func TestMemFSGlobDoublestar(t *testing.T) {
}
}

// TestMemDirEntry_Type covers both branches of the fs.DirEntry.Type() path.
func TestMemDirEntry_Type(t *testing.T) {
dir := memDirEntry{name: "docs", dir: true}
if got := dir.Type(); got != fs.ModeDir {
t.Errorf("Type() dir = %v, want %v", got, fs.ModeDir)
}
file := memDirEntry{name: "a.md", dir: false}
if got := file.Type(); got != 0 {
t.Errorf("Type() file = %v, want 0", got)
}
}

// TestMemFileInfo_Mode covers both branches of the fs.FileInfo.Mode() path.
func TestMemFileInfo_Mode(t *testing.T) {
dir := memFileInfo{name: "docs", dir: true}
if got := dir.Mode(); got != fs.ModeDir|0o555 {
t.Errorf("Mode() dir = %v, want %v", got, fs.ModeDir|0o555)
}
file := memFileInfo{name: "a.md", size: 10, dir: false}
if got := file.Mode(); got != 0o444 {
t.Errorf("Mode() file = %v, want 0o444", got)
}
}

// --- indexSlash ---

// TestIndexSlash covers the four boundary cases: no slash, slash at
Expand Down
8 changes: 4 additions & 4 deletions plan/2606211910_arch-fix-workspace-exemptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: 2606211910
title: >-
arch-fix: add trivial-accessor exemption
comments in workspace.go
status: '🔲'
status: ''
summary: >-
Add one-line "no test by design" comments
to the trivial one-liner methods in
Expand Down Expand Up @@ -55,9 +55,9 @@ Future audits pass without flagging them.

## Acceptance Criteria

- [ ] Every trivial one-liner method in
- [x] Every trivial one-liner method in
`pkg/mdsmith/workspace.go` carries an
exemption comment.
- [ ] `go build ./...` passes.
- [ ] `mdsmith check pkg/mdsmith/workspace.go`
- [x] `go build ./...` passes.
- [x] `mdsmith check pkg/mdsmith/workspace.go`
reports no new violations.
Loading