mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 16:30:29 +08:00
dee355b4a7
- artifacts/decompiled 树与相关源码变更 - maven-cw-elevator-application 业务 docs 与 package-info - scripts 下 formatter 校验与辅助脚本 - 其他子工程/接口与发布线一并纳入版本控制 Made-with: Cursor Former-commit-id: e102e8cab64e575bcd23c9a66a598aa1892bb492
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Scan *.java for block comments in the last N lines (tail noise / orphan */). Read-only."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
TAIL_LINES = 50
|
|
REPO = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
def main() -> int:
|
|
suspicious: list[tuple[Path, str]] = []
|
|
with_slash: list[Path] = []
|
|
for p in REPO.rglob("*.java"):
|
|
sp = str(p)
|
|
if "/target/" in sp:
|
|
continue
|
|
try:
|
|
t = p.read_text(encoding="utf-8", errors="replace")
|
|
except OSError:
|
|
continue
|
|
lines = t.splitlines()
|
|
if not lines:
|
|
continue
|
|
tail = "\n".join(lines[-TAIL_LINES:])
|
|
if "/*" in tail or "*/" in tail:
|
|
with_slash.append(p)
|
|
low = tail.lower()
|
|
if "location" in low and "/*" in tail:
|
|
suspicious.append((p, "Location in tail block"))
|
|
if "jd-core" in low or "jd core" in low:
|
|
suspicious.append((p, "jd-core in tail"))
|
|
if "decompil" in low and "/*" in tail:
|
|
suspicious.append((p, "decompil+block in tail"))
|
|
# Trailing */ only: last non-empty line is */
|
|
nonws = [ln for ln in lines[-20:] if ln.strip()]
|
|
if len(nonws) >= 1 and nonws[-1].strip() == "*/" and "/**" not in "\n".join(lines[-5:]):
|
|
# might be orphan closer (rare)
|
|
if "*/" in tail and tail.count("/*") < tail.count("*/"):
|
|
suspicious.append((p, "possible orphan */ at EOF"))
|
|
|
|
print(f"Scanned under {REPO}")
|
|
print(f"Files with /* or */ in last {TAIL_LINES} lines: {len(with_slash)}")
|
|
print(f"Flagged suspicious: {len(suspicious)}")
|
|
for p, reason in suspicious[:80]:
|
|
print(f" {reason}: {p.relative_to(REPO)}")
|
|
if len(suspicious) > 80:
|
|
print(f" ... and {len(suspicious) - 80} more")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|