بنقرة واحدة
pow10-rule-04-short-functions
NASA Power of 10 Rule 4 — Functions ≤60 lines (one printed page). Severity: high.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
NASA Power of 10 Rule 4 — Functions ≤60 lines (one printed page). Severity: high.
التثبيت باستخدام 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 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-04-short-functions |
| description | NASA Power of 10 Rule 4 — Functions ≤60 lines (one printed page). Severity: high. |
Severity: high
Each function fits on one printed page — hard limit 60 source lines (excluding comments), soft limit 40. Functions exceeding the hard limit must be decomposed or carry a documented waiver.
A function that fits on one page can be reviewed and tested as a unit. Longer functions hide bugs by combining responsibilities. Short functions also make refactoring safer and unit testing tractable.
if/for)Extract by responsibility. Each helper takes one phase of the work and returns its output to the caller, which now reads as a sequential pipeline. Each helper is independently testable.
Generated code, large switch dispatchers (consider table-driven instead), state machines. Document with a waiver:
// pow10: allow rule=4 until=YYYY-MM-DD owner=<handle> reason="generated state table"