mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-08 17:37:34 +01:00
Enforced some upper-limit checkstyle rules (#1132)
* Checkstyle: Enforced catch parameter name * Checkstyle: Enforced ClassFanOutComplexity 85 * Checkstyle: Enforced ClassTypeParameterName * Checkstyle: Enforced CommentsIndentation * Checkstyle: Enforced CovariantEquals * Checkstyle: Enforced CyclomaticComplexity 18 * Checkstyle: Enforced DefaultComesLast * Checkstyle: Enforced EmptyCatchBlock * Checkstyle: Enforced EmptyForIteratorPad * Checkstyle: Enforced EmptyStatement * Checkstyle: Enforced FileLength 1750 * Checkstyle: Enforced GenericWhitespace * Checkstyle: Enforced HideUtilityClassConstructor * Checkstyle: Enforced IllegalInstantiation * Checkstyle: Enforced IllegalThrows * Checkstyle: Enforced LambdaParameterName * Checkstyle: Enforced LineLength 3000 * Checkstyle: Enforced MissingOverride * Checkstyle: Enforced PackageAnnotation * Checkstyle: Enforced NestedTryDepth 1 * Checkstyle: Enforced UnnecessaryParentheses * Checkstyle: Enforced MethodLength 150 * Checkstyle: Enforced NoWhitespaceAfter
This commit is contained in:
parent
cf21eccbdf
commit
b05ca2e5eb
@ -102,10 +102,10 @@ public class DeathEventListener implements Listener {
|
||||
Material itemInHand;
|
||||
try {
|
||||
itemInHand = killer.getInventory().getItemInMainHand().getType();
|
||||
} catch (NoSuchMethodError e) {
|
||||
} catch (NoSuchMethodError oldVersion) {
|
||||
try {
|
||||
itemInHand = killer.getInventory().getItemInHand().getType(); // Support for non dual wielding versions.
|
||||
} catch (Exception | NoSuchMethodError | NoSuchFieldError e2) {
|
||||
} catch (Exception | NoSuchMethodError | NoSuchFieldError unknownError) {
|
||||
itemInHand = Material.AIR;
|
||||
}
|
||||
}
|
||||
|
@ -72,17 +72,17 @@ public class ActivityIndex {
|
||||
double max = 4.0;
|
||||
|
||||
long playtimeWeek = weekOne.toActivePlaytime();
|
||||
double weekPlay = (playtimeWeek * 1.0 / activePlayThreshold);
|
||||
double weekPlay = playtimeWeek * 1.0 / activePlayThreshold;
|
||||
if (weekPlay > max) {
|
||||
weekPlay = max;
|
||||
}
|
||||
long playtimeWeek2 = weekTwo.toActivePlaytime();
|
||||
double week2Play = (playtimeWeek2 * 1.0 / activePlayThreshold);
|
||||
double week2Play = playtimeWeek2 * 1.0 / activePlayThreshold;
|
||||
if (week2Play > max) {
|
||||
week2Play = max;
|
||||
}
|
||||
long playtimeWeek3 = weekThree.toActivePlaytime();
|
||||
double week3Play = (playtimeWeek3 * 1.0 / activePlayThreshold);
|
||||
double week3Play = playtimeWeek3 * 1.0 / activePlayThreshold;
|
||||
if (week3Play > max) {
|
||||
week3Play = max;
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ public class UserIdentifierQueries {
|
||||
public Map<UUID, String> processResults(ResultSet set) throws SQLException {
|
||||
Map<UUID, String> names = new HashMap<>();
|
||||
while (set.next()) {
|
||||
UUID uuid = UUID.fromString(set.getString((UsersTable.USER_UUID)));
|
||||
String name = set.getString((UsersTable.USER_NAME));
|
||||
UUID uuid = UUID.fromString(set.getString(UsersTable.USER_UUID));
|
||||
String name = set.getString(UsersTable.USER_NAME);
|
||||
|
||||
names.put(uuid, name);
|
||||
}
|
||||
|
@ -54,12 +54,12 @@ public class KeepAliveTask extends AbsRunnable {
|
||||
statement = connection.createStatement();
|
||||
resultSet = statement.executeQuery("/* ping */ SELECT 1");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException pingException) {
|
||||
logger.debug("Something went wrong during SQL Connection upkeep task.");
|
||||
try {
|
||||
connection = iReconnect.reconnect();
|
||||
} catch (SQLException e1) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e1);
|
||||
} catch (SQLException reconnectionError) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), reconnectionError);
|
||||
logger.error("SQL connection maintaining task had to be closed due to exception.");
|
||||
this.cancel();
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public abstract class InfoSystem implements SubSystem {
|
||||
try {
|
||||
logger.getDebugLogger().logOn(DebugChannels.INFO_REQUESTS, "Exception during request: " + original.toString() + ", running locally.");
|
||||
runLocally(infoRequest);
|
||||
} catch (NoServersException e2) {
|
||||
} catch (NoServersException noServers) {
|
||||
throw original;
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ public class ResponseFactory {
|
||||
public ErrorResponse basicAuthFail(WebUserAuthException e) {
|
||||
try {
|
||||
return PromptAuthorizationResponse.getBasicAuthResponse(e, versionCheckSystem, files);
|
||||
} catch (IOException e1) {
|
||||
} catch (IOException jarReadFailed) {
|
||||
return internalErrorResponse(e, "Failed to parse PromptAuthorizationResponse");
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,10 @@ import org.apache.commons.text.TextStringBuilder;
|
||||
*/
|
||||
public class HtmlStructure {
|
||||
|
||||
private HtmlStructure() {
|
||||
/* Static method class */
|
||||
}
|
||||
|
||||
public static String separateWithDots(String... elements) {
|
||||
TextStringBuilder builder = new TextStringBuilder();
|
||||
builder.appendWithSeparators(elements, " • ");
|
||||
|
@ -65,7 +65,7 @@ public class Line {
|
||||
double x2 = end.getX();
|
||||
double y1 = start.getY();
|
||||
double y2 = end.getY();
|
||||
return Math.sqrt(Math.pow((x2 - x1), 2) + (Math.pow((y2 - y1), 2)));
|
||||
return Math.sqrt(Math.pow(x2 - x1, 2) + (Math.pow(y2 - y1, 2)));
|
||||
}
|
||||
|
||||
public double getPerpendicularDistance(Point from) {
|
||||
|
@ -45,7 +45,7 @@ class ActivityStackGraph extends StackGraph {
|
||||
StackDataSet[] dataSets = new StackDataSet[groups.length];
|
||||
|
||||
for (int i = 0; i < groups.length; i++) {
|
||||
dataSets[i] = new StackDataSet(new ArrayList<>(), groups[i], colors[(i) % maxCol]);
|
||||
dataSets[i] = new StackDataSet(new ArrayList<>(), groups[i], colors[i % maxCol]);
|
||||
}
|
||||
|
||||
for (Long date : activityData.navigableKeySet()) {
|
||||
|
@ -95,7 +95,7 @@ class TPSMutatorTest {
|
||||
long expected = TimeAmount.MONTH.toMillis(2L) - periodLength;
|
||||
|
||||
TPSMutator tpsMutator = new TPSMutator(testData.stream()
|
||||
.filter(tps -> (tps.getDate() - time) % (periodLength) == 0)
|
||||
.filter(tps -> (tps.getDate() - time) % periodLength == 0)
|
||||
.collect(Collectors.toList()));
|
||||
assertFalse(tpsMutator.all().isEmpty());
|
||||
assertNotEquals(testData, tpsMutator.all());
|
||||
@ -111,7 +111,7 @@ class TPSMutatorTest {
|
||||
|
||||
long monthAgo = time - TimeAmount.MONTH.toMillis(1L);
|
||||
TPSMutator tpsMutator = new TPSMutator(testData.stream()
|
||||
.filter(tps -> (tps.getDate() - time) % (periodLength) == 0)
|
||||
.filter(tps -> (tps.getDate() - time) % periodLength == 0)
|
||||
.collect(Collectors.toList()))
|
||||
.filterDataBetween(monthAgo, time);
|
||||
|
||||
@ -131,7 +131,7 @@ class TPSMutatorTest {
|
||||
Collections.shuffle(randomOrder);
|
||||
long monthAgo = time - TimeAmount.MONTH.toMillis(1L);
|
||||
TPSMutator tpsMutator = new TPSMutator(randomOrder.stream()
|
||||
.filter(tps -> (tps.getDate() - time) % (periodLength) == 0)
|
||||
.filter(tps -> (tps.getDate() - time) % periodLength == 0)
|
||||
.collect(Collectors.toList()))
|
||||
.filterDataBetween(monthAgo, time);
|
||||
|
||||
|
@ -28,6 +28,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
*/
|
||||
public class OptionalAssert {
|
||||
|
||||
private OptionalAssert() {
|
||||
/* Static method class */
|
||||
}
|
||||
|
||||
public static <T> void equals(T expected, Optional<T> result) {
|
||||
assertTrue(result.isPresent(), () -> "No result present, expected: " + expected);
|
||||
assertEquals(expected, result.get(), () -> "Wrong result, expected: " + expected + ", got: " + result.get());
|
||||
|
@ -33,6 +33,10 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class RandomData {
|
||||
|
||||
private RandomData() {
|
||||
/* Static method class */
|
||||
}
|
||||
|
||||
private static final Random r = new Random();
|
||||
|
||||
public static int randomInt(int rangeStart, int rangeEnd) {
|
||||
|
@ -25,6 +25,10 @@ import java.util.UUID;
|
||||
*/
|
||||
public class TestConstants {
|
||||
|
||||
private TestConstants() {
|
||||
/* Static variable class */
|
||||
}
|
||||
|
||||
public static final UUID SERVER_UUID = UUID.fromString("e4ec2edd-e0ed-3c58-a87d-8a9021899479");
|
||||
public static final UUID SERVER_TWO_UUID = UUID.fromString("c4ec2edd-e0ed-3c58-a87d-8a9024791899");
|
||||
public static final UUID PLAYER_ONE_UUID = UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db");
|
||||
|
@ -41,6 +41,10 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class TestData {
|
||||
|
||||
private TestData() {
|
||||
/* Utility class */
|
||||
}
|
||||
|
||||
private static UUID playerUUID = TestConstants.PLAYER_ONE_UUID;
|
||||
private static UUID player2UUID = TestConstants.PLAYER_TWO_UUID;
|
||||
private static UUID serverUUID = TestConstants.SERVER_UUID;
|
||||
|
@ -49,9 +49,6 @@ public class TestDatabaseCreator {
|
||||
|
||||
boolean oldDB = testDB.exists();
|
||||
|
||||
// db = new SQLiteDB(testDB, Locale::new);
|
||||
// db.init();
|
||||
|
||||
r = new Random();
|
||||
|
||||
if (oldDB) {
|
||||
|
@ -2,7 +2,6 @@
|
||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<module name="Checker">
|
||||
|
||||
<!-- Language Settings -->
|
||||
<property name="localeCountry" value="EN"/>
|
||||
<property name="localeLanguage" value="en"/>
|
||||
@ -10,12 +9,79 @@
|
||||
<module name="RegexpHeader">
|
||||
<property name="headerFile" value="config/checkstyle/java.header"/>
|
||||
</module>
|
||||
<module name="FileLength">
|
||||
<!-- This value is high. Notable: DatabaseTest 1521 -->
|
||||
<property name="max" value="1750"/>
|
||||
<property name="fileExtensions" value=".java"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="EqualsAvoidNull"/>
|
||||
<module name="FallThrough"/>
|
||||
|
||||
<!-- Length restriction -->
|
||||
<module name="AnonInnerLength">
|
||||
<property name="max" value="50"/>
|
||||
</module>
|
||||
<module name="LineLength">
|
||||
<!-- This value is very high. Notable: ExtensionExtractor: 254, DeepHelpLang 345, WorldMap 2964 -->
|
||||
<property name="max" value="3000"/>
|
||||
</module>
|
||||
<module name="MethodLength">
|
||||
<!-- This value is high. Notable: InspectPage: 138 -->
|
||||
<property name="max" value="150"/>
|
||||
</module>
|
||||
|
||||
<!-- Java Style -->
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="CommentsIndentation"/>
|
||||
<module name="DefaultComesLast"> <!-- Switches -->
|
||||
<property name="skipIfLastAndSharedWithCase" value="true"/>
|
||||
</module>
|
||||
<module name="FallThrough"/> <!-- Switches -->
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="GenericWhitespace"/>
|
||||
<module name="InnerAssignment"/>
|
||||
<module name="MissingOverride"/>
|
||||
<module name="NestedTryDepth">
|
||||
<property name="max" value="1"/>
|
||||
</module>
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
<module name="NoWhitespaceAfter"/>
|
||||
|
||||
<!-- Variable naming -->
|
||||
<module name="CatchParameterName"/>
|
||||
<module name="ClassTypeParameterName"/>
|
||||
<module name="InterfaceTypeParameterName"/>
|
||||
<module name="LocalVariableName"/>
|
||||
<module name="MethodTypeParameterName"/>
|
||||
<module name="LambdaParameterName"/>
|
||||
|
||||
<!-- Metrics -->
|
||||
<module name="ClassFanOutComplexity">
|
||||
<!-- This value is high. Notable: DatabaseTest: 84, SQLDB: 56 -->
|
||||
<property name="max" value="85"/>
|
||||
</module>
|
||||
<module name="CyclomaticComplexity">
|
||||
<!-- This value is high. Notable: ActivityIndex: 18 -->
|
||||
<property name="max" value="18"/>
|
||||
</module>
|
||||
|
||||
<!-- Bugs -->
|
||||
<module name="CovariantEquals"/>
|
||||
<module name="EqualsAvoidNull"/>
|
||||
<module name="EmptyCatchBlock">
|
||||
<property name="exceptionVariableName" value="expected|ignore"/>
|
||||
</module>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="IllegalThrows"/>
|
||||
<module name="PackageAnnotation"/>
|
||||
|
||||
<!-- Performance-->
|
||||
<module name="IllegalInstantiation">
|
||||
<property name="classes" value="java.lang.Boolean"/>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
|
Loading…
Reference in New Issue
Block a user