From cc25524508e8bcf9205320006f475b2f2454236c Mon Sep 17 00:00:00 2001 From: Ishan-3213 Date: Mon, 9 Oct 2023 00:42:08 -0400 Subject: [PATCH 1/3] Corrected expected and actual value by swapping them. --- build.gradle | 27 ++++++++++++++++++- gradle.properties | 3 +++ gradle/wrapper/gradle-wrapper.properties | 3 ++- .../VoiceAnnouncementUtilsTest.java | 4 +-- .../settings/PreferencesUtilsTest.java | 8 +++--- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 0e9d2bbef..eaea30fd7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,17 @@ apply plugin: 'com.android.application' buildscript { + ext { + agp_version = '8.1.1' + } repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.2.0-beta01' + classpath "com.android.tools.build:gradle:$agp_version" + classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1" + } } @@ -17,6 +22,26 @@ allprojects { } } +apply plugin: "org.sonarqube" + +sonarqube { + properties { + property "sonar.projectName", "OpenTracksConcordia" + property "sonar.projectKey", "OpenTracksConcordia" + property "sonar.tests", ["src/androidTest/java"] + property "sonar.test.inclusions", "*/*Test/**" + property "sonar.sourceEncoding", "UTF-8" + property "sonar.sources", "src/main/java" + property "sonar.exclusions", '*/*Test/**,' + + '*.json,' + + '*/*test/**,' + + '**/.gradle/**,' + + '**/R.class' + } +} + + + def getVersionName = { -> try { def stdout = new ByteArrayOutputStream() diff --git a/gradle.properties b/gradle.properties index 3c8ba69b7..08a446e9f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,5 @@ android.useAndroidX=true org.gradle.jvmargs=-Xmx1024m +systemProp.sonar.host.url=http://localhost:9000 +systemProp.sonar.login=sqp_61650630da8d6ff10b29db5c39ba42ef7feed25e + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34e8..47194dbbe 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ +#Sun Oct 08 22:27:07 EDT 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java b/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java index 1727c7af2..ab805fad6 100644 --- a/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java +++ b/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java @@ -312,7 +312,7 @@ public void getAnnouncement_heart_rate_and_sensor_statistics() { lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1); } - SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null); + SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null); // when String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString(); @@ -342,7 +342,7 @@ public void getAnnouncement_only_lap_heart_rate() { lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1); } - SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null); + SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null); // when String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString(); diff --git a/src/androidTest/java/de/dennisguse/opentracks/settings/PreferencesUtilsTest.java b/src/androidTest/java/de/dennisguse/opentracks/settings/PreferencesUtilsTest.java index adb806d00..4bc94e361 100644 --- a/src/androidTest/java/de/dennisguse/opentracks/settings/PreferencesUtilsTest.java +++ b/src/androidTest/java/de/dennisguse/opentracks/settings/PreferencesUtilsTest.java @@ -309,11 +309,11 @@ public void testEditCustomLayout() { // then only updated profile is modified in the custom layouts List layoutsAfter = PreferencesUtils.getAllCustomLayouts(); - assertEquals(layoutsBefore.size(), 2); - assertEquals(layoutsAfter.size(), 2); + assertEquals(2, layoutsBefore.size()); + assertEquals(2, layoutsAfter.size()); - assertEquals(layoutsBefore.get(0).getFields().stream().filter(DataField::isVisible).count(), 4); - assertEquals(layoutsAfter.get(0).getFields().stream().filter(DataField::isVisible).count(), 1); + assertEquals(4, layoutsBefore.get(0).getFields().stream().filter(DataField::isVisible).count()); + assertEquals(1, layoutsAfter.get(0).getFields().stream().filter(DataField::isVisible).count()); } @Test From 7d93c93a4874f51feaed49d12693316bc2520ef5 Mon Sep 17 00:00:00 2001 From: Ishan-3213 Date: Mon, 9 Oct 2023 12:25:38 -0400 Subject: [PATCH 2/3] Added missing annotation to the method onAttach() --- .../opentracks/fragments/ChooseActivityTypeDialogFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/de/dennisguse/opentracks/fragments/ChooseActivityTypeDialogFragment.java b/src/main/java/de/dennisguse/opentracks/fragments/ChooseActivityTypeDialogFragment.java index 1aacf353f..35f9b177a 100644 --- a/src/main/java/de/dennisguse/opentracks/fragments/ChooseActivityTypeDialogFragment.java +++ b/src/main/java/de/dennisguse/opentracks/fragments/ChooseActivityTypeDialogFragment.java @@ -102,6 +102,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, return viewBinding.getRoot(); } + @Override public void onAttach(@NonNull Context context) { super.onAttach(context); try { From 134043da2572963981f49e12cd2411aae9b33a9e Mon Sep 17 00:00:00 2001 From: Ishan-3213 Date: Mon, 9 Oct 2023 12:32:21 -0400 Subject: [PATCH 3/3] Modified onAttach method --- .../opentracks/fragments/ChooseActivityTypeDialogFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/fragments/ChooseActivityTypeDialogFragment.java b/src/main/java/de/dennisguse/opentracks/fragments/ChooseActivityTypeDialogFragment.java index 35f9b177a..1aacf353f 100644 --- a/src/main/java/de/dennisguse/opentracks/fragments/ChooseActivityTypeDialogFragment.java +++ b/src/main/java/de/dennisguse/opentracks/fragments/ChooseActivityTypeDialogFragment.java @@ -102,7 +102,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, return viewBinding.getRoot(); } - @Override public void onAttach(@NonNull Context context) { super.onAttach(context); try {