Skip to content

Commit

Permalink
Update for ktlint 1.0.0 (ktlint-maven-plugin 3.0.0). (jitsi#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLennox authored Oct 3, 2023
1 parent f49982f commit bebfb15
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 47 deletions.
4 changes: 1 addition & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ charset = utf-8
[*.{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
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ abstract class AbstractReadOnlyConfigurationService : ConfigurationService {
protected val logger = LoggerImpl(this::class.qualifiedName)
protected abstract val properties: Properties

override fun getString(propertyName: String): String? =
getProperty(propertyName)?.toString()?.trim()
override fun getString(propertyName: String): String? = getProperty(propertyName)?.toString()?.trim()

override fun getString(propertyName: String, defaultValue: String?): String? =
getString(propertyName) ?: defaultValue
Expand All @@ -47,17 +46,14 @@ abstract class AbstractReadOnlyConfigurationService : ConfigurationService {
override fun getDouble(propertyName: String, defaultValue: Double): Double =
getString(propertyName)?.toDouble() ?: defaultValue

override fun getInt(propertyName: String, defaultValue: Int): Int =
getString(propertyName)?.toInt() ?: defaultValue
override fun getInt(propertyName: String, defaultValue: Int): Int = getString(propertyName)?.toInt() ?: defaultValue

override fun getLong(propertyName: String, defaultValue: Long): Long =
getString(propertyName)?.toLong() ?: defaultValue

override fun getAllPropertyNames(): MutableList<String> =
properties.keys.map { it as String }.toMutableList()
override fun getAllPropertyNames(): MutableList<String> = properties.keys.map { it as String }.toMutableList()

override fun getProperty(propertyName: String): Any? =
properties[propertyName] ?: System.getProperty(propertyName)
override fun getProperty(propertyName: String): Any? = properties[propertyName] ?: System.getProperty(propertyName)

override fun getPropertyNamesByPrefix(prefix: String, exactPrefixMatch: Boolean): MutableList<String> {
val matchingPropNames = mutableListOf<String>()
Expand Down Expand Up @@ -86,57 +82,43 @@ abstract class AbstractReadOnlyConfigurationService : ConfigurationService {
}
}

override fun getConfigurationFilename(): String =
throw Exception("Unsupported")
override fun getConfigurationFilename(): String = throw Exception("Unsupported")

override fun getScHomeDirLocation(): String =
throw Exception("Unsupported")
override fun getScHomeDirLocation(): String = throw Exception("Unsupported")

override fun getScHomeDirName(): String =
throw Exception("Unsupported")
override fun getScHomeDirName(): String = throw Exception("Unsupported")

override fun addPropertyChangeListener(listener: PropertyChangeListener?) =
throw Exception("Unsupported")
override fun addPropertyChangeListener(listener: PropertyChangeListener?) = throw Exception("Unsupported")

override fun addPropertyChangeListener(propertyName: String?, listener: PropertyChangeListener?) =
throw Exception("Unsupported")

override fun addVetoableChangeListener(listener: ConfigVetoableChangeListener?) =
throw Exception("Unsupported")
override fun addVetoableChangeListener(listener: ConfigVetoableChangeListener?) = throw Exception("Unsupported")

override fun addVetoableChangeListener(propertyName: String?, listener: ConfigVetoableChangeListener?) =
throw Exception("Unsupported")

override fun removePropertyChangeListener(listener: PropertyChangeListener?) =
throw Exception("Unsupported")
override fun removePropertyChangeListener(listener: PropertyChangeListener?) = throw Exception("Unsupported")

override fun removePropertyChangeListener(propertyName: String?, listener: PropertyChangeListener?) =
throw Exception("Unsupported")

override fun removeVetoableChangeListener(listener: ConfigVetoableChangeListener?) =
throw Exception("Unsupported")
override fun removeVetoableChangeListener(listener: ConfigVetoableChangeListener?) = throw Exception("Unsupported")

override fun removeVetoableChangeListener(propertyName: String?, listener: ConfigVetoableChangeListener?) =
throw Exception("Unsupported")

override fun purgeStoredConfiguration() =
throw Exception("Unsupported")
override fun purgeStoredConfiguration() = throw Exception("Unsupported")

override fun storeConfiguration() =
throw Exception("Unsupported")
override fun storeConfiguration() = throw Exception("Unsupported")

override fun setProperties(properties: MutableMap<String, Any>?) =
throw Exception("Unsupported")
override fun setProperties(properties: MutableMap<String, Any>?) = throw Exception("Unsupported")

override fun setProperty(propertyName: String?, property: Any?) =
throw Exception("Unsupported")
override fun setProperty(propertyName: String?, property: Any?) = throw Exception("Unsupported")

override fun setProperty(propertyName: String?, property: Any?, isSystem: Boolean) =
throw Exception("Unsupported")
override fun setProperty(propertyName: String?, property: Any?, isSystem: Boolean) = throw Exception("Unsupported")

override fun removeProperty(propertyName: String?) =
throw Exception("Unsupported")
override fun removeProperty(propertyName: String?) = throw Exception("Unsupported")

override fun getPropertyNamesBySuffix(suffix: String?): MutableList<String> =
throw Exception("Unsupported")
override fun getPropertyNamesBySuffix(suffix: String?): MutableList<String> = throw Exception("Unsupported")
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ class ConfigSourceWrapper(
override val name: String
get() = innerSource.name

override fun getterFor(type: KType): (String) -> Any =
innerSource.getterFor(type)
override fun getterFor(type: KType): (String) -> Any = innerSource.getterFor(type)
}
10 changes: 5 additions & 5 deletions jicoco-config/src/main/kotlin/org/jitsi/config/JitsiConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ class JitsiConfig {
/**
* A [ConfigSource] loaded via [ConfigFactory].
*/
var TypesafeConfig: ConfigSource = TypesafeConfigSource("typesafe config", loadNewConfig())
var typesafeConfig: ConfigSource = TypesafeConfigSource("typesafe config", loadNewConfig())
private set

private var numTypesafeReloads = 0

/**
* The 'new' [ConfigSource] that should be used by configuration properties. Able to be changed for testing.
*/
private val _newConfig: ConfigSourceWrapper = ConfigSourceWrapper(TypesafeConfig).also {
logger.info("Initialized newConfig: ${TypesafeConfig.description}")
private val _newConfig: ConfigSourceWrapper = ConfigSourceWrapper(typesafeConfig).also {
logger.info("Initialized newConfig: ${typesafeConfig.description}")
}
val newConfig: ConfigSource
get() = _newConfig
Expand Down Expand Up @@ -94,11 +94,11 @@ class JitsiConfig {
logger.info("Reloading the Typesafe config source (previously reloaded $numTypesafeReloads times).")
ConfigFactory.invalidateCaches()
numTypesafeReloads++
TypesafeConfig = TypesafeConfigSource(
typesafeConfig = TypesafeConfigSource(
"typesafe config (reloaded $numTypesafeReloads times)",
loadNewConfig()
)
_newConfig.innerSource = TypesafeConfig
_newConfig.innerSource = typesafeConfig
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,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

0 comments on commit bebfb15

Please sign in to comment.