Skip to content

Commit 0ed465b

Browse files
rwblaireffigies
authored andcommitted
add file read issues, have citation.ts report it when applicable.
1 parent 3c0b39f commit 0ed465b

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

bids-validator/src/issues/list.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ export const bidsIssues: IssueDefinitionRecord = {
162162
severity: 'error',
163163
reason: 'A json sidecar file was found without a corresponding data file',
164164
},
165+
BLACKLISTED_MODALITY: {
166+
severity: 'error',
167+
reason: 'The modality in this file is blacklisted through validator configuration.',
168+
},
169+
CITATION_CFF_VALIDATION_ERROR: {
170+
severity: 'error',
171+
reason:
172+
"The file does not pass validation using the citation.cff standard's schema." +
173+
'https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md'
174+
},
175+
FILE_READ: {
176+
severity: 'error',
177+
reason: 'We were unable to read this file.'
178+
}
165179
}
166180

167181
const hedIssues: IssueDefinitionRecord = {
@@ -191,10 +205,6 @@ const hedIssues: IssueDefinitionRecord = {
191205
reason:
192206
"You should define 'HEDVersion' for this file. If you don't provide this information, the HED validation will use the latest version available.",
193207
},
194-
BLACKLISTED_MODALITY: {
195-
severity: 'error',
196-
reason: 'The modality in this file is blacklisted through validator configuration.',
197-
},
198208
}
199209

200210
export const hedOldToNewLookup: Record<number, Partial<keyof IssueDefinitionRecord>> = {

bids-validator/src/validators/citation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ Deno.test('citation validation', async (t) => {
2020
const file = new BIDSFileDeno('tests/data/citation', 'bad.cff')
2121
tree.files[0].text = () => file.text()
2222
await citationValidate({} as GenericSchema, dsContext)
23-
assert(dsContext.issues.size === 1)
23+
assert(dsContext.issues.get({ code: 'CITATION_CFF_VALIDATION_ERROR' }).length === 1)
2424
})
2525
})

bids-validator/src/validators/citation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export async function citationValidate(
1818
try {
1919
citation = parse(await citationFile.text())
2020
} catch (error) {
21-
throw error
21+
dsContext.issues.add({
22+
code: 'FILE_READ',
23+
issueMessage: `Error from attempted read of file:\n${error}`,
24+
location: citationFilename,
25+
})
2226
return
2327
}
2428
const validate = compile(citationSchema)

0 commit comments

Comments
 (0)