- Detects violation comments in dacli/src/** (BS-*/R\d+/jxcj/v0.x+ patterns) - Whitelists _anti_patterns.ts (must retain source references) - Run: ./scripts/check_clean_comments.sh - Finds 1709 current violations (to be cleaned in Task 3.5)
53 lines
1.2 KiB
Bash
Executable File
53 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# 检查 dacli/src/** 内违规注释:
|
|
# - BS-* / BS-new* / R\d+ / Round\d+
|
|
# - jxcj / workSystem / developSystem / tds
|
|
# - v0\.\d+\+? 版本号
|
|
# - ssw-...-biz / ssw-common 跨语言反向引用
|
|
# 命中即报错 (含具体文件:行号).
|
|
|
|
set -uo pipefail
|
|
|
|
DACLI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
SRC_DIR="$DACLI_DIR/src"
|
|
|
|
PATTERNS=(
|
|
'BS-[a-zA-Z]*[0-9]'
|
|
'R[0-9]+[a-z]*\b'
|
|
'Round[0-9]+'
|
|
'\b(jxcj|workSystem|developSystem|tds)\b'
|
|
'v0\.[0-9]+[a-z]*\+'
|
|
'ssw-[a-z]+-(biz|common)'
|
|
)
|
|
|
|
# 白名单文件 (必须保留 source 引用)
|
|
WHITELIST=(
|
|
"_anti_patterns.ts"
|
|
)
|
|
|
|
EXIT_CODE=0
|
|
for pattern in "${PATTERNS[@]}"; do
|
|
while IFS=: read -r file line content; do
|
|
if [ -z "$file" ]; then continue; fi
|
|
|
|
# Check whitelist
|
|
basename_file=$(basename "$file")
|
|
skip=0
|
|
for wl in "${WHITELIST[@]}"; do
|
|
if [ "$basename_file" = "$wl" ]; then skip=1; break; fi
|
|
done
|
|
[ $skip -eq 1 ] && continue
|
|
|
|
echo "VIOLATION: $file:$line"
|
|
echo " pattern: /$pattern/"
|
|
echo " content: $content"
|
|
EXIT_CODE=1
|
|
done < <(grep -rnE "$pattern" "$SRC_DIR" --include="*.ts" --include="*.tsx" 2>/dev/null || true)
|
|
done
|
|
|
|
if [ $EXIT_CODE -eq 0 ]; then
|
|
echo "OK: no violations found"
|
|
fi
|
|
|
|
exit $EXIT_CODE
|