Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
FloEdelmann committed Aug 23, 2023
1 parent ba6bbb1 commit b623dcc
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class BooleanExpressionBuilder<I : Matcher<T>, T> {
}
node = node.parent!!

if (node is Not)
{
if (node is Not) {
node = node.parent!!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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δλ)
}
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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`() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class StreetParkingCreatorKtTest {
@Test
fun `applying incomplete left throws exception`() {
assertFailsWith<IllegalArgumentException> {
LeftAndRightStreetParking(IncompleteStreetParking,null)
LeftAndRightStreetParking(IncompleteStreetParking, null)
.applyTo(StringMapChangesBuilder(mapOf()))
}
}
Expand Down

0 comments on commit b623dcc

Please sign in to comment.