268 *** Methods ***
269 */
270
271var Vulnerability = mongoose.model('Vulnerability', VulnerabilitySchema);272module.exports = Vulnerability;
229 });
230 else {
231 primeVuln = row;
232 var removeIndex = mergeVuln.details233 .map(d => d.title)234 .indexOf(mergeDetail.title);235 mergeVuln.details.splice(removeIndex, 1);
236 if (mergeVuln.details.length === 0)
237 return Vulnerability.findByIdAndDelete(mergeVuln._id);
214 else {
215 mergeVuln = row;
216 mergeDetail = row.details.find(d => d.locale === locale);
217 var query = Vulnerability.findById(vulnIdPrime);218 return query.exec();
219 }
220 })
176 rows.forEach(row => {
177 row.details.forEach(detail => {
178 if (detail.locale === locale && detail.title) {
179 var temp = {};180 temp.cvssv3 = row.cvssv3;
181 temp.priority = row.priority;
182 temp.remediationComplexity = row.remediationComplexity;
172 .exec()
173 .then(rows => {
174 if (rows) {
175 var result = [];176 rows.forEach(row => {
177 row.details.forEach(detail => {
178 if (detail.locale === locale && detail.title) {
Declare variables at the top of their scope as it improves code readability, performance and also helps in code navigation.
The vars-on-top
rule generates warnings when variable declarations are not used serially at the top of a function scope or the top of a program. By default variable declarations are always moved (“hoisted”) invisibly to the top of their containing scope by the JavaScript interpreter. This rule forces the programmer to represent that behavior by manually moving the variable declaration to the top of its containing scope.
// Variable declarations in a block:
function doSomething() {
var first;
if (true) {
first = true;
}
var second;
}
// Variable declaration in for initializer:
function doSomething() {
for (var i=0; i<10; i++) {}
}
function doSomething() {
var first;
var second; //multiple declarations are allowed at the top
if (true) {
first = true;
}
}
function doSomething() {
var i;
for (i=0; i<10; i++) {}
}