Java 声纳问题-开关箱应以“无条件”结束;“中断”;陈述
我想请你们在声纳问题上给予帮助。声纳标记的情况下等于以下代码作为声纳问题squid:S128 -开关箱应以无条件“断开”语句结束。 我不认为在这种情况下,我必须添加“break”语句。 有人能帮我吗?这是假阳性问题吗 先谢谢你Java 声纳问题-开关箱应以“无条件”结束;“中断”;陈述,java,sonarqube,sonarlint,Java,Sonarqube,Sonarlint,我想请你们在声纳问题上给予帮助。声纳标记的情况下等于以下代码作为声纳问题squid:S128 -开关箱应以无条件“断开”语句结束。 我不认为在这种情况下,我必须添加“break”语句。 有人能帮我吗?这是假阳性问题吗 先谢谢你 public boolean causeException(Throwable throwable) { Throwable causeException = ExceptionUtils.getRootCause(throwable);
public boolean causeException(Throwable throwable) {
Throwable causeException = ExceptionUtils.getRootCause(throwable);
Map<String, MatchMode> configuration = infoMessage.get(causeException.getClass());
String message = throwable.getMessage();
for (String key : configuration.keySet()) {
MatchMode matchMode = configuration.get(key);
switch (matchMode) {
case EQUALS:
if (message.equals(key)) {
return true;
}
case CONTAINS:
if (message.contains(key)) {
return false;
}
}
}
return false;
}
public boolean原因异常(Throwable-Throwable){
Throwable CauseeException=ExceptionUtils.getRootCause(Throwable);
Map configuration=infoMessage.get(causeeexception.getClass());
String message=throwable.getMessage();
for(字符串键:configuration.keySet()){
MatchMode MatchMode=configuration.get(键);
开关(匹配模式){
案例等于:
if(message.equals(key)){
返回true;
}
案件包括:
if(message.contains(key)){
返回false;
}
}
}
返回false;
}
如果您的消息不等于密钥,您将遇到故障。您需要添加中断来解决此问题:
public boolean causeException(Throwable throwable) {
Throwable causeException = ExceptionUtils.getRootCause(throwable);
Map<String, MatchMode> configuration = infoMessage.get(causeException.getClass());
String message = throwable.getMessage();
for (String key : configuration.keySet()) {
MatchMode matchMode = configuration.get(key);
switch (matchMode) {
case EQUALS:
if (message.equals(key)) {
return true;
}
break; // stops fallthrough
// With no "break" it would do the CONTAINS block as well
case CONTAINS:
if (message.contains(key)) {
return true;
}
break; // stops fallthrough
default:
// just for clarity
break;
}
}
return false;
}
public boolean原因异常(Throwable-Throwable){
Throwable CauseeException=ExceptionUtils.getRootCause(Throwable);
Map configuration=infoMessage.get(causeeexception.getClass());
String message=throwable.getMessage();
for(字符串键:configuration.keySet()){
MatchMode MatchMode=configuration.get(键);
开关(匹配模式){
案例等于:
if(message.equals(key)){
返回true;
}
中断;//停止故障
//如果没有“中断”,它也会执行包含块
案件包括:
if(message.contains(key)){
返回true;
}
中断;//停止故障
违约:
//只是为了澄清
打破
}
}
返回false;
}
如果您的消息不等于密钥,您将遇到故障。您需要添加中断来解决此问题:
public boolean causeException(Throwable throwable) {
Throwable causeException = ExceptionUtils.getRootCause(throwable);
Map<String, MatchMode> configuration = infoMessage.get(causeException.getClass());
String message = throwable.getMessage();
for (String key : configuration.keySet()) {
MatchMode matchMode = configuration.get(key);
switch (matchMode) {
case EQUALS:
if (message.equals(key)) {
return true;
}
break; // stops fallthrough
// With no "break" it would do the CONTAINS block as well
case CONTAINS:
if (message.contains(key)) {
return true;
}
break; // stops fallthrough
default:
// just for clarity
break;
}
}
return false;
}
public boolean原因异常(Throwable-Throwable){
Throwable CauseeException=ExceptionUtils.getRootCause(Throwable);
Map configuration=infoMessage.get(causeeexception.getClass());
String message=throwable.getMessage();
for(字符串键:configuration.keySet()){
MatchMode MatchMode=configuration.get(键);
开关(匹配模式){
案例等于:
if(message.equals(key)){
返回true;
}
中断;//停止故障
//如果没有“中断”,它也会执行包含块
案件包括:
if(message.contains(key)){
返回true;
}
中断;//停止故障
违约:
//只是为了澄清
打破
}
}
返回false;
}
非常感谢您的解释。非常感谢您的解释。