Merge pull request #8080 from chivesrs/fix-checkstyle-errors

Fix CheckStyle issues and enable CheckStyle in test code.
This commit is contained in:
Adam
2019-03-04 15:17:12 -05:00
committed by GitHub
10 changed files with 21 additions and 19 deletions

View File

@@ -26,7 +26,6 @@
package net.runelite.http.service.hiscore; package net.runelite.http.service.hiscore;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.ExecutionException;
import net.runelite.http.api.hiscore.HiscoreResult; import net.runelite.http.api.hiscore.HiscoreResult;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;

View File

@@ -219,6 +219,7 @@
<configLocation>checkstyle.xml</configLocation> <configLocation>checkstyle.xml</configLocation>
<!-- exclude generated sources from checkstyle https://stackoverflow.com/a/30406454/7189686 --> <!-- exclude generated sources from checkstyle https://stackoverflow.com/a/30406454/7189686 -->
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@@ -342,7 +342,8 @@ public class ItemVariationMappingTest
@Test @Test
public void testMappedNames() public void testMappedNames()
{ {
ITEMS_MAP.forEach((key, value) -> { ITEMS_MAP.forEach((key, value) ->
{
assertEquals(value, (Integer) ItemVariationMapping.map(key)); assertEquals(value, (Integer) ItemVariationMapping.map(key));
}); });
} }

View File

@@ -35,15 +35,11 @@ import net.runelite.api.Item;
import net.runelite.api.ItemComposition; import net.runelite.api.ItemComposition;
import net.runelite.api.ItemContainer; import net.runelite.api.ItemContainer;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import net.runelite.api.queries.BankItemQuery;
import net.runelite.api.widgets.WidgetItem;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.util.QueryRunner;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static org.mockito.Matchers.any;
import org.mockito.Mock; import org.mockito.Mock;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@@ -116,4 +112,4 @@ public class BankCalculationTest
long value = bankCalculation.getHaPrice(); long value = bankCalculation.getHaPrice();
assertTrue(value > Integer.MAX_VALUE); assertTrue(value > Integer.MAX_VALUE);
} }
} }

View File

@@ -64,7 +64,8 @@ public class CombatLevelPluginTest
when(client.getLocalPlayer()).thenReturn(player); when(client.getLocalPlayer()).thenReturn(player);
} }
private HashMap<String, Double> getBaseValues() { private HashMap<String, Double> getBaseValues()
{
int attackLevel = client.getRealSkillLevel(Skill.ATTACK); int attackLevel = client.getRealSkillLevel(Skill.ATTACK);
int strengthLevel = client.getRealSkillLevel(Skill.STRENGTH); int strengthLevel = client.getRealSkillLevel(Skill.STRENGTH);
int defenceLevel = client.getRealSkillLevel(Skill.DEFENCE); int defenceLevel = client.getRealSkillLevel(Skill.DEFENCE);

View File

@@ -31,7 +31,8 @@ public class HiscorePanelTest
@Test @Test
public void testConstructor() public void testConstructor()
{ {
new HiscorePanel(new HiscoreConfig() {}); new HiscorePanel(new HiscoreConfig()
{
});
} }
} }

View File

@@ -25,7 +25,6 @@
package net.runelite.client.plugins.timetracking.clocks; package net.runelite.client.plugins.timetracking.clocks;
import java.time.format.DateTimeParseException; import java.time.format.DateTimeParseException;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;

View File

@@ -27,7 +27,6 @@ package net.runelite.client.ui.overlay.components;
import java.awt.Color; import java.awt.Color;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -85,4 +84,4 @@ public class TextComponentTest
verify(graphics, atLeastOnce()).setColor(Color.BLUE); verify(graphics, atLeastOnce()).setColor(Color.BLUE);
verify(graphics, atLeastOnce()).setColor(Color.GREEN); verify(graphics, atLeastOnce()).setColor(Color.GREEN);
} }
} }

View File

@@ -49,7 +49,8 @@ public class ColorUtilTest
@Test @Test
public void colorTag() public void colorTag()
{ {
COLOR_HEXSTRING_MAP.forEach((color, hex) -> { COLOR_HEXSTRING_MAP.forEach((color, hex) ->
{
assertEquals("<col=" + hex + ">", ColorUtil.colorTag(color)); assertEquals("<col=" + hex + ">", ColorUtil.colorTag(color));
}); });
} }
@@ -57,7 +58,8 @@ public class ColorUtilTest
@Test @Test
public void prependColorTag() public void prependColorTag()
{ {
COLOR_HEXSTRING_MAP.forEach((color, hex) -> { COLOR_HEXSTRING_MAP.forEach((color, hex) ->
{
assertEquals("<col=" + hex + ">test", ColorUtil.prependColorTag("test", color)); assertEquals("<col=" + hex + ">test", ColorUtil.prependColorTag("test", color));
assertEquals("<col=" + hex + ">", ColorUtil.prependColorTag("", color)); assertEquals("<col=" + hex + ">", ColorUtil.prependColorTag("", color));
}); });
@@ -68,7 +70,8 @@ public class ColorUtilTest
@Test @Test
public void wrapWithColorTag() public void wrapWithColorTag()
{ {
COLOR_HEXSTRING_MAP.forEach((color, hex) -> { COLOR_HEXSTRING_MAP.forEach((color, hex) ->
{
assertEquals("<col=" + hex + ">test</col>", ColorUtil.wrapWithColorTag("test", color)); assertEquals("<col=" + hex + ">test</col>", ColorUtil.wrapWithColorTag("test", color));
assertEquals("<col=" + hex + "></col>", ColorUtil.wrapWithColorTag("", color)); assertEquals("<col=" + hex + "></col>", ColorUtil.wrapWithColorTag("", color));
}); });
@@ -77,7 +80,8 @@ public class ColorUtilTest
@Test @Test
public void toHexColor() public void toHexColor()
{ {
COLOR_HEXSTRING_MAP.forEach((color, hex) -> { COLOR_HEXSTRING_MAP.forEach((color, hex) ->
{
assertEquals("#" + hex, ColorUtil.toHexColor(color)); assertEquals("#" + hex, ColorUtil.toHexColor(color));
}); });
} }
@@ -94,7 +98,8 @@ public class ColorUtilTest
@Test @Test
public void colorToHexCode() public void colorToHexCode()
{ {
COLOR_HEXSTRING_MAP.forEach((color, hex) -> { COLOR_HEXSTRING_MAP.forEach((color, hex) ->
{
assertEquals(hex, ColorUtil.colorToHexCode(color)); assertEquals(hex, ColorUtil.colorToHexCode(color));
}); });
} }

View File

@@ -304,7 +304,7 @@ public class ImageUtilTest
// outlineImage(BufferedImage image, Color color, Predicate<Color> fillCondition, Boolean outlineCorners) // outlineImage(BufferedImage image, Color color, Predicate<Color> fillCondition, Boolean outlineCorners)
test = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB); test = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
test.setRGB(2, 2, BLACK.getRGB()); test.setRGB(2, 2, BLACK.getRGB());
test.setRGB(1,2, new Color(50, 50, 50).getRGB()); test.setRGB(1, 2, new Color(50, 50, 50).getRGB());
test.setRGB(3, 2, new Color(100, 100, 100).getRGB()); test.setRGB(3, 2, new Color(100, 100, 100).getRGB());
test.setRGB(2, 3, new Color(150, 150, 150).getRGB()); test.setRGB(2, 3, new Color(150, 150, 150).getRGB());
expected = test; expected = test;