Conversation
Define a Trash interface (Put, List, Restore, Remove) in the trash package. CLI and UI now depend on the interface instead of the concrete *Manager type, enabling mock-based testing.
OrphanedFile type, FindOrphanedTrashInfoFiles(), and ParseTrashInfoFile() are XDG trash domain logic that was incorrectly placed in the CLI package. Move them to trash/xdg/orphan.go with their tests in orphan_test.go. CLI now delegates to xdg package.
Restore() and Remove() had identical logic to compute the .trashinfo path from a trash file path. Extract into infoPathForFile() helper. Also replace fmt.Fprintf(os.Stderr) with slog.Warn for consistency.
Contributor
Code Metrics Report
Details | | main (5f8a73d) | #119 (016fee9) | +/- |
|---------------------|----------------|----------------|-------|
- | Coverage | 50.6% | 44.5% | -6.2% |
| Files | 23 | 24 | +1 |
| Lines | 1565 | 1810 | +245 |
+ | Covered | 793 | 806 | +13 |
- | Code to Test Ratio | 1:1.5 | 1:1.5 | -0.1 |
| Code | 2701 | 2775 | +74 |
+ | Test | 4203 | 4248 | +45 |
+ | Test Execution Time | 4s | 3s | -1s |Code coverage of files in pull request scope (69.1% → 36.9%)
Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHAT
Structural improvements across the trash management codebase: extract a
Trashinterface for mockability, relocate XDG-specific domain logic from CLI to its proper package, and eliminate code duplication in XDG storage operations.WHY
A comprehensive code review identified three structural issues:
*trash.Managertype, making mock-based testing impossiblefindOrphanedTrashInfoFiles,parseTrashInfoFile,OrphanedFile) was XDG-specific domain logic incorrectly placed in the CLI packageRestore()andRemove()in XDG storage had identical.trashinfopath reconstruction codeThis PR also includes Phase 1 safety fixes (SelectionManager global removal + legacy Storage mutex) since those aren't merged yet.