Skip to content

Commit

Permalink
Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0 (#1853)
Browse files Browse the repository at this point in the history
* Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0

* Disable expression rule

* Reformat

* Whatever

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <[email protected]>
  • Loading branch information
renovate[bot] and JakeWharton authored Jun 22, 2024
1 parent 807934f commit 7ea4eca
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 22 deletions.
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ spotless {
}
kotlin {
ktlint(libs.ktlint.get().version).editorConfigOverride(
mapOf("ktlint_standard_filename" to "disabled"),
mapOf(
"ktlint_standard_filename" to "disabled",
// Making something an expression body should be a choice around readability.
"ktlint_standard_function-expression-body" to "disabled",
),
)
target("**/*.kt")
trimTrailingWhitespace()
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ kotlinCompileTesting = { module = "dev.zacsweers.kctfork:core", version.ref = "k
kotlinCompileTesting-ksp = { module = "dev.zacsweers.kctfork:ksp", version.ref ="kotlinCompileTesting" }
truth = "com.google.truth:truth:1.4.2"
googleJavaFormat = "com.google.googlejavaformat:google-java-format:1.22.0"
ktlint = "com.pinterest.ktlint:ktlint-cli:1.2.1"
ktlint = "com.pinterest.ktlint:ktlint-cli:1.3.0"
Original file line number Diff line number Diff line change
Expand Up @@ -774,20 +774,24 @@ private sealed class FromJsonComponent {

data class ParameterOnly(
override val parameter: TargetParameter,
) : FromJsonComponent(), ParameterComponent {
) : FromJsonComponent(),
ParameterComponent {
override val type: TypeName = parameter.type
}

data class PropertyOnly(
override val property: PropertyGenerator,
) : FromJsonComponent(), PropertyComponent {
) : FromJsonComponent(),
PropertyComponent {
override val type: TypeName = property.target.type
}

data class ParameterProperty(
override val parameter: TargetParameter,
override val property: PropertyGenerator,
) : FromJsonComponent(), ParameterComponent, PropertyComponent {
) : FromJsonComponent(),
ParameterComponent,
PropertyComponent {
override val type: TypeName = parameter.type
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ internal fun Resolver.getClassDeclarationByName(name: String): KSClassDeclaratio

internal fun <T : Annotation> KSAnnotated.getAnnotationsByType(annotationKClass: KClass<T>): Sequence<T> {
return this.annotations.filter {
it.shortName.getShortName() == annotationKClass.simpleName && it.annotationType.resolve().declaration
.qualifiedName?.asString() == annotationKClass.qualifiedName
it.shortName.getShortName() == annotationKClass.simpleName &&
it.annotationType.resolve().declaration
.qualifiedName?.asString() == annotationKClass.qualifiedName
}.map { it.toAnnotation(annotationKClass.java) }
}

Expand Down
3 changes: 2 additions & 1 deletion moshi-kotlin-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ enum class TestMode {
}

val testMode =
findProperty("kotlinTestMode")?.toString()
findProperty("kotlinTestMode")
?.toString()
?.let(TestMode::valueOf)
?: REFLECT

Expand Down
3 changes: 2 additions & 1 deletion moshi-kotlin-tests/codegen-only/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ enum class TestMode {
}

val testMode =
findProperty("kotlinTestMode")?.toString()
findProperty("kotlinTestMode")
?.toString()
?.let(TestMode::valueOf)
?: KSP

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ abstract class Layer1<A> {
var layer1: A? = null
}

abstract class Layer2<B> : Layer1<B>(), LayerInterface<B> {
abstract class Layer2<B> :
Layer1<B>(),
LayerInterface<B> {
var layer2: B? = null
}

Expand All @@ -147,4 +149,5 @@ abstract class Layer3<C, D> : Layer2<D>() {
data class Layer4<E : Personable, F>(
val layer4E: E,
val layer4F: F? = null,
) : Layer3<List<Int>, String>(), LayerInterface<String>
) : Layer3<List<Int>, String>(),
LayerInterface<String>
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ class MoshiKspTest {
// NOTE the Any() superclass is important to test that we're detecting the farthest parent class
// correct.y
@JsonClass(generateAdapter = true)
data class SimpleImpl(override val a: String, val b: String) : Any(), SimpleInterface
data class SimpleImpl(override val a: String, val b: String) :
Any(),
SimpleInterface
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
message = "this moved to avoid a package name conflict in the Java Platform Module System.",
replaceWith = ReplaceWith("com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory"),
)
public class KotlinJsonAdapterFactory :
JsonAdapter.Factory by KotlinJsonAdapterFactory()
public class KotlinJsonAdapterFactory : JsonAdapter.Factory by KotlinJsonAdapterFactory()
3 changes: 2 additions & 1 deletion moshi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ tasks.withType<Test>().configureEach {
jvmArgs("--add-opens=java.base/java.io=ALL-UNNAMED")
}

tasks.withType<KotlinCompile>()
tasks
.withType<KotlinCompile>()
.configureEach {
compilerOptions {
freeCompilerArgs.addAll(
Expand Down
9 changes: 6 additions & 3 deletions moshi/src/main/java/com/squareup/moshi/JsonUtf8Writer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ internal class JsonUtf8Writer(
check(stackSize != 0) { "JsonWriter is closed." }
val context = peekScope()
val isWritingObject = !(
context != JsonScope.EMPTY_OBJECT && context != JsonScope.NONEMPTY_OBJECT ||
deferredName != null || promoteValueToName
context != JsonScope.EMPTY_OBJECT &&
context != JsonScope.NONEMPTY_OBJECT ||
deferredName != null ||
promoteValueToName
)
check(isWritingObject) { "Nesting problem." }
deferredName = name
Expand Down Expand Up @@ -281,7 +283,8 @@ internal class JsonUtf8Writer(
if (context == JsonScope.NONEMPTY_OBJECT) { // first in object
sink.writeByte(','.code)
} else {
check(context == JsonScope.EMPTY_OBJECT) { // not in an object!
check(context == JsonScope.EMPTY_OBJECT) {
// not in an object!
"Nesting problem."
}
}
Expand Down
3 changes: 2 additions & 1 deletion moshi/src/main/java/com/squareup/moshi/JsonValueReader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ internal class JsonValueReader : JsonReader {
val endToken: Token,
val array: Array<Any?>,
var next: Int,
) : Iterator<Any?>, Cloneable {
) : Iterator<Any?>,
Cloneable {
override fun hasNext() = next < array.size

override fun next() = array[next++]
Expand Down
4 changes: 3 additions & 1 deletion moshi/src/main/java/com/squareup/moshi/JsonWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ import kotlin.Throws
* Each `JsonWriter` may be used to write a single JSON stream. Instances of this class are
* not thread safe. Calls that would result in a malformed JSON string will fail with an [IllegalStateException].
*/
public sealed class JsonWriter : Closeable, Flushable {
public sealed class JsonWriter :
Closeable,
Flushable {
/**
* The nesting stack. Using a manual array rather than an ArrayList saves 20%. This stack will
* grow itself up to 256 levels of nesting including the top-level document. Deeper nesting is
Expand Down
3 changes: 2 additions & 1 deletion moshi/src/main/java/com/squareup/moshi/LinkedHashTreeMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ private val NATURAL_ORDER = Comparator<Any> { o1, o2 -> (o1 as Comparable<Any>).
*/
internal class LinkedHashTreeMap<K, V>(
comparator: Comparator<Any?>? = null,
) : AbstractMutableMap<K, V>(), Serializable {
) : AbstractMutableMap<K, V>(),
Serializable {
@Suppress("UNCHECKED_CAST")
private val comparator: Comparator<Any?> = (comparator ?: NATURAL_ORDER) as Comparator<Any?>
private var table: Array<Node<K, V>?> = arrayOfNulls(16) // TODO: sizing/resizing policies
Expand Down
3 changes: 2 additions & 1 deletion moshi/src/main/java/com/squareup/moshi/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ public object Types {
val bTypeArguments = if (b is ParameterizedTypeImpl) b.typeArguments else b.actualTypeArguments
return (
equals(a.ownerType, b.ownerType) &&
(a.rawType == b.rawType) && aTypeArguments.contentEquals(bTypeArguments)
(a.rawType == b.rawType) &&
aTypeArguments.contentEquals(bTypeArguments)
)
}

Expand Down

0 comments on commit 7ea4eca

Please sign in to comment.