Enable detekt rules UnnecessaryParentheses and cleanup the code.
This commit is contained in:
@@ -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,
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -93,7 +93,7 @@ class RoomInviteMembersPresenter @Inject constructor(
|
||||
value = if (value.contains(user)) {
|
||||
value.filterNot { it == user }
|
||||
} else {
|
||||
(value + user)
|
||||
value + user
|
||||
}.toImmutableList()
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -16,6 +16,9 @@ style:
|
||||
active: true
|
||||
UnusedParameter:
|
||||
active: true
|
||||
UnnecessaryParentheses:
|
||||
active: true
|
||||
allowForUnclearPrecedence: false
|
||||
UnusedImports:
|
||||
active: true
|
||||
UnusedPrivateProperty:
|
||||
|
||||
Reference in New Issue
Block a user