Skip to content

Commit eec5b97

Browse files
junit and docker file sonar issue fixes (#4447)
--------- Signed-off-by: Gino Augustine <[email protected]> Co-authored-by: Vladimir Kotal <[email protected]>
1 parent d5fd3ef commit eec5b97

File tree

78 files changed

+291
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+291
-235
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved.
22
# Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
33

4-
FROM ubuntu:jammy as build
4+
FROM ubuntu:jammy AS build
55

66
# hadolint ignore=DL3008
77
RUN apt-get update && apt-get install --no-install-recommends -y openjdk-17-jdk python3 python3-venv && \

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/PendingTokenTest.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
package org.opengrok.indexer.analysis;
2525

2626
import org.junit.jupiter.api.Test;
27+
import org.junit.jupiter.params.ParameterizedTest;
28+
import org.junit.jupiter.params.provider.MethodSource;
29+
30+
import java.util.stream.Stream;
2731

2832
import static org.junit.jupiter.api.Assertions.assertEquals;
2933
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -50,28 +54,17 @@ void testEquals2() {
5054
assertTrue(result, "PendingToken instance equivalence false");
5155
}
5256

53-
@Test
54-
void testNotEquals1() {
55-
PendingToken instance1 = new PendingToken("", 0, 0);
56-
PendingToken instance2 = new PendingToken("", 0, 1); // nonsense but ok
57-
boolean result = instance1.equals(instance2);
58-
assertFalse(result, "PendingToken equals() only 2 immutables match");
59-
}
60-
61-
@Test
62-
void testNotEquals2() {
57+
@ParameterizedTest
58+
@MethodSource
59+
void testNotEquals(PendingToken instance2) {
6360
PendingToken instance1 = new PendingToken("", 0, 0);
64-
PendingToken instance2 = new PendingToken("", 1, 0); // nonsense but ok
6561
boolean result = instance1.equals(instance2);
6662
assertFalse(result, "PendingToken equals() only 2 immutables match");
6763
}
68-
69-
@Test
70-
void testNotEquals3() {
71-
PendingToken instance1 = new PendingToken("", 0, 0);
72-
PendingToken instance2 = new PendingToken("a", 0, 0); // nonsense but ok
73-
boolean result = instance1.equals(instance2);
74-
assertFalse(result, "PendingToken equals() only 2 immutables match");
64+
static Stream<PendingToken> testNotEquals() {
65+
return Stream.of(new PendingToken("", 0, 1),
66+
new PendingToken("", 1, 0),
67+
new PendingToken("a", 0, 0));
7568
}
7669

7770
@Test

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/ScopesTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ void testGetScope() {
5050
instance.addScope(new Scope(80, 90, "scope5", "ns"));
5151
instance.addScope(new Scope(91, 100, "scope6", "ns"));
5252

53-
assertEquals(instance.size(), 6);
54-
assertEquals(instance.getScope(1), globalScope);
55-
assertEquals(instance.getScope(10).getName(), "scope1");
56-
assertEquals(instance.getScope(15).getName(), "scope1");
57-
assertEquals(instance.getScope(20).getName(), "scope1");
58-
assertEquals(instance.getScope(21), globalScope);
59-
assertEquals(instance.getScope(24), globalScope);
60-
assertEquals(instance.getScope(39), globalScope);
61-
assertEquals(instance.getScope(40).getName(), "scope3");
62-
assertEquals(instance.getScope(41), globalScope);
63-
assertEquals(instance.getScope(90).getName(), "scope5");
64-
assertEquals(instance.getScope(100).getName(), "scope6");
65-
assertEquals(instance.getScope(101), globalScope);
66-
assertEquals(instance.getScope(500), globalScope);
53+
assertEquals(6, instance.size());
54+
assertEquals(globalScope, instance.getScope(1));
55+
assertEquals("scope1", instance.getScope(10).getName());
56+
assertEquals("scope1", instance.getScope(15).getName());
57+
assertEquals("scope1", instance.getScope(20).getName());
58+
assertEquals(globalScope, instance.getScope(21));
59+
assertEquals(globalScope, instance.getScope(24));
60+
assertEquals(globalScope, instance.getScope(39));
61+
assertEquals("scope3", instance.getScope(40).getName());
62+
assertEquals(globalScope, instance.getScope(41));
63+
assertEquals("scope5", instance.getScope(90).getName());
64+
assertEquals("scope6", instance.getScope(100).getName());
65+
assertEquals(globalScope, instance.getScope(101));
66+
assertEquals(globalScope, instance.getScope(500));
6767
}
6868

6969
@Test

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/ada/AdaXrefTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
class AdaXrefTest extends XrefTestBase {
3434

3535
@Test
36+
@SuppressWarnings("squid:S2699")
3637
void sampleTest() throws IOException {
3738
writeAndCompare(new AdaAnalyzerFactory(),
3839
"analysis/ada/sample.adb",

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/c/CXrefTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
class CXrefTest extends XrefTestBase {
3636

3737
@Test
38+
@SuppressWarnings("squid:S2699")
3839
void sampleTest() throws IOException {
3940
writeAndCompare(new CAnalyzerFactory(),
4041
"analysis/c/sample.c",

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/c/CxxXrefTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
class CxxXrefTest extends XrefTestBase {
3636

3737
@Test
38+
@SuppressWarnings("squid:S2699")
3839
void sampleTest() throws IOException {
3940
writeAndCompare(new CxxAnalyzerFactory(),
4041
"analysis/c/sample.cc",

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/clojure/ClojureXrefTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
class ClojureXrefTest extends XrefTestBase {
3636

3737
@Test
38+
@SuppressWarnings("squid:S2699")
3839
void sampleTest() throws IOException {
3940
writeAndCompare(new ClojureAnalyzerFactory(),
4041
"analysis/clojure/sample.clj",
@@ -43,6 +44,7 @@ void sampleTest() throws IOException {
4344
}
4445

4546
@Test
47+
@SuppressWarnings("squid:S2699")
4648
void shouldCloseTruncatedStringSpan() throws IOException {
4749
writeAndCompare(new ClojureAnalyzerFactory(),
4850
"analysis/clojure/truncated.clj",

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/csharp/CSharpXrefTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
class CSharpXrefTest extends XrefTestBase {
3636

3737
@Test
38+
@SuppressWarnings("squid:S2699")
3839
void sampleTest() throws IOException {
3940
writeAndCompare(new CSharpAnalyzerFactory(),
4041
"analysis/csharp/sample.cs",
@@ -43,6 +44,7 @@ void sampleTest() throws IOException {
4344
}
4445

4546
@Test
47+
@SuppressWarnings("squid:S2699")
4648
void shouldCloseTruncatedStringSpan() throws IOException {
4749
writeAndCompare(new CSharpAnalyzerFactory(),
4850
"analysis/csharp/truncated.cs",

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/document/TroffAnalyzerTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.opengrok.indexer.util.TestRepository;
3939
import org.opengrok.indexer.web.Util;
4040

41+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4142
import static org.junit.jupiter.api.Assertions.assertNotNull;
4243
import static org.junit.jupiter.api.Assertions.assertTrue;
4344

@@ -99,11 +100,11 @@ public static void tearDownAfterClass() throws Exception {
99100
void testAnalyze() throws Exception {
100101
Document doc = new Document();
101102
StringWriter xrefOut = new StringWriter();
102-
analyzer.analyze(doc, new StreamSource() {
103+
assertDoesNotThrow(() -> analyzer.analyze(doc, new StreamSource() {
103104
@Override
104105
public InputStream getStream() throws IOException {
105106
return new ByteArrayInputStream(content.getBytes());
106107
}
107-
}, xrefOut);
108+
}, xrefOut));
108109
}
109110
}

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/document/TroffXrefTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
class TroffXrefTest extends XrefTestBase {
3434

3535
@Test
36+
@SuppressWarnings("squid:S2699")
3637
void sampleTest() throws IOException {
3738
writeAndCompare(new TroffAnalyzerFactory(),
3839
"analysis/document/sync.1m",

0 commit comments

Comments
 (0)