Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.
Closed
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
4 changes: 3 additions & 1 deletion plans/refactor-line-gate-targets.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Line gate targets for large-file decoupling refactor.
# Default limit: 300 lines
# Backend default limit: 300 lines
# Frontend (webui/) default limit: 500 lines
# Entry/facade limit: 120 lines (enforced in script)
# Test files are ignored by the gate script.

internal/config/config.go
internal/config/logger.go
Expand Down
9 changes: 5 additions & 4 deletions plans/refactor-line-gate.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

## Rules

1. Production file default upper bound: `<= 300` lines.
2. Entry/facade files upper bound: `<= 120` lines.
3. Scope is limited to target files in `plans/refactor-line-gate-targets.txt`.
4. Test files are out of scope for this gate.
1. Backend production files upper bound: `<= 300` lines.
2. Frontend (`webui/`) production files upper bound: `<= 500` lines.
3. Entry/facade files upper bound: `<= 120` lines.
4. Scope is limited to target files in `plans/refactor-line-gate-targets.txt`.
5. Test files are out of scope for this gate.

## Command

Expand Down
30 changes: 29 additions & 1 deletion tests/scripts/check-refactor-line-gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
TARGETS_FILE="$ROOT_DIR/plans/refactor-line-gate-targets.txt"

DEFAULT_MAX=300
FRONTEND_MAX=500
ENTRY_MAX=120

is_entry_file() {
Expand All @@ -22,6 +23,27 @@ is_entry_file() {
return 1
}

is_frontend_file() {
[[ "$1" == webui/* ]]
}

is_test_file() {
local file="$1"
local base
base="$(basename "$file")"

[[ "$file" == tests/* ]] && return 0
[[ "$file" == */tests/* ]] && return 0
[[ "$file" == */__tests__/* ]] && return 0
[[ "$base" == *_test.go ]] && return 0
[[ "$base" == *.test.js ]] && return 0
[[ "$base" == *.test.jsx ]] && return 0
[[ "$base" == *.test.ts ]] && return 0
[[ "$base" == *.test.tsx ]] && return 0

return 1
}

if [[ ! -f "$TARGETS_FILE" ]]; then
echo "missing targets file: $TARGETS_FILE" >&2
exit 1
Expand All @@ -35,6 +57,10 @@ while IFS= read -r file; do
[[ -z "$file" ]] && continue
[[ "${file:0:1}" == "#" ]] && continue

if is_test_file "$file"; then
continue
fi

checked=$((checked + 1))
abs="$ROOT_DIR/$file"
if [[ ! -f "$abs" ]]; then
Expand All @@ -45,7 +71,9 @@ while IFS= read -r file; do

lines="$(wc -l < "$abs" | tr -d ' ')"
limit="$DEFAULT_MAX"
if is_entry_file "$file"; then
if is_frontend_file "$file"; then
limit="$FRONTEND_MAX"
elif is_entry_file "$file"; then
Comment on lines +74 to +76

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Apply entry/facade limit before frontend limit

This ordering makes every webui/* entry file in is_entry_file use the 500-line frontend cap instead of the intended 120-line entry/facade cap. For example, webui/src/App.jsx now matches is_frontend_file first and never reaches the is_entry_file branch, which weakens the gate for the exact files meant to stay strict and contradicts the documented “Entry/facade limit: 120 lines.”

Useful? React with 👍 / 👎.

limit="$ENTRY_MAX"
fi

Expand Down
Loading