Skip to content

Commit 14ed5f8

Browse files
Knut Anders Hatlentrondn
authored andcommitted
Fixed PMD warnings (Type: CollapsibleIfStatements)
1 parent e86a65c commit 14ed5f8

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/org/opensolaris/opengrok/analysis/TextAnalyzer.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,18 @@ public final void analyze(Document doc, InputStream in) throws IOException {
4040
byte[] head = new byte[3];
4141
int br = in.read(head, 0, 3);
4242

43-
if (br >= 2) {
44-
if ((head[0] == (byte)0xFE && head[1] == (byte)0xFF) || (head[0] == (byte)0xFF && (byte)head[1] == (byte)0xFE)) {
45-
charset = "UTF16";
46-
in.reset();
47-
}
48-
}
49-
if (br >= 3) {
50-
if (head[0] == (byte)0xEF && head[1] == (byte)0xBB && head[2] == (byte)0xBF) {
51-
/* InputStreamReader does not properly discard BOM on UTF8 streams,
52-
* so don't reset the stream. */
53-
charset = "UTF8";
54-
}
55-
}
56-
43+
if (br >= 2 &&
44+
(head[0] == (byte)0xFE && head[1] == (byte)0xFF) ||
45+
(head[0] == (byte)0xFF && head[1] == (byte)0xFE)) {
46+
charset = "UTF-16";
47+
in.reset();
48+
} else if (br >= 3 & head[0] == (byte)0xEF && head[1] == (byte)0xBB &&
49+
head[2] == (byte)0xBF) {
50+
// InputStreamReader does not properly discard BOM on UTF8 streams,
51+
// so don't reset the stream.
52+
charset = "UTF-8";
53+
}
54+
5755
if (charset == null) {
5856
in.reset();
5957
charset = Charset.defaultCharset().name();

0 commit comments

Comments
 (0)