集合大小和数组长度 - sonarqube
collection size and array length - sonarqube
我正在使用 sonarqube 检查我们代码的质量,sonarqube 发现数组总是大于或等于 0。
$.each(ssntxtArrayText, function (index, value) {
if (value.length >= 0) {
$('#resultValidation').css({
'display': 'none',
});
return false;
}
else {
$("#resultValidation").removeAttr("style");
}
});
将 if (value.length >= 0)
更改为 if (value.length > 0)
是否可以解决问题,或者这是否会影响正在发生的事情的其余部分?
sonarqube has found arrays will always [have length] greater than or equal to 0.
独立于sonarqube,在JS中始终如此。即,您的 if 条件是不必要的,您的代码相当于
$.each(ssntxtArrayText, function (index, value) {
$('#resultValidation').css({
'display': 'none',
});
return false;
});
如果这是故意的,那么继续并删除 if 语句。如果这不是故意的,那么修复将取决于预期的行为是什么。
我正在使用 sonarqube 检查我们代码的质量,sonarqube 发现数组总是大于或等于 0。
$.each(ssntxtArrayText, function (index, value) {
if (value.length >= 0) {
$('#resultValidation').css({
'display': 'none',
});
return false;
}
else {
$("#resultValidation").removeAttr("style");
}
});
将 if (value.length >= 0)
更改为 if (value.length > 0)
是否可以解决问题,或者这是否会影响正在发生的事情的其余部分?
sonarqube has found arrays will always [have length] greater than or equal to 0.
独立于sonarqube,在JS中始终如此。即,您的 if 条件是不必要的,您的代码相当于
$.each(ssntxtArrayText, function (index, value) {
$('#resultValidation').css({
'display': 'none',
});
return false;
});
如果这是故意的,那么继续并删除 if 语句。如果这不是故意的,那么修复将取决于预期的行为是什么。