Cleanup: Codacy conformance

This commit is contained in:
Stefan Neuhaus
2017-02-28 08:23:57 +01:00
parent 0e313d1910
commit 4951ee5a62

View File

@@ -78,11 +78,10 @@ public final class CveDB {
*/ */
private final DatabaseProperties databaseProperties; private final DatabaseProperties databaseProperties;
/** /**
* Creates a new CveDB object and opens the database connection. Note, the * Does the underlying connection support batch operations?
* connection must be closed by the caller by calling the close method. * Currently we do not support batch execution.
* ======= Does the underlying connection support batch operations?
*/ */
private final boolean batchSupported; private final boolean batchSupported = false;
/** /**
* The prepared statements. * The prepared statements.
*/ */
@@ -127,7 +126,6 @@ public final class CveDB {
public CveDB() throws DatabaseException { public CveDB() throws DatabaseException {
open(); open();
final String databaseProductName = determineDatabaseProductName(); final String databaseProductName = determineDatabaseProductName();
batchSupported = isBatchSupportedFor(databaseProductName);
statementBundle = databaseProductName != null ? statementBundle = databaseProductName != null ?
ResourceBundle.getBundle("data/dbStatements", new Locale(databaseProductName)) : ResourceBundle.getBundle("data/dbStatements", new Locale(databaseProductName)) :
ResourceBundle.getBundle("data/dbStatements"); ResourceBundle.getBundle("data/dbStatements");
@@ -151,21 +149,6 @@ public final class CveDB {
} }
} }
/**
* Returns if the database supports batch execution of statements.
*
* @param databaseProductName the product name of the database
* @return if the database supports batch execution
*/
private boolean isBatchSupportedFor(String databaseProductName) {
if ("mysql".equalsIgnoreCase(databaseProductName)) {
return false;
}
// per default we do not support batch execution
return false;
}
/** /**
* Returns the database connection. * Returns the database connection.
* *
@@ -227,7 +210,7 @@ public final class CveDB {
throws DatabaseException { throws DatabaseException {
final EnumMap<PreparedStatementCveDb, PreparedStatement> result = new EnumMap<PreparedStatementCveDb, PreparedStatement>(PreparedStatementCveDb.class); final EnumMap<PreparedStatementCveDb, PreparedStatement> result = new EnumMap<PreparedStatementCveDb, PreparedStatement>(PreparedStatementCveDb.class);
for (PreparedStatementCveDb key : PreparedStatementCveDb.values()) { for (PreparedStatementCveDb key : values()) {
final String statementString = statementBundle.getString(key.name()); final String statementString = statementBundle.getString(key.name());
final PreparedStatement preparedStatement; final PreparedStatement preparedStatement;
try { try {
@@ -610,7 +593,7 @@ public final class CveDB {
} }
final PreparedStatement insertReference = getPreparedStatement(INSERT_REFERENCE); final PreparedStatement insertReference = getPreparedStatement(INSERT_REFERENCE);
if(batchSupported) { if (batchSupported) {
insertReference.clearBatch(); insertReference.clearBatch();
} }
for (Reference r : vuln.getReferences()) { for (Reference r : vuln.getReferences()) {
@@ -631,7 +614,7 @@ public final class CveDB {
} }
final PreparedStatement insertSoftware = getPreparedStatement(INSERT_SOFTWARE); final PreparedStatement insertSoftware = getPreparedStatement(INSERT_SOFTWARE);
if(batchSupported) { if (batchSupported) {
insertSoftware.clearBatch(); insertSoftware.clearBatch();
} }
for (VulnerableSoftware s : vuln.getVulnerableSoftware()) { for (VulnerableSoftware s : vuln.getVulnerableSoftware()) {