Skip to content

Commit 8b52ab3

Browse files
committed
Tighten default cleanup directories
1 parent cddbd61 commit 8b52ab3

File tree

3 files changed

+29
-32
lines changed

3 files changed

+29
-32
lines changed

README.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ These directory names are treated as candidates (they are only counted/deleted i
104104
- `dist`
105105
- `build`
106106
- `out`
107-
- `bin`
108107
- `obj`
109108
- `Debug`
110109
- `Release`
@@ -117,10 +116,7 @@ These directory names are treated as candidates (they are only counted/deleted i
117116
- `.astro`
118117
- `storybook-static`
119118
- `_site`
120-
- `public`
121-
- `.vercel`
122119
- `.turbo`
123-
- `.cache`
124120
- `.parcel-cache`
125121
- `.vite`
126122
- `.angular`
@@ -132,9 +128,6 @@ These directory names are treated as candidates (they are only counted/deleted i
132128
- `.nox`
133129
- `.venv`
134130
- `venv`
135-
- `env`
136-
- `ENV`
137-
- `.direnv`
138131
- `.ipynb_checkpoints`
139132
- `htmlcov`
140133
- `.pyre`
@@ -143,7 +136,6 @@ These directory names are treated as candidates (they are only counted/deleted i
143136
- `dist-newstyle`
144137
- `.stack-work`
145138
- `.vs`
146-
- `packages`
147139
- `CMakeFiles`
148140
- `cmake-build-debug`
149141
- `cmake-build-release`
@@ -155,16 +147,13 @@ These directory names are treated as candidates (they are only counted/deleted i
155147
- `.build`
156148
- `DerivedData`
157149
- `.dart_tool`
158-
- `.serverless`
159150
- `coverage`
160-
- `tmp`
161-
- `temp`
162151

163152
## Notes
164153

165154
- Size is computed as the sum of file sizes (not disk blocks like `du`).
166155
- Requires `git` on `PATH` and follows Git ignore rules (`.gitignore`, `.git/info/exclude`, global excludes).
167156
- Git worktree and other multi-level layouts are supported; when a directory is not a repo, scan probes 1-2 levels below for nested git repos.
168157
- Linux prebuilt releases (`x86_64-unknown-linux-gnu`) are CI-checked to require at most `GLIBC_2.36`.
169-
- The built-in list intentionally does not include some stateful directories (e.g. `.terraform`, `.pulumi`, `.vagrant`). Add them explicitly via `--artifact` if you really want to clean them.
158+
- The built-in list is intentionally conservative. It excludes stateful or user-managed directories that may contain secrets, deployment metadata, uploads, or local state (e.g. `.terraform`, `.direnv`, `.vercel`, `.serverless`, `public`, `packages`, `bin`, `tmp`, `.pulumi`, `.vagrant`). Add them explicitly via `--artifact` only if you are sure they are safe to remove.
170159
- The TUI is built with `ratatui` + `crossterm`. If keybindings/rendering are odd, check your terminal settings and input method conflicts.

npm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ clean-my-code --no-default-artifacts --artifact target --artifact node_modules
4646

4747
Run `clean-my-code --help` for the full CLI reference.
4848

49-
Stateful infrastructure directories such as `.terraform` are intentionally excluded from the built-in artifact list. Add them explicitly via `--artifact` only if you are sure they are safe to remove.
49+
The built-in artifact list is intentionally conservative. It excludes stateful or user-managed directories that may contain secrets, deployment metadata, uploads, or local state, such as `.terraform`, `.direnv`, `.vercel`, `.serverless`, `public`, `packages`, `bin`, and `tmp`. Add them explicitly via `--artifact` only if you are sure they are safe to remove.
5050

5151
## TUI keybindings
5252

src/cli.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ use clap::{Args, Parser, Subcommand};
55

66
use crate::{report::collect_reports, report::print_scan_report, tui::TuiOptions};
77

8-
const DEFAULT_ARTIFACT_DIR_NAMES: [&str; 59] = [
8+
const DEFAULT_ARTIFACT_DIR_NAMES: &[&str] = &[
99
// General build outputs.
1010
"target",
1111
"dist",
1212
"build",
1313
"out",
14-
"bin",
1514
"obj",
1615
"Debug",
1716
"Release",
@@ -25,10 +24,7 @@ const DEFAULT_ARTIFACT_DIR_NAMES: [&str; 59] = [
2524
".astro",
2625
"storybook-static",
2726
"_site",
28-
"public",
29-
".vercel",
3027
".turbo",
31-
".cache",
3228
".parcel-cache",
3329
".vite",
3430
".angular",
@@ -41,9 +37,6 @@ const DEFAULT_ARTIFACT_DIR_NAMES: [&str; 59] = [
4137
".nox",
4238
".venv",
4339
"venv",
44-
"env",
45-
"ENV",
46-
".direnv",
4740
".ipynb_checkpoints",
4841
"htmlcov",
4942
".pyre",
@@ -54,7 +47,6 @@ const DEFAULT_ARTIFACT_DIR_NAMES: [&str; 59] = [
5447
".stack-work",
5548
// .NET / Visual Studio.
5649
".vs",
57-
"packages",
5850
// CMake (CLion).
5951
"CMakeFiles",
6052
"cmake-build-debug",
@@ -69,12 +61,8 @@ const DEFAULT_ARTIFACT_DIR_NAMES: [&str; 59] = [
6961
"DerivedData",
7062
// Mobile / Flutter.
7163
".dart_tool",
72-
// Infra / DevOps.
73-
".serverless",
7464
// Misc.
7565
"coverage",
76-
"tmp",
77-
"temp",
7866
];
7967

8068
#[derive(Parser, Debug)]
@@ -187,7 +175,12 @@ fn run_with_cli(cli: Cli) -> Result<()> {
187175

188176
let mut artifact_dir_names: HashSet<OsString> = HashSet::new();
189177
if !cli.common.no_default_artifacts {
190-
artifact_dir_names.extend(DEFAULT_ARTIFACT_DIR_NAMES.map(OsString::from));
178+
artifact_dir_names.extend(
179+
DEFAULT_ARTIFACT_DIR_NAMES
180+
.iter()
181+
.copied()
182+
.map(OsString::from),
183+
);
191184
}
192185
artifact_dir_names.extend(cli.common.artifacts.into_iter().map(OsString::from));
193186

@@ -238,10 +231,25 @@ mod tests {
238231
use super::DEFAULT_ARTIFACT_DIR_NAMES;
239232

240233
#[test]
241-
fn default_artifacts_do_not_include_terraform_state_dirs() {
242-
assert!(
243-
!DEFAULT_ARTIFACT_DIR_NAMES.contains(&".terraform"),
244-
"default artifacts must not include .terraform because it can contain state"
245-
);
234+
fn default_artifacts_exclude_stateful_or_user_managed_dirs() {
235+
for name in [
236+
".terraform",
237+
".direnv",
238+
".vercel",
239+
".serverless",
240+
".cache",
241+
"public",
242+
"packages",
243+
"bin",
244+
"env",
245+
"ENV",
246+
"tmp",
247+
"temp",
248+
] {
249+
assert!(
250+
!DEFAULT_ARTIFACT_DIR_NAMES.contains(&name),
251+
"default artifacts must not include {name} because it may contain local state, secrets, or user-managed data"
252+
);
253+
}
246254
}
247255
}

0 commit comments

Comments
 (0)