Skip to content

Commit 2d45432

Browse files
authored
Merge pull request #242 from effigies/deprecate-89plus
feat: Split out deprecation warning for age=="89+"
2 parents 96c2b52 + 5ec7863 commit 2d45432

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
### Added
9+
10+
- Issue deprecation warning for `"89+"` in `age` columns, per
11+
[bids-standard/bids-specification#2162][].
12+
13+
[bids-standard/bids-specification#2162]: https://github.com/bids-standard/bids-specification/pull/2162
14+
15+
<!--
16+
### Changed
17+
18+
- A bullet item for the Changed category.
19+
20+
-->
21+
<!--
22+
### Fixed
23+
24+
- A bullet item for the Fixed category.
25+
26+
-->
27+
<!--
28+
### Deprecated
29+
30+
- A bullet item for the Deprecated category.
31+
32+
-->
33+
<!--
34+
### Removed
35+
36+
- A bullet item for the Removed category.
37+
38+
-->
39+
<!--
40+
### Security
41+
42+
- A bullet item for the Security category.
43+
44+
-->
45+
<!--
46+
### Infrastructure
47+
48+
- A bullet item for the Infrastructure category.
49+
50+
-->

src/issues/list.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ export const bidsIssues: IssueDefinitionRecord = {
133133
reason:
134134
'A column required in a TSV file has been redefined in a sidecar file. This redefinition is being ignored.',
135135
},
136+
TSV_PSEUDO_AGE_DEPRECATED: {
137+
severity: 'warning',
138+
reason: 'Use of the value "89+" in column "age" is deprecated. Use 89 for all ages 89 and over.',
139+
},
136140
INVALID_GZIP: {
137141
severity: 'error',
138142
reason: 'The gzip file could not be decompressed. It may be corrupt or misnamed.',

src/schema/tables.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,25 @@ Deno.test('tables eval* tests', async (t) => {
166166
assertEquals(issues[0].issueMessage, "'f'")
167167
})
168168

169+
await t.step('verify pseudo-age deprecation', () => {
170+
const context = {
171+
path: '/participants.tsv',
172+
extension: '.tsv',
173+
sidecar: {},
174+
columns: {
175+
participant_id: ['sub-01', 'sub-02', 'sub-03'],
176+
age: ['10', '89+', '89+'],
177+
},
178+
dataset: { issues: new DatasetIssues() },
179+
}
180+
const rule = schemaDefs.rules.tabular_data.modality_agnostic.Participants
181+
evalColumns(rule, context, schema, 'rules.tabular_data.modality_agnostic.Participants')
182+
183+
// age gets a warning
184+
let issues = context.dataset.issues.get({ code: 'TSV_PSEUDO_AGE_DEPRECATED' })
185+
assertEquals(issues.length, 1)
186+
})
187+
169188
await t.step('verify column ordering', () => {
170189
const context = {
171190
path: '/sub-01/sub-01_scans.tsv',

src/schema/tables.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,23 @@ export function evalColumns(
257257
rule: schemaPath,
258258
}
259259

260+
const ageCheck = name === 'age'
261+
let ageWarningIssued = false
262+
260263
const column = context.columns[name] as string[]
261264
for (const [index, value] of column.entries()) {
262265
if (!checkValue(value, spec)) {
266+
if (ageCheck && value === '89+') {
267+
if (!ageWarningIssued) {
268+
ageWarningIssued = true
269+
context.dataset.issues.add({
270+
code: 'TSV_PSEUDO_AGE_DEPRECATED',
271+
location: context.path,
272+
line: index + 2,
273+
})
274+
}
275+
continue
276+
}
263277
const issueMessage = `'${value}'` +
264278
(value.match(/^\s*(NA|na|nan|NaN|n\/a)\s*$/) ? ", did you mean 'n/a'?" : '')
265279
context.dataset.issues.add({

0 commit comments

Comments
 (0)