508 : Sonar qube critical Issue Fix (#854)
* 508 : Sonar qube critical Issue Fix Refactor this method to reduce its Cognitive Complexity from 30 to the 15 allowed. * 508: Sonar Qube Issue fxes Define a constant instead of duplicating this literal " does not exist." 3 times. * 508: sonar qube issue fixes Define a constant instead of duplicating this literal "Some external api for only realtime execution could be called here." 3 times.
This commit is contained in:
committed by
Ilkka Seppälä
parent
c6ecf58687
commit
f7e22a1cf6
@ -39,6 +39,8 @@ public class EventManager implements ThreadCompleteListener {
|
||||
private int currentlyRunningSyncEvent = -1;
|
||||
private Random rand;
|
||||
private Map<Integer, Event> eventPool;
|
||||
|
||||
private static final String DOES_NOT_EXIST = " does not exist.";
|
||||
|
||||
/**
|
||||
* EventManager constructor.
|
||||
@ -112,7 +114,7 @@ public class EventManager implements ThreadCompleteListener {
|
||||
*/
|
||||
public void start(int eventId) throws EventDoesNotExistException {
|
||||
if (!eventPool.containsKey(eventId)) {
|
||||
throw new EventDoesNotExistException(eventId + " does not exist.");
|
||||
throw new EventDoesNotExistException(eventId + DOES_NOT_EXIST);
|
||||
}
|
||||
|
||||
eventPool.get(eventId).start();
|
||||
@ -126,7 +128,7 @@ public class EventManager implements ThreadCompleteListener {
|
||||
*/
|
||||
public void cancel(int eventId) throws EventDoesNotExistException {
|
||||
if (!eventPool.containsKey(eventId)) {
|
||||
throw new EventDoesNotExistException(eventId + " does not exist.");
|
||||
throw new EventDoesNotExistException(eventId + DOES_NOT_EXIST);
|
||||
}
|
||||
|
||||
if (eventId == currentlyRunningSyncEvent) {
|
||||
@ -145,7 +147,7 @@ public class EventManager implements ThreadCompleteListener {
|
||||
*/
|
||||
public void status(int eventId) throws EventDoesNotExistException {
|
||||
if (!eventPool.containsKey(eventId)) {
|
||||
throw new EventDoesNotExistException(eventId + " does not exist.");
|
||||
throw new EventDoesNotExistException(eventId + DOES_NOT_EXIST);
|
||||
}
|
||||
|
||||
eventPool.get(eventId).status();
|
||||
|
Reference in New Issue
Block a user