BetterThanTomorrow / calva

Clojure & ClojureScript Interactive Programming for VS Code
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
Other
1.61k stars 213 forks source link

Malformed clj-kondo config can be hard to notice #2265

Open simonacca opened 1 year ago

simonacca commented 1 year ago

Hello there, had a bit of a snafu with the linting tools, reporting to see if there's anything that can be done to improve the developer experience.

Thanks in advance for looking into this! Simon


tl;dr: I recently happened to modify the clj-kondo config in a way that produced an invalid config. Calva silently stopped reporting clj-kondo feedback altogether.

To be specific, the mistake was that I assumed :exclude here takes a seq when it actually takes a map {:linters {:unused-referred-var {:exclude []}}}.

The state of my codebase was such that I had no other outstanding linter warnings at the time, other than the :unused-referred-var warning that I was trying to silence with my config change (on a form like (ns (:require [cloure.core.async :refer [go <!]))).

As soon as I changed the kondo config, the warning went away, which added to my confirmation bias that the config change was correct.

Were this to be a project of some importance, I would have had CI running clj-kondo, which would have alerted me of the issue (clj-kondo crashes.

Clj kondo crash

``` $ clj -Mkondo --lint . Unexpected error. Please report an issue. java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol at clojure.lang.RT.seqFrom(RT.java:557) at clojure.lang.RT.seq(RT.java:537) at clojure.core$seq__5467.invokeStatic(core.clj:139) at clojure.core$reduce1.invokeStatic(core.clj:932) at clojure.core$set.invokeStatic(core.clj:4114) at clojure.core$set.invoke(core.clj:4106) at clj_kondo.impl.utils$map_vals$fn__3879$fn__3880.invoke(utils.clj:246) at clojure.lang.PersistentVector.kvreduce(PersistentVector.java:357) at clojure.core$fn__8525.invokeStatic(core.clj:6908) at clojure.core$fn__8525.invoke(core.clj:6888) at clojure.core.protocols$fn__8257$G__8252__8266.invoke(protocols.clj:175) at clojure.core$reduce_kv.invokeStatic(core.clj:6919) at clojure.core$reduce_kv.invoke(core.clj:6910) at clj_kondo.impl.utils$reduce_map.invokeStatic(utils.clj:241) at clj_kondo.impl.utils$reduce_map.invoke(utils.clj:235) at clj_kondo.impl.utils$map_vals.invokeStatic(utils.clj:246) at clj_kondo.impl.utils$map_vals.invoke(utils.clj:243) at clj_kondo.impl.config$eval4607$delayed_cfg__4608.invoke(config.clj:277) at clojure.lang.AFn.applyToHelper(AFn.java:154) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$memoize$fn__6946.doInvoke(core.clj:6388) at clojure.lang.RestFn.invoke(RestFn.java:408) at clj_kondo.impl.config$eval4607$unused_referred_var_excluded__4610.invoke(config.clj:280) at clj_kondo.impl.linters$lint_unused_namespaces_BANG_.invokeStatic(linters.clj:557) at clj_kondo.impl.linters$lint_unused_namespaces_BANG_.invoke(linters.clj:511) at clj_kondo.core$run_BANG_.invokeStatic(core.clj:219) at clj_kondo.core$run_BANG_.invoke(core.clj:56) at clj_kondo.main$main.invokeStatic(main.clj:149) at clj_kondo.main$main.doInvoke(main.clj:135) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$apply.invoke(core.clj:662) at clj_kondo.main$_main$fn__16203.invoke(main.clj:186) at clj_kondo.main$_main.invokeStatic(main.clj:186) at clj_kondo.main$_main.doInvoke(main.clj:184) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:705) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.main$main_opt.invokeStatic(main.clj:514) at clojure.main$main_opt.invoke(main.clj:510) at clojure.main$main.invokeStatic(main.clj:664) at clojure.main$main.doInvoke(main.clj:616) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:705) at clojure.main.main(main.java:40) ```

Since this was in a minor project I did not have CI, so had to spend a few more occasional days coding before the sense that something wasn't right with the linting kicked in :sweat_smile: .

Ideally I would have received some kind of feedback from calva right away stating that it was unable to run clj-kondo.

A repro for this issue can be found in this repo.

simonacca commented 1 year ago

Just noticed that this is even trickier to spot since when the :unused-referred-var is not triggered, clj-kondo works just fine. :thinking:

Added lines 8-10 in the repro to document this behavior.

Perhaps this is a bug in clj-kondo @borkdude ? See repro steps

borkdude commented 1 year ago

Feel free to post an issue with clj-kondo with a clj-kondo only repo. This is basically the repro:

$ clj-kondo --lint - --config '{:linters {:unused-referred-var {:exclude [clojure.core.async]}}}' <<< "(ns dude (:require [clojure.set :refer [union]]))"
Unexpected error. Please report an issue.
java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol

The issue here is indeed that clj-kondo doesn't do a good job of catching this error. And perhaps clojure-lsp swallows this error as well. Anyway, something to improve.

simonacca commented 1 year ago

Thank you for the quick reply! Issue filed

bpringe commented 1 year ago

@simonacca When you reproduce the issue, do you see any errors in the client<->server logs or the clojure-lsp server logs? I'm wondering if clojure-lsp is telling Calva about the issue or not.

simonacca commented 1 year ago

client<->server logs

expand

``` [Trace - 11:06:17 AM] Sending request 'initialize - (0)'. Params: { "processId": 23252, "clientInfo": { "name": "Visual Studio Code", "version": "1.79.2" }, "locale": "en-us", "rootPath": "/home/simon/Tmp/calva-kondo-incorrect-config-repro", "rootUri": "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro", "capabilities": { "workspace": { "applyEdit": true, "workspaceEdit": { "documentChanges": true, "resourceOperations": [ "create", "rename", "delete" ], "failureHandling": "textOnlyTransactional", "normalizesLineEndings": true, "changeAnnotationSupport": { "groupsOnLabel": true } }, "configuration": true, "didChangeWatchedFiles": { "dynamicRegistration": true, "relativePatternSupport": true }, "symbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "tagSupport": { "valueSet": [ 1 ] }, "resolveSupport": { "properties": [ "location.range" ] } }, "codeLens": { "refreshSupport": true }, "executeCommand": { "dynamicRegistration": true }, "didChangeConfiguration": { "dynamicRegistration": true }, "semanticTokens": { "refreshSupport": true }, "fileOperations": { "dynamicRegistration": true, "didCreate": true, "didRename": true, "didDelete": true, "willCreate": true, "willRename": true, "willDelete": true }, "inlineValue": { "refreshSupport": true }, "inlayHint": { "refreshSupport": true }, "diagnostics": { "refreshSupport": true } }, "textDocument": { "publishDiagnostics": { "relatedInformation": true, "versionSupport": false, "tagSupport": { "valueSet": [ 1, 2 ] }, "codeDescriptionSupport": true, "dataSupport": true }, "synchronization": { "dynamicRegistration": true, "willSave": true, "willSaveWaitUntil": true, "didSave": true }, "completion": { "dynamicRegistration": true, "contextSupport": true, "completionItem": { "snippetSupport": true, "commitCharactersSupport": true, "documentationFormat": [ "markdown", "plaintext" ], "deprecatedSupport": true, "preselectSupport": true, "tagSupport": { "valueSet": [ 1 ] }, "insertReplaceSupport": true, "resolveSupport": { "properties": [ "documentation", "detail", "additionalTextEdits" ] }, "insertTextModeSupport": { "valueSet": [ 1, 2 ] }, "labelDetailsSupport": true }, "insertTextMode": 2, "completionItemKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ] }, "completionList": { "itemDefaults": [ "commitCharacters", "editRange", "insertTextFormat", "insertTextMode" ] } }, "hover": { "dynamicRegistration": true, "contentFormat": [ "markdown", "plaintext" ] }, "signatureHelp": { "dynamicRegistration": true, "signatureInformation": { "documentationFormat": [ "markdown", "plaintext" ], "parameterInformation": { "labelOffsetSupport": true }, "activeParameterSupport": true }, "contextSupport": true }, "definition": { "dynamicRegistration": true, "linkSupport": true }, "references": { "dynamicRegistration": true }, "documentHighlight": { "dynamicRegistration": true }, "documentSymbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "hierarchicalDocumentSymbolSupport": true, "tagSupport": { "valueSet": [ 1 ] }, "labelSupport": true }, "codeAction": { "dynamicRegistration": true, "isPreferredSupport": true, "disabledSupport": true, "dataSupport": true, "resolveSupport": { "properties": [ "edit" ] }, "codeActionLiteralSupport": { "codeActionKind": { "valueSet": [ "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" ] } }, "honorsChangeAnnotations": false }, "codeLens": { "dynamicRegistration": true }, "formatting": { "dynamicRegistration": true }, "rangeFormatting": { "dynamicRegistration": true }, "onTypeFormatting": { "dynamicRegistration": true }, "rename": { "dynamicRegistration": true, "prepareSupport": true, "prepareSupportDefaultBehavior": 1, "honorsChangeAnnotations": true }, "documentLink": { "dynamicRegistration": true, "tooltipSupport": true }, "typeDefinition": { "dynamicRegistration": true, "linkSupport": true }, "implementation": { "dynamicRegistration": true, "linkSupport": true }, "colorProvider": { "dynamicRegistration": true }, "foldingRange": { "dynamicRegistration": true, "rangeLimit": 5000, "lineFoldingOnly": true, "foldingRangeKind": { "valueSet": [ "comment", "imports", "region" ] }, "foldingRange": { "collapsedText": false } }, "declaration": { "dynamicRegistration": true, "linkSupport": true }, "selectionRange": { "dynamicRegistration": true }, "callHierarchy": { "dynamicRegistration": true }, "semanticTokens": { "dynamicRegistration": true, "tokenTypes": [ "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" ], "tokenModifiers": [ "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" ], "formats": [ "relative" ], "requests": { "range": true, "full": { "delta": true } }, "multilineTokenSupport": false, "overlappingTokenSupport": false, "serverCancelSupport": true, "augmentsSyntaxTokens": true }, "linkedEditingRange": { "dynamicRegistration": true }, "typeHierarchy": { "dynamicRegistration": true }, "inlineValue": { "dynamicRegistration": true }, "inlayHint": { "dynamicRegistration": true, "resolveSupport": { "properties": [ "tooltip", "textEdits", "label.tooltip", "label.location", "label.command" ] } }, "diagnostic": { "dynamicRegistration": true, "relatedDocumentSupport": false } }, "window": { "showMessage": { "messageActionItem": { "additionalPropertiesSupport": true } }, "showDocument": { "support": true }, "workDoneProgress": true }, "general": { "staleRequestSupport": { "cancel": true, "retryOnContentModified": [ "textDocument/semanticTokens/full", "textDocument/semanticTokens/range", "textDocument/semanticTokens/full/delta" ] }, "regularExpressions": { "engine": "ECMAScript", "version": "ES2020" }, "markdown": { "parser": "marked", "version": "1.1.0" }, "positionEncodings": [ "utf-16" ] }, "notebookDocument": { "synchronization": { "dynamicRegistration": true, "executionSummarySupport": true } }, "experimental": { "testTree": true } }, "initializationOptions": { "dependency-scheme": "jar", "auto-add-ns-to-new-files?": true, "document-formatting?": false, "document-range-formatting?": false, "keep-require-at-start?": true }, "trace": "verbose", "workspaceFolders": [ { "uri": "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro", "name": "/home/simon/Tmp/calva-kondo-incorrect-config-repro" } ] } [Trace - 11:06:17 AM] Received response 'initialize - (0)' in 85ms. Result: { "capabilities": { "documentSymbolProvider": true, "textDocumentSync": { "openClose": true, "change": 1, "save": { "includeText": true } }, "declarationProvider": true, "semanticTokensProvider": { "legend": { "tokenTypes": [ "namespace", "type", "function", "macro", "keyword", "class", "variable", "method", "event", "interface" ], "tokenModifiers": [ "definition", "defaultLibrary", "implementation" ] }, "range": true, "full": true }, "linkedEditingRangeProvider": true, "workspaceSymbolProvider": true, "experimental": { "testTree": true, "cursorInfo": true, "serverInfo": true, "clojuredocs": true }, "codeActionProvider": { "codeActionKinds": [ "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" ] }, "documentHighlightProvider": true, "completionProvider": { "resolveProvider": true, "triggerCharacters": [ ":", "/" ] }, "workspace": { "fileOperations": { "willRename": { "filters": [ { "scheme": "file", "pattern": { "glob": "**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}", "matches": "file" } } ] } } }, "implementationProvider": true, "signatureHelpProvider": { "triggerCharacters": [] }, "documentRangeFormattingProvider": false, "executeCommandProvider": { "commands": [ "add-import-to-namespace", "add-missing-import", "add-missing-libspec", "add-require-suggestion", "change-coll", "clean-ns", "create-function", "create-test", "cycle-coll", "cycle-keyword-auto-resolve", "cycle-privacy", "demote-fn", "destructure-keys", "drag-backward", "drag-forward", "drag-param-backward", "drag-param-forward", "expand-let", "extract-function", "extract-to-def", "get-in-all", "get-in-less", "get-in-more", "get-in-none", "inline-symbol", "introduce-let", "move-coll-entry-down", "move-coll-entry-up", "move-form", "move-to-let", "promote-fn", "replace-refer-all-with-alias", "replace-refer-all-with-refer", "resolve-macro-as", "restructure-keys", "sort-clauses", "sort-map", "suppress-diagnostic", "thread-first", "thread-first-all", "thread-last", "thread-last-all", "unwind-all", "unwind-thread" ] }, "referencesProvider": true, "codeLensProvider": { "resolveProvider": true }, "callHierarchyProvider": true, "documentFormattingProvider": false, "renameProvider": { "prepareProvider": true }, "definitionProvider": true, "hoverProvider": true } } [Trace - 11:06:17 AM] Sending notification 'initialized'. Params: {} [Trace - 11:06:17 AM] Sending request 'clojure/serverInfo/raw - (1)'. [Trace - 11:06:17 AM] Sending notification 'textDocument/didOpen'. Params: { "textDocument": { "uri": "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", "languageId": "clojure", "version": 1, "text": "(ns core\n (:require [clojure.core.async :refer [go]]))\n\n\n; would expect this to be linted with `invalid-arity`\n(assoc)\n\n; try uncommenting this form while keeping the incorrect clj-kondo config.\n; you will find that clj-kondo starts working again (i.e. the `assoc` form gets linted)\n#_(go)" } } [Trace - 11:06:17 AM] Sending notification 'workspace/didChangeConfiguration'. Params: { "settings": {} } [Trace - 11:06:17 AM] Received request 'client/registerCapability - (1)'. Params: { "registrations": [ { "id": "id", "method": "workspace/didChangeWatchedFiles", "registerOptions": { "watchers": [ { "globPattern": "**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}" } ] } } ] } [Trace - 11:06:17 AM] Sending response 'client/registerCapability - (1)'. Processing request took 0ms No result returned. [Trace - 11:06:17 AM] Sending request 'textDocument/documentSymbol - (2)'. Params: { "textDocument": { "uri": "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj" } } [Trace - 11:06:17 AM] Sending request 'textDocument/codeAction - (3)'. Params: { "textDocument": { "uri": "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj" }, "range": { "start": { "line": 9, "character": 4 }, "end": { "line": 9, "character": 4 } }, "context": { "diagnostics": [], "triggerKind": 2 } } [Trace - 11:06:17 AM] Received response 'clojure/serverInfo/raw - (1)' in 3ms. Result: { "log-path": "/tmp/clojure-lsp.16295043569369432187.out", "project-settings": {}, "classpath": [ "/home/simon/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar", "src", "/home/simon/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar", "test", "/home/simon/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar" ], "project-root-uri": "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro", "client-settings": { "auto-add-ns-to-new-files?": true, "document-formatting?": false, "dependency-scheme": "jar", "keep-require-at-start?": true, "source-paths": null, "text-document-sync-kind": null, "source-aliases": null, "document-range-formatting?": false, "cljfmt-config-path": ".cljfmt.edn" }, "clj-kondo-version": "2023.06.02-SNAPSHOT", "server-version": "2023.07.01-22.35.41", "port": "NREPL only available on :debug profile (`bb debug-cli`)", "final-settings": { "auto-add-ns-to-new-files?": true, "document-formatting?": false, "dependency-scheme": "jar", "keep-require-at-start?": true, "source-paths": [ "/home/simon/Tmp/calva-kondo-incorrect-config-repro/test", "/home/simon/Tmp/calva-kondo-incorrect-config-repro/src" ], "project-specs": [ { "project-path": "project.clj", "classpath-cmd": [ "lein", "with-profile", "+test,+dev", "classpath" ] }, { "project-path": "deps.edn", "classpath-cmd": [ "/run/current-system/sw/bin/clojure", "-A:test:dev", "-Spath" ] }, { "project-path": "build.boot", "classpath-cmd": [ "boot", "show", "--fake-classpath" ] }, { "project-path": "shadow-cljs.edn", "classpath-cmd": [ "npx", "shadow-cljs", "classpath" ] }, { "project-path": "bb.edn", "classpath-cmd": [ "/run/current-system/sw/bin/bb", "print-deps", "--format", "classpath" ] } ], "text-document-sync-kind": null, "source-aliases": [ "test", "dev" ], "uri-format": { "upper-case-drive-letter?": false, "encode-colons-in-path?": false }, "document-range-formatting?": false, "cljfmt-config-path": ".cljfmt.edn" }, "classpath-settings": null, "cljfmt-raw": "{}" } [Trace - 11:06:17 AM] Received response 'textDocument/documentSymbol - (2)' in 5ms. No result returned. [Trace - 11:06:17 AM] Received response 'textDocument/codeAction - (3)' in 7ms. Result: [ { "title": "Move to let", "kind": "refactor.extract", "command": { "title": "Move to let", "command": "move-to-let", "arguments": [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4, "new-binding" ] } }, { "title": "Extract to def", "kind": "refactor.extract", "command": { "title": "Extract to def", "command": "extract-to-def", "arguments": [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4, null ] } }, { "title": "Thread first all", "kind": "refactor.rewrite", "command": { "title": "Thread first all", "command": "thread-first-all", "arguments": [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } }, { "title": "Thread last all", "kind": "refactor.rewrite", "command": { "title": "Thread last all", "command": "thread-last-all", "arguments": [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } }, { "title": "Sort list", "kind": "refactor.rewrite", "command": { "title": "Sort list", "command": "sort-clauses", "arguments": [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } }, { "title": "Introduce let", "kind": "refactor.extract", "command": { "title": "Introduce let", "command": "introduce-let", "arguments": [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4, "new-binding" ] } }, { "title": "Create test for 'go'", "kind": "refactor.rewrite", "command": { "title": "Create test", "command": "create-test", "arguments": [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } }, { "title": "Clean namespace", "kind": "source.organizeImports", "command": { "title": "Clean namespace", "command": "clean-ns", "arguments": [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } } ] [Trace - 11:06:17 AM] Received notification 'textDocument/publishDiagnostics'. Params: { "uri": "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", "diagnostics": [] } [Trace - 11:06:18 AM] Sending request 'textDocument/semanticTokens/full - (4)'. Params: { "textDocument": { "uri": "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj" } } [Trace - 11:06:18 AM] Received response 'textDocument/semanticTokens/full - (4)' in 2ms. Result: { "data": [] } ```

here there seem to be no errors

clojure-lsp server logs

expand

``` 2023-07-31T09:06:17.778Z INFO [clojure-lsp.server:596] - [SERVER] Starting server... 2023-07-31T09:06:17.779Z DEBUG [clojure-lsp.nrepl:21] - nrepl not found, skipping nrepl server start... 2023-07-31T09:06:17.780Z INFO [clojure-lsp.server:483] - Initializing... 2023-07-31T09:06:17.825Z INFO [clojure-lsp.db:69] - [DB] Reading transit analysis cache from /home/simon/Tmp/calva-kondo-incorrect-config-repro/.lsp/.cache/db.transit.json db took 43ms 2023-07-31T09:06:17.826Z INFO [clojure-lsp.dep-graph:269] - :maintain-dep-graph 1ms 2023-07-31T09:06:17.833Z INFO [clojure-lsp.startup:225] - [Startup] Using cached classpath #{"/home/simon/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar" "src" "/home/simon/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar" "test" "/home/simon/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar"} 2023-07-31T09:06:17.833Z INFO [clojure-lsp.source-paths:85] - [Startup] Using source-paths from classpath: ["/home/simon/Tmp/calva-kondo-incorrect-config-repro/test" "/home/simon/Tmp/calva-kondo-incorrect-config-repro/src"] 2023-07-31T09:06:17.833Z INFO [clojure-lsp.startup:113] - Copying kondo configs from classpath to project if any... 2023-07-31T09:06:17.843Z WARN [clojure-lsp.kondo:342] - Non-fatal error from clj-kondo: No configs copied. 2023-07-31T09:06:17.843Z INFO [clojure-lsp.startup:115] - Copied kondo configs, took 10ms secs. 2023-07-31T09:06:17.843Z INFO [clojure-lsp.startup:261] - [Startup] Analyzing source paths for project root /home/simon/Tmp/calva-kondo-incorrect-config-repro 2023-07-31T09:06:17.844Z INFO [clojure-lsp.startup:74] - [Startup] Project only paths analyzed by clj-depend, took 0ms 2023-07-31T09:06:17.848Z ERROR [clojure-lsp.kondo:345] - Error running clj-kondo on paths /home/simon/Tmp/calva-kondo-incorrect-config-repro/test, /home/simon/Tmp/calva-kondo-incorrect-config-repro/src com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine PosixPlatformThreads.java: 203 com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine PlatformThreads.java: 775 java.lang.Thread.run Thread.java: 829 java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 628 java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1128 java.util.concurrent.FutureTask.run FutureTask.java: 264 ... clojure.core/binding-conveyor-fn/fn core.clj: 2047 clojure-lsp.startup/analyze-source-paths!/fn startup.clj: 72 clojure-lsp.kondo/run-kondo-on-paths! kondo.clj: 355 clojure-lsp.kondo/run-kondo! kondo.clj: 339 clojure-lsp.kondo/run-kondo!/fn kondo.clj: 340 clj-kondo.core/run! core.clj: 219 clj-kondo.impl.linters/lint-unused-namespaces! linters.clj: 555 clj-kondo.impl.config/fn/unused-referred-var-excluded config.clj: 279 ... clojure.core/memoize/fn core.clj: 6388 clojure.core/apply core.clj: 667 ... clj-kondo.impl.config/fn/delayed-cfg config.clj: 276 clj-kondo.impl.utils/map-vals utils.clj: 239 clj-kondo.impl.utils/reduce-map utils.clj: 234 clojure.core/reduce-kv core.clj: 6919 clojure.core.protocols/fn/G protocols.clj: 175 clojure.core/fn core.clj: 6908 ... clj-kondo.impl.utils/map-vals/fn/fn utils.clj: 239 clojure.core/set core.clj: 4114 clojure.core/reduce1 core.clj: 932 clojure.core/seq core.clj: 139 ... java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol 2023-07-31T09:06:17.850Z INFO [clojure-lsp.startup:70] - [Startup] Project only paths analyzed by clj-kondo, took 6ms 2023-07-31T09:06:17.850Z INFO [clojure-lsp.dep-graph:269] - :maintain-dep-graph 0ms 2023-07-31T09:06:17.851Z INFO [clojure-lsp.handlers:191] - [Startup] Analyzing test paths for project root file:///home/simon/Tmp/calva-kondo-incorrect-config-repro 2023-07-31T09:06:17.851Z INFO [clojure-lsp.feature.clojuredocs:21] - [Clojuredocs] Refreshing clojuredocs cache... 2023-07-31T09:06:17.851Z INFO [clojure-lsp.handlers:164] - :initialize 71ms 2023-07-31T09:06:17.851Z INFO [clojure-lsp.server:164] - :refreshing-test-tree 0ms 2023-07-31T09:06:17.855Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.855Z] Sending response 'initialize - (0)'. Request took 75ms. Result: { "capabilities" : { "signature-help-provider" : { "trigger-characters" : [ ] }, "document-symbol-provider" : true, "hover-provider" : true, "workspace" : { "file-operations" : { "will-rename" : { "filters" : [ { "scheme" : "file", "pattern" : { "glob" : "**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}", "matches" : "file" } } ] } } }, "code-lens-provider" : { "resolve-provider" : true }, "code-action-provider" : { "code-action-kinds" : [ "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" ] }, "document-formatting-provider" : false, "text-document-sync" : { "open-close" : true, "change" : 1, "save" : { "include-text" : true } }, "definition-provider" : true, "call-hierarchy-provider" : true, "completion-provider" : { "resolve-provider" : true, "trigger-characters" : [ ":", "/" ] }, "experimental" : { "test-tree" : true, "cursor-info" : true, "server-info" : true, "clojuredocs" : true }, "rename-provider" : { "prepare-provider" : true }, "declaration-provider" : true, "document-highlight-provider" : true, "workspace-symbol-provider" : true, "references-provider" : true, "implementation-provider" : true, "semantic-tokens-provider" : { "legend" : { "token-types" : [ "namespace", "type", "function", "macro", "keyword", "class", "variable", "method", "event", "interface" ], "token-modifiers" : [ "definition", "defaultLibrary", "implementation" ] }, "range" : true, "full" : true }, "document-range-formatting-provider" : false, "linked-editing-range-provider" : true, "execute-command-provider" : { "commands" : [ "add-import-to-namespace", "add-missing-import", "add-missing-libspec", "add-require-suggestion", "change-coll", "clean-ns", "create-function", "create-test", "cycle-coll", "cycle-keyword-auto-resolve", "cycle-privacy", "demote-fn", "destructure-keys", "drag-backward", "drag-forward", "drag-param-backward", "drag-param-forward", "expand-let", "extract-function", "extract-to-def", "get-in-all", "get-in-less", "get-in-more", "get-in-none", "inline-symbol", "introduce-let", "move-coll-entry-down", "move-coll-entry-up", "move-form", "move-to-let", "promote-fn", "replace-refer-all-with-alias", "replace-refer-all-with-refer", "resolve-macro-as", "restructure-keys", "sort-clauses", "sort-map", "suppress-diagnostic", "thread-first", "thread-first-all", "thread-last", "thread-last-all", "unwind-all", "unwind-thread" ] } } } 2023-07-31T09:06:17.857Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.857Z] Received notification 'initialized' Params: { } 2023-07-31T09:06:17.857Z INFO [clojure-lsp.server:505] - Initialized! 2023-07-31T09:06:17.857Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.857Z] Sending request 'client/registerCapability - (1)' Params: { "registrations" : [ { "id" : "id", "method" : "workspace/didChangeWatchedFiles", "register-options" : { "watchers" : [ { "glob-pattern" : "**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}" } ] } } ] } 2023-07-31T09:06:17.860Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.860Z] Received request 'clojure/serverInfo/raw - (1)' Params: null 2023-07-31T09:06:17.860Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.860Z] Received response 'client/registerCapability - (1)'. Request took 3ms. Result: null 2023-07-31T09:06:17.860Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.860Z] Received notification 'textDocument/didOpen' Params: { "text-document" : { "uri" : "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", "language-id" : "clojure", "version" : 1, "text" : "(ns core\n (:require [clojure.core.async :refer [go]]))\n\n\n; would expect this to be linted with `invalid-arity`\n(assoc)\n\n; try uncommenting this form while keeping the incorrect clj-kondo config.\n; you will find that clj-kondo starts working again (i.e. the `assoc` form gets linted)\n#_(go)" } } 2023-07-31T09:06:17.861Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.861Z] Sending response 'clojure/serverInfo/raw - (1)'. Request took 1ms. Result: { "log-path" : "/tmp/clojure-lsp.16295043569369432187.out", "project-settings" : { }, "classpath" : [ "/home/simon/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar", "src", "/home/simon/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar", "test", "/home/simon/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar" ], "project-root-uri" : "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro", "client-settings" : { "auto-add-ns-to-new-files?" : true, "document-formatting?" : false, "dependency-scheme" : "jar", "keep-require-at-start?" : true, "source-paths" : null, "text-document-sync-kind" : null, "source-aliases" : null, "document-range-formatting?" : false, "cljfmt-config-path" : ".cljfmt.edn" }, "clj-kondo-version" : "2023.06.02-SNAPSHOT", "server-version" : "2023.07.01-22.35.41", "port" : "NREPL only available on :debug profile (`bb debug-cli`)", "final-settings" : { "auto-add-ns-to-new-files?" : true, "document-formatting?" : false, "dependency-scheme" : "jar", "keep-require-at-start?" : true, "source-paths" : [ "/home/simon/Tmp/calva-kondo-incorrect-config-repro/test", "/home/simon/Tmp/calva-kondo-incorrect-config-repro/src" ], "project-specs" : [ { "project-path" : "project.clj", "classpath-cmd" : [ "lein", "with-profile", "+test,+dev", "classpath" ] }, { "project-path" : "deps.edn", "classpath-cmd" : [ "/run/current-system/sw/bin/clojure", "-A:test:dev", "-Spath" ] }, { "project-path" : "build.boot", "classpath-cmd" : [ "boot", "show", "--fake-classpath" ] }, { "project-path" : "shadow-cljs.edn", "classpath-cmd" : [ "npx", "shadow-cljs", "classpath" ] }, { "project-path" : "bb.edn", "classpath-cmd" : [ "/run/current-system/sw/bin/bb", "print-deps", "--format", "classpath" ] } ], "text-document-sync-kind" : null, "source-aliases" : [ "test", "dev" ], "uri-format" : { "upper-case-drive-letter?" : false, "encode-colons-in-path?" : false }, "document-range-formatting?" : false, "cljfmt-config-path" : ".cljfmt.edn" }, "classpath-settings" : null, "cljfmt-raw" : "{}" } 2023-07-31T09:06:17.863Z ERROR [clojure-lsp.kondo:345] - Error running clj-kondo on /home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine PosixPlatformThreads.java: 203 com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine PlatformThreads.java: 775 java.lang.Thread.run Thread.java: 829 java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 628 java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1128 java.util.concurrent.FutureTask.run FutureTask.java: 264 ... clojure.core/binding-conveyor-fn/fn core.clj: 2047 clojure-lsp.feature.file-management/did-open/fn file_management.clj: 40 clojure-lsp.kondo/run-kondo-on-text! kondo.clj: 401 clojure-lsp.kondo/run-kondo! kondo.clj: 339 clojure-lsp.kondo/run-kondo!/fn kondo.clj: 340 clj-kondo.core/run! core.clj: 219 clj-kondo.impl.linters/lint-unused-namespaces! linters.clj: 555 clj-kondo.impl.config/fn/unused-referred-var-excluded config.clj: 279 ... clojure.core/memoize/fn core.clj: 6388 clojure.core/apply core.clj: 667 ... clj-kondo.impl.config/fn/delayed-cfg config.clj: 276 clj-kondo.impl.utils/map-vals utils.clj: 239 clj-kondo.impl.utils/reduce-map utils.clj: 234 clojure.core/reduce-kv core.clj: 6919 clojure.core.protocols/fn/G protocols.clj: 175 clojure.core/fn core.clj: 6908 ... clj-kondo.impl.utils/map-vals/fn/fn utils.clj: 239 clojure.core/set core.clj: 4114 clojure.core/reduce1 core.clj: 932 clojure.core/seq core.clj: 139 ... java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol 2023-07-31T09:06:17.864Z INFO [clojure-lsp.dep-graph:269] - :maintain-dep-graph 0ms 2023-07-31T09:06:17.864Z INFO [clojure-lsp.handlers:196] - :did-open 3ms 2023-07-31T09:06:17.864Z WARN [clojure-lsp.server:401] - {:settings {}} 2023-07-31T09:06:17.864Z INFO [clojure-lsp.server:164] - :refreshing-test-tree 0ms 2023-07-31T09:06:17.864Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.864Z] Received notification 'workspace/didChangeConfiguration' Params: { "settings" : { } } 2023-07-31T09:06:17.864Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.864Z] Received request 'textDocument/documentSymbol - (2)' Params: { "text-document" : { "uri" : "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj" } } 2023-07-31T09:06:17.864Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.864Z] Received request 'textDocument/codeAction - (3)' Params: { "text-document" : { "uri" : "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj" }, "range" : { "start" : { "line" : 9, "character" : 4 }, "end" : { "line" : 9, "character" : 4 } }, "context" : { "diagnostics" : [ ], "trigger-kind" : 2 } } 2023-07-31T09:06:17.865Z INFO [clojure-lsp.handlers:293] - :document-symbol 0ms 2023-07-31T09:06:17.865Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.865Z] Sending response 'textDocument/documentSymbol - (2)'. Request took 1ms. Result: null 2023-07-31T09:06:17.866Z INFO [clojure-lsp.handlers:465] - :code-actions 1ms 2023-07-31T09:06:17.867Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.866Z] Sending response 'textDocument/codeAction - (3)'. Request took 2ms. Result: [ { "title" : "Move to let", "kind" : "refactor.extract", "command" : { "title" : "Move to let", "command" : "move-to-let", "arguments" : [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4, "new-binding" ] } }, { "title" : "Extract to def", "kind" : "refactor.extract", "command" : { "title" : "Extract to def", "command" : "extract-to-def", "arguments" : [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4, null ] } }, { "title" : "Thread first all", "kind" : "refactor.rewrite", "command" : { "title" : "Thread first all", "command" : "thread-first-all", "arguments" : [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } }, { "title" : "Thread last all", "kind" : "refactor.rewrite", "command" : { "title" : "Thread last all", "command" : "thread-last-all", "arguments" : [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } }, { "title" : "Sort list", "kind" : "refactor.rewrite", "command" : { "title" : "Sort list", "command" : "sort-clauses", "arguments" : [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } }, { "title" : "Introduce let", "kind" : "refactor.extract", "command" : { "title" : "Introduce let", "command" : "introduce-let", "arguments" : [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4, "new-binding" ] } }, { "title" : "Create test for 'go'", "kind" : "refactor.rewrite", "command" : { "title" : "Create test", "command" : "create-test", "arguments" : [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } }, { "title" : "Clean namespace", "kind" : "source.organizeImports", "command" : { "title" : "Clean namespace", "command" : "clean-ns", "arguments" : [ "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", 9, 4 ] } } ] 2023-07-31T09:06:17.890Z INFO [clojure-lsp.server:102] - :publish-diagnostics 0ms 2023-07-31T09:06:17.890Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:17.889Z] Sending notification 'textDocument/publishDiagnostics' Params: { "uri" : "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj", "diagnostics" : [ ] } 2023-07-31T09:06:18.163Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:18.163Z] Received request 'textDocument/semanticTokens/full - (4)' Params: { "text-document" : { "uri" : "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro/src/core.clj" } } 2023-07-31T09:06:18.163Z INFO [clojure-lsp.handlers:492] - :semantic-tokens-full 0ms 2023-07-31T09:06:18.164Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:06:18.163Z] Sending response 'textDocument/semanticTokens/full - (4)'. Request took 0ms. Result: { "data" : [ ] } 2023-07-31T09:06:18.561Z INFO [clojure-lsp.feature.clojuredocs:23] - [Clojuredocs] Refreshing clojuredocs cache took 710ms. 2023-07-31T09:06:20.717Z INFO [clojure-lsp.db:69] - [DB] Reading transit analysis cache from /home/simon/.cache/clojure-lsp/db.transit.json db took 2156ms 2023-07-31T09:06:20.717Z INFO [clojure-lsp.feature.java-interop:271] - [Java] JDK source already present on global LSP cache dir. 2023-07-31T09:06:20.734Z INFO [clojure-lsp.dep-graph:269] - :maintain-dep-graph 14ms 2023-07-31T09:06:20.736Z INFO [clojure-lsp.feature.java-interop:312] - [Java] JDK source analysis cache loaded successfully. 2023-07-31T09:08:35.232Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:08:35.231Z] Received request 'clojure/serverInfo/raw - (5)' Params: null 2023-07-31T09:08:35.232Z DEBUG [clojure-lsp.server:55] - [Trace - 2023-07-31T09:08:35.232Z] Sending response 'clojure/serverInfo/raw - (5)'. Request took 1ms. Result: { "log-path" : "/tmp/clojure-lsp.16295043569369432187.out", "project-settings" : { }, "classpath" : [ "/home/simon/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar", "src", "/home/simon/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar", "test", "/home/simon/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar" ], "project-root-uri" : "file:///home/simon/Tmp/calva-kondo-incorrect-config-repro", "client-settings" : { "auto-add-ns-to-new-files?" : true, "document-formatting?" : false, "dependency-scheme" : "jar", "keep-require-at-start?" : true, "source-paths" : null, "text-document-sync-kind" : null, "source-aliases" : null, "document-range-formatting?" : false, "cljfmt-config-path" : ".cljfmt.edn" }, "clj-kondo-version" : "2023.06.02-SNAPSHOT", "server-version" : "2023.07.01-22.35.41", "port" : "NREPL only available on :debug profile (`bb debug-cli`)", "final-settings" : { "auto-add-ns-to-new-files?" : true, "document-formatting?" : false, "dependency-scheme" : "jar", "keep-require-at-start?" : true, "source-paths" : [ "/home/simon/Tmp/calva-kondo-incorrect-config-repro/test", "/home/simon/Tmp/calva-kondo-incorrect-config-repro/src" ], "project-specs" : [ { "project-path" : "project.clj", "classpath-cmd" : [ "lein", "with-profile", "+test,+dev", "classpath" ] }, { "project-path" : "deps.edn", "classpath-cmd" : [ "/run/current-system/sw/bin/clojure", "-A:test:dev", "-Spath" ] }, { "project-path" : "build.boot", "classpath-cmd" : [ "boot", "show", "--fake-classpath" ] }, { "project-path" : "shadow-cljs.edn", "classpath-cmd" : [ "npx", "shadow-cljs", "classpath" ] }, { "project-path" : "bb.edn", "classpath-cmd" : [ "/run/current-system/sw/bin/bb", "print-deps", "--format", "classpath" ] } ], "text-document-sync-kind" : null, "source-aliases" : [ "test", "dev" ], "uri-format" : { "upper-case-drive-letter?" : false, "encode-colons-in-path?" : false }, "document-range-formatting?" : false, "cljfmt-config-path" : ".cljfmt.edn" }, "classpath-settings" : null, "cljfmt-raw" : "{}" } ```

Here we do get Error running clj-kondo on paths [...]

bpringe commented 1 year ago

Thanks for the info. @ericdallo Any idea on how clojure-lsp could and should notify Calva when an error like this occurs?

ericdallo commented 1 year ago

Unfortunately, clojure-lsp relies on clj-kondo analysis for diagnostics report, but I'm wondering if clj-kondo could warn or return findings (diagnostics) about wrong/malformed .clj-kondo/config.edn, WDYT @borkdude? would help a lot with those kind of issues

borkdude commented 1 year ago

clj-kondo tries to do its best to detect these issues, but there may be cases where it doesn't succeed. please post such issues at clj-kondo so they may be resolved. the above issue has already been filed: https://github.com/clj-kondo/clj-kondo/issues/2148