Files
dacli/scripts/check_clean_comments.sh
sushub f403a7e80e import: ssw/dacli@eea0ebc (2026-08-12) 起点版本
本仓 2026-08-12 从 ssw main (192.168.1.18:13300/ssw/ssw-mvp) 的
dacli/ subpath 抽取,作为独立仓托管到 gitea:3000/ssw/dacli.git。

- 工作树为 ssw main dacli subpath 最新版 (110 commit, 08-12)
- 历史未带 ssw main 整体历史(避免大仓污染)
- 此为新仓基线 commit,未来以本仓历史为主
2026-08-12 15:58:06 +08:00

59 lines
1.5 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
# Only flag comment lines (//, *, or /* ... */)
trimmed=$(echo "$content" | sed 's/^[[:space:]]*//')
if ! echo "$trimmed" | grep -qE '^(//|/\*|\*)'; then
continue # skip code/string lines, only check comments
fi
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