Skip to content

Commit

Permalink
Detekt: fix ConstructorParameterNaming
Browse files Browse the repository at this point in the history
UserProperties fix is also in matrix-org/matrix-analytics-events#62
  • Loading branch information
bmarty committed May 12, 2022
1 parent 6f3b9c7 commit 03ec994
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ package org.matrix.android.sdk.api.logger
* val loggerTag = LoggerTag("MyTag", LoggerTag.VOIP)
* Timber.tag(loggerTag.value).v("My log message")
*/
open class LoggerTag(_value: String, parentTag: LoggerTag? = null) {
open class LoggerTag(name: String, parentTag: LoggerTag? = null) {

object SYNC : LoggerTag("SYNC")
object VOIP : LoggerTag("VOIP")
object CRYPTO : LoggerTag("CRYPTO")

val value: String = if (parentTag == null) {
_value
name
} else {
"${parentTag.value}/$_value"
"${parentTag.value}/$name"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import timber.log.Timber
@JsonClass(generateAdapter = true)
data class RoomGuestAccessContent(
// Required. Whether guests can join the room. One of: ["can_join", "forbidden"]
@Json(name = "guest_access") val _guestAccess: String? = null
@Json(name = "guest_access") val guestAccessStr: String? = null
) {
val guestAccess: GuestAccess? = when (_guestAccess) {
val guestAccess: GuestAccess? = when (guestAccessStr) {
"can_join" -> GuestAccess.CanJoin
"forbidden" -> GuestAccess.Forbidden
else -> {
Timber.w("Invalid value for GuestAccess: `$_guestAccess`")
Timber.w("Invalid value for GuestAccess: `$guestAccessStr`")
null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import timber.log.Timber

@JsonClass(generateAdapter = true)
data class RoomHistoryVisibilityContent(
@Json(name = "history_visibility") val _historyVisibility: String? = null
@Json(name = "history_visibility") val historyVisibilityStr: String? = null
) {
val historyVisibility: RoomHistoryVisibility? = when (_historyVisibility) {
val historyVisibility: RoomHistoryVisibility? = when (historyVisibilityStr) {
"world_readable" -> RoomHistoryVisibility.WORLD_READABLE
"shared" -> RoomHistoryVisibility.SHARED
"invited" -> RoomHistoryVisibility.INVITED
"joined" -> RoomHistoryVisibility.JOINED
else -> {
Timber.w("Invalid value for RoomHistoryVisibility: `$_historyVisibility`")
Timber.w("Invalid value for RoomHistoryVisibility: `$historyVisibilityStr`")
null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ import timber.log.Timber
*/
@JsonClass(generateAdapter = true)
data class RoomJoinRulesContent(
@Json(name = "join_rule") val _joinRules: String? = null,
@Json(name = "join_rule") val joinRulesStr: String? = null,
/**
* If the allow key is an empty list (or not a list at all),
* then no users are allowed to join without an invite.
* Each entry is expected to be an object with the following keys:
*/
@Json(name = "allow") val allowList: List<RoomJoinRulesAllowEntry>? = null
) {
val joinRules: RoomJoinRules? = when (_joinRules) {
val joinRules: RoomJoinRules? = when (joinRulesStr) {
"public" -> RoomJoinRules.PUBLIC
"invite" -> RoomJoinRules.INVITE
"knock" -> RoomJoinRules.KNOCK
"private" -> RoomJoinRules.PRIVATE
"restricted" -> RoomJoinRules.RESTRICTED
else -> {
Timber.w("Invalid value for RoomJoinRules: `$_joinRules`")
Timber.w("Invalid value for RoomJoinRules: `$joinRulesStr`")
null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RestrictedRoomPreset(val homeServerCapabilities: HomeServerCapabilities, v
type = EventType.STATE_ROOM_JOIN_RULES,
stateKey = "",
content = RoomJoinRulesContent(
_joinRules = RoomJoinRules.RESTRICTED.value,
joinRulesStr = RoomJoinRules.RESTRICTED.value,
allowList = restrictedList
).toContent()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = false)
sealed class LazyRoomSyncEphemeral {
data class Parsed(val _roomSyncEphemeral: RoomSyncEphemeral) : LazyRoomSyncEphemeral()
data class Parsed(val roomSyncEphemeral: RoomSyncEphemeral) : LazyRoomSyncEphemeral()
object Stored : LazyRoomSyncEphemeral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

package org.matrix.android.sdk.internal.session.identity.model

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
internal data class SignInvitationBody(
/**The Matrix user ID of the user accepting the invitation.*/
/** The Matrix user ID of the user accepting the invitation.*/
val mxid: String,
/**The token from the call to store- invite..*/
/** The token from the call to store- invite..*/
val token: String,
/** The private key, encoded as Unpadded base64. */
val private_key: String
@Json(name = "private_key")
val privateKey: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ internal class DefaultStateService @AssistedInject constructor(@Assisted private
if (joinRules != null) {
val body = if (joinRules == RoomJoinRules.RESTRICTED) {
RoomJoinRulesContent(
_joinRules = RoomJoinRules.RESTRICTED.value,
joinRulesStr = RoomJoinRules.RESTRICTED.value,
allowList = allowList
).toContent()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal data class SearchRequestRoomEvents(
* Requests the server return the current state for each room returned.
*/
@Json(name = "include_state")
val include_state: Boolean? = null
val includeState: Boolean? = null

/**
* Requests that the server partitions the result set based on the provided list of keys.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ internal class RoomSyncHandler @Inject constructor(
val isInitialSync = insertType == EventInsertType.INITIAL_SYNC

val ephemeralResult = (roomSync.ephemeral as? LazyRoomSyncEphemeral.Parsed)
?._roomSyncEphemeral
?.roomSyncEphemeral
?.events
?.takeIf { it.isNotEmpty() }
?.let { handleEphemeral(realm, roomId, it, insertType == EventInsertType.INITIAL_SYNC, aggregator) }
Expand Down
3 changes: 0 additions & 3 deletions tools/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ naming:
VariableNaming:
# TODO Enable it
active: false
ConstructorParameterNaming:
# TODO Enable it
active: false
TopLevelPropertyNaming:
# TODO Enable it
active: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ data class UserProperties(
/**
* Whether the user has the favourites space enabled
*/
val WebMetaSpaceFavouritesEnabled: Boolean? = null,
val webMetaSpaceFavouritesEnabled: Boolean? = null,
/**
* Whether the user has the home space set to all rooms
*/
val WebMetaSpaceHomeAllRooms: Boolean? = null,
val webMetaSpaceHomeAllRooms: Boolean? = null,
/**
* Whether the user has the home space enabled
*/
val WebMetaSpaceHomeEnabled: Boolean? = null,
val webMetaSpaceHomeEnabled: Boolean? = null,
/**
* Whether the user has the other rooms space enabled
*/
val WebMetaSpaceOrphansEnabled: Boolean? = null,
val webMetaSpaceOrphansEnabled: Boolean? = null,
/**
* Whether the user has the people space enabled
*/
val WebMetaSpacePeopleEnabled: Boolean? = null,
val webMetaSpacePeopleEnabled: Boolean? = null,
/**
* The selected messaging use case during the onboarding flow.
*/
Expand Down Expand Up @@ -82,11 +82,11 @@ data class UserProperties(

fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
WebMetaSpaceFavouritesEnabled?.let { put("WebMetaSpaceFavouritesEnabled", it) }
WebMetaSpaceHomeAllRooms?.let { put("WebMetaSpaceHomeAllRooms", it) }
WebMetaSpaceHomeEnabled?.let { put("WebMetaSpaceHomeEnabled", it) }
WebMetaSpaceOrphansEnabled?.let { put("WebMetaSpaceOrphansEnabled", it) }
WebMetaSpacePeopleEnabled?.let { put("WebMetaSpacePeopleEnabled", it) }
webMetaSpaceFavouritesEnabled?.let { put("WebMetaSpaceFavouritesEnabled", it) }
webMetaSpaceHomeAllRooms?.let { put("WebMetaSpaceHomeAllRooms", it) }
webMetaSpaceHomeEnabled?.let { put("WebMetaSpaceHomeEnabled", it) }
webMetaSpaceOrphansEnabled?.let { put("WebMetaSpaceOrphansEnabled", it) }
webMetaSpacePeopleEnabled?.let { put("WebMetaSpacePeopleEnabled", it) }
ftueUseCaseSelection?.let { put("ftueUseCaseSelection", it.name) }
numFavouriteRooms?.let { put("numFavouriteRooms", it) }
numSpaces?.let { put("numSpaces", it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AutoCompleter @AssistedInject constructor(
@Assisted val isInThreadTimeline: Boolean,
private val avatarRenderer: AvatarRenderer,
private val commandAutocompletePolicy: CommandAutocompletePolicy,
AutocompleteCommandPresenterFactory: AutocompleteCommandPresenter.Factory,
autocompleteCommandPresenterFactory: AutocompleteCommandPresenter.Factory,
private val autocompleteMemberPresenterFactory: AutocompleteMemberPresenter.Factory,
private val autocompleteRoomPresenter: AutocompleteRoomPresenter,
private val autocompleteGroupPresenter: AutocompleteGroupPresenter,
Expand All @@ -68,7 +68,7 @@ class AutoCompleter @AssistedInject constructor(
}

private val autocompleteCommandPresenter: AutocompleteCommandPresenter by lazy {
AutocompleteCommandPresenterFactory.create(isInThreadTimeline)
autocompleteCommandPresenterFactory.create(isInThreadTimeline)
}

private var editText: EditText? = null
Expand Down

0 comments on commit 03ec994

Please sign in to comment.