Skip to content

Commit

Permalink
Lint: Standardize spacing around colons
Browse files Browse the repository at this point in the history
reported and fixed by `colon-spacing` ktlint rule
  • Loading branch information
FloEdelmann committed Jan 28, 2022
1 parent 8d1aee5 commit 6aa3fb1
Show file tree
Hide file tree
Showing 84 changed files with 139 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ indent_style = tab
[*.{kt,kts}]
indent_style = space
indent_size = 4
disabled_rules = colon-spacing,comma-spacing,curly-spacing,keyword-spacing,op-spacing,paren-spacing,comment-spacing,parameter-list-wrapping,chain-wrapping,indent,no-multi-spaces,string-template,import-ordering,no-wildcard-imports,no-unused-imports,filename
disabled_rules = comma-spacing,curly-spacing,keyword-spacing,op-spacing,paren-spacing,comment-spacing,parameter-list-wrapping,chain-wrapping,indent,no-multi-spaces,string-template,import-ordering,no-wildcard-imports,no-unused-imports,filename

[gradlew]
indent_style = space
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class ChangelogFragment : Fragment(R.layout.fragment_changelog) {
}

/** A dialog that shows the changelog */
class WhatsNewDialog(context: Context, sinceVersion: String)
: AlertDialog(context, R.style.Theme_Bubble_Dialog) {
class WhatsNewDialog(context: Context, sinceVersion: String) :
AlertDialog(context, R.style.Theme_Bubble_Dialog) {

private val scope = CoroutineScope(Dispatchers.Main)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private inline fun <T> Cursor.toSequence(crossinline transform: (CursorPosition)
return result
}

class AndroidCursorPosition(private val cursor: Cursor): CursorPosition {
class AndroidCursorPosition(private val cursor: Cursor) : CursorPosition {
override fun getShort(columnName: String): Short = cursor.getShort(columnName)
override fun getInt(columnName: String): Int = cursor.getInt(columnName)
override fun getLong(columnName: String): Long = cursor.getLong(columnName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import javax.inject.Singleton
/** Controls downloading */
@Singleton class DownloadController @Inject constructor(
private val context: Context
): DownloadProgressSource {
) : DownloadProgressSource {

private var downloadServiceIsBound: Boolean = false
private var downloadService: DownloadService.Interface? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Edit {

sealed class EditKey

data class ElementEditKey(val id: Long): EditKey()
data class NoteEditKey(val id: Long): EditKey()
data class OsmQuestHiddenKey(val osmQuestKey: OsmQuestKey): EditKey()
data class OsmNoteQuestHiddenKey(val osmNoteQuestKey: OsmNoteQuestKey): EditKey()
data class ElementEditKey(val id: Long) : EditKey()
data class NoteEditKey(val id: Long) : EditKey()
data class OsmQuestHiddenKey(val osmQuestKey: OsmQuestKey) : EditKey()
data class OsmNoteQuestHiddenKey(val osmNoteQuestKey: OsmNoteQuestKey) : EditKey()
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import javax.inject.Singleton
private val noteEditsController: NoteEditsController,
private val noteQuestController: OsmNoteQuestController,
private val osmQuestController: OsmQuestController
): EditHistorySource {
) : EditHistorySource {
private val listeners: MutableList<EditHistorySource.Listener> = CopyOnWriteArrayList()

private val osmElementEditsListener = object : ElementEditsSource.Listener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,49 +70,49 @@ class HasTagLike(val key: String, val value: String) : ElementFilter {
obj.tags.entries.any { keyRegex.matches(it.key) && valueRegex.matches(it.value) }
}

class HasTagLessThan(key: String, value: Float): CompareTagValue(key, value) {
class HasTagLessThan(key: String, value: Float) : CompareTagValue(key, value) {
override fun toString() = "$key < $value"
override fun compareTo(tagValue: Float) = tagValue < value
}
class HasTagGreaterThan(key: String, value: Float): CompareTagValue(key, value) {
class HasTagGreaterThan(key: String, value: Float) : CompareTagValue(key, value) {
override fun toString() = "$key > $value"
override fun compareTo(tagValue: Float) = tagValue > value
}
class HasTagLessOrEqualThan(key: String, value: Float): CompareTagValue(key, value) {
class HasTagLessOrEqualThan(key: String, value: Float) : CompareTagValue(key, value) {
override fun toString() = "$key <= $value"
override fun compareTo(tagValue: Float) = tagValue <= value
}
class HasTagGreaterOrEqualThan(key: String, value: Float): CompareTagValue(key, value) {
class HasTagGreaterOrEqualThan(key: String, value: Float) : CompareTagValue(key, value) {
override fun toString() = "$key >= $value"
override fun compareTo(tagValue: Float) = tagValue >= value
}

abstract class CompareTagValue(val key: String, val value: Float): ElementFilter {
abstract class CompareTagValue(val key: String, val value: Float) : ElementFilter {
abstract fun compareTo(tagValue: Float): Boolean
override fun matches(obj: Element): Boolean {
val tagValue = obj.tags[key]?.toFloatOrNull() ?: return false
return compareTo(tagValue)
}
}

class HasDateTagLessThan(key: String, dateFilter: DateFilter): CompareDateTagValue(key, dateFilter) {
class HasDateTagLessThan(key: String, dateFilter: DateFilter) : CompareDateTagValue(key, dateFilter) {
override fun toString() = "$key < $dateFilter"
override fun compareTo(tagValue: LocalDate) = tagValue < dateFilter.date
}
class HasDateTagGreaterThan(key: String, dateFilter: DateFilter): CompareDateTagValue(key, dateFilter) {
class HasDateTagGreaterThan(key: String, dateFilter: DateFilter) : CompareDateTagValue(key, dateFilter) {
override fun toString() = "$key > $dateFilter"
override fun compareTo(tagValue: LocalDate) = tagValue > dateFilter.date
}
class HasDateTagLessOrEqualThan(key: String, dateFilter: DateFilter): CompareDateTagValue(key, dateFilter) {
class HasDateTagLessOrEqualThan(key: String, dateFilter: DateFilter) : CompareDateTagValue(key, dateFilter) {
override fun toString() = "$key <= $dateFilter"
override fun compareTo(tagValue: LocalDate) = tagValue <= dateFilter.date
}
class HasDateTagGreaterOrEqualThan(key: String, dateFilter: DateFilter): CompareDateTagValue(key, dateFilter) {
class HasDateTagGreaterOrEqualThan(key: String, dateFilter: DateFilter) : CompareDateTagValue(key, dateFilter) {
override fun toString() = "$key >= $dateFilter"
override fun compareTo(tagValue: LocalDate) = tagValue >= dateFilter.date
}

abstract class CompareDateTagValue(val key: String, val dateFilter: DateFilter): ElementFilter {
abstract class CompareDateTagValue(val key: String, val dateFilter: DateFilter) : ElementFilter {
abstract fun compareTo(tagValue: LocalDate): Boolean
override fun matches(obj: Element): Boolean {
val tagValue = obj.tags[key]?.toCheckDate() ?: return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface DateFilter {
}

/** A date relative to (start of) today (positive: future, negative: past) */
class RelativeDate(val deltaDays: Float): DateFilter {
class RelativeDate(val deltaDays: Float) : DateFilter {
override val date: LocalDate get() {
val now = LocalDateTime.now()
val plusHours = (deltaDays * MULTIPLIER * 24).toLong()
Expand All @@ -27,6 +27,6 @@ class RelativeDate(val deltaDays: Float): DateFilter {
}
}

class FixedDate(override val date: LocalDate): DateFilter {
class FixedDate(override val date: LocalDate) : DateFilter {
override fun toString() = date.toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import de.westnordost.streetcomplete.data.user.achievements.Achievement
sealed class Notification

data class OsmUnreadMessagesNotification(val unreadMessages: Int) : Notification()
data class NewAchievementNotification(val achievement: Achievement, val level: Int): Notification()
data class NewVersionNotification(val sinceVersion: String): Notification()
object QuestSelectionHintNotification: Notification()
data class NewAchievementNotification(val achievement: Achievement, val level: Int) : Notification()
data class NewVersionNotification(val sinceVersion: String) : Notification()
object QuestSelectionHintNotification : Notification()
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import javax.inject.Singleton

@Singleton class CreatedElementsController @Inject constructor(
private val db: CreatedElementsDao
): CreatedElementsSource {
) : CreatedElementsSource {

private val cache: MutableSet<ElementKey> by lazy { db.getAll().toMutableSet() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import javax.inject.Singleton
private val editsDB: ElementEditsDao,
private val elementIdProviderDB: ElementIdProviderDao,
private val lastEditTimeStore: LastEditTimeStore
): ElementEditsSource {
) : ElementEditsSource {
/* Must be a singleton because there is a listener that should respond to a change in the
* database table */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import java.lang.System.currentTimeMillis
* end, it is not considered compatible anymore
* */
@Serializable
data class SplitWayAction(private val splits: List<SplitPolylineAtPosition>): ElementEditAction {
data class SplitWayAction(private val splits: List<SplitPolylineAtPosition>) : ElementEditAction {

override val newElementsCount get() = NewElementsCount(
nodes = splits.count { it is SplitAtLinePosition },
Expand Down Expand Up @@ -181,7 +181,7 @@ private fun getUpdatedRelations(
originalWay: Way,
newWays: List<Way>,
mapDataRepository: MapDataRepository
) : Collection<Relation> {
): Collection<Relation> {
val relations = mapDataRepository.getRelationsForWay(originalWay.id)
val result = ArrayList<Relation>()
for (relation in relations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable

/** Contains the information necessary to apply a revert of tag changes made on an element */
@Serializable
data class RevertUpdateElementTagsAction(private val changes: StringMapChanges): ElementEditAction, IsRevertAction {
data class RevertUpdateElementTagsAction(private val changes: StringMapChanges) : ElementEditAction, IsRevertAction {

override val newElementsCount get() = NewElementsCount(0,0,0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.westnordost.streetcomplete.data.osm.edits.update_tags

class StringMapChangesBuilder(private val source: Map<String, String>): Map<String, String> {
class StringMapChangesBuilder(private val source: Map<String, String>) : Map<String, String> {
private val changes: MutableMap<String, StringMapEntryChange> = mutableMapOf()

/** Remove the given key from the map */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlinx.serialization.Serializable
* the tag update made may not be correct anymore, so that is considered a conflict.
* */
@Serializable
data class UpdateElementTagsAction(val changes: StringMapChanges): ElementEditAction, IsActionRevertable {
data class UpdateElementTagsAction(val changes: StringMapChanges) : ElementEditAction, IsActionRevertable {

override val newElementsCount get() = NewElementsCount(0,0,0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ data class BoundingBox(val min: LatLon, val max: LatLon) {
constructor(
minLatitude: Double, minLongitude: Double,
maxLatitude: Double, maxLongitude: Double
): this(LatLon(minLatitude, minLongitude), LatLon(maxLatitude, maxLongitude))
) : this(LatLon(minLatitude, minLongitude), LatLon(maxLatitude, maxLongitude))

init {
require(min.latitude <= max.latitude) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ class MapDataApiImpl(osm: OsmConnection) : MapDataApi {
private inline fun <T> wrapExceptions(block: () -> T): T =
try {
block()
} catch (e : OsmAuthorizationException) {
} catch (e: OsmAuthorizationException) {
throw AuthorizationException(e.message, e)
} catch (e : OsmConflictException) {
} catch (e: OsmConflictException) {
throw ConflictException(e.message, e)
} catch (e : OsmQueryTooBigException) {
} catch (e: OsmQueryTooBigException) {
throw QueryTooBigException(e.message, e)
} catch (e : OsmConnectionException) {
} catch (e: OsmConnectionException) {
throw ConnectionException(e.message, e)
} catch (e : OsmApiReadResponseException) {
} catch (e: OsmApiReadResponseException) {
// probably a temporary connection error
throw ConnectionException(e.message, e)
} catch (e : OsmApiException) {
} catch (e: OsmApiException) {
// request timeout is a temporary connection error
throw if (e.errorCode == 408) ConnectionException(e.message, e) else e
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ import javax.inject.Singleton
mapData.addAll(ways)
}

fun get(type: ElementType, id: Long) : Element? =
fun get(type: ElementType, id: Long): Element? =
elementDB.get(type, id)

fun getGeometry(type: ElementType, id: Long) : ElementGeometry? =
fun getGeometry(type: ElementType, id: Long): ElementGeometry? =
geometryDB.get(type, id)

fun getGeometries(keys: Collection<ElementKey>): List<ElementGeometryEntry> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MapDataDownloader @Inject constructor(
private fun getMapAndHandleTooBigQuery(bounds: BoundingBox, mutableMapData: MutableMapData) {
try {
mapDataApi.getMap(bounds, mutableMapData, ApplicationConstants.IGNORED_RELATION_TYPES)
} catch (e : QueryTooBigException) {
} catch (e: QueryTooBigException) {
for (subBounds in bounds.splitIntoFour()) {
getMapAndHandleTooBigQuery(subBounds, mutableMapData)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ class RelationDao @Inject constructor(private val db: Database) {
}
}

fun getAllForNode(nodeId: Long) : List<Relation> =
fun getAllForNode(nodeId: Long): List<Relation> =
getAllForElement(ElementType.NODE, nodeId)

fun getAllForWay(wayId: Long) : List<Relation> =
fun getAllForWay(wayId: Long): List<Relation> =
getAllForElement(ElementType.WAY, wayId)

fun getAllForRelation(relationId: Long) : List<Relation> =
fun getAllForRelation(relationId: Long): List<Relation> =
getAllForElement(ElementType.RELATION, relationId)

fun getIdsOlderThan(timestamp: Long, limit: Int? = null): List<Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import javax.inject.Singleton
private val notesSource: NotesWithEditsSource,
private val questTypeRegistry: QuestTypeRegistry,
private val countryBoundariesFuture: FutureTask<CountryBoundaries>
): OsmQuestSource {
) : OsmQuestSource {

/* Must be a singleton because there is a listener that should respond to a change in the
* database table */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AvatarsDownloader @Inject constructor(
private fun getProfileImageUrl(userId: Long): String? {
return try {
userApi.get(userId)?.profileImageUrl
} catch (e : Exception) {
} catch (e: Exception) {
Log.w(TAG, "Unable to query info for user id $userId")
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ class NotesApiImpl(osm: OsmConnection) : NotesApi {
private inline fun <T> wrapExceptions(block: () -> T): T =
try {
block()
} catch (e : OsmAuthorizationException) {
} catch (e: OsmAuthorizationException) {
throw AuthorizationException(e.message, e)
} catch (e : OsmConflictException) {
} catch (e: OsmConflictException) {
throw ConflictException(e.message, e)
} catch (e : OsmQueryTooBigException) {
} catch (e: OsmQueryTooBigException) {
throw QueryTooBigException(e.message, e)
} catch (e : OsmConnectionException) {
} catch (e: OsmConnectionException) {
throw ConnectionException(e.message, e)
} catch (e : OsmApiReadResponseException) {
} catch (e: OsmApiReadResponseException) {
// probably a temporary connection error
throw ConnectionException(e.message, e)
} catch (e : OsmApiException) {
} catch (e: OsmApiException) {
// request timeout is a temporary connection error
throw if (e.errorCode == 408) ConnectionException(e.message, e) else e
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class StreetCompleteImageUploader(private val baseUrl: String) {
}
}

class ImageUploadServerException(message: String? = null, cause: Throwable? = null)
: RuntimeException(message, cause)
class ImageUploadServerException(message: String? = null, cause: Throwable? = null) :
RuntimeException(message, cause)

class ImageUploadClientException(message: String? = null, cause: Throwable? = null)
: RuntimeException(message, cause)
class ImageUploadClientException(message: String? = null, cause: Throwable? = null) :
RuntimeException(message, cause)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data class NoteEdit(

/** Whether the images attached still need activation. Already true if imagePaths is empty */
val imagesNeedActivation: Boolean
): Edit {
) : Edit {
override val isUndoable: Boolean get() = !isSynced
override val key: NoteEditKey get() = NoteEditKey(id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.inject.Singleton

@Singleton class NoteEditsController @Inject constructor(
private val editsDB: NoteEditsDao
): NoteEditsSource {
) : NoteEditsSource {
/* Must be a singleton because there is a listener that should respond to a change in the
* database table */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import javax.inject.Singleton
private val userDataSource: UserDataSource,
private val userLoginStatusSource: UserLoginStatusSource,
private val notesPreferences: NotesPreferences,
): OsmNoteQuestSource {
) : OsmNoteQuestSource {
/* Must be a singleton because there is a listener that should respond to a change in the
* database table */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ import javax.inject.Singleton
return@withContext true
}

private fun createOsmQuestChanges(quest: OsmQuest, element: Element, answer: Any) : StringMapChanges {
private fun createOsmQuestChanges(quest: OsmQuest, element: Element, answer: Any): StringMapChanges {
val changesBuilder = StringMapChangesBuilder(element.tags)
quest.osmElementQuestType.applyAnswerToUnsafe(answer, changesBuilder, element.timestampEdited)
return changesBuilder.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package de.westnordost.streetcomplete.data.quest
* Could theoretically be done with Reflection, but that doesn't really work on Android
*/

class QuestTypeRegistry(private val quests: List<QuestType<*>>): List<QuestType<*>> by quests {
class QuestTypeRegistry(private val quests: List<QuestType<*>>) : List<QuestType<*>> by quests {

private val typeMap: Map<String, QuestType<*>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import javax.inject.Singleton
/** Controls uploading */
@Singleton class UploadController @Inject constructor(
private val context: Context
): UploadProgressSource {
) : UploadProgressSource {

private var uploadServiceIsBound = false
private var uploadService: UploadService.Interface? = null
Expand Down

0 comments on commit 6aa3fb1

Please sign in to comment.