Skip to content

Commit 7483fa4

Browse files
author
Vladimir Kotal
authored
fix more Sonar issues in Eftar (#3813)
* fix more Sonar issues * fix javadoc
1 parent 007bf26 commit 7483fa4

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/EftarFile.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@
3535
* An Extremely Fast Tagged Attribute Read-only File System.
3636
* Created on October 12, 2005
3737
*
38-
* A Eftar File has the following format
38+
* <i>Eftar</i> File has the following format
39+
* <code>
3940
* FILE --&gt; Record ( Record | tagString ) *
41+
* <br>
4042
* Record --&gt; 64bit:Hash 16bit:childrenOffset 16bit:(numberChildren|lenthOfTag) 16bit:tagOffset
43+
* </code>
4144
*
42-
* It is a tree of tagged names,
43-
* doing binary search in sorted list of children
45+
* It is a tree of tagged names, doing binary search in sorted list of children
4446
*
4547
* @author Chandan
4648
*/
@@ -52,11 +54,11 @@ public class EftarFile {
5254

5355
static class Node {
5456

55-
public long hash;
56-
public String tag;
57-
public Map<Long, Node> children;
58-
public long tagOffset;
59-
public long childOffset;
57+
private final long hash;
58+
private String tag;
59+
private final Map<Long, Node> children;
60+
private long tagOffset;
61+
private long childOffset;
6062

6163
Node(long hash, String tag) {
6264
this.hash = hash;
@@ -65,10 +67,7 @@ static class Node {
6567
}
6668

6769
public Node put(long hash, String desc) {
68-
if (children.get(hash) == null) {
69-
children.put(hash, new Node(hash, desc));
70-
}
71-
return children.get(hash);
70+
return children.computeIfAbsent(hash, newNode -> new Node(hash, desc));
7271
}
7372

7473
public Node get(long hash) {

opengrok-indexer/src/test/java/org/opengrok/indexer/web/EftarFileTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static void tearDownClass() {
7474
* @throws IOException if an error occurs while accessing the eftar file
7575
*/
7676
@Test
77-
public void searchEftarFile() throws IOException {
77+
void searchEftarFile() throws IOException {
7878
searchEftarFile(new EftarFileReader(eftar));
7979
searchEftarFile(new EftarFileReader(eftar.getAbsolutePath()));
8080
}

0 commit comments

Comments
 (0)