Skip to content

Commit

Permalink
Merge pull request #944 from bids-standard/943-column-evidence-fix
Browse files Browse the repository at this point in the history
Fix TSV checks returning arrays for evidence values
  • Loading branch information
rwblair committed Apr 22, 2020
2 parents 906e07a + 5053402 commit 376115b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
16 changes: 15 additions & 1 deletion bids-validator/utils/issues/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,20 @@ const constructHelpUrl = issue => {
* Issue
*
* A constructor for BIDS issues.
*
* @param {Object} options
* @param {string} options.key The descriptive string matching the issue code
* @param {number} options.code Issue code - see 'list.js' for definitions
* @param {string} [options.file] The relative path of the affected file
* @param {string} [options.evidence] The value throwing this issue
* @param {number} [options.line] The line of the affected file (if within a file)
* @param {number} [options.character] The character offset in the affected line
* @param {string} [options.severity] Is this an error or warning?
* @param {string} [options.reason] A descriptive
* @param {string} [options.helpUrl] A URL providing documentation to help solve this error
* @returns {Object} Issue object
*/
export default function(options) {
function Issue(options) {
const code = options.hasOwnProperty('code') ? options.code : null
const issue = issues[code]

Expand All @@ -36,3 +48,5 @@ export default function(options) {
this.reason = options.hasOwnProperty('reason') ? options.reason : issue.reason
this.helpUrl = constructHelpUrl(issue)
}

export default Issue
20 changes: 13 additions & 7 deletions bids-validator/validators/tsv/tsv.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import utils from '../../utils'
const Issue = utils.issues.Issue
import Issue from '../../utils/issues/issue'
import checkAcqTimeFormat from './checkAcqTimeFormat'
import checkAge89 from './checkAge89'
import checkStatusCol from './checkStatusCol'
import parseTSV from './tsvParser'

/**
* Format TSV headers for evidence string
* @param {Array[string]} headers
* @returns {string}
*/
const headersEvidence = headers => `Column headers: ${headers.join(', ')}`

/**
* TSV
*
Expand Down Expand Up @@ -98,7 +105,7 @@ const TSV = (file, contents, fileList, callback) => {
issues.push(
new Issue({
file: file,
evidence: headers,
evidence: headersEvidence(headers),
line: 1,
character: rows[0].indexOf(headers[idx]),
code: code,
Expand All @@ -113,7 +120,7 @@ const TSV = (file, contents, fileList, callback) => {
issues.push(
new Issue({
file: file,
evidence: headers,
evidence: headersEvidence(headers),
line: 1,
code: 20,
}),
Expand All @@ -123,7 +130,7 @@ const TSV = (file, contents, fileList, callback) => {
issues.push(
new Issue({
file: file,
evidence: headers,
evidence: headersEvidence(headers),
line: 1,
code: 21,
}),
Expand Down Expand Up @@ -181,7 +188,7 @@ const TSV = (file, contents, fileList, callback) => {
issues.push(
new Issue({
file: file,
evidence: headers.join('\t'),
evidence: headersEvidence(headers),
line: 1,
code: 48,
}),
Expand Down Expand Up @@ -287,7 +294,6 @@ const TSV = (file, contents, fileList, callback) => {
if (file.name === 'participants.tsv') {
checkAge89(rows, file, issues)
}


if (file.name.endsWith('_scans.tsv')) {
// check _scans.tsv for column filename
Expand All @@ -296,7 +302,7 @@ const TSV = (file, contents, fileList, callback) => {
new Issue({
line: 1,
file: file,
evidence: headers.join('\t'),
evidence: headersEvidence(headers),
code: 68,
}),
)
Expand Down

0 comments on commit 376115b

Please sign in to comment.