Skip to content

Commit fda6c76

Browse files
committed
Allow sidecar extensions to bypass required entities check.
1 parent e63f9a2 commit fda6c76

File tree

2 files changed

+49
-20
lines changed

2 files changed

+49
-20
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
For top level release notes, leave all the headers commented out.
6+
-->
7+
8+
<!--
9+
### Added
10+
11+
- A bullet item for the Added category.
12+
13+
-->
14+
### Changed
15+
16+
- Categorically prevent required entites on metadata files to more closely follow inheritance principle.
17+
18+
<!--
19+
### Fixed
20+
21+
- A bullet item for the Fixed category.
22+
23+
-->
24+
<!--
25+
### Deprecated
26+
27+
- A bullet item for the Deprecated category.
28+
29+
-->
30+
<!--
31+
### Removed
32+
33+
- A bullet item for the Removed category.
34+
35+
-->
36+
<!--
37+
### Security
38+
39+
- A bullet item for the Security category.
40+
41+
-->
42+
<!--
43+
### Infrastructure
44+
45+
- A bullet item for the Infrastructure category.
46+
47+
-->

src/validators/filenameValidate.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const sidecarExtensions = ['.json', '.tsv', '.bvec', '.bval']
99

1010
const CHECKS: ContextCheckFunction[] = [
1111
missingLabel,
12-
atRoot,
1312
entityLabelCheck,
1413
checkRules,
1514
reconstructionFailure,
@@ -25,13 +24,6 @@ export async function filenameValidate(
2524
return Promise.resolve()
2625
}
2726

28-
export function isAtRoot(context: BIDSContext) {
29-
if (context.file.path.split(SEPARATOR_PATTERN).length !== 2) {
30-
return false
31-
}
32-
return true
33-
}
34-
3527
export async function missingLabel(
3628
schema: GenericSchema,
3729
context: BIDSContext,
@@ -57,15 +49,6 @@ export async function missingLabel(
5749
return Promise.resolve()
5850
}
5951

60-
export function atRoot(schema: GenericSchema, context: BIDSContext) {
61-
/*
62-
if (fileIsAtRoot && !sidecarExtensions.includes(context.extension)) {
63-
// create issue for data file in root of dataset
64-
}
65-
*/
66-
return Promise.resolve()
67-
}
68-
6952
export function lookupEntityLiteral(name: string, schema: GenericSchema) {
7053
if (
7154
schema.objects &&
@@ -203,9 +186,8 @@ function entityRuleIssue(
203186
const fileEntities = Object.keys(context.entities)
204187
const ruleEntities = Object.keys(rule.entities).map((key) => lookupEntityLiteral(key, schema))
205188

206-
// skip required entity checks if file is at root.
207-
// No requirements for inherited sidecars at this level.
208-
if (!isAtRoot(context)) {
189+
// skip required entity checks for 'metadata' per inheritance rules 1 + 2
190+
if (!sidecarExtensions.includes(context.extension)) {
209191
const ruleEntitiesRequired = Object.entries(rule.entities)
210192
.filter(([_, v]) => v === 'required')
211193
.map(([k, _]) => lookupEntityLiteral(k, schema))

0 commit comments

Comments
 (0)