Sonar:Merge this if statement with the enclosing one

Sonar常见问题及修改建议(201912):https://blog.csdn.net/libusi001/article/details/103717457

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

一、问题

Merge this if statement with the enclosing one

应该合并可折叠的"if"语句

二、示例及解决

原代码:

if (StringUtils.isNotBlank(oldName)) {
    if(oldName.equals(newName)){
    }    
}

修改后代码:

if (StringUtils.isNotBlank(oldName) && oldName.equals(newName)) {
}

有用请点赞,养成良好习惯!

疑问、交流、鼓励请留言!

发布了267 篇原创文章 · 获赞 145 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/libusi001/article/details/103717499
one