SonarQube 提示以下 JS 代码有错误
Remove this access to "contains" property, it doesn't exist, as a built-in, on a String.
String.prototype.contains = function (str, startIndex) {
return -1 !== this.indexOf(str, startIndex);
};
使用原型(prototype)创建的其他方法也存在同样的问题。如何解决此问题而不从规则检查中排除文件?
最佳答案
此规则假设项目中未进行猴子修补。如果您大量使用猴子修补,很可能最好禁用该规则。否则,只需在 SQ UI 中将问题标记为“无法修复”
关于javascript - SonarQube 无法识别 String.prototype 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49384342/