skills/check-test-code-quality/rules/R007/SKILL.md
# R007: Test.json禁止配置项 ## 规则信息 | 属性 | 值 | |------|------| | 规则编号 | R007 | | 问题类型 | Test.json禁止配置项 | | 严重级别 | Critical | | 规则复杂度 | simple | ## 问题描述 Test.json配置文件中存在禁止的配置项: - `setenforce 0` — 会关闭SELinux,引入安全问题 - `rerun: true` — 会导致测试报告出现异常 - `appfreeze.filter_bundle_name` — 会屏蔽appfreeze异常 **规范来源**: - 用例低级问题.md 第9条 — "禁止配置setenforce 0,会关闭selinux引入问题" - 用例低级问题.md 第10条 — "禁止配置rerun:true,会导致报告出现异常" - 用例低级问题.md 第11条 — "禁止配置appfreeze.filter_bundle_name,会屏蔽appfreeze异常" ## 扫描范围 | 应扫描 | 文件名 | |-----
npx skillsauth add openharmonyinsight/openharmony-skills skills/check-test-code-quality/rules/R007Install this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| 属性 | 值 | |------|------| | 规则编号 | R007 | | 问题类型 | Test.json禁止配置项 | | 严重级别 | Critical | | 规则复杂度 | simple |
Test.json配置文件中存在禁止的配置项:
setenforce 0 — 会关闭SELinux,引入安全问题rerun: true — 会导致测试报告出现异常appfreeze.filter_bundle_name — 会屏蔽appfreeze异常规范来源:
| 应扫描 | 文件名 |
|--------|--------|
| Test.json文件 | 所有名为 Test.json 的文件(不区分大小写) |
R007只扫描Test.json配置文件,不扫描源代码文件。
import os
import re
def get_r007_scan_files(directory: str) -> list[str]:
test_json_files = []
for root, dirs, files in os.walk(directory):
for f in files:
if f.lower() == 'test.json':
test_json_files.append(os.path.join(root, f))
return test_json_files
def check_r007(file_path: str) -> list[dict]:
issues = []
with open(file_path, 'r', encoding='utf-8') as f:
lines = f.readlines()
for i, line in enumerate(lines, 1):
stripped = line.strip()
# 检测1: setenforce 0(不检测 setenforce 1)
if 'setenforce 0' in stripped:
issues.append({
'rule': 'R007',
'type': 'Test.json禁止配置项',
'severity': 'Critical',
'file': file_path,
'line': i,
'testcase': '-',
'snippet': stripped,
'suggestion': (
f'路径: {file_path}, 行号: {i}, '
f'问题描述: 禁止配置setenforce 0,会关闭SELinux引入安全问题。请移除该配置。'
),
'detail': 'setenforce 0'
})
continue
# 检测2: rerun 配置
# 匹配 "rerun": true, "rerun":"true", "rerun":"ture", "rerun": 1 等
if re.search(r'"rerun"\s*:\s*(true|1|"true"|"ture")', stripped, re.IGNORECASE):
issues.append({
'rule': 'R007',
'type': 'Test.json禁止配置项',
'severity': 'Critical',
'file': file_path,
'line': i,
'testcase': '-',
'snippet': stripped,
'suggestion': (
f'路径: {file_path}, 行号: {i}, '
f'问题描述: 禁止配置rerun:true,会导致测试报告出现异常。请移除该配置。'
),
'detail': 'rerun'
})
continue
# 检测3: appfreeze.filter_bundle_name
if 'appfreeze.filter_bundle_name' in stripped:
issues.append({
'rule': 'R007',
'type': 'Test.json禁止配置项',
'severity': 'Critical',
'file': file_path,
'line': i,
'testcase': '-',
'snippet': stripped,
'suggestion': (
f'路径: {file_path}, 行号: {i}, '
f'问题描述: 禁止配置appfreeze.filter_bundle_name,会屏蔽appfreeze异常。请移除该配置。'
),
'detail': 'appfreeze.filter_bundle_name'
})
return issues
setenforce 0,不检测 setenforce 1(setenforce 1是允许的)"rerun": true、"rerun": 1、"rerun": "true"、"rerun": "ture"(注意常见拼写错误)-(配置文件,无对应用例)| 列名 | 说明 |
|------|------|
| 问题ID | R007 |
| 问题类型 | Test.json禁止配置项 |
| 严重级别 | Critical |
| 文件路径 | 相对路径 |
| 行号 | 问题所在行号 |
| 所属用例 | -(配置文件) |
| 代码片段 | 匹配到的代码行 |
| 修复建议 | 路径+行号+问题描述 |
// 错误1: 配置setenforce 0
{
"kits": [
{
"type": "ShellKit",
"run-command": [
"setenforce 0",
"hilog -Q pidoff"
]
}
]
}
// 错误2: 配置rerun
{
"driver": {
"type": "OHJSUnitTest",
"rerun": true
}
}
// 错误3: 配置appfreeze.filter_bundle_name
{
"kits": [
{
"type": "ShellKit",
"run-command": [
"param set hiviewdfx.appfreeze.filter_bundle_name com.example.myapplication"
]
}
]
}
// 正确: 不配置setenforce 0、rerun、appfreeze.filter_bundle_name
{
"kits": [
{
"type": "ShellKit",
"run-command": [
"setenforce 1",
"hilog -Q pidoff"
]
}
],
"driver": {
"type": "OHJSUnitTest"
}
}
# 扫描setenforce 0
grep -rn 'setenforce 0' --include='Test.json' /path/to/code
# 扫描rerun
grep -rn '"rerun"' --include='Test.json' /path/to/code
# 扫描appfreeze
grep -rn 'appfreeze.filter_bundle_name' --include='Test.json' /path/to/code
Test.json、test.json、TEST.JSON 均匹配)setenforce 1 是允许的,不应报告rerun: false 或 rerun: 0 不视为违规-,因为Test.json是配置文件testing
--- name: ohos-req-value-decision description: Use after review meeting to record decision and route to next step. Triggers: 评审决策纪要, 评审结论回流, value decision, 评审接纳, 评审不接纳, 评审退回, 下次重新上会. Do NOT use for feature baseline (ohos-req-feature-baseline), review gate checks (ohos-req-review-gate), or IR generation (ohos-req-feature-to-ir). metadata: author: openharmony scope: common stage: requirements capability: value-decision version: 0.3.0 status: draft tags: - sdd - requirements
development
Use when converting an OpenHarmony requirement document, spec, or design proposal into an OpenHarmony review slide deck (需求评审 / 需求变更评审 / 设计评审 PPTX) — produces the fixed OpenHarmony-branded review-deck structure (OH logo on every page) with architecture/flow diagrams and field tables. Triggers on "需求评审PPT", "需求变更评审", "把需求文档转成评审PPT", "spec转评审PPT", "requirement/spec to review deck". NOT for arbitrary or generic slide decks unrelated to OpenHarmony requirement/design review.
testing
Use when performing the Phase 0 Step 0.5 Review Ready Gate on a 04-feature.md, especially when the user says "evaluate gate", "review readiness", "feature ready?", "should we generate IR", or when the ohos-req-intake-orchestration main session needs a structured Ready / Conditional Ready / Not Ready judgment instead of doing the check inline. Reads 01-04, runs seven fixed checks plus a conditional-items check, and returns a machine-readable JSON summary plus a human-readable table that the main session can route on. Do NOT use for feature baseline generation (ohos-req-feature-baseline), value decision recording (ohos-req-value-decision), or IR generation (ohos-req-feature-to-ir).
testing
--- name: ohos-req-requirement-intake description: Use when importing an OHOS requirement into Phase 0.1, especially for 01-requirement.md, requirement intake, background, user value, scenarios, scope, FR/NFR, affected modules, or priority. Triggers: 需求导入, 01-requirement, 需求基线, RR单号. Do NOT use for feasibility analysis (ohos-req-feasibility-analysis), architecture decision (ohos-req-arch-decision), or feature baseline (ohos-req-feature-baseline). metadata: author: openharmony scope: common