#989 Ensure config comments never exceed 90 chars
- Prevents horizontal scrollbar on markdown page (and in users' editors) - Add test that each property is accompanied with a comment
This commit is contained in:
@@ -36,7 +36,10 @@ public class PluginSettings implements SettingsHolder {
|
||||
public static final Property<Boolean> SESSIONS_EXPIRE_ON_IP_CHANGE =
|
||||
newProperty("settings.sessions.sessionExpireOnIpChange", true);
|
||||
|
||||
@Comment("Message language, available: en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt")
|
||||
@Comment({
|
||||
"Message language, available languages:",
|
||||
"https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md"
|
||||
})
|
||||
public static final Property<String> MESSAGES_LANGUAGE =
|
||||
newProperty("settings.messagesLanguage", "en");
|
||||
|
||||
@@ -65,8 +68,8 @@ public class PluginSettings implements SettingsHolder {
|
||||
newProperty(LogLevel.class, "settings.logLevel", LogLevel.FINE);
|
||||
|
||||
@Comment({
|
||||
"By default we schedule async tasks when talking to the database",
|
||||
"If you want typical communication with the database to happen synchronously, set this to false"
|
||||
"By default we schedule async tasks when talking to the database. If you want",
|
||||
"typical communication with the database to happen synchronously, set this to false"
|
||||
})
|
||||
public static final Property<Boolean> USE_ASYNC_TASKS =
|
||||
newProperty("settings.useAsyncTasks", true);
|
||||
|
||||
@@ -20,13 +20,16 @@ public class ProtectionSettings implements SettingsHolder {
|
||||
public static final Property<Boolean> ENABLE_PROTECTION_REGISTERED =
|
||||
newProperty("Protection.enableProtectionRegistered", true);
|
||||
|
||||
@Comment({"Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes",
|
||||
"PLEASE USE QUOTES!"})
|
||||
@Comment({
|
||||
"Countries allowed to join the server and register. For country codes, see",
|
||||
"http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/",
|
||||
"PLEASE USE QUOTES!"})
|
||||
public static final Property<List<String>> COUNTRIES_WHITELIST =
|
||||
newListProperty("Protection.countries", "US", "GB");
|
||||
|
||||
@Comment({"Countries not allowed to join the server and register",
|
||||
"PLEASE USE QUOTES!"})
|
||||
@Comment({
|
||||
"Countries not allowed to join the server and register",
|
||||
"PLEASE USE QUOTES!"})
|
||||
public static final Property<List<String>> COUNTRIES_BLACKLIST =
|
||||
newListProperty("Protection.countriesBlacklist", "A1");
|
||||
|
||||
@@ -34,7 +37,9 @@ public class ProtectionSettings implements SettingsHolder {
|
||||
public static final Property<Boolean> ENABLE_ANTIBOT =
|
||||
newProperty("Protection.enableAntiBot", true);
|
||||
|
||||
@Comment("Max number of players allowed to login in 5 secs before the AntiBot system is enabled automatically")
|
||||
@Comment({
|
||||
"Max number of players allowed to login in 5 secs",
|
||||
"before the AntiBot system is enabled automatically"})
|
||||
public static final Property<Integer> ANTIBOT_SENSIBILITY =
|
||||
newProperty("Protection.antiBotSensibility", 10);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public class PurgeSettings implements SettingsHolder {
|
||||
public static final Property<Boolean> USE_AUTO_PURGE =
|
||||
newProperty("Purge.useAutoPurge", false);
|
||||
|
||||
@Comment("Number of Days an account become Unused")
|
||||
@Comment("Number of days after which an account should be purged")
|
||||
public static final Property<Integer> DAYS_BEFORE_REMOVE_PLAYER =
|
||||
newProperty("Purge.daysBeforeRemovePlayer", 60);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PurgeSettings implements SettingsHolder {
|
||||
public static final Property<String> DEFAULT_WORLD =
|
||||
newProperty("Purge.defaultWorld", "world");
|
||||
|
||||
@Comment("Do we need to remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge process ?")
|
||||
@Comment("Remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge?")
|
||||
public static final Property<Boolean> REMOVE_LIMITED_CREATIVE_INVENTORIES =
|
||||
newProperty("Purge.removeLimitedCreativesInventories", false);
|
||||
|
||||
|
||||
@@ -52,8 +52,9 @@ public class RegistrationSettings implements SettingsHolder {
|
||||
public static final Property<List<String>> FORCE_COMMANDS =
|
||||
newListProperty("settings.forceCommands");
|
||||
|
||||
@Comment("Force these commands after /login as service console, without any '/'. "
|
||||
+ "Use %p to replace with player name")
|
||||
@Comment({
|
||||
"Force these commands after /login as service console, without any '/'.",
|
||||
"Use %p to replace with player name"})
|
||||
public static final Property<List<String>> FORCE_COMMANDS_AS_CONSOLE =
|
||||
newListProperty("settings.forceCommandsAsConsole");
|
||||
|
||||
@@ -61,22 +62,25 @@ public class RegistrationSettings implements SettingsHolder {
|
||||
public static final Property<List<String>> FORCE_REGISTER_COMMANDS =
|
||||
newListProperty("settings.forceRegisterCommands");
|
||||
|
||||
@Comment("Force these commands after /register as a server console, without any '/'. "
|
||||
+ "Use %p to replace with player name")
|
||||
@Comment({
|
||||
"Force these commands after /register as a server console, without any '/'.",
|
||||
"Use %p to replace with player name"})
|
||||
public static final Property<List<String>> FORCE_REGISTER_COMMANDS_AS_CONSOLE =
|
||||
newListProperty("settings.forceRegisterCommandsAsConsole");
|
||||
|
||||
@Comment({
|
||||
"Enable to display the welcome message (welcome.txt) after a login",
|
||||
"You can use colors in this welcome.txt + some replaced strings:",
|
||||
"{PLAYER}: player name, {ONLINE}: display number of online players, {MAXPLAYERS}: display server slots,",
|
||||
"{IP}: player ip, {LOGINS}: number of players logged, {WORLD}: player current world, {SERVER}: server name",
|
||||
"{PLAYER}: player name, {ONLINE}: display number of online players,",
|
||||
"{MAXPLAYERS}: display server slots, {IP}: player ip, {LOGINS}: number of players logged,",
|
||||
"{WORLD}: player current world, {SERVER}: server name",
|
||||
"{VERSION}: get current bukkit version, {COUNTRY}: player country"})
|
||||
public static final Property<Boolean> USE_WELCOME_MESSAGE =
|
||||
newProperty("settings.useWelcomeMessage", true);
|
||||
|
||||
@Comment("Do we need to broadcast the welcome message to all server or only to the player? set true for "
|
||||
+ "server or false for player")
|
||||
@Comment({
|
||||
"Broadcast the welcome message to the server or only to the player?",
|
||||
"set true for server or false for player"})
|
||||
public static final Property<Boolean> BROADCAST_WELCOME_MESSAGE =
|
||||
newProperty("settings.broadcastWelcomeMessage", false);
|
||||
|
||||
|
||||
@@ -50,9 +50,9 @@ public class RestrictionSettings implements SettingsHolder {
|
||||
newProperty("settings.restrictions.ForceSingleSession", true);
|
||||
|
||||
@Comment({
|
||||
"If enabled, every player that spawn in one of the world listed in \"ForceSpawnLocOnJoin.worlds\"",
|
||||
"will be teleported to the spawnpoint after successful authentication.",
|
||||
"The quit location of the player will be overwritten.",
|
||||
"If enabled, every player that spawn in one of the world listed in",
|
||||
"\"ForceSpawnLocOnJoin.worlds\" will be teleported to the spawnpoint after successful",
|
||||
"authentication. The quit location of the player will be overwritten.",
|
||||
"This is different from \"teleportUnAuthedToSpawn\" that teleport player",
|
||||
"to the spawnpoint on join."})
|
||||
public static final Property<Boolean> FORCE_SPAWN_LOCATION_AFTER_LOGIN =
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import com.github.authme.configme.knownproperties.ConfigurationData;
|
||||
import com.github.authme.configme.properties.Property;
|
||||
import fr.xephi.authme.settings.properties.AuthMeSettingsRetriever;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Tests the consistency of the settings configuration.
|
||||
*/
|
||||
public class SettingsConsistencyTest {
|
||||
|
||||
/**
|
||||
* Maximum characters one comment line may have (prevents horizontal scrolling).
|
||||
*/
|
||||
private static final int MAX_COMMENT_LENGTH = 90;
|
||||
|
||||
private static ConfigurationData configurationData;
|
||||
|
||||
@BeforeClass
|
||||
public static void buildConfigurationData() {
|
||||
configurationData = AuthMeSettingsRetriever.buildConfigurationData();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHaveCommentOnEachProperty() {
|
||||
// given
|
||||
List<Property<?>> properties = configurationData.getProperties();
|
||||
|
||||
// when / then
|
||||
for (Property<?> property : properties) {
|
||||
if (configurationData.getCommentsForSection(property.getPath()).length == 0) {
|
||||
fail("No comment defined for '" + property + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotHaveVeryLongCommentLines() {
|
||||
// given
|
||||
List<Property<?>> properties = configurationData.getProperties();
|
||||
List<Property<?>> badProperties = new ArrayList<>();
|
||||
|
||||
// when
|
||||
for (Property<?> property : properties) {
|
||||
for (String comment : configurationData.getCommentsForSection(property.getPath())) {
|
||||
if (comment.length() > MAX_COMMENT_LENGTH) {
|
||||
badProperties.add(property);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// then
|
||||
if (!badProperties.isEmpty()) {
|
||||
fail("Comment lines should not be longer than " + MAX_COMMENT_LENGTH + " chars, "
|
||||
+ "but found too long comments for:\n- "
|
||||
+ badProperties.stream().map(Property::getPath).collect(Collectors.joining("\n- ")));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user