Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save ktlint rules to project #230

Merged
merged 18 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[*.{kt,kts}]
end_of_line = lf
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_imports_layout = *
ij_kotlin_indent_before_arrow_on_new_line = false
ij_kotlin_line_break_after_multiline_when_entry = true
ij_kotlin_packages_to_use_import_on_demand = java.util.*,kotlinx.android.synthetic.**
indent_size = 4
indent_style = space
insert_final_newline = true
ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = 8
ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = 4
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset
ktlint_code_style = android_studio
ktlint_enum_entry_name_casing = upper_or_camel_cases
ktlint_function_naming_ignore_when_annotated_with = [unset]
ktlint_function_signature_body_expression_wrapping = default
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset
ktlint_ignore_back_ticked_identifier = false
max_line_length = 140
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,29 @@ class NotificationLocalizedStringFactory(
) : NotificationSchedulingService.LocalizedStringFactory {

override fun reminderTitle(roomName: String?): String {
val ending = roomName?.let { NSString.stringWithFormat(bundle.localizedStringForKey("Notification.Reminder.Title.InRoom", null, null).convertParametersForPrintf(), it.cstr) } ?: ""
return NSString.stringWithFormat(bundle.localizedStringForKey("Notification.Reminder.Title.Base", null, null).convertParametersForPrintf(), ending.cstr)
val ending = roomName?.let {
NSString
.stringWithFormat(
bundle.localizedStringForKey("Notification.Reminder.Title.InRoom", null, null)
.convertParametersForPrintf(),
it.cstr
)
} ?: ""
return NSString
.stringWithFormat(
bundle.localizedStringForKey("Notification.Reminder.Title.Base", null, null)
.convertParametersForPrintf(),
ending.cstr
)
}

override fun reminderBody(sessionTitle: String): String {
return NSString.stringWithFormat(bundle.localizedStringForKey("Notification.Reminder.Body", null, null).convertParametersForPrintf(), sessionTitle.cstr)
return NSString
.stringWithFormat(
bundle.localizedStringForKey("Notification.Reminder.Body", null, null)
.convertParametersForPrintf(),
sessionTitle.cstr
)
}

override fun feedbackTitle(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class IOSDateFormatter : DateFormatter {
private fun LocalDate.date() = NSCalendar.currentCalendar.dateFromComponents(toNSDateComponents())

private fun LocalDateTime.date() =
NSCalendar.currentCalendar.dateFromComponents(toNSDateComponents()) // TODOKPG - Pretty sure this is device time zone, might be OK. Just for local formating
// TODOKPG - Pretty sure this is device time zone, might be OK. Just for local formating
NSCalendar.currentCalendar.dateFromComponents(toNSDateComponents())

private fun interval(from: String?, to: String?) = listOfNotNull(from, to).joinToString(" – ")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package co.touchlab.droidcon.ui.util

import androidx.compose.runtime.Composable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.window.Dialog as AndroidXComposeDialog
import androidx.compose.ui.window.DialogProperties

@OptIn(ExperimentalComposeUiApi::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ internal fun SessionListView(
Modifier.tabIndicatorOffset(tabPositions[pagerState.currentPage])
)
} else {
Logger.w("SessionList TabRow requested an indicator for selectedTabIndex: ${pagerState.currentPage}, but only got ${tabPositions.count()} tabs.")
Logger.w(
"SessionList TabRow requested an indicator for selectedTabIndex: " +
"${pagerState.currentPage}, but only got ${tabPositions.count()} tabs."
)
TabRowDefaults.SecondaryIndicator()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ internal fun UIImage.toSkiaImage(): Image? {
val alphaType = when (alphaInfo) {
CGImageAlphaInfo.kCGImageAlphaPremultipliedFirst, CGImageAlphaInfo.kCGImageAlphaPremultipliedLast -> ColorAlphaType.PREMUL
CGImageAlphaInfo.kCGImageAlphaFirst, CGImageAlphaInfo.kCGImageAlphaLast -> ColorAlphaType.UNPREMUL
CGImageAlphaInfo.kCGImageAlphaNone, CGImageAlphaInfo.kCGImageAlphaNoneSkipFirst, CGImageAlphaInfo.kCGImageAlphaNoneSkipLast -> ColorAlphaType.OPAQUE
CGImageAlphaInfo.kCGImageAlphaNone, CGImageAlphaInfo.kCGImageAlphaNoneSkipFirst, CGImageAlphaInfo.kCGImageAlphaNoneSkipLast
-> ColorAlphaType.OPAQUE
else -> ColorAlphaType.UNKNOWN
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package co.touchlab.droidcon.util.formatter

import co.touchlab.droidcon.Constants.conferenceTimeZone
import co.touchlab.droidcon.domain.service.DateTimeService
import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.atTime
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.atTime

class AndroidDateFormatter(private val dateTimeService: DateTimeService) : DateFormatter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ class DefaultSyncService(
while (isActive) {
val lastSessionizeSync = lastSessionizeSync
// If this is the first Sessionize sync or if the last sync occurred more than 2 hours ago.
if (lastSessionizeSync == null || lastSessionizeSync <= dateTimeService.now().minus(SESSIONIZE_SYNC_SINCE_LAST_MINUTES, DateTimeUnit.MINUTE)) {
if (
lastSessionizeSync == null ||
lastSessionizeSync <= dateTimeService.now().minus(SESSIONIZE_SYNC_SINCE_LAST_MINUTES, DateTimeUnit.MINUTE)
) {
try {
runApiDataSourcesSynchronization()
} catch (e: Exception) {
Expand Down Expand Up @@ -280,7 +283,10 @@ class DefaultSyncService(
}
}

private fun updateSponsorsFromDataSource(sponsorSessionsGroups: List<SponsorSessionsDto.SessionGroupDto>, sponsors: SponsorsDto.SponsorCollectionDto) {
private fun updateSponsorsFromDataSource(
sponsorSessionsGroups: List<SponsorSessionsDto.SessionGroupDto>,
sponsors: SponsorsDto.SponsorCollectionDto
) {
val sponsorSessions = sponsorSessionsGroups.flatMap { it.sessions }.associateBy { it.id }
val sponsorGroupsToSponsorDtos = sponsors.groups.map { group ->
val groupName = (group.name.split('/').lastOrNull() ?: group.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package co.touchlab.droidcon

import co.touchlab.droidcon.util.printThrowable
import co.touchlab.kermit.Logger
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlin.coroutines.CoroutineContext

class MainScope(private val mainContext: CoroutineContext, private val log: Logger) : CoroutineScope {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class BundleResourceReader(
name to null
}
}
val path = bundle.pathForResource(filename, type) ?: error("Couldn't get path of $name (parsed as: ${listOfNotNull(filename, type).joinToString(".")})")
val path = bundle
.pathForResource(filename, type) ?: error(
"Couldn't get path of $name (parsed as: ${listOfNotNull(filename, type)
.joinToString(".")})"
)
KevinSchildhorn marked this conversation as resolved.
Show resolved Hide resolved

return memScoped {
val errorPtr = alloc<ObjCObjectVar<NSError?>>()
Expand Down
Loading