I have installed an extension called sonarlint, I am trying to refactor my code and reduce code smells, the plugin is suggesting I do further modifications like
This is one example where it complains
public ResponseWrapper update(TerritoryDto territoryDto) throws IOException {
// Validate the payload
var validationResponse = validateUpdatePayload(territoryDto);
if (validationResponse.getCode() != HttpStatus.OK.value()) return validationResponse;
TerritoryEntity territory = (TerritoryEntity) validationResponse.getData();
territory.setPolygon(territoryDto.getPolygon());
var updated = territoryRepository.save(territory);
var erpResponse = territoryErpClient.updateTerritory(
new UpdateTerritoryBoundary(territory.getPolygon().toString()),
territory.getName()
);
if (erpResponse == null) {
// todo - Consider sending notifications to slack about ERPNext not being reachable.
}
return ResponseWrapper
.builder()
.code(HttpStatus.OK.value())
.message("Territory updated successfully")
.data(TerritoryConverterInterface.TerritoryEntityToDtoMapper.INSTANCE.converter(updated))
.build();
}
I tried to make modifications according to the sonarLint alert but it is not working. Please help me with this problem. Thank you all.
