#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:
ljacqu 2016-10-23 21:12:49 +02:00
parent b7a7d5b3bd
commit 9466577993
7 changed files with 126 additions and 38 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly --> <!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Sun Oct 23 18:25:12 CEST 2016. See docs/config/config.tpl.md --> <!-- File auto-generated on Sun Oct 23 21:08:57 CEST 2016. See docs/config/config.tpl.md -->
## AuthMe Configuration ## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -99,7 +99,8 @@ settings:
# Should the session expire if the player tries to log in with # Should the session expire if the player tries to log in with
# another IP address? # another IP address?
sessionExpireOnIpChange: true sessionExpireOnIpChange: true
# Message language, available: en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt # Message language, available languages:
# https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md
messagesLanguage: 'en' messagesLanguage: 'en'
restrictions: restrictions:
# Keeps collisions disabled for logged players # Keeps collisions disabled for logged players
@ -131,9 +132,9 @@ settings:
# This setting will prevent potential security exploits. # This setting will prevent potential security exploits.
ForceSingleSession: true ForceSingleSession: true
ForceSpawnLocOnJoin: ForceSpawnLocOnJoin:
# If enabled, every player that spawn in one of the world listed in "ForceSpawnLocOnJoin.worlds" # If enabled, every player that spawn in one of the world listed in
# will be teleported to the spawnpoint after successful authentication. # "ForceSpawnLocOnJoin.worlds" will be teleported to the spawnpoint after successful
# The quit location of the player will be overwritten. # authentication. The quit location of the player will be overwritten.
# This is different from "teleportUnAuthedToSpawn" that teleport player # This is different from "teleportUnAuthedToSpawn" that teleport player
# to the spawnpoint on join. # to the spawnpoint on join.
enabled: false enabled: false
@ -202,8 +203,8 @@ settings:
# FINE for some additional detailed ones (like password failed), # FINE for some additional detailed ones (like password failed),
# and DEBUG for debugging # and DEBUG for debugging
logLevel: 'FINE' logLevel: 'FINE'
# By default we schedule async tasks when talking to the database # By default we schedule async tasks when talking to the database. If you want
# If you want typical communication with the database to happen synchronously, set this to false # typical communication with the database to happen synchronously, set this to false
useAsyncTasks: true useAsyncTasks: true
GameMode: GameMode:
# Force survival gamemode when player joins? # Force survival gamemode when player joins?
@ -277,19 +278,23 @@ settings:
forceLoginAfterRegister: false forceLoginAfterRegister: false
# Force these commands after /login, without any '/', use %p to replace with player name # Force these commands after /login, without any '/', use %p to replace with player name
forceCommands: [] forceCommands: []
# Force these commands after /login as service console, without any '/'. Use %p to replace with player name # Force these commands after /login as service console, without any '/'.
# Use %p to replace with player name
forceCommandsAsConsole: [] forceCommandsAsConsole: []
# Force these commands after /register, without any '/', use %p to replace with player name # Force these commands after /register, without any '/', use %p to replace with player name
forceRegisterCommands: [] forceRegisterCommands: []
# Force these commands after /register as a server console, without any '/'. Use %p to replace with player name # Force these commands after /register as a server console, without any '/'.
# Use %p to replace with player name
forceRegisterCommandsAsConsole: [] forceRegisterCommandsAsConsole: []
# Enable to display the welcome message (welcome.txt) after a login # Enable to display the welcome message (welcome.txt) after a login
# You can use colors in this welcome.txt + some replaced strings: # You can use colors in this welcome.txt + some replaced strings:
# {PLAYER}: player name, {ONLINE}: display number of online players, {MAXPLAYERS}: display server slots, # {PLAYER}: player name, {ONLINE}: display number of online players,
# {IP}: player ip, {LOGINS}: number of players logged, {WORLD}: player current world, {SERVER}: server name # {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 # {VERSION}: get current bukkit version, {COUNTRY}: player country
useWelcomeMessage: true useWelcomeMessage: true
# Do we need to broadcast the welcome message to all server or only to the player? set true for server or false for player # Broadcast the welcome message to the server or only to the player?
# set true for server or false for player
broadcastWelcomeMessage: false broadcastWelcomeMessage: false
# Should we delay the join message and display it once the player has logged in? # Should we delay the join message and display it once the player has logged in?
delayJoinMessage: false delayJoinMessage: false
@ -361,7 +366,8 @@ Protection:
enableProtection: false enableProtection: false
# Apply the protection also to registered usernames # Apply the protection also to registered usernames
enableProtectionRegistered: true enableProtectionRegistered: true
# Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes # 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! # PLEASE USE QUOTES!
countries: countries:
- 'US' - 'US'
@ -372,7 +378,8 @@ Protection:
- 'A1' - 'A1'
# Do we need to enable automatic antibot system? # Do we need to enable automatic antibot system?
enableAntiBot: true enableAntiBot: true
# Max number of players allowed to login in 5 secs before the AntiBot system is enabled automatically # Max number of players allowed to login in 5 secs
# before the AntiBot system is enabled automatically
antiBotSensibility: 10 antiBotSensibility: 10
# Duration in minutes of the antibot automatic system # Duration in minutes of the antibot automatic system
antiBotDuration: 10 antiBotDuration: 10
@ -381,7 +388,7 @@ Protection:
Purge: Purge:
# If enabled, AuthMe automatically purges old, unused accounts # If enabled, AuthMe automatically purges old, unused accounts
useAutoPurge: false useAutoPurge: false
# Number of Days an account become Unused # Number of days after which an account should be purged
daysBeforeRemovePlayer: 60 daysBeforeRemovePlayer: 60
# Do we need to remove the player.dat file during purge process? # Do we need to remove the player.dat file during purge process?
removePlayerDat: false removePlayerDat: false
@ -389,7 +396,7 @@ Purge:
removeEssentialsFile: false removeEssentialsFile: false
# World where are players.dat stores # World where are players.dat stores
defaultWorld: 'world' defaultWorld: 'world'
# Do we need to remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge process ? # Remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge?
removeLimitedCreativesInventories: false removeLimitedCreativesInventories: false
# Do we need to remove the AntiXRayData/PlayerData/player file during purge process? # Do we need to remove the AntiXRayData/PlayerData/player file during purge process?
removeAntiXRayFile: false removeAntiXRayFile: false
@ -448,4 +455,4 @@ To change settings on a running server, save your changes to config.yml and use
--- ---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Oct 23 18:25:12 CEST 2016 This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Oct 23 21:08:57 CEST 2016

View File

@ -36,7 +36,10 @@ public class PluginSettings implements SettingsHolder {
public static final Property<Boolean> SESSIONS_EXPIRE_ON_IP_CHANGE = public static final Property<Boolean> SESSIONS_EXPIRE_ON_IP_CHANGE =
newProperty("settings.sessions.sessionExpireOnIpChange", true); 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 = public static final Property<String> MESSAGES_LANGUAGE =
newProperty("settings.messagesLanguage", "en"); newProperty("settings.messagesLanguage", "en");
@ -65,8 +68,8 @@ public class PluginSettings implements SettingsHolder {
newProperty(LogLevel.class, "settings.logLevel", LogLevel.FINE); newProperty(LogLevel.class, "settings.logLevel", LogLevel.FINE);
@Comment({ @Comment({
"By default we schedule async tasks when talking to the database", "By default we schedule async tasks when talking to the database. If you want",
"If you want typical communication with the database to happen synchronously, set this to false" "typical communication with the database to happen synchronously, set this to false"
}) })
public static final Property<Boolean> USE_ASYNC_TASKS = public static final Property<Boolean> USE_ASYNC_TASKS =
newProperty("settings.useAsyncTasks", true); newProperty("settings.useAsyncTasks", true);

View File

@ -20,13 +20,16 @@ public class ProtectionSettings implements SettingsHolder {
public static final Property<Boolean> ENABLE_PROTECTION_REGISTERED = public static final Property<Boolean> ENABLE_PROTECTION_REGISTERED =
newProperty("Protection.enableProtectionRegistered", true); 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", @Comment({
"PLEASE USE QUOTES!"}) "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 = public static final Property<List<String>> COUNTRIES_WHITELIST =
newListProperty("Protection.countries", "US", "GB"); newListProperty("Protection.countries", "US", "GB");
@Comment({"Countries not allowed to join the server and register", @Comment({
"PLEASE USE QUOTES!"}) "Countries not allowed to join the server and register",
"PLEASE USE QUOTES!"})
public static final Property<List<String>> COUNTRIES_BLACKLIST = public static final Property<List<String>> COUNTRIES_BLACKLIST =
newListProperty("Protection.countriesBlacklist", "A1"); newListProperty("Protection.countriesBlacklist", "A1");
@ -34,7 +37,9 @@ public class ProtectionSettings implements SettingsHolder {
public static final Property<Boolean> ENABLE_ANTIBOT = public static final Property<Boolean> ENABLE_ANTIBOT =
newProperty("Protection.enableAntiBot", true); 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 = public static final Property<Integer> ANTIBOT_SENSIBILITY =
newProperty("Protection.antiBotSensibility", 10); newProperty("Protection.antiBotSensibility", 10);

View File

@ -12,7 +12,7 @@ public class PurgeSettings implements SettingsHolder {
public static final Property<Boolean> USE_AUTO_PURGE = public static final Property<Boolean> USE_AUTO_PURGE =
newProperty("Purge.useAutoPurge", false); 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 = public static final Property<Integer> DAYS_BEFORE_REMOVE_PLAYER =
newProperty("Purge.daysBeforeRemovePlayer", 60); newProperty("Purge.daysBeforeRemovePlayer", 60);
@ -28,7 +28,7 @@ public class PurgeSettings implements SettingsHolder {
public static final Property<String> DEFAULT_WORLD = public static final Property<String> DEFAULT_WORLD =
newProperty("Purge.defaultWorld", "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 = public static final Property<Boolean> REMOVE_LIMITED_CREATIVE_INVENTORIES =
newProperty("Purge.removeLimitedCreativesInventories", false); newProperty("Purge.removeLimitedCreativesInventories", false);

View File

@ -52,8 +52,9 @@ public class RegistrationSettings implements SettingsHolder {
public static final Property<List<String>> FORCE_COMMANDS = public static final Property<List<String>> FORCE_COMMANDS =
newListProperty("settings.forceCommands"); newListProperty("settings.forceCommands");
@Comment("Force these commands after /login as service console, without any '/'. " @Comment({
+ "Use %p to replace with player name") "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 = public static final Property<List<String>> FORCE_COMMANDS_AS_CONSOLE =
newListProperty("settings.forceCommandsAsConsole"); newListProperty("settings.forceCommandsAsConsole");
@ -61,22 +62,25 @@ public class RegistrationSettings implements SettingsHolder {
public static final Property<List<String>> FORCE_REGISTER_COMMANDS = public static final Property<List<String>> FORCE_REGISTER_COMMANDS =
newListProperty("settings.forceRegisterCommands"); newListProperty("settings.forceRegisterCommands");
@Comment("Force these commands after /register as a server console, without any '/'. " @Comment({
+ "Use %p to replace with player name") "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 = public static final Property<List<String>> FORCE_REGISTER_COMMANDS_AS_CONSOLE =
newListProperty("settings.forceRegisterCommandsAsConsole"); newListProperty("settings.forceRegisterCommandsAsConsole");
@Comment({ @Comment({
"Enable to display the welcome message (welcome.txt) after a login", "Enable to display the welcome message (welcome.txt) after a login",
"You can use colors in this welcome.txt + some replaced strings:", "You can use colors in this welcome.txt + some replaced strings:",
"{PLAYER}: player name, {ONLINE}: display number of online players, {MAXPLAYERS}: display server slots,", "{PLAYER}: player name, {ONLINE}: display number of online players,",
"{IP}: player ip, {LOGINS}: number of players logged, {WORLD}: player current world, {SERVER}: server name", "{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"}) "{VERSION}: get current bukkit version, {COUNTRY}: player country"})
public static final Property<Boolean> USE_WELCOME_MESSAGE = public static final Property<Boolean> USE_WELCOME_MESSAGE =
newProperty("settings.useWelcomeMessage", true); newProperty("settings.useWelcomeMessage", true);
@Comment("Do we need to broadcast the welcome message to all server or only to the player? set true for " @Comment({
+ "server or false for player") "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 = public static final Property<Boolean> BROADCAST_WELCOME_MESSAGE =
newProperty("settings.broadcastWelcomeMessage", false); newProperty("settings.broadcastWelcomeMessage", false);

View File

@ -50,9 +50,9 @@ public class RestrictionSettings implements SettingsHolder {
newProperty("settings.restrictions.ForceSingleSession", true); newProperty("settings.restrictions.ForceSingleSession", true);
@Comment({ @Comment({
"If enabled, every player that spawn in one of the world listed in \"ForceSpawnLocOnJoin.worlds\"", "If enabled, every player that spawn in one of the world listed in",
"will be teleported to the spawnpoint after successful authentication.", "\"ForceSpawnLocOnJoin.worlds\" will be teleported to the spawnpoint after successful",
"The quit location of the player will be overwritten.", "authentication. The quit location of the player will be overwritten.",
"This is different from \"teleportUnAuthedToSpawn\" that teleport player", "This is different from \"teleportUnAuthedToSpawn\" that teleport player",
"to the spawnpoint on join."}) "to the spawnpoint on join."})
public static final Property<Boolean> FORCE_SPAWN_LOCATION_AFTER_LOGIN = public static final Property<Boolean> FORCE_SPAWN_LOCATION_AFTER_LOGIN =

View File

@ -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- ")));
}
}
}