From d35e5eab255de3122e93dadc6f6a6e64e6541ae3 Mon Sep 17 00:00:00 2001 From: "CJACK." Date: Mon, 16 Mar 2026 22:58:13 +0800 Subject: [PATCH 1/2] ci: ignore tests in line gate and raise frontend limit --- plans/refactor-line-gate-targets.txt | 4 ++- plans/refactor-line-gate.md | 9 ++++--- tests/scripts/check-refactor-line-gate.sh | 30 ++++++++++++++++++++++- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/plans/refactor-line-gate-targets.txt b/plans/refactor-line-gate-targets.txt index 645b7e1..ac45d57 100644 --- a/plans/refactor-line-gate-targets.txt +++ b/plans/refactor-line-gate-targets.txt @@ -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 diff --git a/plans/refactor-line-gate.md b/plans/refactor-line-gate.md index 86f0d82..103782d 100644 --- a/plans/refactor-line-gate.md +++ b/plans/refactor-line-gate.md @@ -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 diff --git a/tests/scripts/check-refactor-line-gate.sh b/tests/scripts/check-refactor-line-gate.sh index 4118d15..8a7f890 100755 --- a/tests/scripts/check-refactor-line-gate.sh +++ b/tests/scripts/check-refactor-line-gate.sh @@ -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() { @@ -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 @@ -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 @@ -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 limit="$ENTRY_MAX" fi From 7648d5f1929a1fea7cd50fd0a481b70dd94d5198 Mon Sep 17 00:00:00 2001 From: "CJACK." Date: Mon, 16 Mar 2026 23:06:58 +0800 Subject: [PATCH 2/2] ci: keep entry line cap precedence over frontend cap --- tests/scripts/check-refactor-line-gate.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/scripts/check-refactor-line-gate.sh b/tests/scripts/check-refactor-line-gate.sh index 8a7f890..3fda714 100755 --- a/tests/scripts/check-refactor-line-gate.sh +++ b/tests/scripts/check-refactor-line-gate.sh @@ -71,10 +71,10 @@ while IFS= read -r file; do lines="$(wc -l < "$abs" | tr -d ' ')" limit="$DEFAULT_MAX" - if is_frontend_file "$file"; then - limit="$FRONTEND_MAX" - elif is_entry_file "$file"; then + if is_entry_file "$file"; then limit="$ENTRY_MAX" + elif is_frontend_file "$file"; then + limit="$FRONTEND_MAX" fi if (( lines > limit )); then