Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions changelog.d/20251204_121918_markiewicz_bep028.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
For top level release notes, leave all the headers commented out.
-->

### Added

- Support for JSON files in `/prov/` as standalone files. Avoiding
false positive `SIDECAR_WITHOUT_DATAFILE` errors.
28 changes: 21 additions & 7 deletions src/validators/internal/unusedFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,29 @@ export async function unusedStimulus(

const standalone_json = ['dataset_description.json', 'genetic_info.json']

function isSidecarFile(file: BIDSFile): boolean {
if (!file.name.endsWith('.json')) {
return false
}
if (standalone_json.includes(file.name)) {
return false
}
// prov files are not sidecars
if (file.path.startsWith('/prov/')) {
return false
}
// coordsystem.json files are kind-of sidecars, and they're picked up by
// associations. We may want to exclude them in the future.
return true
}

export async function sidecarWithoutDatafile(
schema: GenericSchema,
dsContext: BIDSContextDataset,
) {
const unusedSidecars = [...walkFileTree(dsContext.tree, dsContext)].filter(
(file) => (!file.viewed && file.name.endsWith('.json') &&
!standalone_json.includes(file.name)),
)
unusedSidecars.forEach((sidecar) => {
dsContext.issues.add({ code: 'SIDECAR_WITHOUT_DATAFILE', location: sidecar.path })
})
for (const file of walkFileTree(dsContext.tree, dsContext)) {
if (!file.viewed && isSidecarFile(file)) {
dsContext.issues.add({ code: 'SIDECAR_WITHOUT_DATAFILE', location: file.path })
}
}
}
Loading