一键导入
pow10-rule-09-restrict-pointers
NASA Power of 10 Rule 9 — At most one level of dereferencing; no function pointers (analogues for non-C langs). Severity: blocker.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
NASA Power of 10 Rule 9 — At most one level of dereferencing; no function pointers (analogues for non-C langs). Severity: blocker.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
NASA Power of 10 Rule 1 — Restrict control flow to simple constructs (no goto, setjmp/longjmp, recursion). Severity: blocker.
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.
| name | pow10-rule-09-restrict-pointers |
| description | NASA Power of 10 Rule 9 — At most one level of dereferencing; no function pointers (analogues for non-C langs). Severity: blocker. |
Severity: blocker
In C: at most one level of dereferencing per declaration. No function pointers.
In other languages: limit indirection — first-class function/lambda passing across module boundaries, multi-level reference chains, and dynamic dispatch all reduce static analyzability the same way.
Each level of indirection multiplies the state space a reviewer or static analyzer must track. Multi-level pointers make aliasing analysis effectively impossible. Function pointers defeat call-graph construction — the foundation of reachability, coverage, and worst-case execution time analysis.
**, ***, function pointer typesMap<String, Function<...>> registries crossing module boundaries(A) -> (B) -> R as cross-module parametersReplace open dispatch with a sealed/closed mechanism: switch, sealed interface, enum-keyed map, named callback class. The set of reachable targets becomes enumerable at compile time.
Document with a waiver near the indirection.