Skip to content

Latest commit

 

History

History
104 lines (84 loc) · 4.8 KB

CONTRIBUTING.md

File metadata and controls

104 lines (84 loc) · 4.8 KB

Contributing

Thanks for taking a look. This is a disk cleaner — code here deletes people's files, so a few of the rules below are firmer than usual.

Getting set up

git clone <repo> && cd iCleaner
./build.sh --run          # build, assemble the .app, launch it
swift test                # the engine has unit tests; the UI does not
./setup-signing.sh        # once, so Full Disk Access survives rebuilds

Requires macOS 13+ and Xcode 16 or matching Command Line Tools (Package.swift is swift-tools-version 6.0).

The one hard rule

Sources/iCleanerCore/Trash.swift is the single gate every deletion goes through. validate() refuses, in order: paths outside the home directory, protected standard directories, things already in the Trash, missing paths, and symlinks.

If you add a new way to delete something, it must call validate() first. Do not add a second path, do not add an "internal, trusted" shortcut, and do not relax a check to make a feature work — the feature is wrong, not the check. TrashSafetyTests and ForceDeleteTests exist to keep this true; a PR that changes them needs to say why in the description.

Conventions worth knowing before you write code

These are all things that have already cost someone a day:

  • Never rename ScanCategory to Category. It collides with the Objective-C runtime's Category typedef and produces dozens of unrelated compiler errors.
  • .frame(min…) must always come with a max…, and max alone does not stop a child from over-reporting its size — see ContentView.swift, where a GeometryReader pins the detail area for exactly this reason.
  • UI strings are English source strings used directly as keys. Add a new L("…") and you must add the same key to both Resources/en.lproj/Localizable.strings and zh-Hans.lproj, or LocalizationTests fails.
  • Logs are always English and never go through L(). Paths are logged .private, counts and durations .public. See AppLog.swift.
  • A View that shows localized text must observe store or @Environment(\.locale). L() is invisible to SwiftUI's dependency graph, so a view with no changing input never re-renders on a language switch. Theme.swift explains this at the top.
  • Rows laid out horizontally must be compressible: .lineLimit(1) + truncation + .frame(minWidth: 0) + .layoutPriority(0) for text, .fixedSize() for buttons. One stubborn row can widen the detail area and squeeze the sidebar out of the window.

And a few that are less about SwiftUI and more about not repeating an afternoon someone already lost:

  • Never run a global find-and-replace over Swift here. Two separate incidents: renaming Category also hit every .category, and replacing an unused detail variable hit an identically-shaped loop in another function. grep -n first, then replace with enough surrounding context to be unique.
  • No mixed-type ternaries inside a ViewBuilder or a sort closure — the type checker gives up with "unable to type-check this expression in reasonable time". Write the closure out with explicit types.
  • No bare % in a .strings value. Write %%, or make it a real format string with arguments.
  • import os in every file that touches AppLog — Swift imports are per-file.
  • Never add .clipped() to the root frame. NavigationSplitView is meant to draw past the title bar; clipping cuts the top 52pt, which is the first sidebar row and the entire detail header.
  • In shell scripts, $VAR followed by CJK punctuation must be ${VAR}. In a non-UTF-8 locale bash swallows the first byte of the punctuation as part of the variable name and set -u aborts. Check with: grep -nP '\$[A-Za-z_][A-Za-z0-9_]*(?=[^\x00-\x7f])' *.sh

DOCS/DESIGN.md covers what the app is meant to be and why (§12 is the decision log); DOCS/TECH_SPEC.md covers how it is built.

Pull requests

  • Keep the diff to one concern.
  • swift test must pass. If you touch scanning or deletion, add a test.
  • UI changes: include a before/after screenshot. Keep the window at a consistent size so the two are comparable — the README shots are 1280×800.
  • English in code, comments and commit messages.

Reporting a bug

Include your macOS version, whether Full Disk Access is granted, and the version from Settings → About. Logs help a lot:

log stream --predicate 'subsystem == "local.icleaner.app"' --level info

Paths are redacted as <private> in logs by default — that is intentional. If you can reproduce with a path you are willing to share, say so in words rather than pasting a log you have not read.

Please do not file an issue that includes a path you would not want public. This project deletes files; issues are the wrong place for a directory listing of your home folder.