Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public void should_transpile_jsp() throws Exception {
Telemetry java.dependency.spring-boot: absent
Telemetry java.dependency.spring-web: absent
Telemetry java.is_autoscan: false
Telemetry java.is_android: false
Telemetry java.language.version: 8
Telemetry java.module_count: 1
Telemetry java.scanner_app: ScannerMaven
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ private void executeAndAssertBuild(MavenBuild build, String projectKey) {
Telemetry java.dependency.spring-boot: absent
Telemetry java.dependency.spring-web: 5.3.18
Telemetry java.is_autoscan: false
Telemetry java.is_android: false
Telemetry java.language.version: 17
Telemetry java.module_count: 1
Telemetry java.scanner_app: ScannerMaven
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void test() {
.containsOnlyOnce("Telemetry java.module_count: 2")
.containsOnlyOnce("Telemetry java.scanner_app: ScannerMaven")
.containsOnlyOnce("Telemetry java.is_autoscan: false")
.containsOnlyOnce("Telemetry java.is_android: false")
.containsOnlyOnce("Telemetry java.dependency.lombok: 1.18.30,1.18.38");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum TelemetryKey {
JAVA_LANGUAGE_VERSION("java.language.version"),
JAVA_SCANNER_APP("java.scanner_app"),
JAVA_IS_AUTOSCAN("java.is_autoscan"),
JAVA_IS_ANDROID("java.is_android"),
JAVA_ANALYSIS_MAIN_SUCCESS_SIZE_CHARS("java.analysis.main.success.size_chars"),
JAVA_ANALYSIS_MAIN_SUCCESS_TIME_MS("java.analysis.main.success.time_ms"),
JAVA_ANALYSIS_MAIN_PARSE_ERRORS_SIZE_CHARS("java.analysis.main.parse_errors.size_chars"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.sonarsource.performance.measure.PerformanceMeasure;

import static org.sonar.api.rules.RuleAnnotationUtils.getRuleKey;
import static org.sonar.java.telemetry.TelemetryKey.JAVA_IS_ANDROID;
import static org.sonar.java.telemetry.TelemetryKey.JAVA_IS_AUTOSCAN;
import static org.sonar.java.telemetry.TelemetryKey.JAVA_LANGUAGE_VERSION;
import static org.sonar.java.telemetry.TelemetryKey.JAVA_MODULE_COUNT;
Expand Down Expand Up @@ -117,6 +118,7 @@ public void execute(SensorContext context) {

telemetry.aggregateAsSortedSet(JAVA_SCANNER_APP, settings.get("sonar.scanner.app").orElse("none"));
telemetry.aggregateAsFlag(JAVA_IS_AUTOSCAN, sonarComponents.isAutoScan());
telemetry.aggregateAsFlag(JAVA_IS_ANDROID, sonarComponents.inAndroidContext());

JavaFrontend frontend = new JavaFrontend(javaVersion,
sonarComponents,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ void test_issues_creation_on_main_file() throws IOException {
"java.dependency.spring-boot",
"java.dependency.spring-web",
"java.is_autoscan",
"java.is_android",
"java.language.version",
"java.module_count",
"java.scanner_app");
Expand All @@ -146,6 +147,7 @@ void test_issues_creation_on_test_file() throws IOException { // NOSONAR require
"java.dependency.spring-boot",
"java.dependency.spring-web",
"java.is_autoscan",
"java.is_android",
"java.language.version",
"java.module_count",
"java.scanner_app");
Expand All @@ -169,8 +171,8 @@ private void testIssueCreation(InputFile.Type onType, int expectedIssues) throws
JavaSensor jss = new JavaSensor(sonarComponents, fs, javaResourceLocator, settings.asConfig(), noSonarFilter, null, telemetry);

jss.execute(context);
// argument 138 refers to the comment on line #138 in this file, each time this file changes, this argument should be updated
verify(noSonarFilter, times(1)).noSonarInFile(fs.inputFiles().iterator().next(), Collections.singleton(138));
// argument 139 refers to the comment on line #139 in this file, each time this file changes, this argument should be updated
verify(noSonarFilter, times(1)).noSonarInFile(fs.inputFiles().iterator().next(), Collections.singleton(139));
verify(sonarComponents, times(expectedIssues)).reportIssue(any(AnalyzerMessage.class));

// There are additional entries, but we do not test them.
Expand All @@ -179,6 +181,7 @@ private void testIssueCreation(InputFile.Type onType, int expectedIssues) throws
entry("java.dependency.spring-boot", "absent"),
entry("java.dependency.spring-web", "absent"),
entry("java.is_autoscan", "false"),
entry("java.is_android", "false"),
entry("java.language.version", "22"),
entry("java.module_count", "1"),
entry("java.scanner_app", "ScannerJavaSensorTest"));
Expand Down