From 57a41cb62f4e401f83ed17eb1df77f60d59c133d Mon Sep 17 00:00:00 2001 From: Chris Filo Gorgolewski Date: Sun, 11 Mar 2018 14:02:56 -0700 Subject: [PATCH 1/2] Improve header check robustness --- validators/tsv.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validators/tsv.js b/validators/tsv.js index a2ad33b00..fb2c81582 100644 --- a/validators/tsv.js +++ b/validators/tsv.js @@ -76,7 +76,7 @@ var TSV = function TSV (file, contents, fileList, callback) { // events.tsv if (file.name.endsWith('_events.tsv')) { - if (headers[0] !== "onset"){ + if ((headers.length == 0) || (headers[0] !== "onset")){ issues.push(new Issue({ file: file, evidence: headers, @@ -85,7 +85,7 @@ var TSV = function TSV (file, contents, fileList, callback) { code: 20 })); } - if (headers[1].trim() !== "duration"){ + if ((headers.length <= 1) || (headers[1].trim() !== "duration")){ issues.push(new Issue({ file: file, evidence: headers, From e0f70d813c58a0f95af9a183c1e517e954e36e9a Mon Sep 17 00:00:00 2001 From: Chris Filo Gorgolewski Date: Sun, 11 Mar 2018 15:07:38 -0700 Subject: [PATCH 2/2] better handling of missing headers --- validators/tsv.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/validators/tsv.js b/validators/tsv.js index fb2c81582..e8690e3ce 100644 --- a/validators/tsv.js +++ b/validators/tsv.js @@ -81,16 +81,14 @@ var TSV = function TSV (file, contents, fileList, callback) { file: file, evidence: headers, line: 1, - character: rows[0].indexOf(headers[0]), code: 20 })); } - if ((headers.length <= 1) || (headers[1].trim() !== "duration")){ + if ((headers.length == 1) || (headers[1].trim() !== "duration")){ issues.push(new Issue({ file: file, evidence: headers, line: 1, - character: rows[0].indexOf(headers[1]), code: 21 })); }