gpt4 book ai didi

java - Sonar 违规

转载 作者:行者123 更新时间:2023-11-29 04:30:34 26 4
gpt4 key购买 nike

public Integer getMaxCount(String id,String type) {
String maxCount ="SELECT MAX(ID) AS COUNT FROM STUDENT";
try {
return queryForObject(
maxCount,
new Object[]{id,type},
(rs, i) -> {return rs.getInt(COUNT);},
"maxCount"
);
} catch (EmptyResultDataAccessException ex) {
LOG.error(ex);
return 9999;
}
}

如何修复上述代码块的 Sonar 违规问题。

Lambdas should be replaced with method references

Lambdas containing only one statement should not nest this statement in a block

最佳答案

它们是:

两个页面都包含有关如何修复代码的示例。

x -> System.out.println(x+1)
(a, b) -> a+b //For return statement, the return keyword should also be dropped

关于java - Sonar 违规,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43961135/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com