声纳中用于 Java 中导入语句的重复代码块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36111476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Duplicated block of Code in Sonar for import statements in Java
提问by tuk
In Sonar 4.5.6 (with default settings) I am seeing Duplicated Blocks
message as
在声纳 4.5.6(使用默认设置)中,我看到的Duplicated Blocks
消息为
My java code for which I am getting the message is like below:-
我收到消息的 Java 代码如下所示:-
package com.jabong.orchestratorservice.adapter.order.endpoints;
import com.jabong.orchestratorservice.adapter.order.request.UpdateOrderStatusReadyShipRequest;
public class UpdateOrderReadyShipEndPoint extends BaseOrderEndPoint {
private final static String API_NAME = "setStatusToReadyToShip";
@Override
public String getSourceEndPoint() {
return new StringBuilder("direct:").append(API_NAME).toString();
}
@Override
public String getDestinationEndPoint() {
return new StringBuilder("bean:orderHelper?method=").append(API_NAME).toString();
}
@Override
protected String getName() {
return API_NAME;
}
@Override
protected String getApiInputClassName() {
return UpdateOrderStatusReadyShipRequest.class.getName();
}
}
UpdateOrderStatusReadyShipRequest
also does not import UpdateOrderReadyShipEndPoint
UpdateOrderStatusReadyShipRequest
也不导入 UpdateOrderReadyShipEndPoint
package com.jabong.orchestratorservice.adapter.order.request;
public class UpdateOrderStatusReadyShipRequest extends BaseOrderRequest {
Can some let me know what does this mean?
有人可以让我知道这是什么意思吗?
采纳答案by G. Ann - SonarSource Team
The Duplicate Blocks rule raises issues at the file level. So it's not trying to tell you that your import statement is duplicated, but that somewhere in the file is a duplicate block. If you'll scroll down, you should see a vertical yellow/orange bar in the left margin. It marks the duplicate block. Click on the bar to get details of where the block is duplicated.
Duplicate Blocks 规则会在文件级别引发问题。所以它不是试图告诉你你的 import 语句是重复的,而是文件中的某个地方是一个重复的块。如果向下滚动,您应该会在左边距中看到一个垂直的黄色/橙色条。它标记重复块。单击该栏以获取有关块复制位置的详细信息。
EDITIn more recent versions the duplication marker is brown or gray.
编辑在更新的版本中,重复标记为棕色或灰色。