Enable detekt rules UnnecessaryParentheses and cleanup the code.

This commit is contained in:
Benoit Marty 2023-07-20 18:05:37 +02:00
parent 2928073e22
commit c75eabbcb0
16 changed files with 27 additions and 23 deletions

View file

@ -59,7 +59,7 @@ fun Context.isAnimationEnabled(): Boolean {
}
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
fun supportNotificationChannels() = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
fun supportNotificationChannels() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
/**
* Return the application label of the provided package. If not found, the package is returned.

View file

@ -138,7 +138,7 @@ fun Modifier.shapeShadow(
val paint = Paint()
val frameworkPaint = paint.asFrameworkPaint()
if (blurRadius != 0.dp) {
frameworkPaint.maskFilter = (BlurMaskFilter(blurRadius.toPx(), BlurMaskFilter.Blur.NORMAL))
frameworkPaint.maskFilter = BlurMaskFilter(blurRadius.toPx(), BlurMaskFilter.Blur.NORMAL)
}
frameworkPaint.color = color.toArgb()

View file

@ -45,7 +45,7 @@ class EventMessageMapper {
fun map(message: Message): MessageContent = message.use {
val type = it.msgtype().use(this::mapMessageType)
val inReplyToId = it.inReplyTo()?.eventId?.let(::EventId)
val inReplyToEvent: InReplyTo? = (it.inReplyTo()?.event)?.use { details ->
val inReplyToEvent: InReplyTo? = it.inReplyTo()?.event?.use { details ->
when (details) {
is RepliedToEventDetails.Ready -> {
val senderProfile = details.senderProfile as? ProfileDetails.Ready

View file

@ -88,7 +88,7 @@ fun SelectedUsersList(
val maxVisibleUsers = rowWidth / userWidthWithSpacing
// Round down the number of visible users to end with a state where one is half visible
val targetFraction = (userWidth / 2) / userWidthWithSpacing
val targetFraction = userWidth / 2 / userWidthWithSpacing
val targetUsers = floor(maxVisibleUsers - targetFraction) + targetFraction
// Work out how much extra spacing we need to reduce the number of users that much, then split it evenly amongst the visible users
@ -153,7 +153,7 @@ private fun ContentToPreview() {
SelectedUsersList(
selectedUsers = aMatrixUserList().take(6).toImmutableList(),
modifier = Modifier
.width((200 + (i * 20)).dp)
.width((200 + (i * 20).dp)
.border(1.dp, Color.Red)
)
}

View file

@ -91,7 +91,7 @@ class ImageCompressor @Inject constructor(
) {
val (width, height) = when (resizeMode) {
is ResizeMode.Approximate -> resizeMode.desiredWidth to resizeMode.desiredHeight
is ResizeMode.Strict -> (resizeMode.maxWidth / 2) to (resizeMode.maxHeight / 2)
is ResizeMode.Strict -> resizeMode.maxWidth / 2 to resizeMode.maxHeight / 2
is ResizeMode.None -> return
}
// Read bounds only

View file

@ -69,7 +69,7 @@ class RoomGroupMessageCreator @Inject constructor(
val lastMessageTimestamp = events.last().timestamp
val smartReplyErrors = events.filter { it.isSmartReplyError() }
val messageCount = (events.size - smartReplyErrors.size)
val messageCount = events.size - smartReplyErrors.size
val meta = RoomNotification.Message.Meta(
summaryLine = createRoomMessagesGroupSummaryLine(events, roomName, roomIsDirect = !roomIsGroup),
messageCount = messageCount,

View file

@ -162,7 +162,7 @@ class NotificationChannels @Inject constructor(
private const val CALL_NOTIFICATION_CHANNEL_ID = "CALL_NOTIFICATION_CHANNEL_ID_V2"
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
private fun supportNotificationChannels() = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
private fun supportNotificationChannels() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
fun openSystemSettingsForSilentCategory(activity: Activity) {
activity.startNotificationChannelSettingsIntent(SILENT_NOTIFICATION_CHANNEL_ID)