6

I am trying to refactor my code using the IntelliJ idea extension called sonarLint. In there, sonarLint suggests further modification like this picture below(I have marked the issue in red)

SonarLint error alert

here is my code

 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);

    }
}

I tried to make modifications according to the sonarLint alert but it is not working. Please help me with this problem. Thank you all.

hansika
  • 79
  • 1
  • 6
  • Where is the ResponseEntityTransformer in the code? I cannot find it – sigur Dec 10 '21 at 15:47
  • Specify the generic type, e.g.: `public class AbcController extends BaseController` – Andrew S Dec 10 '21 at 15:51
  • thank you @AndrewS do you mean like this public class AbcController extends BaseController. but it's not supported for getGroups API return statement – hansika Dec 10 '21 at 17:05

0 Answers0