Minor fixes as reported by CodeClimate

This commit is contained in:
ljacqu
2018-09-01 09:17:42 +02:00
parent 58e04556ee
commit f79c364f84
14 changed files with 60 additions and 18 deletions
@@ -182,7 +182,11 @@ public class SQLite extends AbstractSqlDataSource {
ConsoleLogger.info("SQLite Setup finished");
}
protected void migrateIfNeeded() throws SQLException {
/**
* Migrates the database if necessary. See {@link SqLiteMigrater} for details.
*/
@VisibleForTesting
void migrateIfNeeded() throws SQLException {
DatabaseMetaData metaData = con.getMetaData();
if (SqLiteMigrater.isMigrationRequired(metaData, tableName, col)) {
new SqLiteMigrater(settings, dataFolder).performMigration(this);
@@ -35,7 +35,14 @@ class XfBcryptExtension extends MySqlExtension {
updateXenforoTablesOnSave(auth, authId.getAsInt(), con);
}
}
/**
* Updates the xenforo tables after a player auth has been saved.
*
* @param auth the player auth which was saved
* @param id the account id
* @param con connection to the database
*/
private void updateXenforoTablesOnSave(PlayerAuth auth, int id, Connection con) throws SQLException {
// Insert player password, salt in xf_user_authenticate
String sql = "INSERT INTO " + xfPrefix + "user_authenticate (user_id, scheme_class, data) VALUES (?,?,?)";
@@ -79,6 +79,9 @@ public class ProtocolLibService implements SettingsDependent {
this.isEnabled = true;
}
/**
* Stops all features based on ProtocolLib.
*/
public void disable() {
isEnabled = false;
@@ -10,6 +10,7 @@ import static fr.xephi.authme.security.HashUtils.md5;
@Recommendation(Usage.ACCEPTABLE)
@HasSalt(value = SaltType.TEXT, length = 8)
@SuppressWarnings({"checkstyle:AbbreviationAsWordInName"})
public class MyBB extends SeparateSaltMethod {
@Override
@@ -97,6 +97,11 @@ public class BackupService {
return false;
}
/**
* Performs a backup for the MySQL data source.
*
* @return true if successful, false otherwise
*/
private boolean performMySqlBackup() {
FileUtils.createDirectory(backupFolder);
File sqlBackupFile = constructBackupFile("sql");
@@ -226,8 +226,8 @@ public class GeoIpService {
HashCode actualHash = function.hashBytes(Files.readAllBytes(file));
HashCode expectedHash = HashCode.fromString(expectedChecksum);
if (!Objects.equals(actualHash, expectedHash)) {
throw new IOException("GEO IP Checksum verification failed. " +
"Expected: " + expectedChecksum + "Actual:" + actualHash);
throw new IOException("GEO IP Checksum verification failed. "
+ "Expected: " + expectedChecksum + "Actual:" + actualHash);
}
}
@@ -267,10 +267,10 @@ public class GeoIpService {
*
* @param ip textual IP address to lookup.
* @return two-character ISO 3166-1 alpha code for the country, "LOCALHOST" for local addresses
* or "--" if it cannot be fetched.
* or "--" if it cannot be fetched.
*/
public String getCountryCode(String ip) {
if(InternetProtocolUtils.isLocalAddress(ip)) {
if (InternetProtocolUtils.isLocalAddress(ip)) {
return "LOCALHOST";
}
return getCountry(ip).map(Country::getIsoCode).orElse("--");
@@ -283,7 +283,7 @@ public class GeoIpService {
* @return The name of the country, "LocalHost" for local addresses, or "N/A" if it cannot be fetched.
*/
public String getCountryName(String ip) {
if(InternetProtocolUtils.isLocalAddress(ip)) {
if (InternetProtocolUtils.isLocalAddress(ip)) {
return "LocalHost";
}
return getCountry(ip).map(Country::getName).orElse("N/A");
@@ -69,7 +69,7 @@ public class PluginHookService {
*/
public File getCmiDataFolder() {
Plugin plugin = pluginManager.getPlugin("CMI");
if(plugin == null) {
if (plugin == null) {
return null;
}
return plugin.getDataFolder();