Skip to content

Commit

Permalink
SLLS-292 use latest analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
sophio-japharidze-sonarsource committed Dec 27, 2024
1 parent a7c976a commit 0ade96f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 28 deletions.
31 changes: 20 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
<!-- Version used by Xodus -->
<kotlin.version>1.6.10</kotlin.version>
<!-- analyzers used for tests -->
<sonar.java.version>7.33.0.35775</sonar.java.version>
<sonar.javascript.version>10.13.0.25911</sonar.javascript.version>
<sonar.php.version>3.35.0.11659</sonar.php.version>
<sonar.python.version>4.17.0.14845</sonar.python.version>
<sonar.html.version>3.16.0.5274</sonar.html.version>
<sonar.xml.version>2.10.0.4108</sonar.xml.version>
<sonar.text.version>2.18.0.4812</sonar.text.version>
<sonar.go.version>1.15.0.4655</sonar.go.version>
<sonar.iac.version>1.27.0.9518</sonar.iac.version>
<sonar.csharp.version>10.2.0.103721</sonar.csharp.version>
<sonar.java.version>8.8.0.37665</sonar.java.version>
<sonar.javascript.version>10.20.0.29356</sonar.javascript.version>
<sonar.php.version>3.41.0.12692</sonar.php.version>
<sonar.python.version>4.24.0.18631</sonar.python.version>
<sonar.html.version>3.18.0.5605</sonar.html.version>
<sonar.xml.version>2.12.0.5749</sonar.xml.version>
<sonar.text.version>2.20.0.5038</sonar.text.version>
<sonar.go.version>1.18.0.240</sonar.go.version>
<sonar.iac.version>1.40.0.13983</sonar.iac.version>
<sonar.csharp.version>10.3.0.106239</sonar.csharp.version>
<sonarlint.omnisharp.version>1.25.0.100242</sonarlint.omnisharp.version>
<gitRepositoryName>sonarlint-language-server</gitRepositoryName>
<!-- Release: enable publication to Bintray -->
Expand Down Expand Up @@ -205,6 +205,15 @@
<outputDirectory>${project.build.directory}/plugins</outputDirectory>
<destFileName>sonarjava.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.sonarsource.java</groupId>
<artifactId>sonar-java-symbolic-execution-plugin</artifactId>
<version>${sonar.java.version}</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/plugins</outputDirectory>
<destFileName>sonarjavasymbolicexecution.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.sonarsource.javascript</groupId>
<artifactId>sonar-javascript-plugin</artifactId>
Expand Down Expand Up @@ -426,7 +435,7 @@
<artifactItem>
<groupId>com.sonarsource.cpp</groupId>
<artifactId>sonar-cfamily-plugin</artifactId>
<version>6.56.0.72172</version>
<version>6.62.0.78645</version>
<destFileName>cfamily.jar</destFileName>
<type>jar</type>
</artifactItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,14 @@ static void startServer() throws Exception {
var iac = fullPathToJar("sonariac");
var html = fullPathToJar("sonarhtml");
var java = fullPathToJar("sonarjava");
var javasymbolicexecution = fullPathToJar("sonarjavasymbolicexecution");
var js = fullPathToJar("sonarjs");
var php = fullPathToJar("sonarphp");
var py = fullPathToJar("sonarpython");
var text = fullPathToJar("sonartext");
var xml = fullPathToJar("sonarxml");
var omnisharp = fullPathToJar("sonarlintomnisharp");
String[] languageServerArgs = new String[]{"-port", "" + port, "-analyzers", go, java, js, php, py, html, xml, text, iac, omnisharp};
String[] languageServerArgs = new String[]{"-port", "" + port, "-analyzers", go, java, javasymbolicexecution, js, php, py, html, xml, text, iac, omnisharp};
if (COMMERCIAL_ENABLED) {
var cfamily = fullPathToJar("cfamily");
languageServerArgs = ArrayUtils.add(languageServerArgs, cfamily);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,21 @@ void analyzeSimpleJavaFileWithFlows() throws Exception {
client.javaConfigs.put(uri, javaConfigResponse);

didOpen(uri, "java",
"public class AnalyzeSimpleJavaFileWithFlows {\n" +
" private AnalyzeSimpleJavaFileWithFlows() {}\n" +
" static int computeValue(int input) {\n" +
" String message = \"polop\";\n" +
" if (input == 42) {\n" +
" message = null;\n" +
" }\n" +
" return doSomeThingWith(message);\n" +
" }\n" +
" private static int doSomeThingWith(String param) {\n" +
" return param.length();\n" +
" }\n" +
"}");
"""
public class AnalyzeSimpleJavaFileWithFlows {
private AnalyzeSimpleJavaFileWithFlows() {}
static int computeValue(int input) {
String message = "polop";
if (input == 42) {
message = null;
}
return doSomeThingWith(message);
}
private static int doSomeThingWith(String param) {
return param.length();
}
}
""");

awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri))
.extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity)
Expand Down Expand Up @@ -242,7 +244,7 @@ void analyzeSimpleJavaTestFileOnOpen() throws Exception {

awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri))
.extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity)
.containsExactlyInAnyOrder(
.contains(
tuple(3, 14, 3, 18, "java:S2699", "sonarqube", "Add at least one assertion to this test case.", DiagnosticSeverity.Warning)));
}

Expand Down Expand Up @@ -270,16 +272,20 @@ void testClassPathUpdateEvictCacheAndTriggersNewAnalysis(@TempDir Path projectRo

awaitUntilAsserted(() -> assertThat(client.logs)
.extracting(withoutTimestampAndMillis())
.contains("[Info] Analysis detected 0 issues and 0 Security Hotspots in XXXms"));
.contains("[Info] Analysis detected 2 issues and 0 Security Hotspots in XXXms"));
client.logs.clear();

// Update classpath
javaConfigResponse.setClasspath(new String[]{Paths.get(this.getClass().getResource("/junit-4.12.jar").toURI()).toAbsolutePath().toString()});
lsProxy.didClasspathUpdate(new DidClasspathUpdateParams(projectRootUri2));

awaitUntilAsserted(() -> assertThat(client.logs)
.extracting(withoutTimestampAndMillis())
.contains("[Info] Analysis detected 3 issues and 0 Security Hotspots in XXXms"));

awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uri))
.extracting(startLine(), startCharacter(), endLine(), endCharacter(), code(), Diagnostic::getSource, Diagnostic::getMessage, Diagnostic::getSeverity)
.containsExactlyInAnyOrder(
.contains(
tuple(3, 14, 3, 18, "java:S2699", "sonarqube", "Add at least one assertion to this test case.", DiagnosticSeverity.Warning)));

assertThat(client.logs)
Expand Down

0 comments on commit 0ade96f

Please sign in to comment.