diff --git a/features/location/api/src/main/kotlin/io/element/android/features/location/api/internal/ModifierCenterBottomEdge.kt b/features/location/api/src/main/kotlin/io/element/android/features/location/api/internal/ModifierCenterBottomEdge.kt index 7ad299adae..736f24e609 100644 --- a/features/location/api/src/main/kotlin/io/element/android/features/location/api/internal/ModifierCenterBottomEdge.kt +++ b/features/location/api/src/main/kotlin/io/element/android/features/location/api/internal/ModifierCenterBottomEdge.kt @@ -29,7 +29,7 @@ fun Modifier.centerBottomEdge(scope: BoxScope): Modifier = with(scope) { Modifier.align { size, space, _ -> IntOffset( x = (space.width - size.width) / 2, - y = (space.height / 2) - size.height, + y = space.height / 2 - size.height, ) } ) diff --git a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordState.kt b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordState.kt index c8fa2f4ad3..cf4e0d8ee5 100644 --- a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordState.kt +++ b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordState.kt @@ -30,7 +30,8 @@ data class LoginPasswordState( ) { val submitEnabled: Boolean get() = loginAction !is Async.Failure && - ((formState.login.isNotEmpty() && formState.password.isNotEmpty())) + formState.login.isNotEmpty() && + formState.password.isNotEmpty() } @Parcelize diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/ExtraPadding.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/ExtraPadding.kt index d941b8a814..65101183d9 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/ExtraPadding.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/ExtraPadding.kt @@ -65,7 +65,7 @@ fun TimelineItem.Event.toExtraPadding(): ExtraPadding { fun ExtraPadding.getStr(fontSize: TextUnit): String { if (nbChars == 0) return "" val timestampFontSize = ElementTheme.typography.fontBodyXsRegular.fontSize // 11.sp - val nbOfSpaces = ((timestampFontSize.value / fontSize.value) * nbChars).toInt() + 1 + val nbOfSpaces = (timestampFontSize.value / fontSize.value * nbChars).toInt() + 1 // A space and some unbreakable spaces return " " + "\u00A0".repeat(nbOfSpaces) } diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html/HtmlDocument.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html/HtmlDocument.kt index 76df891a93..82d73cc1a0 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html/HtmlDocument.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html/HtmlDocument.kt @@ -351,7 +351,7 @@ private fun HtmlMxReply( Surface( modifier = modifier .padding(bottom = 4.dp) - .offset(x = -(8.dp)), + .offset(x = (-8).dp), color = MaterialTheme.colorScheme.background, shape = shape, ) { diff --git a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/attachments/AttachmentsPreviewPresenterTest.kt b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/attachments/AttachmentsPreviewPresenterTest.kt index a96d7104a3..fb8b3b1948 100644 --- a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/attachments/AttachmentsPreviewPresenterTest.kt +++ b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/attachments/AttachmentsPreviewPresenterTest.kt @@ -86,7 +86,7 @@ class AttachmentsPreviewPresenterTest { val loadingState = awaitItem() assertThat(loadingState.sendActionState).isEqualTo(SendActionState.Sending.Processing) val failureState = awaitItem() - assertThat(failureState.sendActionState).isEqualTo((SendActionState.Failure(failure))) + assertThat(failureState.sendActionState).isEqualTo(SendActionState.Failure(failure)) assertThat(room.sendMediaCount).isEqualTo(0) failureState.eventSink(AttachmentsPreviewEvents.ClearSendState) val clearedState = awaitItem() diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersPresenter.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersPresenter.kt index 00cb04b118..cc0886c3af 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersPresenter.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersPresenter.kt @@ -93,7 +93,7 @@ class RoomInviteMembersPresenter @Inject constructor( value = if (value.contains(user)) { value.filterNot { it == user } } else { - (value + user) + value + user }.toImmutableList() } diff --git a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/members/RoomMemberListPresenterTests.kt b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/members/RoomMemberListPresenterTests.kt index 9d21e668f0..5a3141ea09 100644 --- a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/members/RoomMemberListPresenterTests.kt +++ b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/members/RoomMemberListPresenterTests.kt @@ -72,7 +72,7 @@ class RoomMemberListPresenterTests { loadedState.eventSink(RoomMemberListEvents.OnSearchActiveChanged(true)) val searchActiveState = awaitItem() - Truth.assertThat((searchActiveState.isSearchActive)).isTrue() + Truth.assertThat(searchActiveState.isSearchActive).isTrue() } } @@ -88,7 +88,7 @@ class RoomMemberListPresenterTests { val searchActiveState = awaitItem() loadedState.eventSink(RoomMemberListEvents.UpdateSearchQuery("something")) val searchQueryUpdatedState = awaitItem() - Truth.assertThat((searchQueryUpdatedState.searchQuery)).isEqualTo("something") + Truth.assertThat(searchQueryUpdatedState.searchQuery).isEqualTo("something") val searchSearchResultDelivered = awaitItem() Truth.assertThat(searchSearchResultDelivered.searchResults).isInstanceOf(SearchBarResultState.NoResults::class.java) } @@ -106,9 +106,9 @@ class RoomMemberListPresenterTests { val searchActiveState = awaitItem() loadedState.eventSink(RoomMemberListEvents.UpdateSearchQuery("Alice")) val searchQueryUpdatedState = awaitItem() - Truth.assertThat((searchQueryUpdatedState.searchQuery)).isEqualTo("Alice") + Truth.assertThat(searchQueryUpdatedState.searchQuery).isEqualTo("Alice") val searchSearchResultDelivered = awaitItem() - Truth.assertThat((searchSearchResultDelivered.searchResults)).isInstanceOf(SearchBarResultState.Results::class.java) + Truth.assertThat(searchSearchResultDelivered.searchResults).isInstanceOf(SearchBarResultState.Results::class.java) Truth.assertThat((searchSearchResultDelivered.searchResults as SearchBarResultState.Results).results.joined.first().displayName) .isEqualTo("Alice") diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt index b32f169e6b..aab174c6a4 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt @@ -155,7 +155,7 @@ private fun RowScope.NameAndTimestampRow(room: RoomListRoomSummary) { @Composable private fun RowScope.LastMessageAndIndicatorRow(room: RoomListRoomSummary) { // Last Message - val attributedLastMessage = (room.lastMessage as? AnnotatedString) + val attributedLastMessage = room.lastMessage as? AnnotatedString ?: AnnotatedString(room.lastMessage.orEmpty().toString()) Text( modifier = Modifier @@ -186,10 +186,10 @@ class PercentRectangleSizeShape(private val percent: Float) : Shape { val halfPercent = percent / 2f val path = Path().apply { val rect = Rect( - 0f, - size.height * halfPercent, - size.width, - size.height - (size.height * halfPercent) + left = 0f, + top = size.height * halfPercent, + right = size.width, + bottom = size.height * (1 - halfPercent) ) addRect(rect) close() diff --git a/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/system/SystemUtils.kt b/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/system/SystemUtils.kt index 65a5dc9e0d..8347990303 100644 --- a/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/system/SystemUtils.kt +++ b/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/system/SystemUtils.kt @@ -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. diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/atoms/ElementLogoAtom.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/atoms/ElementLogoAtom.kt index 94e50d5953..8f96ed6b6e 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/atoms/ElementLogoAtom.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/atoms/ElementLogoAtom.kt @@ -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() diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt index 9f4df1f6b3..96b61fd558 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt @@ -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 diff --git a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/SelectedUsersList.kt b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/SelectedUsersList.kt index c0ed0460dc..9938fde395 100644 --- a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/SelectedUsersList.kt +++ b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/SelectedUsersList.kt @@ -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) ) } diff --git a/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/ImageCompressor.kt b/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/ImageCompressor.kt index 94e71fef59..938072433a 100644 --- a/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/ImageCompressor.kt +++ b/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/ImageCompressor.kt @@ -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 diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/RoomGroupMessageCreator.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/RoomGroupMessageCreator.kt index 5f2f6db263..989ba2ad09 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/RoomGroupMessageCreator.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/RoomGroupMessageCreator.kt @@ -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, diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/channels/NotificationChannels.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/channels/NotificationChannels.kt index 0624b863ed..ab115262de 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/channels/NotificationChannels.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/channels/NotificationChannels.kt @@ -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) diff --git a/tools/detekt/detekt.yml b/tools/detekt/detekt.yml index 7db4114585..facace06a1 100644 --- a/tools/detekt/detekt.yml +++ b/tools/detekt/detekt.yml @@ -16,6 +16,9 @@ style: active: true UnusedParameter: active: true + UnnecessaryParentheses: + active: true + allowForUnclearPrecedence: false UnusedImports: active: true UnusedPrivateProperty: