Skip to content

Commit 3415c5c

Browse files
committed
refactor2
1 parent 1ee6368 commit 3415c5c

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

validators/nii.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
var utils = require('../utils');
22
var Issue = utils.issues.Issue;
33

4+
function checkIfIntendedExists(path, intendedForFile, fileList, issues, file) {
5+
var intendedForFileFull = "/" + path.split("/")[1] + "/" + intendedForFile;
6+
var onTheList = false;
7+
8+
for (var key2 in fileList) {
9+
var filePath = fileList[key2].relativePath;
10+
if (filePath === intendedForFileFull) {
11+
onTheList = true;
12+
}
13+
}
14+
if (!onTheList) {
15+
issues.push(new Issue({
16+
file: file,
17+
code: 37,
18+
reason: "'IntendedFor' property of this fieldmap ('" + path +
19+
"') does not point to an existing file('" + intendedForFile + "'). Please mind that this value should not include subject level directory " +
20+
"('/" + path.split("/")[1] + "/').",
21+
evidence: intendedForFile
22+
}));
23+
}
24+
}
25+
426
/**
527
* NIFTI
628
*
@@ -224,26 +246,7 @@ module.exports = function NIFTI (header, file, jsonContentsDict, bContentsDict,
224246

225247
for (var key = 0; key < intendedFor.length; key++) {
226248
var intendedForFile = intendedFor[key];
227-
var intendedForFileFull = "/" + path.split("/")[1] + "/" + intendedForFile;
228-
var onTheList = false;
229-
230-
for (var key2 in fileList) {
231-
var filePath = fileList[key2].relativePath;
232-
if (filePath === intendedForFileFull) {
233-
onTheList = true;
234-
}
235-
}
236-
if (!onTheList) {
237-
issues.push(new Issue({
238-
file: file,
239-
code: 37,
240-
reason: "'IntendedFor' property of this fieldmap ('" + path +
241-
"') does not point to an existing file('" + intendedForFile + "'). Please mind that this value should not include subject level directory " +
242-
"('/" + path.split("/")[1] + "/').",
243-
evidence: intendedForFile
244-
}));
245-
}
246-
}
249+
checkIfIntendedExists(path, intendedForFile, fileList, issues, file);
247250
}
248251
}
249252
}

0 commit comments

Comments
 (0)