Skip to content

Commit 024f556

Browse files
committed
IDE warning cleanup
1 parent 42e7d5f commit 024f556

22 files changed

+934
-901
lines changed

src/test/java/org/owasp/html/AntiSamyTest.java

Lines changed: 812 additions & 811 deletions
Large diffs are not rendered by default.

src/test/java/org/owasp/html/Benchmark.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,16 @@
4141

4242
import nu.validator.htmlparser.dom.HtmlDocumentBuilder;
4343

44+
/**
45+
* An executable that benchmarks the sanitizer against an alternative.
46+
*/
4447
public class Benchmark {
4548

49+
/**
50+
* By default times all alternatives.
51+
* If there is an input of the form {@code /[hsp]+/} then each letter
52+
* specifies a benchmark to run and unspecified ones are not run.
53+
*/
4654
public static void main(String[] args) throws Exception {
4755
String html = Files.toString(new File(args[0]), Charsets.UTF_8);
4856

@@ -129,7 +137,7 @@ private static int parseUsingLibhtmlparser(String html) throws Exception {
129137
return System.identityHashCode(node) >> 24;
130138
}
131139

132-
private static String sanitize(String html) throws Exception {
140+
private static String sanitize(String html) {
133141
StringBuilder sb = new StringBuilder(html.length());
134142

135143
final HtmlStreamRenderer renderer = HtmlStreamRenderer.create(
@@ -181,8 +189,7 @@ public void closeTag(String elementName) {
181189

182190
private static HtmlPolicyBuilder policyBuilder;
183191

184-
private static String sanitizeUsingPolicyBuilder(String html)
185-
throws Exception {
192+
private static String sanitizeUsingPolicyBuilder(String html) {
186193
if (policyBuilder == null) {
187194
policyBuilder = new HtmlPolicyBuilder()
188195
.allowStandardUrlProtocols()

src/test/java/org/owasp/html/CssFuzzerTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import com.google.common.collect.Maps;
4040

41+
@SuppressWarnings("javadoc")
4142
public class CssFuzzerTest extends FuzzyTestCase {
4243

4344
private static final String[] TOKEN_PARTS = new String[] {
@@ -65,9 +66,7 @@ public void run() {
6566
try {
6667
while (true) {
6768
this.wait(1000 /* ms = 1s */);
68-
String input = this.input;
6969
if (input == null) { break; } // Done
70-
long started = this.started;
7170
long now = System.nanoTime();
7271
if (now - started >= 1000000000L /* ns = 1s */) {
7372
System.err.println(
@@ -76,6 +75,7 @@ public void run() {
7675
}
7776
} catch (InterruptedException ex) {
7877
// Done
78+
ignore(ex);
7979
}
8080
}
8181
}
@@ -303,4 +303,9 @@ static String fixDigitSpaceUnit(CssTokens tokens) {
303303
}
304304
return sb.toString();
305305
}
306+
307+
/** @param o ignored */
308+
static void ignore(Object o) {
309+
// Do nothing.
310+
}
306311
}

src/test/java/org/owasp/html/CssGrammarTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737

3838
import junit.framework.TestCase;
3939

40+
@SuppressWarnings("javadoc")
4041
public class CssGrammarTest extends TestCase {
4142
@Test
42-
public static final void testLex() throws Exception {
43+
public static final void testLex() {
4344
CssTokens tokens = CssTokens.lex(Joiner.on('\n').join(
4445
"/* A comment */",
4546
"words with-dashes #hashes .dots. -and-leading-dashes",

src/test/java/org/owasp/html/CssSchemaTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import junit.framework.TestCase;
3636

37+
@SuppressWarnings("javadoc")
3738
public final class CssSchemaTest extends TestCase {
3839

3940
@Test

src/test/java/org/owasp/html/CssTokensTest.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
import static org.owasp.html.CssTokens.TokenType.*;
4242

43+
@SuppressWarnings({ "javadoc" })
4344
public class CssTokensTest extends TestCase {
4445

4546
private static CssTokens lex(String s) {
@@ -81,15 +82,15 @@ public static final void testBracketIndices() {
8182
}
8283

8384
@Test
84-
public static final void testStringEscaping() throws Exception {
85+
public static final void testStringEscaping() {
8586
// input golden
8687
String[] tests = {
8788
"''", "''",
8889
"\"\"", "''",
8990
"\"\\a\"", "'\\a'",
9091
"\"\\0d\\0a\"", "'\\d\\a'",
9192
"'\\000000d'", "'\\0 d'", // too many hex digits
92-
"'\\1fffff'", "'\ufffd'", // exceeeds max codepoint
93+
"'\\1fffff'", "'\ufffd'", // exceeds max codepoint
9394
"\"'\"", "'\\27'",
9495
"\"\\\"\"", "'\\22'",
9596
"'\\\\'", "'\\\\'",
@@ -128,7 +129,7 @@ public static final void testStringEscaping() throws Exception {
128129
}
129130

130131
@Test
131-
public static final void testComments() throws Exception {
132+
public static final void testComments() {
132133
assertEquals(
133134
"a b c d e f g h",
134135
lex(
@@ -137,12 +138,12 @@ public static final void testComments() throws Exception {
137138
}
138139

139140
@Test
140-
public static final void testNonCommentSlash() throws Exception {
141+
public static final void testNonCommentSlash() {
141142
assertEquals("foo/ bar/", lex("foo/bar/").normalizedCss);
142143
}
143144

144145
@Test
145-
public static final void testCdoCdc() throws Exception {
146+
public static final void testCdoCdc() {
146147
assertEquals(
147148
"|| and are ignorable||",
148149
lex("||<!-- and --> are ignorable||").normalizedCss);
@@ -152,7 +153,7 @@ public static final void testCdoCdc() throws Exception {
152153
}
153154

154155
@Test
155-
public static final void testIdentReencoding() throws Exception {
156+
public static final void testIdentReencoding() {
156157
// input golden
157158
String[] tests = {
158159
"\\", null,
@@ -222,12 +223,12 @@ public static final void testIdentReencoding() throws Exception {
222223
}
223224

224225
@Test
225-
public static final void testOrphanedCloseBrackets() throws Exception {
226+
public static final void testOrphanedCloseBrackets() {
226227
assertEquals("{foo bar}", lex("{foo]bar").normalizedCss);
227228
}
228229

229230
@Test
230-
public static final void testAtDirectives() throws Exception {
231+
public static final void testAtDirectives() {
231232
assertTokens(
232233
"@import \"foo/bar\"; @ at, @34",
233234
"@import:AT", " ", "'foo/bar':STRING", ";:SEMICOLON",
@@ -236,7 +237,7 @@ public static final void testAtDirectives() throws Exception {
236237
}
237238

238239
@Test
239-
public static final void testHash() throws Exception {
240+
public static final void testHash() {
240241
assertTokens(
241242
"#fff #foo #-moz-foo #abcd #abcdef #012f34 #888 #42foo # #",
242243
"#fff:HASH_UNRESTRICTED", " ",
@@ -251,7 +252,7 @@ public static final void testHash() throws Exception {
251252
}
252253

253254
@Test
254-
public static final void testSignsAndDots() throws Exception {
255+
public static final void testSignsAndDots() {
255256
assertTokens(
256257
"- . + +1 + 1 (1 + 1)--> .5 -.5 +.5 ++.5 .foo -",
257258
"-:IDENT", " ", ".:DELIM", " ", "+:DELIM", " ", "1:NUMBER", " ",
@@ -262,7 +263,7 @@ public static final void testSignsAndDots() throws Exception {
262263
// TODO: is a single "-" an IDENT or a DELIM? "--"? "---"?
263264
}
264265

265-
public static final void testMultiCharPunctuation() throws Exception {
266+
public static final void testMultiCharPunctuation() {
266267
assertTokens(
267268
"|| ~= === |= =^= $= *= = : % & ~",
268269
"||:COLUMN", " ", "~=:MATCH", " ", "=:DELIM", "=:DELIM", "=:DELIM", " ",
@@ -272,13 +273,13 @@ public static final void testMultiCharPunctuation() throws Exception {
272273
}
273274

274275
@Test
275-
public static final void testNul() throws Exception {
276+
public static final void testNul() {
276277
assertTokens("\u0000");
277278
assertTokens("\u0000x\u0000", "x:IDENT");
278279
}
279280

280281
@Test
281-
public static final void testNumbers() throws Exception {
282+
public static final void testNumbers() {
282283
assertTokens(
283284
"0 -0 +0 0.0 -0.0 -.0 0e12 0e-12 0e+12",
284285
"0:NUMBER", " ",
@@ -314,7 +315,7 @@ public static final void testNumbers() throws Exception {
314315
}
315316

316317
@Test
317-
public static final void testUrls() throws Exception {
318+
public static final void testUrls() {
318319
assertTokens(
319320
"url() url('..')url( \"foo\" ) URL( f\"/(bar'\\\\baz ) url('foo \\a b')"
320321
+ "Url( \u0080\u1234\ud801\udc02\\110000)",
@@ -328,7 +329,7 @@ public static final void testUrls() throws Exception {
328329
}
329330

330331
@Test
331-
public static final void testFunctions() throws Exception {
332+
public static final void testFunctions() {
332333
assertTokens("( rgb(0,0,0) rgba(0,50%,0,100%)",
333334
"(:LEFT_PAREN",
334335
" ",

src/test/java/org/owasp/html/ElementPolicyTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import static org.owasp.html.ElementPolicy.IDENTITY_ELEMENT_POLICY;
1717
import static org.owasp.html.ElementPolicy.Util.join;
1818

19+
@SuppressWarnings("javadoc")
1920
public final class ElementPolicyTest extends TestCase {
2021

2122
static class HasCharElementPolicy implements ElementPolicy {

src/test/java/org/owasp/html/EncodingTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
import junit.framework.TestCase;
3434

35-
public class EncodingTest extends TestCase {
35+
@SuppressWarnings("javadoc")
36+
public final class EncodingTest extends TestCase {
3637

3738
@Test
3839
public static final void testDecodeHtml() {

src/test/java/org/owasp/html/ExamplesTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import junit.framework.TestCase;
4343

44+
@SuppressWarnings("javadoc")
4445
public class ExamplesTest extends TestCase {
4546
@Test
4647
public static final void testExamplesRun() throws Exception {

src/test/java/org/owasp/html/FuzzyTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* If you see a failure, please report it along with the seed from the output.
3939
* If you want to repeat a failure, set the system property "junit.seed".
4040
*
41-
* @author Mike Samuel <[email protected]>
41+
* @author Mike Samuel ([email protected])
4242
*/
4343
abstract class FuzzyTestCase extends TestCase {
4444

0 commit comments

Comments
 (0)