mirror of
https://github.com/fankes/moshi.git
synced 2025-10-18 07:29:22 +08:00
Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0 (#1853)
* 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 <jw@squareup.com>
This commit is contained in:
@@ -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()
|
||||
|
@@ -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"
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -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) }
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,8 @@ enum class TestMode {
|
||||
}
|
||||
|
||||
val testMode =
|
||||
findProperty("kotlinTestMode")?.toString()
|
||||
findProperty("kotlinTestMode")
|
||||
?.toString()
|
||||
?.let(TestMode::valueOf)
|
||||
?: REFLECT
|
||||
|
||||
|
@@ -13,7 +13,8 @@ enum class TestMode {
|
||||
}
|
||||
|
||||
val testMode =
|
||||
findProperty("kotlinTestMode")?.toString()
|
||||
findProperty("kotlinTestMode")
|
||||
?.toString()
|
||||
?.let(TestMode::valueOf)
|
||||
?: KSP
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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()
|
||||
|
@@ -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(
|
||||
|
@@ -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
|
||||
@@ -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."
|
||||
}
|
||||
}
|
||||
|
@@ -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++]
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user