From b623dccefb4a45430b6664bbf78bc69b4aea4621 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Wed, 23 Aug 2023 16:23:31 +0200 Subject: [PATCH] Lint --- .../data/osm/edits/ElementIdProviderDaoTest.kt | 2 +- .../data/osm/geometry/RelationGeometryDaoTest.kt | 2 +- .../streetcomplete/data/osm/geometry/WayGeometryDaoTest.kt | 2 +- .../data/elementfilter/BooleanExpressionBuilder.kt | 3 +-- .../streetcomplete/overlays/AbstractOverlayForm.kt | 4 ++-- .../streetcomplete/quests/AbstractOsmQuestForm.kt | 4 ++-- .../quests/crossing_kerb_height/AddCrossingKerbHeight.kt | 1 - .../screens/main/bottom_sheet/SplitWayFragment.kt | 4 ++-- .../screens/main/map/LocationAwareMapFragment.kt | 2 +- .../screens/tutorial/OverlaysTutorialFragment.kt | 5 ++--- .../streetcomplete/util/math/ElementGeometryMath.kt | 3 --- .../westnordost/streetcomplete/util/math/FlatEarthMath.kt | 6 ++++-- .../data/elementfilter/ElementFiltersParserTest.kt | 4 +--- .../data/elementfilter/StringWithCursorTest.kt | 2 +- .../osm/street_parking/StreetParkingCreatorKtTest.kt | 2 +- 15 files changed, 20 insertions(+), 26 deletions(-) diff --git a/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/edits/ElementIdProviderDaoTest.kt b/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/edits/ElementIdProviderDaoTest.kt index 7c1c613520..24964f16e2 100644 --- a/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/edits/ElementIdProviderDaoTest.kt +++ b/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/edits/ElementIdProviderDaoTest.kt @@ -4,11 +4,11 @@ import de.westnordost.streetcomplete.data.ApplicationDbTestCase import de.westnordost.streetcomplete.data.osm.mapdata.ElementIdUpdate import de.westnordost.streetcomplete.data.osm.mapdata.ElementKey import de.westnordost.streetcomplete.data.osm.mapdata.ElementType -import kotlin.test.assertFailsWith import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test +import kotlin.test.assertFailsWith class ElementIdProviderDaoTest : ApplicationDbTestCase() { private lateinit var dao: ElementIdProviderDao diff --git a/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/geometry/RelationGeometryDaoTest.kt b/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/geometry/RelationGeometryDaoTest.kt index 3a2939577e..692fe8d45e 100644 --- a/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/geometry/RelationGeometryDaoTest.kt +++ b/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/geometry/RelationGeometryDaoTest.kt @@ -4,13 +4,13 @@ import de.westnordost.streetcomplete.data.ApplicationDbTestCase import de.westnordost.streetcomplete.data.osm.mapdata.ElementType import de.westnordost.streetcomplete.data.osm.mapdata.LatLon import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder -import kotlin.test.assertFailsWith import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test +import kotlin.test.assertFailsWith class RelationGeometryDaoTest : ApplicationDbTestCase() { private lateinit var dao: RelationGeometryDao diff --git a/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/geometry/WayGeometryDaoTest.kt b/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/geometry/WayGeometryDaoTest.kt index e3f1c9580c..bfd46f3261 100644 --- a/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/geometry/WayGeometryDaoTest.kt +++ b/app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/geometry/WayGeometryDaoTest.kt @@ -4,13 +4,13 @@ import de.westnordost.streetcomplete.data.ApplicationDbTestCase import de.westnordost.streetcomplete.data.osm.mapdata.ElementType import de.westnordost.streetcomplete.data.osm.mapdata.LatLon import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder -import kotlin.test.assertFailsWith import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test +import kotlin.test.assertFailsWith class WayGeometryDaoTest : ApplicationDbTestCase() { private lateinit var dao: WayGeometryDao diff --git a/app/src/main/java/de/westnordost/streetcomplete/data/elementfilter/BooleanExpressionBuilder.kt b/app/src/main/java/de/westnordost/streetcomplete/data/elementfilter/BooleanExpressionBuilder.kt index 2007ac506e..0e6112fcbc 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/data/elementfilter/BooleanExpressionBuilder.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/data/elementfilter/BooleanExpressionBuilder.kt @@ -46,8 +46,7 @@ class BooleanExpressionBuilder, T> { } node = node.parent!! - if (node is Not) - { + if (node is Not) { node = node.parent!! } diff --git a/app/src/main/java/de/westnordost/streetcomplete/overlays/AbstractOverlayForm.kt b/app/src/main/java/de/westnordost/streetcomplete/overlays/AbstractOverlayForm.kt index 3e79391d82..0cc37f7373 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/overlays/AbstractOverlayForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/overlays/AbstractOverlayForm.kt @@ -22,6 +22,8 @@ import androidx.viewbinding.ViewBinding import de.westnordost.countryboundaries.CountryBoundaries import de.westnordost.osmfeatures.FeatureDictionary import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.location.RecentLocationStore +import de.westnordost.streetcomplete.data.location.checkIsSurvey import de.westnordost.streetcomplete.data.meta.CountryInfo import de.westnordost.streetcomplete.data.meta.CountryInfos import de.westnordost.streetcomplete.data.meta.getByLocation @@ -41,10 +43,8 @@ import de.westnordost.streetcomplete.data.osm.mapdata.Way import de.westnordost.streetcomplete.data.osm.mapdata.key import de.westnordost.streetcomplete.data.overlays.OverlayRegistry import de.westnordost.streetcomplete.databinding.FragmentOverlayBinding -import de.westnordost.streetcomplete.data.location.RecentLocationStore import de.westnordost.streetcomplete.screens.main.bottom_sheet.IsCloseableBottomSheet import de.westnordost.streetcomplete.screens.main.bottom_sheet.IsMapOrientationAware -import de.westnordost.streetcomplete.data.location.checkIsSurvey import de.westnordost.streetcomplete.util.FragmentViewBindingPropertyDelegate import de.westnordost.streetcomplete.util.getNameAndLocationLabel import de.westnordost.streetcomplete.util.ktx.isSplittable diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt index 21eaf00371..7127272677 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt @@ -13,6 +13,8 @@ import androidx.core.os.bundleOf import androidx.core.view.children import de.westnordost.osmfeatures.FeatureDictionary import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.location.RecentLocationStore +import de.westnordost.streetcomplete.data.location.checkIsSurvey import de.westnordost.streetcomplete.data.osm.edits.AddElementEditsController import de.westnordost.streetcomplete.data.osm.edits.ElementEditAction import de.westnordost.streetcomplete.data.osm.edits.ElementEditType @@ -37,8 +39,6 @@ import de.westnordost.streetcomplete.data.quest.OsmQuestKey import de.westnordost.streetcomplete.osm.IS_SHOP_OR_DISUSED_SHOP_EXPRESSION import de.westnordost.streetcomplete.osm.replaceShop import de.westnordost.streetcomplete.quests.shop_type.ShopGoneDialog -import de.westnordost.streetcomplete.data.location.RecentLocationStore -import de.westnordost.streetcomplete.data.location.checkIsSurvey import de.westnordost.streetcomplete.util.getNameAndLocationLabel import de.westnordost.streetcomplete.util.ktx.geometryType import de.westnordost.streetcomplete.util.ktx.isSplittable diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/crossing_kerb_height/AddCrossingKerbHeight.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/crossing_kerb_height/AddCrossingKerbHeight.kt index df2c2813a5..0f57e041ea 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/crossing_kerb_height/AddCrossingKerbHeight.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/crossing_kerb_height/AddCrossingKerbHeight.kt @@ -6,7 +6,6 @@ import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry import de.westnordost.streetcomplete.data.osm.mapdata.Element import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry import de.westnordost.streetcomplete.data.osm.osmquests.OsmElementQuestType -import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BICYCLIST import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BLIND import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.WHEELCHAIR diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/bottom_sheet/SplitWayFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/bottom_sheet/SplitWayFragment.kt index cf89bbb60f..20ec9e97a5 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/main/bottom_sheet/SplitWayFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/bottom_sheet/SplitWayFragment.kt @@ -18,6 +18,8 @@ import androidx.core.view.isInvisible import androidx.core.view.updateLayoutParams import androidx.fragment.app.Fragment import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.location.RecentLocationStore +import de.westnordost.streetcomplete.data.location.checkIsSurvey import de.westnordost.streetcomplete.data.osm.edits.ElementEditType import de.westnordost.streetcomplete.data.osm.edits.ElementEditsController import de.westnordost.streetcomplete.data.osm.edits.split_way.SplitAtLinePosition @@ -35,8 +37,6 @@ import de.westnordost.streetcomplete.data.overlays.OverlayRegistry import de.westnordost.streetcomplete.data.quest.QuestTypeRegistry import de.westnordost.streetcomplete.databinding.FragmentSplitWayBinding import de.westnordost.streetcomplete.overlays.IsShowingElement -import de.westnordost.streetcomplete.data.location.RecentLocationStore -import de.westnordost.streetcomplete.data.location.checkIsSurvey import de.westnordost.streetcomplete.screens.main.map.ShowsGeometryMarkers import de.westnordost.streetcomplete.util.SoundFx import de.westnordost.streetcomplete.util.ktx.asSequenceOfPairs diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/LocationAwareMapFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/LocationAwareMapFragment.kt index 4c4b9ef3ab..d3b6c91b6b 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/LocationAwareMapFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/LocationAwareMapFragment.kt @@ -9,9 +9,9 @@ import android.os.Bundle import android.view.WindowManager import androidx.core.content.edit import androidx.core.content.getSystemService +import de.westnordost.streetcomplete.data.location.RecentLocationStore import de.westnordost.streetcomplete.data.osm.mapdata.LatLon import de.westnordost.streetcomplete.data.osmtracks.Trackpoint -import de.westnordost.streetcomplete.data.location.RecentLocationStore import de.westnordost.streetcomplete.screens.main.map.components.CurrentLocationMapComponent import de.westnordost.streetcomplete.screens.main.map.components.TracksMapComponent import de.westnordost.streetcomplete.screens.main.map.tangram.screenBottomToCenterDistance diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/tutorial/OverlaysTutorialFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/tutorial/OverlaysTutorialFragment.kt index 132c8a5491..184ec37955 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/tutorial/OverlaysTutorialFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/tutorial/OverlaysTutorialFragment.kt @@ -8,7 +8,6 @@ import android.os.Bundle import android.view.View import android.view.animation.AccelerateDecelerateInterpolator import android.view.animation.AnticipateInterpolator -import android.view.animation.DecelerateInterpolator import android.view.animation.LinearInterpolator import androidx.core.view.isInvisible import androidx.fragment.app.Fragment @@ -130,8 +129,8 @@ class OverlaysTutorialFragment : Fragment(R.layout.fragment_overlays_tutorial) { binding.paintRollerView.animate() .setInterpolator(AccelerateDecelerateInterpolator()) .setDuration(700) - .translationX(-binding.paintRollerView.width/4f) - .translationY(-binding.paintRollerView.height/4f) + .translationX(-binding.paintRollerView.width / 4f) + .translationY(-binding.paintRollerView.height / 4f) .rotation(-45f) .scaleX(1f) .scaleY(1f) diff --git a/app/src/main/java/de/westnordost/streetcomplete/util/math/ElementGeometryMath.kt b/app/src/main/java/de/westnordost/streetcomplete/util/math/ElementGeometryMath.kt index 01666b0dc6..e41d4327d6 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/util/math/ElementGeometryMath.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/util/math/ElementGeometryMath.kt @@ -1,9 +1,6 @@ package de.westnordost.streetcomplete.util.math import de.westnordost.streetcomplete.data.osm.geometry.ElementPolylinesGeometry -import de.westnordost.streetcomplete.data.osm.mapdata.LatLon -import de.westnordost.streetcomplete.util.ktx.asSequenceOfPairs -import kotlin.math.abs fun ElementPolylinesGeometry.getOrientationAtCenterLineInDegrees(): Float { val centerLine = polylines.first().centerLineOfPolyline() diff --git a/app/src/main/java/de/westnordost/streetcomplete/util/math/FlatEarthMath.kt b/app/src/main/java/de/westnordost/streetcomplete/util/math/FlatEarthMath.kt index 093dede7ab..c17c49d8ba 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/util/math/FlatEarthMath.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/util/math/FlatEarthMath.kt @@ -58,8 +58,9 @@ private fun flatAngularDistance(φ1: Double, λ1: Double, φ2: Double, λ2: Doub // https://en.wikipedia.org/wiki/Geographical_distance#Spherical_Earth_projected_to_a_plane val δφ = φ1 - φ2 var δλ = abs(λ1 - λ2) - if (δλ > PI) + if (δλ > PI) { δλ = 2 * PI - δλ + } val cosδλ = approximateCos((φ1 + φ2) / 2) * δλ return sqrt(δφ * δφ + cosδλ * cosδλ) } @@ -72,8 +73,9 @@ private fun flatAngularDistanceToArc(φ1: Double, λ1: Double, φ2: Double, λ2: val δφ12 = φ2 - φ1 val δλ12 = λ2 - λ1 - if (δφ12 == 0.0 && δλ12 == 0.0) + if (δφ12 == 0.0 && δλ12 == 0.0) { return flatAngularDistance(φ1, λ1, φ3, λ3) + } val δλ13 = λ3 - λ1 val c = approximateCos(φ3) diff --git a/app/src/test/java/de/westnordost/streetcomplete/data/elementfilter/ElementFiltersParserTest.kt b/app/src/test/java/de/westnordost/streetcomplete/data/elementfilter/ElementFiltersParserTest.kt index 0dd9dd5748..bc987f5768 100644 --- a/app/src/test/java/de/westnordost/streetcomplete/data/elementfilter/ElementFiltersParserTest.kt +++ b/app/src/test/java/de/westnordost/streetcomplete/data/elementfilter/ElementFiltersParserTest.kt @@ -1,14 +1,12 @@ package de.westnordost.streetcomplete.data.elementfilter -import de.westnordost.streetcomplete.osm.MAXSPEED_TYPE_KEYS -import de.westnordost.streetcomplete.osm.surface.ANYTHING_UNPAVED import de.westnordost.streetcomplete.testutils.node import de.westnordost.streetcomplete.testutils.rel import de.westnordost.streetcomplete.testutils.way -import kotlin.test.assertFailsWith import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test +import kotlin.test.assertFailsWith class ElementFiltersParserTest { @Test fun `fail if no space after or before and or`() { diff --git a/app/src/test/java/de/westnordost/streetcomplete/data/elementfilter/StringWithCursorTest.kt b/app/src/test/java/de/westnordost/streetcomplete/data/elementfilter/StringWithCursorTest.kt index a3754b015f..1a7effc002 100644 --- a/app/src/test/java/de/westnordost/streetcomplete/data/elementfilter/StringWithCursorTest.kt +++ b/app/src/test/java/de/westnordost/streetcomplete/data/elementfilter/StringWithCursorTest.kt @@ -1,12 +1,12 @@ package de.westnordost.streetcomplete.data.elementfilter -import kotlin.test.assertFailsWith import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNotNull import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Test +import kotlin.test.assertFailsWith class StringWithCursorTest { @Test fun advance() { diff --git a/app/src/test/java/de/westnordost/streetcomplete/osm/street_parking/StreetParkingCreatorKtTest.kt b/app/src/test/java/de/westnordost/streetcomplete/osm/street_parking/StreetParkingCreatorKtTest.kt index 70a829c894..bea21a8822 100644 --- a/app/src/test/java/de/westnordost/streetcomplete/osm/street_parking/StreetParkingCreatorKtTest.kt +++ b/app/src/test/java/de/westnordost/streetcomplete/osm/street_parking/StreetParkingCreatorKtTest.kt @@ -551,7 +551,7 @@ class StreetParkingCreatorKtTest { @Test fun `applying incomplete left throws exception`() { assertFailsWith { - LeftAndRightStreetParking(IncompleteStreetParking,null) + LeftAndRightStreetParking(IncompleteStreetParking, null) .applyTo(StringMapChangesBuilder(mapOf())) } }