我正在尝试使用名为 sonarLint 的 IntelliJ 想法扩展来重构我的代码。在那里,sonarLint 建议进一步修改如下图(我已将问题标记为红色)
这是我的代码
public class AbcController extends BaseController{
private final PermissionService permissionService;
public PermissionController(PermissionService permissionService) {
this.permissionService = permissionService;
}
@GetMapping("/groups")
public ResponseEntity<List<GroupResponse>> getGroups( String accessToken) {
List<GroupResponse> groupResponses = permissionService.getGroups(accessToken);
return getResponseEntity(groupResponses);
}
}
public abstract class BaseController <T>{
protected ResponseEntity<T> getResponseEntity(T t, HttpHeaders httpHeaders) {
return new ResponseEntity<> (t, httpHeaders, HttpStatus.OK);
}
protected ResponseEntity<T> getResponseEntity(T t) {
return new ResponseEntity<> (t, HttpStatus.OK);
}
}
我试图根据 sonarLint 警报进行修改,但它不起作用。请帮我解决这个问题。谢谢你们。