Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--
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

- A bullet item for the Added category.

-->
<!--
### Changed


-->
### Fixed

- Categorically prevent required entities on metadata files to more closely follow inheritance principle.
- Also skip required entities on all derivative files.

<!--
### Deprecated

- A bullet item for the Deprecated category.

-->
<!--
### Removed

- A bullet item for the Removed category.

-->
<!--
### Security

- A bullet item for the Security category.

-->
<!--
### Infrastructure

- A bullet item for the Infrastructure category.

-->
2 changes: 1 addition & 1 deletion src/validators/filenameValidate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FileTree } from '../types/filetree.ts'
import type { GenericSchema } from '../types/schema.ts'
import { assertEquals } from '@std/assert'
import { BIDSContext } from '../schema/context.ts'
import { type atRoot, type entityLabelCheck, missingLabel } from './filenameValidate.ts'
import { type entityLabelCheck, missingLabel } from './filenameValidate.ts'
import type { BIDSFileDeno } from '../files/deno.ts'
import { pathToFile } from '../files/filetree.ts'
import type { FileIgnoreRules } from '../files/ignore.ts'
Expand Down
23 changes: 3 additions & 20 deletions src/validators/filenameValidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const sidecarExtensions = ['.json', '.tsv', '.bvec', '.bval']

const CHECKS: ContextCheckFunction[] = [
missingLabel,
atRoot,
entityLabelCheck,
checkRules,
reconstructionFailure,
Expand All @@ -25,13 +24,6 @@ export async function filenameValidate(
return Promise.resolve()
}

export function isAtRoot(context: BIDSContext) {
if (context.file.path.split(SEPARATOR_PATTERN).length !== 2) {
return false
}
return true
}

export async function missingLabel(
schema: GenericSchema,
context: BIDSContext,
Expand All @@ -57,15 +49,6 @@ export async function missingLabel(
return Promise.resolve()
}

export function atRoot(schema: GenericSchema, context: BIDSContext) {
/*
if (fileIsAtRoot && !sidecarExtensions.includes(context.extension)) {
// create issue for data file in root of dataset
}
*/
return Promise.resolve()
}

export function lookupEntityLiteral(name: string, schema: GenericSchema) {
if (
schema.objects &&
Expand Down Expand Up @@ -203,9 +186,9 @@ function entityRuleIssue(
const fileEntities = Object.keys(context.entities)
const ruleEntities = Object.keys(rule.entities).map((key) => lookupEntityLiteral(key, schema))

// skip required entity checks if file is at root.
// No requirements for inherited sidecars at this level.
if (!isAtRoot(context)) {
// skip required entity checks for 'metadata' per inheritance rules 1 + 2
// Also skip for all deriv files.
if (!sidecarExtensions.includes(context.extension) && !path.includes('rules.deriv.')) {
const ruleEntitiesRequired = Object.entries(rule.entities)
.filter(([_, v]) => v === 'required')
.map(([k, _]) => lookupEntityLiteral(k, schema))
Expand Down
Loading