Skip to content

Commit

Permalink
Update plugin kotlinter to v4 (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
juul-mobile-bot authored Oct 23, 2023
1 parent 34cf813 commit bcb30e3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
[*.{kt,kts}]
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true

ktlint_standard_blank-line-before-declaration = disabled
ktlint_standard_filename = disabled
ktlint_standard_function-naming = disabled
ktlint_standard_function-signature = disabled
ktlint_standard_no-blank-line-in-list = disabled
ktlint_standard_no-empty-first-line-in-class-body = disabled
ktlint_standard_no-single-line-block-comment = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_property-wrapping = disabled
ktlint_standard_statement-wrapping = disabled

# `string-template-indent` is disabled because it depends on `multiline-expression-wrapping`.
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_string-template-indent = disabled

[**/*Test/kotlin/**/*.{kt,kts}]
# `if-else-wrapping` is disabled because it depends on `discouraged-comment-location`.
ktlint_standard_discouraged-comment-location = disabled
ktlint_standard_if-else-wrapping = disabled
3 changes: 2 additions & 1 deletion core/src/androidMain/kotlin/WriteNotificationDescriptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package com.juul.kable

/** Mode specifying if config descriptor (0x2902) should be written to when starting/stopping an observation. */
@Deprecated(
message = "Writing notification descriptor is handled automatically by 'observe' function. This class is no longer used and will be removed in a future release.",
message = "Writing notification descriptor is handled automatically by 'observe' function. " +
"This class is no longer used and will be removed in a future release.",
level = DeprecationLevel.HIDDEN,
)
public enum class WriteNotificationDescriptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal class CentralManagerCoreBluetoothScanner(
init {
if (!nativeServiceFiltering) {
logger.warn {
@Suppress("ktlint:standard:max-line-length")
message = "According to Core Bluetooth documentation: " +
"\"The recommended practice is to populate the serviceUUIDs parameter rather than leaving it nil.\" " +
"This means providing only (and at least 1) filter(s) of type `Filter.Service` to Scanner. " +
Expand Down Expand Up @@ -66,8 +67,11 @@ internal class CentralManagerCoreBluetoothScanner(
}
.filterIsInstance<DidDiscoverPeripheral>()
.filter { didDiscoverPeripheral ->
if (nativeServiceFiltering) return@filter true // Short-circuit (i.e. don't filter) when scan is using native service filtering.
if (filters.isEmpty()) return@filter true // Short-circuit (i.e. don't filter) if no filters were provided.
// Short-circuit (i.e. don't filter) when scan is using native service filtering.
if (nativeServiceFiltering) return@filter true

// Short-circuit (i.e. don't filter) if no filters were provided.
if (filters.isEmpty()) return@filter true

val advertisementData = didDiscoverPeripheral.advertisementData.asAdvertisementData()
filters.any { filter ->
Expand Down
13 changes: 8 additions & 5 deletions core/src/appleMain/kotlin/CentralManagerDelegate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ internal class CentralManagerDelegate : NSObject(), CBCentralManagerDelegateProt
_connectionState.emitBlocking(DidConnect(didConnectPeripheral.identifier))
}

@Suppress("CONFLICTING_OVERLOADS") // https://kotlinlang.org/docs/reference/native/objc_interop.html#subclassing-swiftobjective-c-classes-and-protocols-from-kotlin
// https://kotlinlang.org/docs/reference/native/objc_interop.html#subclassing-swiftobjective-c-classes-and-protocols-from-kotlin
@Suppress("CONFLICTING_OVERLOADS")
override fun centralManager(
central: CBCentralManager,
didDisconnectPeripheral: CBPeripheral,
Expand All @@ -86,7 +87,8 @@ internal class CentralManagerDelegate : NSObject(), CBCentralManagerDelegateProt
_connectionState.emitBlocking(DidDisconnect(didDisconnectPeripheral.identifier, error))
}

@Suppress("CONFLICTING_OVERLOADS") // https://kotlinlang.org/docs/reference/native/objc_interop.html#subclassing-swiftobjective-c-classes-and-protocols-from-kotlin
// https://kotlinlang.org/docs/reference/native/objc_interop.html#subclassing-swiftobjective-c-classes-and-protocols-from-kotlin
@Suppress("CONFLICTING_OVERLOADS")
override fun centralManager(
central: CBCentralManager,
didFailToConnectPeripheral: CBPeripheral,
Expand Down Expand Up @@ -121,9 +123,10 @@ internal class CentralManagerDelegate : NSObject(), CBCentralManagerDelegateProt
}

override fun centralManager(central: CBCentralManager, willRestoreState: Map<Any?, *>) {
// No-op: From the documentation: Tells the delegate the system is about to restore the central manager, as part of relaunching the app into the background.
// Use this method to synchronize the state of your app with the state of the Bluetooth system.
// Since the rest of Kable is handling the "synchronize," there's nothing to do here.
// No-op: From the documentation: Tells the delegate the system is about to restore the
// central manager, as part of relaunching the app into the background. Use this method to
// synchronize the state of your app with the state of the Bluetooth system. Since the rest
// of Kable is handling the "synchronize," there's nothing to do here.
}

/* Monitoring the Central Manager’s Authorization */
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ android-library = { id = "com.android.library", version = "8.1.2" }
atomicfu = { id = "kotlinx-atomicfu", version.ref = "atomicfu" }
dokka = { id = "org.jetbrains.dokka", version = "1.9.10" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinter = { id = "org.jmailen.kotlinter", version = "3.16.0" }
kotlinter = { id = "org.jmailen.kotlinter", version = "4.0.0" }
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.25.3" }
validator = { id = "binary-compatibility-validator", version = "0.13.0" }

0 comments on commit bcb30e3

Please sign in to comment.