Skip to content

Commit 376115b

Browse files
authored
Merge pull request #944 from bids-standard/943-column-evidence-fix
Fix TSV checks returning arrays for evidence values
2 parents 906e07a + 5053402 commit 376115b

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

bids-validator/utils/issues/issue.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,20 @@ const constructHelpUrl = issue => {
1717
* Issue
1818
*
1919
* A constructor for BIDS issues.
20+
*
21+
* @param {Object} options
22+
* @param {string} options.key The descriptive string matching the issue code
23+
* @param {number} options.code Issue code - see 'list.js' for definitions
24+
* @param {string} [options.file] The relative path of the affected file
25+
* @param {string} [options.evidence] The value throwing this issue
26+
* @param {number} [options.line] The line of the affected file (if within a file)
27+
* @param {number} [options.character] The character offset in the affected line
28+
* @param {string} [options.severity] Is this an error or warning?
29+
* @param {string} [options.reason] A descriptive
30+
* @param {string} [options.helpUrl] A URL providing documentation to help solve this error
31+
* @returns {Object} Issue object
2032
*/
21-
export default function(options) {
33+
function Issue(options) {
2234
const code = options.hasOwnProperty('code') ? options.code : null
2335
const issue = issues[code]
2436

@@ -36,3 +48,5 @@ export default function(options) {
3648
this.reason = options.hasOwnProperty('reason') ? options.reason : issue.reason
3749
this.helpUrl = constructHelpUrl(issue)
3850
}
51+
52+
export default Issue

bids-validator/validators/tsv/tsv.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import utils from '../../utils'
2-
const Issue = utils.issues.Issue
2+
import Issue from '../../utils/issues/issue'
33
import checkAcqTimeFormat from './checkAcqTimeFormat'
44
import checkAge89 from './checkAge89'
55
import checkStatusCol from './checkStatusCol'
66
import parseTSV from './tsvParser'
77

8+
/**
9+
* Format TSV headers for evidence string
10+
* @param {Array[string]} headers
11+
* @returns {string}
12+
*/
13+
const headersEvidence = headers => `Column headers: ${headers.join(', ')}`
14+
815
/**
916
* TSV
1017
*
@@ -98,7 +105,7 @@ const TSV = (file, contents, fileList, callback) => {
98105
issues.push(
99106
new Issue({
100107
file: file,
101-
evidence: headers,
108+
evidence: headersEvidence(headers),
102109
line: 1,
103110
character: rows[0].indexOf(headers[idx]),
104111
code: code,
@@ -113,7 +120,7 @@ const TSV = (file, contents, fileList, callback) => {
113120
issues.push(
114121
new Issue({
115122
file: file,
116-
evidence: headers,
123+
evidence: headersEvidence(headers),
117124
line: 1,
118125
code: 20,
119126
}),
@@ -123,7 +130,7 @@ const TSV = (file, contents, fileList, callback) => {
123130
issues.push(
124131
new Issue({
125132
file: file,
126-
evidence: headers,
133+
evidence: headersEvidence(headers),
127134
line: 1,
128135
code: 21,
129136
}),
@@ -181,7 +188,7 @@ const TSV = (file, contents, fileList, callback) => {
181188
issues.push(
182189
new Issue({
183190
file: file,
184-
evidence: headers.join('\t'),
191+
evidence: headersEvidence(headers),
185192
line: 1,
186193
code: 48,
187194
}),
@@ -287,7 +294,6 @@ const TSV = (file, contents, fileList, callback) => {
287294
if (file.name === 'participants.tsv') {
288295
checkAge89(rows, file, issues)
289296
}
290-
291297

292298
if (file.name.endsWith('_scans.tsv')) {
293299
// check _scans.tsv for column filename
@@ -296,7 +302,7 @@ const TSV = (file, contents, fileList, callback) => {
296302
new Issue({
297303
line: 1,
298304
file: file,
299-
evidence: headers.join('\t'),
305+
evidence: headersEvidence(headers),
300306
code: 68,
301307
}),
302308
)

0 commit comments

Comments
 (0)