تخطَّ إلى المحتوى

خرج الفحص meem --check --json

منقول من الكتاب المرجعي: docs/handbook/tools/check-json.md · الإيداع 7a52f6c

meem --check --json ملف.م يطبع سطر JSON واحداً ولا ينفّذ البرنامج؛ رمز الخروج 0 بلا أخطاء و2 معها. مخططه (JSON Schema) في check-json.schema.json، ويتحقق منه tests/test_docs.py على خرج المجمّع الفعلي لبرامج فيها أخطاء وتحذيرات واستيراد ومنطقة خطرة. معاني الحقول وقواعدها (قيمة file، وrelated، والتحذيرات الاستشارية) في tools-contract.md (وثيقة في مستودع المجمّع)، وهو العقد: رقمه contract لا يتغير معناه دون رفعه.

الحقل الأعلى المعنى
version 3 (منذ 0.8.0)
ok لا أخطاء
file، path الملف الرئيسي للعرض، ومساره الكامل
summary عدد الأخطاء والتحذيرات
diagnostics كل تشخيص: id (معرّف الرسالة الثابت، منذ 0.8.0) وseverity وphase وmessage وline وcolumn وlength وhint وnotes وrelated وsource_line وadvisory، وunsafe حين يوجد
imports ما يستورده الملف الرئيسي مباشرة
files كل ملفات البرنامج بترتيب التحميل

خيارات سطر الأوامر كلها في خيارات سطر الأوامر.

ملف tools/check-json.schema.json في الكتاب المرجعي، كما هو:

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "meem --check --json (version 3, tools contract 2)",
"description": "مخطط خرج الفحص كما في docs/tools-contract.md. يتحقق منه tests/test_docs.py على خرج المجمّع الفعلي.",
"type": "object",
"required": ["version", "ok", "file", "path", "summary", "diagnostics", "imports", "files"],
"properties": {
"version": {"type": "integer", "enum": [3]},
"ok": {"type": "boolean"},
"file": {"type": ["string", "null"]},
"path": {"type": ["string", "null"]},
"summary": {
"type": "object",
"required": ["errors", "warnings"],
"properties": {"errors": {"type": "integer"}, "warnings": {"type": "integer"}}
},
"diagnostics": {
"type": "array",
"items": {
"type": "object",
"required": ["id", "file", "path", "severity", "phase", "phase_label", "message", "line", "column", "length",
"hint", "notes", "related", "source_line", "advisory"],
"properties": {
"id": {"type": ["string", "null"], "pattern": "^E[0-9]{4}$"},
"file": {"type": ["string", "null"]},
"path": {"type": ["string", "null"]},
"severity": {"type": "string", "enum": ["error", "warning"]},
"phase": {"type": "string", "enum": ["lexical", "syntax", "semantic", "codegen", "internal"]},
"phase_label": {"type": "string"},
"message": {"type": "string"},
"line": {"type": "integer"},
"column": {"type": "integer"},
"length": {"type": "integer"},
"hint": {"type": ["string", "null"]},
"notes": {"type": "array", "items": {"type": "string"}},
"related": {
"type": "array",
"items": {
"type": "object",
"required": ["kind", "line", "column"],
"properties": {"kind": {"type": "string"}, "file": {"type": ["string", "null"]}, "path": {"type": ["string", "null"]},
"line": {"type": "integer"}, "column": {"type": "integer"}}
}
},
"source_line": {"type": ["string", "null"]},
"advisory": {"type": "boolean"},
"unsafe": {"type": "string", "enum": ["unsafe-required", "unsafe-disabled", "unsafe-managed"]}
}
}
},
"imports": {
"type": "array",
"items": {
"type": "object",
"required": ["target", "quoted", "alias", "module", "line", "column", "file", "path", "standard"],
"properties": {"target": {"type": "string"}, "quoted": {"type": "boolean"}, "alias": {"type": "string"},
"module": {"type": "string"}, "line": {"type": "integer"}, "column": {"type": "integer"},
"file": {"type": ["string", "null"]}, "path": {"type": ["string", "null"]},
"standard": {"type": "boolean"}}
}
},
"files": {
"type": "array",
"items": {
"type": "object",
"required": ["file", "path", "standard", "main"],
"properties": {"file": {"type": ["string", "null"]}, "path": {"type": ["string", "null"]},
"standard": {"type": "boolean"}, "main": {"type": "boolean"}}
}
}
}
}