Skip to content

Update JSON schema for ruff LSP #236

Description

@NorthLake

What happened?

Ruff version 0.15.18 introduced human-readable names for errors and warnings. This means the output schema for both has introduced a new name entry. This extra property causes a JsonDecodingException in RyeCharm.

Steps to reproduce

  1. Install ruff version 0.15.18
  2. Let RyeCharm run ruff either through cli with an error/warning in a script.

Relevant log output or stack trace

kotlinx.serialization.json.internal.JsonDecodingException: Encountered an unknown key 'name' at offset 701 at path: $[0]
Use 'ignoreUnknownKeys = true' in 'Json {}' builder or '@JsonIgnoreUnknownKeys' annotation to ignore unknown keys.
JSON input: .....ve (unused: `PLR0915`)",
    "name": "unused-noqa",
    "noq.....
	at kotlinx.serialization.json.internal.AbstractJsonLexer.failOnUnknownKey(AbstractJsonLexer.kt:579)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.handleUnknown(StreamingJsonDecoder.kt:258)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeObjectIndex(StreamingJsonDecoder.kt:243)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeElementIndex(StreamingJsonDecoder.kt:178)
	at insyncwithfoo.ryecharm.ruff.linting.Diagnostic$$serializer.deserialize(Results.kt:61)
	at insyncwithfoo.ryecharm.ruff.linting.Diagnostic$$serializer.deserialize(Results.kt:61)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)
	at kotlinx.serialization.encoding.CompositeDecoder.decodeSerializableElement$default(Decoding.kt:539)
	at kotlinx.serialization.internal.CollectionLikeSerializer.readElement(CollectionSerializers.kt:80)
	at kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)
	at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)
	at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
	at kotlinx.serialization.json.Json.decodeFromString(Json.kt:149)
	at insyncwithfoo.ryecharm.ruff.linting.CheckKt.runCheckCommand(Check.kt:45)
	at insyncwithfoo.ryecharm.ruff.linting.RuffAnnotator.doAnnotate(RuffAnnotator.kt:83)
	at insyncwithfoo.ryecharm.ruff.linting.RuffAnnotator.doAnnotate(RuffAnnotator.kt:49)
	at com.intellij.codeInsight.daemon.impl.ExternalToolPass.lambda$doAnnotate$1(ExternalToolPass.java:248)
	at com.intellij.codeInsight.daemon.impl.AnnotationSessionImpl.computeWithSession(AnnotationSessionImpl.java:91)
	at com.intellij.codeInsight.daemon.impl.AnnotationSessionImpl.computeWithSession(AnnotationSessionImpl.java:83)
	at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:246)
	at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:240)
	at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.lambda$run$3(ExternalToolPass.java:198)
	at com.intellij.codeInsight.daemon.impl.ExternalToolPass.runChangeAware(ExternalToolPass.java:313)
	at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.lambda$run$5(ExternalToolPass.java:198)
	at com.intellij.openapi.progress.util.BackgroundTaskUtil.lambda$runUnderDisposeAwareIndicator$15(BackgroundTaskUtil.java:387)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:283)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$14(CoreProgressManager.java:744)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:819)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:775)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:743)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:267)
	at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:382)
	at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.run(ExternalToolPass.java:196)
	at com.intellij.util.ui.update.Update.execute$suspendImpl(Update.kt:61)
	at com.intellij.util.ui.update.Update.execute(Update.kt)
	at com.intellij.util.ui.update.MergingUpdateQueue.executeUpdates$suspendImpl(MergingUpdateQueue.kt:386)
	at com.intellij.util.ui.update.MergingUpdateQueue.executeUpdates(MergingUpdateQueue.kt)
	at com.intellij.util.ui.update.MergingUpdateQueue$restart$1.invokeSuspend(MergingUpdateQueue.kt:345)
	at com.intellij.util.ui.update.MergingUpdateQueue$restart$1.invoke(MergingUpdateQueue.kt)
	at com.intellij.util.ui.update.MergingUpdateQueue$restart$1.invoke(MergingUpdateQueue.kt)
	at com.intellij.util.SingleAlarm$scheduleTask$1$1$1$2.invokeSuspend(SingleAlarm.kt:413)
	at com.intellij.util.SingleAlarm$scheduleTask$1$1$1$2.invoke(SingleAlarm.kt)
	at com.intellij.util.SingleAlarm$scheduleTask$1$1$1$2.invoke(SingleAlarm.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndspatched(Undispatched.kt:67)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:157)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.util.SingleAlarm$scheduleTask$1$1.invokeSuspend(SingleAlarm.kt:411)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:610)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runDefaultDispatcherTask(CoroutineScheduler.kt:1194)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:906)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:775)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:762)
[
  {
    "cell": null,
    "code": "RUF100",
    "end_location": {
      "column": 42,
      "row": 472
    },
    "filename": "...",
    "fix": {
      "applicability": "safe",
      "edits": [
        {
          "content": "# noqa: C901, PLR0912",
          "end_location": {
            "column": 42,
            "row": 472
          },
          "location": {
            "column": 12,
            "row": 472
          }
        }
      ],
      "message": "Remove unused `noqa` directive"
    },
    "location": {
      "column": 12,
      "row": 472
    },
    "message": "Unused `noqa` directive (unused: `PLR0915`)",
    "name": "unused-noqa",
    "noqa_row": 472,
    "severity": "error",
    "url": "https://docs.astral.sh/ruff/rules/unused-noqa"
  }
]

Operating system

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions