client: update pmd

This commit is contained in:
Adam
2022-04-24 11:49:53 -04:00
parent 6a4544ed2e
commit 36730dccbc
23 changed files with 53 additions and 51 deletions

View File

@@ -53,13 +53,14 @@
<!-- code style --> <!-- code style -->
<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/> <rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/>
<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/> <rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/>
<rule ref="category/java/codestyle.xml/DontImportJavaLang"/>
<rule ref="category/java/codestyle.xml/ExtendsObject"/> <rule ref="category/java/codestyle.xml/ExtendsObject"/>
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/> <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/> <rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
<rule ref="category/java/codestyle.xml/PackageCase"/> <rule ref="category/java/codestyle.xml/PackageCase"/>
<rule ref="category/java/codestyle.xml/UnnecessaryCast"/> <rule ref="category/java/codestyle.xml/UnnecessaryCast"/>
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/> <rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" />
<rule ref="category/java/codestyle.xml/UnnecessaryImport" />
<rule ref="category/java/codestyle.xml/UnnecessaryModifier"/> <rule ref="category/java/codestyle.xml/UnnecessaryModifier"/>
<rule ref="category/java/codestyle.xml/UseDiamondOperator"/> <rule ref="category/java/codestyle.xml/UseDiamondOperator"/>
<rule ref="category/java/codestyle.xml/UseShortArrayInitializer"/> <rule ref="category/java/codestyle.xml/UseShortArrayInitializer"/>
@@ -84,18 +85,20 @@
<rule ref="category/java/errorprone.xml/EmptyIfStmt"/> <rule ref="category/java/errorprone.xml/EmptyIfStmt"/>
<rule ref="category/java/errorprone.xml/EmptyInitializer"/> <rule ref="category/java/errorprone.xml/EmptyInitializer"/>
<rule ref="category/java/errorprone.xml/EmptyStatementBlock"/> <rule ref="category/java/errorprone.xml/EmptyStatementBlock"/>
<rule ref="category/java/errorprone.xml/ImportFromSamePackage"/>
<rule ref="category/java/errorprone.xml/InstantiationToGetClass"/> <rule ref="category/java/errorprone.xml/InstantiationToGetClass"/>
<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/> <rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/>
<rule ref="category/java/errorprone.xml/JumbledIncrementer"/> <rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/> <rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/> <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/> <rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/>
<!-- performance --> <!-- performance -->
<rule ref="category/java/performance.xml/AppendCharacterWithChar"/> <rule ref="category/java/performance.xml/AppendCharacterWithChar"/>
<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/> <rule ref="category/java/performance.xml/ConsecutiveLiteralAppends">
<properties>
<property name="threshold" value="2"/>
</properties>
</rule>
<rule ref="category/java/performance.xml/InefficientStringBuffering"/> <rule ref="category/java/performance.xml/InefficientStringBuffering"/>
<rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation"/> <rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation"/>
</ruleset> </ruleset>

View File

@@ -462,17 +462,17 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId> <artifactId>maven-pmd-plugin</artifactId>
<version>3.13.0</version> <version>3.16.0</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>net.sourceforge.pmd</groupId> <groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId> <artifactId>pmd-core</artifactId>
<version>6.29.0</version> <version>6.44.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sourceforge.pmd</groupId> <groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId> <artifactId>pmd-java</artifactId>
<version>6.29.0</version> <version>6.44.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<configuration> <configuration>

View File

@@ -34,7 +34,7 @@ public class ChatMessageBuilder
public ChatMessageBuilder append(final ChatColorType type) public ChatMessageBuilder append(final ChatColorType type)
{ {
builder.append("<col").append(type.name()).append(">"); builder.append("<col").append(type.name()).append('>');
return this; return this;
} }

View File

@@ -447,7 +447,7 @@ class WidgetInspector extends DevToolsFrame
picker = parent.createChild(-1, WidgetType.GRAPHIC); picker = parent.createChild(-1, WidgetType.GRAPHIC);
log.info("Picker is {}.{} [{}]", WidgetInfo.TO_GROUP(picker.getId()), WidgetInfo.TO_CHILD(picker.getId()), picker.getIndex()); log.info("Picker is {}.{} [{}]", TO_GROUP(picker.getId()), TO_CHILD(picker.getId()), picker.getIndex());
picker.setSpriteId(SpriteID.MOBILE_FINGER_ON_INTERFACE); picker.setSpriteId(SpriteID.MOBILE_FINGER_ON_INTERFACE);
picker.setOriginalWidth(15); picker.setOriginalWidth(15);
@@ -521,7 +521,7 @@ class WidgetInspector extends DevToolsFrame
{ {
continue; continue;
} }
String name = WidgetInfo.TO_GROUP(entry.getParam1()) + "." + WidgetInfo.TO_CHILD(entry.getParam1()); String name = TO_GROUP(entry.getParam1()) + "." + TO_CHILD(entry.getParam1());
if (entry.getParam0() != -1) if (entry.getParam0() != -1)
{ {

View File

@@ -445,7 +445,7 @@ public class FishingPlugin extends Plugin
if (seconds < 10) if (seconds < 10)
{ {
trawlerText.append("0"); trawlerText.append('0');
} }
trawlerText.append(seconds); trawlerText.append(seconds);

View File

@@ -41,7 +41,6 @@ import jogamp.opengl.x11.glx.X11GLXContext;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.plugins.gpu.template.Template; import net.runelite.client.plugins.gpu.template.Template;
import net.runelite.client.util.OSType; import net.runelite.client.util.OSType;
import org.jocl.CL;
import static org.jocl.CL.*; import static org.jocl.CL.*;
import org.jocl.CLException; import org.jocl.CLException;
import org.jocl.Pointer; import org.jocl.Pointer;
@@ -96,7 +95,7 @@ class OpenCLManager
void init(GL4 gl) void init(GL4 gl)
{ {
CL.setExceptionsEnabled(true); setExceptionsEnabled(true);
switch (OSType.getOSType()) switch (OSType.getOSType())
{ {
@@ -121,55 +120,55 @@ class OpenCLManager
{ {
if (programUnordered != null) if (programUnordered != null)
{ {
CL.clReleaseProgram(programUnordered); clReleaseProgram(programUnordered);
programUnordered = null; programUnordered = null;
} }
if (programSmall != null) if (programSmall != null)
{ {
CL.clReleaseProgram(programSmall); clReleaseProgram(programSmall);
programSmall = null; programSmall = null;
} }
if (programLarge != null) if (programLarge != null)
{ {
CL.clReleaseProgram(programLarge); clReleaseProgram(programLarge);
programLarge = null; programLarge = null;
} }
if (kernelUnordered != null) if (kernelUnordered != null)
{ {
CL.clReleaseKernel(kernelUnordered); clReleaseKernel(kernelUnordered);
kernelUnordered = null; kernelUnordered = null;
} }
if (kernelSmall != null) if (kernelSmall != null)
{ {
CL.clReleaseKernel(kernelSmall); clReleaseKernel(kernelSmall);
kernelSmall = null; kernelSmall = null;
} }
if (kernelLarge != null) if (kernelLarge != null)
{ {
CL.clReleaseKernel(kernelLarge); clReleaseKernel(kernelLarge);
kernelLarge = null; kernelLarge = null;
} }
if (commandQueue != null) if (commandQueue != null)
{ {
CL.clReleaseCommandQueue(commandQueue); clReleaseCommandQueue(commandQueue);
commandQueue = null; commandQueue = null;
} }
if (context != null) if (context != null)
{ {
CL.clReleaseContext(context); clReleaseContext(context);
context = null; context = null;
} }
if (device != null) if (device != null)
{ {
CL.clReleaseDevice(device); clReleaseDevice(device);
device = null; device = null;
} }
} }

View File

@@ -829,7 +829,7 @@ public class GrandExchangePlugin extends Plugin
if (resetTime != null) if (resetTime != null)
{ {
Duration remaining = Duration.between(Instant.now(), resetTime); Duration remaining = Duration.between(Instant.now(), resetTime);
sb.append(" (").append(DurationFormatUtils.formatDuration(remaining.toMillis(), "H:mm")).append(")"); sb.append(" (").append(DurationFormatUtils.formatDuration(remaining.toMillis(), "H:mm")).append(')');
} }
} }

View File

@@ -246,7 +246,7 @@ public class GroundItemsOverlay extends Overlay
{ {
itemStringBuilder.append(" (") itemStringBuilder.append(" (")
.append(QuantityFormatter.quantityToStackSize(item.getQuantity())) .append(QuantityFormatter.quantityToStackSize(item.getQuantity()))
.append(")"); .append(')');
} }
} }

View File

@@ -663,7 +663,7 @@ public class GroundItemsPlugin extends Plugin
{ {
notificationStringBuilder.append(" (") notificationStringBuilder.append(" (")
.append(QuantityFormatter.quantityToStackSize(item.getQuantity())) .append(QuantityFormatter.quantityToStackSize(item.getQuantity()))
.append(")"); .append(')');
} }
} }

View File

@@ -173,7 +173,7 @@ public class ItemStatOverlay extends Overlay
Duration highestDuration = durationRange.getHighestDuration(); Duration highestDuration = durationRange.getHighestDuration();
if (lowestDuration != highestDuration) if (lowestDuration != highestDuration)
{ {
sb.append("~"); sb.append('~');
sb.append(DurationFormatUtils.formatDuration(highestDuration.toMillis(), "m:ss")); sb.append(DurationFormatUtils.formatDuration(highestDuration.toMillis(), "m:ss"));
} }
} }
@@ -381,7 +381,7 @@ public class ItemStatOverlay extends Overlay
{ {
if (config.relative()) if (config.relative())
{ {
b.append("/"); b.append('/');
} }
b.append(c.getFormattedTheoretical()); b.append(c.getFormattedTheoretical());
} }
@@ -397,9 +397,9 @@ public class ItemStatOverlay extends Overlay
if (config.absolute() && (config.relative() || config.theoretical())) if (config.absolute() && (config.relative() || config.theoretical()))
{ {
b.append(")"); b.append(')');
} }
b.append(" ").append(c.getStat().getName()); b.append(' ').append(c.getStat().getName());
b.append("</br>"); b.append("</br>");
return b.toString(); return b.toString();

View File

@@ -106,7 +106,7 @@ class Bookcase
b.append("Center"); b.append("Center");
} }
b.append(" "); b.append(' ');
switch (location.getPlane()) switch (location.getPlane())
{ {
@@ -123,7 +123,7 @@ class Bookcase
if (KourendLibraryPlugin.debug) if (KourendLibraryPlugin.debug)
{ {
b.append(" ").append(index.stream().map(Object::toString).collect(Collectors.joining(", "))); b.append(' ').append(index.stream().map(Object::toString).collect(Collectors.joining(", ")));
} }
return b.toString(); return b.toString();
} }

View File

@@ -79,7 +79,7 @@ class Library
Library() Library()
{ {
populateBooks(); populateBooks();
step = byIndex.size() / Book.values().length; step = byIndex.size() / values().length;
reset(); reset();
} }

View File

@@ -144,7 +144,7 @@ public class Raid
} }
else else
{ {
builder.append(" "); builder.append(' ');
} }
} }

View File

@@ -83,7 +83,7 @@ class RunEnergyOverlay extends Overlay
if (config.replaceOrbText()) if (config.replaceOrbText())
{ {
sb.append("Run Energy: ").append(client.getEnergy()).append("%"); sb.append("Run Energy: ").append(client.getEnergy()).append('%');
} }
else else
{ {

View File

@@ -106,7 +106,7 @@ public class RunepouchOverlay extends WidgetItemOverlay
tooltipBuilder tooltipBuilder
.append(amount) .append(amount)
.append(" ") .append(' ')
.append(ColorUtil.wrapWithColorTag(rune.getName(), Color.YELLOW)) .append(ColorUtil.wrapWithColorTag(rune.getName(), Color.YELLOW))
.append("</br>"); .append("</br>");

View File

@@ -855,7 +855,7 @@ public class SlayerPlugin extends Plugin
sb.append(task.getTask()); sb.append(task.getTask());
if (!Strings.isNullOrEmpty(task.getLocation())) if (!Strings.isNullOrEmpty(task.getLocation()))
{ {
sb.append(" (").append(task.getLocation()).append(")"); sb.append(" (").append(task.getLocation()).append(')');
} }
sb.append(": "); sb.append(": ");
if (killed < 0) if (killed < 0)

View File

@@ -82,7 +82,7 @@ public abstract class TabContentPanel extends JPanel
LocalDateTime currentTime = LocalDateTime.now(); LocalDateTime currentTime = LocalDateTime.now();
if (endTime.getDayOfWeek() != currentTime.getDayOfWeek()) if (endTime.getDayOfWeek() != currentTime.getDayOfWeek())
{ {
sb.append(endTime.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.getDefault())).append(" "); sb.append(endTime.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.getDefault())).append(' ');
} }
sb.append("at "); sb.append("at ");
sb.append(formatter.format(endTime)); sb.append(formatter.format(endTime));

View File

@@ -187,8 +187,8 @@ public class TimeTrackingPlugin extends Plugin
{ {
if (commandExecuted.getCommand().equals("resetfarmtick")) if (commandExecuted.getCommand().equals("resetfarmtick"))
{ {
configManager.unsetRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.FARM_TICK_OFFSET_PRECISION); configManager.unsetRSProfileConfiguration(CONFIG_GROUP, TimeTrackingConfig.FARM_TICK_OFFSET_PRECISION);
configManager.unsetRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.FARM_TICK_OFFSET); configManager.unsetRSProfileConfiguration(CONFIG_GROUP, TimeTrackingConfig.FARM_TICK_OFFSET);
} }
} }

View File

@@ -550,7 +550,7 @@ public class FarmingTracker
// Same RS account but different profile type // Same RS account but different profile type
if (profileType != RuneScapeProfileType.getCurrent(client)) if (profileType != RuneScapeProfileType.getCurrent(client))
{ {
stringBuilder.append("(") stringBuilder.append('(')
.append(Text.titleCase(profile.getType())) .append(Text.titleCase(profile.getType()))
.append(") "); .append(") ");
} }
@@ -564,13 +564,13 @@ public class FarmingTracker
//Don't print profile type when logged out if is STANDARD //Don't print profile type when logged out if is STANDARD
if (client.getGameState() == GameState.LOGIN_SCREEN && profileType == RuneScapeProfileType.STANDARD) if (client.getGameState() == GameState.LOGIN_SCREEN && profileType == RuneScapeProfileType.STANDARD)
{ {
stringBuilder.append("(") stringBuilder.append('(')
.append(profile.getDisplayName()) .append(profile.getDisplayName())
.append(") "); .append(") ");
} }
else else
{ {
stringBuilder.append("(") stringBuilder.append('(')
.append(profile.getDisplayName()) .append(profile.getDisplayName())
.append(" - ") .append(" - ")
.append(Text.titleCase(profile.getType())) .append(Text.titleCase(profile.getType()))
@@ -580,7 +580,7 @@ public class FarmingTracker
// Different RS account but same profile type // Different RS account but same profile type
else else
{ {
stringBuilder.append("(") stringBuilder.append('(')
.append(profile.getDisplayName()) .append(profile.getDisplayName())
.append(") "); .append(") ");
} }
@@ -616,7 +616,7 @@ public class FarmingTracker
stringBuilder.append(patch.getRegion().isDefinite() ? "the " : "") stringBuilder.append(patch.getRegion().isDefinite() ? "the " : "")
.append(patch.getRegion().getName()) .append(patch.getRegion().getName())
.append("."); .append('.');
notifier.notify(stringBuilder.toString()); notifier.notify(stringBuilder.toString());
} }

View File

@@ -100,7 +100,7 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
return; return;
} }
try try // NOPMD: UseTryWithResources
{ {
register(username, password); register(username, password);
join(channel); join(channel);

View File

@@ -105,7 +105,7 @@ public class OverlayUtil
public static void renderImageLocation(Client client, Graphics2D graphics, LocalPoint localPoint, BufferedImage image, int zOffset) public static void renderImageLocation(Client client, Graphics2D graphics, LocalPoint localPoint, BufferedImage image, int zOffset)
{ {
net.runelite.api.Point imageLocation = Perspective.getCanvasImageLocation(client, localPoint, image, zOffset); Point imageLocation = Perspective.getCanvasImageLocation(client, localPoint, image, zOffset);
if (imageLocation != null) if (imageLocation != null)
{ {
renderImageLocation(graphics, imageLocation, image); renderImageLocation(graphics, imageLocation, image);
@@ -182,7 +182,7 @@ public class OverlayUtil
renderImageLocation(client, graphics, localLocation, image, 0); renderImageLocation(client, graphics, localLocation, image, 0);
} }
public static void renderHoverableArea(Graphics2D graphics, Shape area, net.runelite.api.Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor) public static void renderHoverableArea(Graphics2D graphics, Shape area, Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor)
{ {
if (area != null) if (area != null)
{ {

View File

@@ -182,12 +182,12 @@ public class LineComponent implements LayoutableRenderableEntity
if (wordLen + spaceWidth > spaceLeft) if (wordLen + spaceWidth > spaceLeft)
{ {
wrapped.append("\n").append(word); wrapped.append('\n').append(word);
spaceLeft = maxWidth - wordLen; spaceLeft = maxWidth - wordLen;
} }
else else
{ {
wrapped.append(" ").append(word); wrapped.append(' ').append(word);
spaceLeft -= spaceWidth + wordLen; spaceLeft -= spaceWidth + wordLen;
} }
} }

View File

@@ -40,11 +40,11 @@ public class WorldUtil
*/ */
public static EnumSet<WorldType> toWorldTypes(final EnumSet<net.runelite.http.api.worlds.WorldType> apiTypes) public static EnumSet<WorldType> toWorldTypes(final EnumSet<net.runelite.http.api.worlds.WorldType> apiTypes)
{ {
final EnumSet<net.runelite.api.WorldType> types = EnumSet.noneOf(net.runelite.api.WorldType.class); final EnumSet<WorldType> types = EnumSet.noneOf(WorldType.class);
for (net.runelite.http.api.worlds.WorldType apiType : apiTypes) for (net.runelite.http.api.worlds.WorldType apiType : apiTypes)
{ {
types.add(net.runelite.api.WorldType.valueOf(apiType.name())); types.add(WorldType.valueOf(apiType.name()));
} }
return types; return types;