Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions docs/user_guide/command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ warnings, errors or ignored.
}
```

When a configuration specifies `location` without leading `/` it is interpreted
as a glob pattern following gitignore syntax.
The issues are partial matches of the [Issues] that the validator accumulates.
Pass the `--json` flag to see the issues in detail.

Expand Down
10 changes: 9 additions & 1 deletion src/issues/datasetIssues.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { default as ignore } from '@ignore'
import type { Ignore } from '@ignore'
import { nonSchemaIssues } from './list.ts'
import type { Issue, IssueDefinition, IssueFile, Severity } from '../types/issues.ts'
export type { Issue, IssueDefinition, IssueFile, Severity }
Expand Down Expand Up @@ -41,7 +43,13 @@ export class DatasetIssues {
if (!value) {
continue
}
found = found.filter((x) => x[key as keyof Issue] === value)
if (key === 'location' && typeof value === "string" && !value.startsWith('/')){
// @ts-expect-error
const key_ignore = ignore().add(value as string)
found = found.filter((x) => x[key] && key_ignore.ignores(x[key].slice(1, x[key].length)))
} else {
found = found.filter((x) => x[key as keyof Issue] === value)
}
}
return found
}
Expand Down
9 changes: 3 additions & 6 deletions src/validators/filenameIdentify.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assertEquals } from '@std/assert'
import { SEPARATOR_PATTERN } from '@std/path'
import { BIDSContext } from '../schema/context.ts'
import { _findRuleMatches, datatypeFromDirectory, hasMatch } from './filenameIdentify.ts'
import { BIDSFileDeno } from '../files/deno.ts'
Expand Down Expand Up @@ -67,12 +68,8 @@ Deno.test('test hasMatch', async (t) => {

await t.step('No match', async () => {
const tmpFile = Deno.makeTempFileSync()
const parts = tmpFile.split('/')
const file = new BIDSFileDeno(
parts.slice(0, parts.length - 1).join('/'),
parts[parts.length - 1],
ignore,
)
const [ dir, base ] = tmpFile.split(SEPARATOR_PATTERN)
const file = new BIDSFileDeno(dir, `/${base}`, ignore)

const context = new BIDSContext(file)
await hasMatch(schema, context)
Expand Down
Loading