Skip to content

Commit 9c83208

Browse files
Refactor files under 400-line limit (#54)
1 parent b9c77d0 commit 9c83208

91 files changed

Lines changed: 13193 additions & 12493 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/hooks/stop-file-length.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
MAX_LINES=400
5+
6+
repo_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
7+
if [ -z "$repo_root" ]; then
8+
exit 0
9+
fi
10+
cd "$repo_root"
11+
12+
skip_prefixes='^(artifacts/|benchmarks/CsvBenchmarks/(bin|obj)/|project/(Dataplat\.Dbatools\.Csv|dbatools|dbatools\.Tests)/(bin|obj)/|var/(misc|third-party-licenses)/|\.claude/)'
13+
binary_re='\.(7z|dll|exe|gif|gz|ico|jpe?g|nupkg|pdb|pdf|png|snupkg|ttf|vsix|woff2?|zip)$'
14+
15+
violations=""
16+
17+
while IFS= read -r path; do
18+
[ -n "$path" ] || continue
19+
norm=${path//\\//}
20+
21+
if [[ "$norm" =~ $skip_prefixes ]]; then continue; fi
22+
if [[ "$norm" =~ $binary_re ]]; then continue; fi
23+
[ -f "$norm" ] || continue
24+
25+
if grep -qIl '' "$norm" 2>/dev/null; then
26+
lines=$(wc -l < "$norm" | tr -d ' ')
27+
if [ "$lines" -gt "$MAX_LINES" ]; then
28+
violations="${violations} ${lines} lines: ${norm}"$'\n'
29+
fi
30+
fi
31+
done < <(git ls-files --cached --others --exclude-standard)
32+
33+
if [ -n "$violations" ]; then
34+
{
35+
echo "Files exceed ${MAX_LINES}-line limit. Split structurally before finishing:"
36+
echo ""
37+
printf "%s" "$violations"
38+
} >&2
39+
exit 2
40+
fi
41+
42+
exit 0

.claude/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"hooks": {
3+
"Stop": [
4+
{
5+
"hooks": [
6+
{
7+
"type": "command",
8+
"command": "\"${CLAUDE_PROJECT_DIR:-.}\"/.claude/hooks/stop-file-length.sh",
9+
"timeout": 15,
10+
"statusMessage": "Checking file lengths (400-line limit)..."
11+
}
12+
]
13+
}
14+
]
15+
}
16+
}

.codex/hooks/stop-file-length.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
MAX_LINES=400
5+
6+
repo_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
7+
if [ -z "$repo_root" ]; then
8+
exit 0
9+
fi
10+
cd "$repo_root"
11+
12+
skip_prefixes='^(artifacts/|benchmarks/CsvBenchmarks/(bin|obj)/|project/(Dataplat\.Dbatools\.Csv|dbatools|dbatools\.Tests)/(bin|obj)/|var/(misc|third-party-licenses)/|\.claude/)'
13+
binary_re='\.(7z|dll|exe|gif|gz|ico|jpe?g|nupkg|pdb|pdf|png|snupkg|ttf|vsix|woff2?|zip)$'
14+
15+
violations=""
16+
17+
while IFS= read -r path; do
18+
[ -n "$path" ] || continue
19+
norm=${path//\\//}
20+
21+
if [[ "$norm" =~ $skip_prefixes ]]; then continue; fi
22+
if [[ "$norm" =~ $binary_re ]]; then continue; fi
23+
[ -f "$norm" ] || continue
24+
25+
if grep -qIl '' "$norm" 2>/dev/null; then
26+
lines=$(wc -l < "$norm" | tr -d ' ')
27+
if [ "$lines" -gt "$MAX_LINES" ]; then
28+
violations="${violations} ${lines} lines: ${norm}"$'\n'
29+
fi
30+
fi
31+
done < <(git ls-files --cached --others --exclude-standard)
32+
33+
if [ -n "$violations" ]; then
34+
{
35+
echo "Files exceed ${MAX_LINES}-line limit. Split structurally before finishing:"
36+
echo ""
37+
printf "%s" "$violations"
38+
} >&2
39+
exit 2
40+
fi
41+
42+
exit 0

.codex/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"hooks": {
3+
"Stop": [
4+
{
5+
"hooks": [
6+
{
7+
"type": "command",
8+
"command": "\"${CODEX_PROJECT_DIR:-.}\"/.codex/hooks/stop-file-length.sh",
9+
"timeout": 15,
10+
"statusMessage": "Checking file lengths (400-line limit)..."
11+
}
12+
]
13+
}
14+
]
15+
}
16+
}

0 commit comments

Comments
 (0)