Skip to content

Commit

Permalink
Address a few SonarCloud code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
willkroboth committed May 14, 2024
1 parent c2f4766 commit 804e68b
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public <Source> void buildBrigadierNode(
// Collect children into our own list
NodeInformation<CommandSender, Source> newPreviousNodeInformation = new NodeInformation<>(
previousNodeInformation.lastCommandNodes(),
children -> childrenNodeInformation.addAll(children)
childrenNodeInformation::addAll
);

// We need a new list so each branch acts independently
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ protected <Source> List<RegisteredCommand.Node<CommandSender>> createArgumentNod

// Create arguments
if (hasAnyArguments()) {
NodeInformation<CommandSender, Source> previousNodeInformation = new NodeInformation<>(List.of(rootNode), children -> childrenNodes.addAll(children));
NodeInformation<CommandSender, Source> previousNodeInformation = new NodeInformation<>(List.of(rootNode), childrenNodes::addAll);
List<Argument> previousArguments = new ArrayList<>();
List<String> previousArgumentNames = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected <Source> List<RegisteredCommand.Node<CommandSender>> createArgumentNod
// Build branches
for (AbstractArgumentTree<?, Argument, CommandSender> argument : arguments) {
// We need new previousArguments lists for each branch so they don't interfere
NodeInformation<CommandSender, Source> previousNodeInformation = new NodeInformation<>(List.of(rootNode), children -> childrenNodes.addAll(children));
NodeInformation<CommandSender, Source> previousNodeInformation = new NodeInformation<>(List.of(rootNode), childrenNodes::addAll);
List<Argument> previousArguments = new ArrayList<>();
List<String> previousArgumentNames = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public String getName() {
}

public PreviewableCommandNode<Source, T> build() {
final PreviewableCommandNode<Source, T> result = new PreviewableCommandNode<Source, T>(
final PreviewableCommandNode<Source, T> result = new PreviewableCommandNode<>(
previewableFunction, legacy, isListed,
getName(), getType(),
getCommand(), getRequirement(), getRedirect(), getRedirectModifier(), isFork(), getSuggestionsProvider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* An {@link CommandAPIHelpTopic} that can have its short description, full description, and usage edited.
*/
public class EditableHelpTopic<CommandSender> implements CommandAPIHelpTopic<CommandSender> {
private ShortDescriptionGenerator shortDescription = () -> Optional.empty();
private ShortDescriptionGenerator shortDescription = Optional::empty;
private FullDescriptionGenerator<CommandSender> fullDescription = forWho -> Optional.empty();
private UsageGenerator<CommandSender> usage = (forWho, argumentTree) -> Optional.empty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ inline fun CommandTree.lootTableArgument(nodeName: String, block: Argument<*>.()
inline fun CommandTree.mathOperationArgument(nodeName: String, block: Argument<*>.() -> Unit = {}): CommandTree = then(MathOperationArgument(nodeName).apply(block))
inline fun CommandTree.namespacedKeyArgument(nodeName: String, block: Argument<*>.() -> Unit = {}): CommandTree = then(NamespacedKeyArgument(nodeName).apply(block))
inline fun CommandTree.particleArgument(nodeName: String, block: Argument<*>.() -> Unit = {}): CommandTree = then(ParticleArgument(nodeName).apply(block))
inline fun CommandTree.potionEffectArgument(nodeName: String, useNamespacedKey: Boolean = false, optional: Boolean = false, block: Argument<*>.() -> Unit = {}): CommandTree =
inline fun CommandTree.potionEffectArgument(nodeName: String, useNamespacedKey: Boolean = false, block: Argument<*>.() -> Unit = {}): CommandTree =
if (useNamespacedKey) then(PotionEffectArgument.NamespacedKey(nodeName).apply(block)) else then(PotionEffectArgument(nodeName).apply(block))
inline fun CommandTree.recipeArgument(nodeName: String, block: Argument<*>.() -> Unit = {}): CommandTree = then(RecipeArgument(nodeName).apply(block))

Expand Down Expand Up @@ -188,7 +188,7 @@ inline fun Argument<*>.lootTableArgument(nodeName: String, block: Argument<*>.()
inline fun Argument<*>.mathOperationArgument(nodeName: String, block: Argument<*>.() -> Unit = {}): Argument<*> = then(MathOperationArgument(nodeName).apply(block))
inline fun Argument<*>.namespacedKeyArgument(nodeName: String, block: Argument<*>.() -> Unit = {}): Argument<*> = then(NamespacedKeyArgument(nodeName).apply(block))
inline fun Argument<*>.particleArgument(nodeName: String, block: Argument<*>.() -> Unit = {}): Argument<*> = then(ParticleArgument(nodeName).apply(block))
inline fun Argument<*>.potionEffectArgument(nodeName: String, useNamespacedKey: Boolean = false, optional: Boolean = false, block: Argument<*>.() -> Unit = {}): Argument<*> =
inline fun Argument<*>.potionEffectArgument(nodeName: String, useNamespacedKey: Boolean = false, block: Argument<*>.() -> Unit = {}): Argument<*> =
if (useNamespacedKey) then(PotionEffectArgument.NamespacedKey(nodeName).apply(block)) else then(PotionEffectArgument(nodeName).apply(block))
inline fun Argument<*>.recipeArgument(nodeName: String, block: Argument<*>.() -> Unit = {}): Argument<*> = then(RecipeArgument(nodeName).apply(block))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void executionTestWithLiteralArgumentListed() {
}

@Test
public void executionTestWithLiteralArgumentListedAndNodeName() {
void executionTestWithLiteralArgumentListedAndNodeName() {
Mut<String> results = Mut.of();

new CommandAPICommand("test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Tests for the {@link MultiLiteralArgument}
*/
public class ArgumentMultiLiteralTests extends TestBase {
class ArgumentMultiLiteralTests extends TestBase {

/*********
* Setup *
Expand Down

0 comments on commit 804e68b

Please sign in to comment.