chore: add detekt formatting rule set

https://detekt.dev/docs/next/rules/formatting/
This commit is contained in:
andrekir 2024-10-13 23:02:05 -03:00 committed by Andre K
parent 056d4a5829
commit fe56d257f5
58 changed files with 725 additions and 432 deletions

View file

@ -29,15 +29,15 @@ import com.geeksville.mesh.database.entity.QuickChatAction
QuickChatAction::class
],
autoMigrations = [
AutoMigration (from = 3, to = 4),
AutoMigration (from = 4, to = 5),
AutoMigration (from = 5, to = 6),
AutoMigration (from = 6, to = 7),
AutoMigration (from = 7, to = 8),
AutoMigration (from = 8, to = 9),
AutoMigration (from = 9, to = 10),
AutoMigration (from = 10, to = 11),
AutoMigration (from = 11, to = 12),
AutoMigration(from = 3, to = 4),
AutoMigration(from = 4, to = 5),
AutoMigration(from = 5, to = 6),
AutoMigration(from = 6, to = 7),
AutoMigration(from = 7, to = 8),
AutoMigration(from = 8, to = 9),
AutoMigration(from = 9, to = 10),
AutoMigration(from = 10, to = 11),
AutoMigration(from = 11, to = 12),
AutoMigration(from = 12, to = 13, spec = AutoMigration12to13::class),
],
version = 13,

View file

@ -29,5 +29,4 @@ interface MeshLogDao {
@Query("DELETE FROM log")
fun deleteAll()
}
}

View file

@ -164,7 +164,7 @@ interface PacketDao {
fun getContactSettings(): Flow<Map<@MapColumn(columnName = "contact_key") String, ContactSettings>>
@Query("SELECT * FROM contact_settings WHERE contact_key = :contact")
suspend fun getContactSettings(contact:String): ContactSettings?
suspend fun getContactSettings(contact: String): ContactSettings?
@Upsert
fun upsertContactSettings(contacts: List<ContactSettings>)

View file

@ -107,9 +107,9 @@ data class NodeEntity(
val validPosition: MeshProtos.Position? get() = position.takeIf { hasValidPosition() }
// @return distance in meters to some other node (or null if unknown)
fun distance(o: NodeEntity): Int? {
return if (validPosition == null || o.validPosition == null) null
else latLongToMeter(latitude, longitude, o.latitude, o.longitude).toInt()
fun distance(o: NodeEntity): Int? = when {
validPosition == null || o.validPosition == null -> null
else -> latLongToMeter(latitude, longitude, o.latitude, o.longitude).toInt()
}
// @return a nice human readable string for the distance, or null for unknown
@ -119,9 +119,9 @@ data class NodeEntity(
}
// @return bearing to the other position in degrees
fun bearing(o: NodeEntity?): Int? {
return if (validPosition == null || o?.validPosition == null) null
else bearing(latitude, longitude, o.latitude, o.longitude).toInt()
fun bearing(o: NodeEntity?): Int? = when {
validPosition == null || o?.validPosition == null -> null
else -> bearing(latitude, longitude, o.latitude, o.longitude).toInt()
}
fun gpsString(gpsFormat: Int): String = when (gpsFormat) {
@ -140,7 +140,9 @@ data class NodeEntity(
} else {
"%.1f°C".format(temperature)
}
} else null
} else {
null
}
val humidity = if (relativeHumidity != 0f) "%.0f%%".format(relativeHumidity) else null
val pressure = if (barometricPressure != 0f) "%.1fhPa".format(barometricPressure) else null
val gas = if (gasResistance != 0f) "%.0fMΩ".format(gasResistance) else null
@ -188,7 +190,7 @@ data class NodeEntity(
}
companion object {
/// Convert to a double representation of degrees
// Convert to a double representation of degrees
fun degD(i: Int) = i * 1e-7
fun degI(d: Double) = (d * 1e7).toInt()

View file

@ -7,12 +7,13 @@ import androidx.room.PrimaryKey
@Entity(tableName = "quick_chat")
data class QuickChatAction(
@PrimaryKey(autoGenerate = true) val uuid: Long,
@ColumnInfo(name="name") val name: String,
@ColumnInfo(name="message") val message: String,
@ColumnInfo(name="mode") val mode: Mode,
@ColumnInfo(name="position") val position: Int) {
@ColumnInfo(name = "name") val name: String,
@ColumnInfo(name = "message") val message: String,
@ColumnInfo(name = "mode") val mode: Mode,
@ColumnInfo(name = "position") val position: Int
) {
enum class Mode {
Append,
Instant,
}
}
}