Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Allow blacklisting any modality from schema.rules.modalities #2176

Merged
merged 2 commits into from
Oct 28, 2024
Merged
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
3 changes: 2 additions & 1 deletion bids-validator/src/setup/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { LevelName } from '@std/log'
import { Command, EnumType } from '@cliffy/command'
import { getVersion } from '../version.ts'
import type { Issue, Severity } from '../types/issues.ts'
import { schema } from '@bids/schema'

/**
* BIDS Validator config file object definition
Expand Down Expand Up @@ -31,7 +32,7 @@ export type ValidatorOptions = {
}

const modalityType = new EnumType<string>(
['MRI', 'PET', 'MEG', 'EEG', 'iEEG', 'Microscopy', 'NIRS', 'MRS'],
Object.keys(schema.rules.modalities)
)

/** Extendable Cliffy Command with built in BIDS validator options */
Expand Down
9 changes: 7 additions & 2 deletions bids-validator/src/validators/bids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import type { parseOptions } from '../setup/options.ts'
import { hedValidate } from './hed.ts'
import { citationValidate } from './citation.ts'
import { logger } from '../utils/logger.ts'

/**
* Ordering of checks to apply
Expand Down Expand Up @@ -121,8 +122,12 @@
// Map blacklisted datatypes back to the modality that generated them
for (const modality of options.blacklistModalities) {
const datatypes = modalitiesRule[modality.toLowerCase()]?.datatypes as string[]
for (const datatype of datatypes) {
blacklistedDatatypes.set(datatype, modality)
if (datatypes) {
for (const datatype of datatypes) {
blacklistedDatatypes.set(datatype, modality)
}
} else {
logger.warn(`Attempted to blacklist unknown modality: ${modality}`)

Check warning on line 130 in bids-validator/src/validators/bids.ts

View check run for this annotation

Codecov / codecov/patch

bids-validator/src/validators/bids.ts#L130

Added line #L130 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR, relates to

  • #2182

}
}
}
Expand Down
Loading