一键导入
pow10-rule-01-control-flow
NASA Power of 10 Rule 1 — Restrict control flow to simple constructs (no goto, setjmp/longjmp, recursion). Severity: blocker.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
NASA Power of 10 Rule 1 — Restrict control flow to simple constructs (no goto, setjmp/longjmp, recursion). Severity: blocker.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
NASA Power of 10 Rule 2 — Every loop must have a statically determinable upper bound. Severity: blocker.
NASA Power of 10 Rule 3 — No dynamic memory allocation after initialization. Severity: blocker.
NASA Power of 10 Rule 4 — Functions ≤60 lines (one printed page). Severity: high.
NASA Power of 10 Rule 5 — Average ≥2 runtime assertions per function. Severity: high.
NASA Power of 10 Rule 6 — Declare data at smallest possible scope. Severity: medium.
NASA Power of 10 Rule 7 — Check every non-void return value; validate every parameter. Severity: blocker.
| name | pow10-rule-01-control-flow |
| description | NASA Power of 10 Rule 1 — Restrict control flow to simple constructs (no goto, setjmp/longjmp, recursion). Severity: blocker. |
Severity: blocker
Use only straight-line execution, conditionals, and bounded iteration. Forbid goto, setjmp/longjmp, and recursion (direct or indirect, including mutual recursion across translation units).
Simple control flow is verifiable by inspection and by static analysis. goto and non-local jumps make reachability undecidable. Recursion makes call graphs unbounded, which defeats stack-depth analysis, coverage, and bounded model checking.
goto, longjmp, setjmpReplace recursion with explicit iteration over a bounded data structure (work stack, deque, counter). The cap also satisfies Rule 2.
Load the file matching the language under review:
State machines requiring genuine non-local exit (e.g., async-safe signal handlers). Isolate to one well-marked module and tag with a waiver:
// pow10: allow rule=1 until=YYYY-MM-DD owner=<handle> reason="..."