From 227135b3ac4182cb920f93177f61295a1d4221d5 Mon Sep 17 00:00:00 2001 From: Michal Kordas Date: Wed, 19 Aug 2015 18:07:51 +0200 Subject: [PATCH] Remove unused assignments. #1555 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes `UnusedAssignment` inspection violations in test code. Description: >This inspection points out the cases where a variable value is never used after its assignment, i.e.:   - the variable never gets read after assignment OR   - the value is always overwritten with another assignment before the next variable read OR   - the variable initializer is redundant (for one of the above two reasons) OR   - the variable is never used. --- .../tools/checkstyle/checks/header/RegexpHeaderCheckTest.java | 2 -- .../tools/checkstyle/filters/SuppressionsLoaderTest.java | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheckTest.java index 9e319d36d..9666e234b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheckTest.java @@ -59,7 +59,6 @@ public class RegexpHeaderCheckTest extends BaseFileSetCheckTestSupport { // check null passes RegexpHeaderCheck instance = new RegexpHeaderCheck(); // check empty string passes - instance = new RegexpHeaderCheck(); String header = ""; instance.setHeader(header); } @@ -71,7 +70,6 @@ public class RegexpHeaderCheckTest extends BaseFileSetCheckTestSupport { public void testSetHeaderSimple() { RegexpHeaderCheck instance = new RegexpHeaderCheck(); // check valid header passes - instance = new RegexpHeaderCheck(); String header = "abc.*"; instance.setHeader(header); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java index 9167195d5..a817dd3d0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java @@ -185,8 +185,7 @@ public class SuppressionsLoaderTest extends BaseCheckTestSupport { try { URL url = new URL("http://checkstyle.sourceforge.net/"); HttpURLConnection urlConnect = (HttpURLConnection) url.openConnection(); - @SuppressWarnings("unused") - Object objData = urlConnect.getContent(); + urlConnect.getContent(); } catch (IOException e) { return false;