Add NeedBraces checkstyle rule

Also fixed new checkstyle violations
This commit is contained in:
Draycia committed 2022-12-16 14:23:28 -08:00
1 parent ea29ee868c
commit ebaecad617
6 files changed
+51 -12

No files matched your search

+3
View File
@@ -61,6 +61,9 @@
<!-- https://checkstyle.org/config_imports.html#AvoidStarImport --> <!-- https://checkstyle.org/config_imports.html#AvoidStarImport -->
<module name="AvoidStarImport"/> <module name="AvoidStarImport"/>
<!-- https://checkstyle.sourceforge.io/config_blocks.html#NeedBraces -->
<module name="NeedBraces"/>
<!-- https://checkstyle.org/config_misc.html#AvoidEscapedUnicodeCharacters --> <!-- https://checkstyle.org/config_misc.html#AvoidEscapedUnicodeCharacters -->
<module name="AvoidEscapedUnicodeCharacters"> <module name="AvoidEscapedUnicodeCharacters">
<property name="allowByTailComment" value="true"/> <property name="allowByTailComment" value="true"/>
@@ -143,11 +143,25 @@ public final class BasicChatChannel implements ChatChannel {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (!(other instanceof BasicChatChannel otherChannel)) return false; if (!(other instanceof BasicChatChannel otherChannel)) {
if (!(otherChannel.commandName().equals(this.commandName()))) return false; return false;
if (!(Objects.equals(otherChannel.quickPrefix(), this.quickPrefix()))) return false; }
if (!(Objects.equals(otherChannel.permission(), this.permission()))) return false;
if (otherChannel.radius() != this.radius()) return false; if (!(otherChannel.commandName().equals(this.commandName()))) {
return false;
}
if (!(Objects.equals(otherChannel.quickPrefix(), this.quickPrefix()))) {
return false;
}
if (!(Objects.equals(otherChannel.permission(), this.permission()))) {
return false;
}
if (otherChannel.radius() != this.radius()) {
return false;
}
return otherChannel.key().equals(this.key()); return otherChannel.key().equals(this.key());
} }
@@ -156,4 +170,5 @@ public final class BasicChatChannel implements ChatChannel {
public int hashCode() { public int hashCode() {
return Objects.hash(this.commandName(), this.quickPrefix(), this.permission(), this.radius(), this.key()); return Objects.hash(this.commandName(), this.quickPrefix(), this.permission(), this.radius(), this.key());
} }
} }
@@ -292,11 +292,25 @@ public final class ConfigChatChannel implements ChatChannel {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (!(other instanceof BasicChatChannel otherChannel)) return false; if (!(other instanceof BasicChatChannel otherChannel)) {
if (!(otherChannel.commandName().equals(this.commandName()))) return false; return false;
if (!(Objects.equals(otherChannel.quickPrefix(), this.quickPrefix()))) return false; }
if (!(Objects.equals(otherChannel.permission(), this.permission()))) return false;
if (otherChannel.radius() != this.radius()) return false; if (!(otherChannel.commandName().equals(this.commandName()))) {
return false;
}
if (!(Objects.equals(otherChannel.quickPrefix(), this.quickPrefix()))) {
return false;
}
if (!(Objects.equals(otherChannel.permission(), this.permission()))) {
return false;
}
if (otherChannel.radius() != this.radius()) {
return false;
}
return otherChannel.key().equals(this.key()); return otherChannel.key().equals(this.key());
} }
@@ -305,4 +319,5 @@ public final class ConfigChatChannel implements ChatChannel {
public int hashCode() { public int hashCode() {
return Objects.hash(this.commandName(), this.quickPrefix(), this.permission(), this.radius(), this.key()); return Objects.hash(this.commandName(), this.quickPrefix(), this.permission(), this.radius(), this.key());
} }
} }
@@ -123,7 +123,9 @@ public class NicknameCommand extends CarbonCommand {
@Nullable Component cached = null; @Nullable Component cached = null;
}; };
final Supplier<Component> lazyNickname = () -> { final Supplier<Component> lazyNickname = () -> {
if (ref.cached != null) return ref.cached; if (ref.cached != null) {
return ref.cached;
}
ref.cached = ConfigChatChannel.parseMessageTags(sender, handler.flags().get("nickname")); ref.cached = ConfigChatChannel.parseMessageTags(sender, handler.flags().get("nickname"));
return ref.cached; return ref.cached;
@@ -353,7 +353,9 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
@Override @Override
public boolean equals(final @Nullable Object other) { public boolean equals(final @Nullable Object other) {
if (other == null || this.getClass() != other.getClass()) return false; if (other == null || this.getClass() != other.getClass()) {
return false;
}
return this.uuid.equals(((CarbonPlayerCommon) other).uuid); return this.uuid.equals(((CarbonPlayerCommon) other).uuid);
} }
@@ -26,5 +26,7 @@ public final class DiscordRecipient implements Audience {
public static final DiscordRecipient INSTANCE = new DiscordRecipient(); public static final DiscordRecipient INSTANCE = new DiscordRecipient();
private DiscordRecipient() { private DiscordRecipient() {
} }
} }