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

Update for ktlint 1.0.0 (ktlint-maven-plugin 3.0.0). #134

Merged
merged 2 commits into from
Oct 3, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[*.{kt,kts}]
max_line_length = 120

# Comma-separated list of rules to disable (Since 0.34.0)
# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
# by the ruleset identifier.
ktlint_code_style = intellij_idea

# I find trailing commas annoying
ktlint_standard_trailing-comma-on-call-site = disabled
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
<plugin>
<groupId>com.github.gantsign.maven</groupId>
<artifactId>ktlint-maven-plugin</artifactId>
<version>2.0.0</version>
<version>3.0.0</version>
<configuration>
<sourceRoots>
<sourceRoot>${project.basedir}/src/main/kotlin</sourceRoot>
Expand Down
13 changes: 5 additions & 8 deletions src/main/kotlin/org/jitsi/utils/Delegates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@ import kotlin.reflect.KProperty
inline fun <T> observableWhenChanged(
initialValue: T,
crossinline onChange: (property: KProperty<*>, oldValue: T, newValue: T) -> Unit
): ReadWriteProperty<Any?, T> =
Delegates.observable(initialValue) { property, oldValue, newValue ->
if (oldValue != newValue) onChange(property, oldValue, newValue)
}
): ReadWriteProperty<Any?, T> = Delegates.observable(initialValue) { property, oldValue, newValue ->
if (oldValue != newValue) onChange(property, oldValue, newValue)
}

/**
* A delegate which runs a callback (with no arguments) whenever the setter is called and it results in the value
* changing.
*/
inline fun <T> observableWhenChanged(
initialValue: T,
crossinline onChange: () -> Unit
): ReadWriteProperty<Any?, T> = observableWhenChanged(initialValue) { _, _, _ -> onChange() }
inline fun <T> observableWhenChanged(initialValue: T, crossinline onChange: () -> Unit): ReadWriteProperty<Any?, T> =
observableWhenChanged(initialValue) { _, _, _ -> onChange() }

class ResettableLazy<T>(private val initializer: () -> T) {
private var lazyHolder = lazy { initializer() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ class FakeScheduledExecutorService(
}
}

override fun execute(command: Runnable) { schedule(command, 0, TimeUnit.MILLISECONDS) }
override fun execute(command: Runnable) {
schedule(command, 0, TimeUnit.MILLISECONDS)
}

/* Methods required by ScheduledExecutorService, but not needed by our unit tests. */
override fun shutdown() = TODO("Not yet implemented")
Expand Down
6 changes: 2 additions & 4 deletions src/main/kotlin/org/jitsi/utils/logging2/LoggerExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ fun <T : Any> T.createLogger(minLogLevel: Level = Level.ALL, logContext: LogCont
* using the fully-qualified name of the *actual* class (i.e. the instance's
* class, not the class that happens to be calling this method).
*/
fun <T : Any> T.createChildLogger(
parentLogger: Logger,
childContext: Map<String, String> = emptyMap()
): Logger = parentLogger.createChildLogger(getClassForLogging(this.javaClass).name, childContext)
fun <T : Any> T.createChildLogger(parentLogger: Logger, childContext: Map<String, String> = emptyMap()): Logger =
parentLogger.createChildLogger(getClassForLogging(this.javaClass).name, childContext)

/**
* Given a [Class], get the proper class to be used for the name of a logger
Expand Down
11 changes: 8 additions & 3 deletions src/main/kotlin/org/jitsi/utils/queue/QueueStatistics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ class QueueStatistics(queueSize: Int, val clock: Clock) {
stats["dropped_packets"] = totalPacketsDropped.sum()
if (firstPacketAdded != null) {
val duration = Duration.between(firstPacketAdded, now)
val duration_s = duration.toNanos() / 1e9
stats["duration_s"] = duration_s

@Suppress("ktlint:standard:property-naming")
val durationSecs = duration.toNanos() / 1e9

stats["duration_s"] = durationSecs
val packetsRemoved = totalPacketsRemoved.sum().toDouble()
stats["average_remove_rate_pps"] = packetsRemoved / duration_s
stats["average_remove_rate_pps"] = packetsRemoved / durationSecs
}
stats["queue_size_at_remove"] = queueLengthStats.toJson()
queueWaitStats?.let { stats["queue_wait_time"] = it.toJson() }
Expand Down Expand Up @@ -113,11 +116,13 @@ class QueueStatistics(queueSize: Int, val clock: Clock) {
/** Whether specific per-queue statistics should be kept. */
@JvmField
@field:SuppressFBWarnings("MS_SHOULD_BE_FINAL")
@field:Suppress("ktlint:standard:property-naming")
var DEBUG = false

/** Whether queue dwell times should be tracked. */
@JvmField
@field:SuppressFBWarnings("MS_SHOULD_BE_FINAL")
@field:Suppress("ktlint:standard:property-naming")
var TRACK_TIMES = false

private val queueStatsById = ConcurrentHashMap<String, QueueStatistics>()
Expand Down
Loading