Commit f483690
committed
fix(MDS020): anchor non-body diagnostics outside body line range
Address two Copilot review comments (validate.go:223 and the
suppressed-confidence comment on validate.go:1025): diagnostics
that don't correspond to a body line (filename/path-pattern
mismatches, missing required sections, FM compile failures,
fmDiagLine fallback) used to emit at body-coord line 1. In
front-matter-stripped mode, line 1 is the first body line, so
engine.filterGeneratedDiags could silently drop the diagnostic
if the document body started with a generated section.
Introduce schema.NonBodyDiagLine(f) returning `1 - f.LineOffset`
— a non-positive body coord in stripped mode that
filterGeneratedDiags cannot match against any generated line
range. The engine's AdjustDiagnostics adds the offset back so
the surfaced diagnostic still anchors at the file's first
line.
All "doesn't-belong-to-a-body-line" emit sites switch to the
new helper:
- schema.validateFrontmatterDiags: every early-return path
(invalid CUE schema, json.Marshal failure, CompileBytes
failure, validator fallback)
- schema.validateScopes: missing-section diagnostic
- schema.validateFilename: both invalid-pattern and mismatch
paths
- schema.fmDiagLine: both fallback returns (empty keyLines,
key absent from map)
- requiredstructure.missingSectionDiagLegacy: legacy file-
schema path
- requiredstructure.readDocFrontMatterRaw: YAML alias-rejected
and unmarshal-error paths
- requiredstructure.checkPathPatterns: path-pattern mismatch
- requiredstructure.checkFilenamePattern: both paths
Existing fixture tests use lint.NewFile (LineOffset == 0) so
they keep observing line 1 as before; the change only affects
the lint.NewFileFromSource(..., true) production path. New
TestNonBodyDiagLine_StrippedAndUnstripped pins the helper's
contract.
https://claude.ai/code/session_01QcXckX3yVwReho2kaq3qRK1 parent 87eccb4 commit f483690
3 files changed
Lines changed: 92 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1030 | 1030 | | |
1031 | 1031 | | |
1032 | 1032 | | |
1033 | | - | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1034 | 1038 | | |
1035 | 1039 | | |
1036 | 1040 | | |
| |||
1361 | 1365 | | |
1362 | 1366 | | |
1363 | 1367 | | |
1364 | | - | |
| 1368 | + | |
1365 | 1369 | | |
1366 | 1370 | | |
1367 | 1371 | | |
1368 | 1372 | | |
1369 | | - | |
| 1373 | + | |
1370 | 1374 | | |
1371 | 1375 | | |
1372 | 1376 | | |
| |||
1456 | 1460 | | |
1457 | 1461 | | |
1458 | 1462 | | |
1459 | | - | |
| 1463 | + | |
1460 | 1464 | | |
1461 | 1465 | | |
1462 | 1466 | | |
| |||
1493 | 1497 | | |
1494 | 1498 | | |
1495 | 1499 | | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
1496 | 1505 | | |
1497 | 1506 | | |
1498 | 1507 | | |
| |||
1507 | 1516 | | |
1508 | 1517 | | |
1509 | 1518 | | |
1510 | | - | |
| 1519 | + | |
1511 | 1520 | | |
1512 | 1521 | | |
1513 | 1522 | | |
| |||
1518 | 1527 | | |
1519 | 1528 | | |
1520 | 1529 | | |
1521 | | - | |
| 1530 | + | |
1522 | 1531 | | |
1523 | 1532 | | |
1524 | 1533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
139 | | - | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | | - | |
| 148 | + | |
148 | 149 | | |
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
152 | | - | |
| 153 | + | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| |||
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
162 | | - | |
| 163 | + | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| |||
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
191 | 224 | | |
192 | 225 | | |
193 | 226 | | |
| |||
205 | 238 | | |
206 | 239 | | |
207 | 240 | | |
208 | | - | |
209 | | - | |
210 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
211 | 249 | | |
212 | 250 | | |
213 | | - | |
| 251 | + | |
214 | 252 | | |
215 | 253 | | |
216 | 254 | | |
217 | 255 | | |
218 | 256 | | |
219 | 257 | | |
220 | 258 | | |
221 | | - | |
| 259 | + | |
222 | 260 | | |
223 | 261 | | |
224 | 262 | | |
| |||
525 | 563 | | |
526 | 564 | | |
527 | 565 | | |
528 | | - | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
529 | 571 | | |
530 | 572 | | |
531 | 573 | | |
| |||
1007 | 1049 | | |
1008 | 1050 | | |
1009 | 1051 | | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
1010 | 1057 | | |
1011 | 1058 | | |
1012 | 1059 | | |
| |||
1021 | 1068 | | |
1022 | 1069 | | |
1023 | 1070 | | |
1024 | | - | |
| 1071 | + | |
1025 | 1072 | | |
1026 | 1073 | | |
1027 | 1074 | | |
| |||
1036 | 1083 | | |
1037 | 1084 | | |
1038 | 1085 | | |
1039 | | - | |
| 1086 | + | |
1040 | 1087 | | |
1041 | 1088 | | |
1042 | 1089 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
182 | 200 | | |
183 | 201 | | |
184 | 202 | | |
| |||
0 commit comments