我有一个疑问,我有一个类,在其中我对导入常量使用不同的静态导入,我的问题是我收到错误消息:Too many static imports may lead to messy code。但在单元测试中看起来这并不是一个坏习惯。例如,在单元测试类中,我使用此导入来解决任何问题:
import static com.rccl.middleware.kidsclub.engine.web.controller.KidController.KID_FIND_PATH;
import static com.rccl.middleware.kidsclub.engine.web.controller.KidController.KID_LIST_PATH;
import static com.rccl.middleware.kidsclub.engine.web.controller.KidController.KID_PATH;
import static com.rccl.middleware.kidsclub.engine.web.controller.KidController.KID_REGISTER_ALL_PATH;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.times;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;```
相反,在我的课堂上:
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
这些导入给我带来了问题,我收到错误消息:太多静态导入可能会导致代码混乱。我不太确定为什么。
我无法访问 pmd 文件来找出此问题的真正原因。有什么线索吗?
Qyouu
慕盖茨4494581
蝴蝶刀刀
陪伴而非守候
波斯汪
相关分类