refactoring: Critical Sonar Issues (#1833)

* Resolve Sonar Code Smell: Define a constant instead of duplicating this literal 'Space rocket <' 4 times.

* Resolve Sonar Critical Code Smell: Define a constant instead of duplicating this literal 'Error connecting to MongoDB' 4 times.

* Fix checkstyle violation.

* Resolve Sonar Critical Code Smell: Define a constant instead of duplicating this literal 'LITERAL 0' 4 times.

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
This commit is contained in:
Simran Keshri
2021-10-13 13:15:22 +05:30
committed by GitHub
parent cab9048e06
commit 5a644f1092
3 changed files with 32 additions and 20 deletions

View File

@ -50,6 +50,7 @@ public final class DbManager {
private static boolean useMongoDB;
private static Map<String, UserAccount> virtualDB;
private static final String ERROR_MESSAGE_LOG = "Error connecting to MongoDB";
private DbManager() {
}
@ -85,7 +86,7 @@ public final class DbManager {
try {
connect();
} catch (ParseException e) {
LOGGER.error("Error connecting to MongoDB", e);
LOGGER.error(ERROR_MESSAGE_LOG, e);
}
}
var iterable = db
@ -112,7 +113,7 @@ public final class DbManager {
try {
connect();
} catch (ParseException e) {
LOGGER.error("Error connecting to MongoDB", e);
LOGGER.error(ERROR_MESSAGE_LOG, e);
}
}
db.getCollection(CachingConstants.USER_ACCOUNT).insertOne(
@ -134,7 +135,7 @@ public final class DbManager {
try {
connect();
} catch (ParseException e) {
LOGGER.error("Error connecting to MongoDB", e);
LOGGER.error(ERROR_MESSAGE_LOG, e);
}
}
db.getCollection(CachingConstants.USER_ACCOUNT).updateOne(
@ -155,7 +156,7 @@ public final class DbManager {
try {
connect();
} catch (ParseException e) {
LOGGER.error("Error connecting to MongoDB", e);
LOGGER.error(ERROR_MESSAGE_LOG, e);
}
}
db.getCollection(CachingConstants.USER_ACCOUNT).updateOne(