MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / lintFile

Function lintFile

scripts/lint-error-codes.cjs:81–111  ·  view source on GitHub ↗
(filePath, { canonical, aliases })

Source from the content-addressed store, hash-verified

79}
80
81function lintFile(filePath, { canonical, aliases }) {
82 const violations = [];
83 let doc;
84 try {
85 doc = yaml.load(fs.readFileSync(filePath, 'utf8'));
86 } catch (err) {
87 return [{ filePath, trail: [], code: null, reason: `skipped (YAML parse failed: ${err.message}) — fix via upstream YAML lint`, severity: 'warn' }];
88 }
89 if (!doc) return violations;
90 for (const hit of findErrorCodeAssertions(doc, [])) {
91 if (canonical.has(hit.code)) continue;
92 if (aliases.has(hit.code)) {
93 violations.push({
94 filePath,
95 trail: hit.trail,
96 code: hit.code,
97 reason: `deprecated alias — remove or migrate before the alias sunsets`,
98 severity: 'warn',
99 });
100 continue;
101 }
102 violations.push({
103 filePath,
104 trail: hit.trail,
105 code: hit.code,
106 reason: `not in canonical error-code enum (static/schemas/source/enums/error-code.json)`,
107 severity: 'error',
108 });
109 }
110 return violations;
111}
112
113function formatTrail(trail) {
114 return trail.map(seg => (typeof seg === 'number' ? `[${seg}]` : `.${seg}`)).join('').replace(/^\./, '');

Callers 1

mainFunction · 0.70

Calls 2

findErrorCodeAssertionsFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected