29 lines
4.5 KiB
Markdown
29 lines
4.5 KiB
Markdown
# 规则与可复现样例
|
|
|
|
运行 `marqdo-lint explain RULE_ID` 可查看稳定 ID、损失、依据和建议。除安全守卫外,表中条目均为人工修复。所有样例可用冻结核心静态检查,文件路径相对于仓库根目录。
|
|
|
|
| 规则 | 默认级别 | 报告示例 | 对照示例和验证 |
|
|
|---|---|---|---|
|
|
| MQD-DOC-001 | warning | 直接返回且缺少入口说明 | 在首个载体前说明目标。运行 `doc_001_and_doc_002_check_explanation_existence_and_position` |
|
|
| MQD-DOC-002 | info | 返回附近没有结果或限制说明 | 在返回处说明单位或失败结果。同上 |
|
|
| MQD-DOC-003 | warning | 复杂函数的叙述占比低于阈值 | 自然叙述达到门槛,短小平凡函数仅提示。运行 `long_functions_use_warning_ratio_and_h3_reading_sections` 和 `t23_trivial_short_functions_only_receive_info_ratio_diagnostics` |
|
|
| MQD-DOC-004 | info | 长函数无小节 | 在完整控制块之间按业务阶段分段。运行 `long_functions_use_warning_ratio_and_h3_reading_sections` |
|
|
| MQD-BRANCH-001 | warning | [同项包含 if/else](../examples/bad/branch-single-item.mq.md) | [推荐分支](../examples/good/branches.mq.md) |
|
|
| MQD-BRANCH-002 | warning | [不使用列表](../examples/bad/branches-unlisted.mq.md) 或列表先写说明再写 if | 让 if 和 else 分别成为有序项首个载体。运行 `prose_before_first_carrier_does_not_form_a_branch_head` 与 `t01_and_t19_branch_siblings_pass_in_h2_and_h3_segments` |
|
|
| MQD-BRANCH-003 | warning | 条件臂分属不同列表 | 使用同一有序列表中的相邻兄弟项。运行 `t05_branch_arms_in_different_lists_are_not_siblings` |
|
|
| MQD-BRANCH-004 | info | 非空分支的列表项中缺少解释 | [推荐分支](../examples/good/branches.mq.md) 在臂内写原因。运行 `branch_loop_and_end_diagnostics_are_reported_independently` |
|
|
| MQD-LOOP-001 | warning | 编号项承载 while | [嵌套示例](../examples/nested/inventory.mq.md) 的循环使用无序项。运行 `t07_ordered_item_is_not_the_recommended_loop_container` |
|
|
| MQD-LOOP-002 | info | 循环项缺少叙述 | [嵌套示例](../examples/nested/inventory.mq.md) 说明处理对象和终止条件。运行 `branch_loop_and_end_diagnostics_are_reported_independently` |
|
|
| MQD-LOOP-003 | warning | 语义控制体脱离对应项或嵌套层级不一致 | 依据真实列表子树缩进。运行 `a_branch_body_outside_its_item_is_a_layout_mismatch` 与 `t06_loop_item_and_t08_branch_containing_loop_pass` |
|
|
| MQD-CTRL-001 | warning | 循环 end 在项外,或分支 end 仍在分支项内 | 分支 end 在列表后,循环 end 在项末尾。运行 `branch_loop_and_end_diagnostics_are_reported_independently` 与 `t06_loop_item_and_t08_branch_containing_loop_pass` |
|
|
| MQD-PROSE-001 | warning | 句中的粗体、斜体或反引号成为执行载体 | 普通文字留在 Exec,富文本可进入 [Knowledge](../examples/knowledge/discount.mq.md)。运行 `t16_exec_emphasis_inside_prose_is_not_a_comment` |
|
|
| MQD-PROSE-002 | info | 已绑定的 I/O 调用或索引写入缺少相邻叙述 | 说明权限、后果或失败处理。运行 `supplemental_rules_use_bound_calls_and_allow_rich_knowledge` |
|
|
| MQD-PARAM-001 | info | 显式签名附近没有自然文字 | 说明单位、范围和用途。运行 `supplemental_rules_use_bound_calls_and_allow_rich_knowledge` |
|
|
| MQD-STYLE-001 | info | 用行内代码承载 return | [推荐分支](../examples/good/branches.mq.md) 用斜体表示返回,粗体表示赋值。运行 `supplemental_rules_use_bound_calls_and_allow_rich_knowledge` |
|
|
| MQD-KNOW-001 | warning | 在两个执行段之间切出一段纯文字,或出现 [跨段控制](../tests/fixtures/golden/invalid-control.mq.md) | 普通说明留在 Exec,同段关闭控制,公式和富文本可留在 Knowledge。运行 `supplemental_rules_use_bound_calls_and_allow_rich_knowledge` |
|
|
| MQD-SAFETY-001 | error | AST、执行载荷或 Analysis 不等价,或无法取得可靠验证输入 | 放弃写回。运行 `safe_fix_rejects_changes_to_inert_payload_and_unavailable_analysis` 与 `safe_fix_previews_then_persists_verified_whitespace_in_a_manifest_project` |
|
|
|
|
自动检测可以判断结构、覆盖和位置。对叙述内容的业务正确性仍须由作者和评审者判断。当前副作用识别使用公开 Analysis 中已绑定的资源、外部执行、标准库 I/O、插件调用和索引写入。未知绑定和普通本地函数不被猜测为副作用。
|
|
|
|
渲染对照位于 [examples/rendered](../examples/rendered)。使用 `cargo run --locked --example render_fixtures` 按冻结 Markdown Profile 重新生成。
|