|
1 | 1 | var utils = require('../utils'); |
2 | 2 | var Issue = utils.issues.Issue; |
3 | 3 |
|
| 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 | + |
4 | 26 | /** |
5 | 27 | * NIFTI |
6 | 28 | * |
@@ -224,26 +246,7 @@ module.exports = function NIFTI (header, file, jsonContentsDict, bContentsDict, |
224 | 246 |
|
225 | 247 | for (var key = 0; key < intendedFor.length; key++) { |
226 | 248 | 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); |
247 | 250 | } |
248 | 251 | } |
249 | 252 | } |
|
0 commit comments