Skip to content

Update KTLint #585

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

Merged
merged 17 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 15 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
[*.{kt,kts}]
root = true

ktlint_disabled_rules=no-wildcard-imports,max-line-length
[*]
ij_continuation_indent_size = 4

[*.{kt,kts}]
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
# Imports must be ordered in lexicographic order without any empty lines in-between.
# https://github.com/pinterest/ktlint/issues/1236
ij_kotlin_imports_layout=*
ktlint_code_style = intellij_idea
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_max-line-length = disabled

ktlint_standard_class-naming = disabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the -naming rules required a breaking update?

ktlint_standard_comment-wrapping = disabled
ktlint_standard_discouraged-comment-location = disabled
ktlint_standard_function-naming = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ androidx-lifecycle = "2.8.7"
androidx-media = "1.7.0"
androidx-media2 = "1.3.0"
androidx-media3 = "1.4.1"
androidx-navigation = "2.8.3"
androidx-paging = "3.3.2"
androidx-navigation = "2.8.4"
androidx-paging = "3.3.4"
androidx-recyclerview = "1.3.2"
androidx-room = "2.6.1"
androidx-viewpager2 = "1.1.0"
Expand All @@ -52,7 +52,7 @@ kotlinx-serialization-json = "1.7.3"
# See https://github.com/google/ksp/releases
ksp = "2.0.21-1.0.25"

ktlint = "11.5.1"
ktlint = "12.1.1"

# We cannot upgrade to 1.9.0 as it conflicts with liblcp.
# See https://github.com/readium/kotlin-toolkit/issues/29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.readium.r2.shared.util.toUrl
*/
@OptIn(UnstableApi::class)
public class DefaultExoPlayerCacheProvider(
private val cache: Cache
private val cache: Cache,
) : ExoPlayerCacheProvider {

@kotlin.OptIn(DelicateReadiumApi::class)
Expand All @@ -30,7 +30,7 @@ public class DefaultExoPlayerCacheProvider(

@OptIn(UnstableApi::class)
public fun ExoPlayerCacheProvider.createCacheDataSourceFactory(
publication: Publication
publication: Publication,
): CacheDataSource.Factory? {
val cache = getCache(publication) ?: return null
val upstreamDataSourceFactory = ExoPlayerDataSource.Factory(publication)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class ExoAudiobookPlayer(
private val player: ExoPlayer,
private val itemDurations: List<Duration>?,
private val seekForwardIncrement: Duration,
private val seekBackwardIncrement: Duration
private val seekBackwardIncrement: Duration,
) : ForwardingPlayer(player) {

fun seekBy(offset: Duration) {
Expand All @@ -46,7 +46,7 @@ internal class ExoAudiobookPlayer(
@OptIn(ExperimentalTime::class)
private fun smartSeekBy(
offset: Duration,
durations: List<Duration>
durations: List<Duration>,
) {
val (newIndex, newPosition) =
SmartSeeker.dispatchSeek(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import timber.log.Timber
*/
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
internal class ExoPlayerDataSource internal constructor(
private val publication: Publication
private val publication: Publication,
) : BaseDataSource(/* isNetwork = */ true) {

class Factory(
private val publication: Publication,
private val transferListener: TransferListener? = null
private val transferListener: TransferListener? = null,
) : DataSource.Factory {

override fun createDataSource(): DataSource =
Expand All @@ -49,7 +49,7 @@ internal class ExoPlayerDataSource internal constructor(
val resource: Resource,
val uri: Uri,
var position: Long,
var remaining: Long
var remaining: Long,
)

private var openedResource: OpenedResource? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package org.readium.adapter.exoplayer.audio
*/
public data class ExoPlayerDefaults(
val pitch: Double? = null,
val speed: Double? = null
val speed: Double? = null,
) {
init {
require(pitch == null || pitch > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ExoPlayerEngine private constructor(
private val exoPlayer: ExoAudiobookPlayer,
private val settingsResolver: SettingsResolver,
private val configuration: Configuration,
initialPreferences: ExoPlayerPreferences
initialPreferences: ExoPlayerPreferences,
) : AudioEngine<ExoPlayerSettings, ExoPlayerPreferences> {

public companion object {
Expand All @@ -67,7 +67,7 @@ public class ExoPlayerEngine private constructor(
configuration: Configuration,
initialIndex: Int,
initialPosition: Duration,
initialPreferences: ExoPlayerPreferences
initialPreferences: ExoPlayerPreferences,
): ExoPlayerEngine {
val exoPlayer = ExoPlayer.Builder(application)
.setMediaSourceFactory(DefaultMediaSourceFactory(dataSourceFactory))
Expand Down Expand Up @@ -143,18 +143,18 @@ public class ExoPlayerEngine private constructor(
public data class Configuration(
val positionRefreshRate: Hz = 2.0.hz,
val seekBackwardIncrement: Duration = 15.seconds,
val seekForwardIncrement: Duration = 30.seconds
val seekForwardIncrement: Duration = 30.seconds,
)

public data class Playlist(
val mediaMetadata: MediaMetadata,
val duration: Duration?,
val items: List<Item>
val items: List<Item>,
) {
public data class Item(
val url: Url,
val mediaMetadata: MediaMetadata,
val duration: Duration?
val duration: Duration?,
)
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public class ExoPlayerEngine private constructor(

public sealed class Error(
override val message: String,
override val cause: org.readium.r2.shared.util.Error?
override val cause: org.readium.r2.shared.util.Error?,
) : AudioEngine.Error {

public data class Engine(override val cause: ThrowableError<ExoPlaybackException>) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public class ExoPlayerEngineProvider(
private val metadataProvider: MediaMetadataProvider = DefaultMediaMetadataProvider(),
private val cacheProvider: ExoPlayerCacheProvider? = null,
private val defaults: ExoPlayerDefaults = ExoPlayerDefaults(),
private val configuration: ExoPlayerEngine.Configuration = ExoPlayerEngine.Configuration()
private val configuration: ExoPlayerEngine.Configuration = ExoPlayerEngine.Configuration(),
) : AudioEngineProvider<ExoPlayerSettings, ExoPlayerPreferences, ExoPlayerPreferencesEditor> {

override suspend fun createEngine(
publication: Publication,
initialLocator: Locator,
initialPreferences: ExoPlayerPreferences
initialPreferences: ExoPlayerPreferences,
): Try<ExoPlayerEngine, Nothing> {
val metadataFactory = metadataProvider.createMetadataFactory(publication)
val settingsResolver = ExoPlayerSettingsResolver(defaults)
Expand Down Expand Up @@ -80,7 +80,7 @@ public class ExoPlayerEngineProvider(

override fun createPreferenceEditor(
publication: Publication,
initialPreferences: ExoPlayerPreferences
initialPreferences: ExoPlayerPreferences,
): ExoPlayerPreferencesEditor =
ExoPlayerPreferencesEditor(
initialPreferences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.readium.r2.navigator.preferences.Configurable
@kotlinx.serialization.Serializable
public data class ExoPlayerPreferences(
val pitch: Double? = null,
val speed: Double? = null
val speed: Double? = null,
) : Configurable.Preferences<ExoPlayerPreferences> {

override fun plus(other: ExoPlayerPreferences): ExoPlayerPreferences =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import org.readium.r2.shared.publication.Metadata
public class ExoPlayerPreferencesEditor(
initialPreferences: ExoPlayerPreferences,
@Suppress("UNUSED_PARAMETER") publicationMetadata: Metadata,
defaults: ExoPlayerDefaults
defaults: ExoPlayerDefaults,
) : PreferencesEditor<ExoPlayerPreferences> {

private data class State(
val preferences: ExoPlayerPreferences,
val settings: ExoPlayerSettings
val settings: ExoPlayerSettings,
)

private val settingsResolver: ExoPlayerSettingsResolver =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ import org.readium.r2.navigator.preferences.Configurable
*/
public data class ExoPlayerSettings(
val pitch: Double,
val speed: Double
val speed: Double,
) : Configurable.Settings
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.readium.r2.shared.ExperimentalReadiumApi

@OptIn(ExperimentalReadiumApi::class)
internal class ExoPlayerSettingsResolver(
private val defaults: ExoPlayerDefaults
private val defaults: ExoPlayerDefaults,
) : ExoPlayerEngine.SettingsResolver {

override fun settings(preferences: ExoPlayerPreferences): ExoPlayerSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal object SmartSeeker {
offset: Duration,
currentPosition: Duration,
currentIndex: Int,
playlist: List<Duration>
playlist: List<Duration>,
): Result {
val currentDuration = playlist[currentIndex]
val dummyNewPosition = currentPosition + offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class PdfiumDocument(
@InternalReadiumApi public val core: PdfiumCore,
@InternalReadiumApi public val document: _PdfiumDocument,
override val identifier: String?,
override val pageCount: Int
override val pageCount: Int,
) : PdfDocument {

private val metadata: _PdfiumDocument.Meta by lazy { core.getDocumentMeta(document) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ import org.readium.r2.navigator.preferences.ReadingProgression
*/
public data class PdfiumDefaults(
val pageSpacing: Double? = null,
val readingProgression: ReadingProgression? = null
val readingProgression: ReadingProgression? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class PdfiumDocumentFragment internal constructor(
private val href: Url,
private val initialPageIndex: Int,
initialSettings: PdfiumSettings,
private val listener: Listener?
private val listener: Listener?,
) : PdfDocumentFragment<PdfiumSettings>() {

// Dummy constructor to address https://github.com/readium/kotlin-toolkit/issues/395
Expand Down Expand Up @@ -78,7 +78,7 @@ public class PdfiumDocumentFragment internal constructor(
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
savedInstanceState: Bundle?,
): View =
PDFView(inflater.context, null)
.also { pdfView = it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.readium.r2.shared.util.data.ReadError
@ExperimentalReadiumApi
public class PdfiumEngineProvider(
private val defaults: PdfiumDefaults = PdfiumDefaults(),
private val listener: Listener? = null
private val listener: Listener? = null,
) : PdfEngineProvider<PdfiumSettings, PdfiumPreferences, PdfiumPreferencesEditor> {

public interface Listener : PdfEngineProvider.Listener {
Expand All @@ -43,7 +43,7 @@ public class PdfiumEngineProvider(
}

override fun createDocumentFragmentFactory(
input: PdfDocumentFragmentInput<PdfiumSettings>
input: PdfDocumentFragmentInput<PdfiumSettings>,
): SingleFragmentFactory<PdfiumDocumentFragment> =
createFragmentFactory {
PdfiumDocumentFragment(
Expand Down Expand Up @@ -80,7 +80,7 @@ public class PdfiumEngineProvider(

override fun createPreferenceEditor(
publication: Publication,
initialPreferences: PdfiumPreferences
initialPreferences: PdfiumPreferences,
): PdfiumPreferencesEditor =
PdfiumPreferencesEditor(
initialPreferences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public data class PdfiumPreferences(
val fit: Fit? = null,
val pageSpacing: Double? = null,
val readingProgression: ReadingProgression? = null,
val scrollAxis: Axis? = null
val scrollAxis: Axis? = null,
) : Configurable.Preferences<PdfiumPreferences> {

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import org.readium.r2.shared.publication.Metadata
public class PdfiumPreferencesEditor internal constructor(
initialPreferences: PdfiumPreferences,
publicationMetadata: Metadata,
defaults: PdfiumDefaults
defaults: PdfiumDefaults,
) : PreferencesEditor<PdfiumPreferences> {

private data class State(
val preferences: PdfiumPreferences,
val settings: PdfiumSettings
val settings: PdfiumSettings,
)

private val settingsResolver: PdfiumSettingsResolver =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public data class PdfiumSettings(
val fit: Fit,
val pageSpacing: Double,
val readingProgression: ReadingProgression,
val scrollAxis: Axis
val scrollAxis: Axis,
) : Configurable.Settings
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.readium.r2.shared.publication.ReadingProgression as PublicationReadin

internal class PdfiumSettingsResolver(
private val metadata: Metadata,
private val defaults: PdfiumDefaults
private val defaults: PdfiumDefaults,
) {

fun settings(preferences: PdfiumPreferences): PdfiumSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class PsPdfKitDocumentFactory(context: Context) : PdfDocumentFactory<PsPd
}

public class PsPdfKitDocument(
public val document: _PsPdfKitDocument
public val document: _PsPdfKitDocument,
) : PdfDocument {

// FIXME: Doesn't seem to be exposed by PSPDFKit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import timber.log.Timber

internal class ResourceDataProvider(
resource: Resource,
private val onResourceError: (ReadError) -> Unit = { Timber.e(it.toDebugDescription()) }
private val onResourceError: (ReadError) -> Unit = { Timber.e(it.toDebugDescription()) },
) : DataProvider {

var error: ReadError? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ public data class PsPdfKitDefaults(
val pageSpacing: Double? = null,
val readingProgression: ReadingProgression? = null,
val scroll: Boolean? = null,
val spread: Spread? = null
val spread: Spread? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class PsPdfKitDocumentFragment internal constructor(
private val href: Url,
initialPageIndex: Int,
initialSettings: PsPdfKitSettings,
private val listener: Listener?
private val listener: Listener?,
) : PdfDocumentFragment<PsPdfKitSettings>() {

internal interface Listener {
Expand All @@ -93,7 +93,7 @@ public class PsPdfKitDocumentFragment internal constructor(
private val psPdfKitListener = PsPdfKitListener()

private class DocumentViewModel(
document: suspend () -> ReadTry<PsPdfKitDocument>
document: suspend () -> ReadTry<PsPdfKitDocument>,
) : ViewModel() {

private val _document: Deferred<ReadTry<PsPdfKitDocument>> =
Expand Down Expand Up @@ -142,7 +142,7 @@ public class PsPdfKitDocumentFragment internal constructor(
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
savedInstanceState: Bundle?,
): View =
FragmentContainerView(inflater.context)
.apply {
Expand Down Expand Up @@ -276,7 +276,7 @@ public class PsPdfKitDocumentFragment internal constructor(
pageIndex: Int,
event: MotionEvent?,
pagePosition: PointF?,
clickedAnnotation: Annotation?
clickedAnnotation: Annotation?,
): Boolean {
if (
pagePosition == null || clickedAnnotation is LinkAnnotation ||
Expand Down
Loading