next-ls icon indicating copy to clipboard operation
next-ls copied to clipboard

next-ls should display a message on invalid credo.exs (currently fails silently)

Open tensiondriven opened this issue 2 years ago • 0 comments

While working on a workaround for next-ls's inability to ignore credo.exs, described in #288, I accidentally saved my .credo.exs file with a syntax error. Upon launching vs-code with elixir-tools enabled, the following was displayed in my Output tab with NextLS selected:

[NextLS] NextLS v0.14.1 has initialized!
[NextLS] Booting runtimes...
[NextLS] Beginning DB migration...
[Info  - 9:00:51 AM] [NextLS] Database is on the latest version: 5
[NextLS] Finished DB migration...
[NextLS] Using `elixir` found at: /Users/j/.asdf/shims/elixir
[NextLS] Connected to node nextls-runtime-1698674451879528417@WorkMini
[NextLS] Runtime for folder gondor is ready...
[NextLS] Compiling 8 files (.ex)
[NextLS] Compiled gondor!
[NextLS] warning: Execution halted during Elixir.Credo.Execution.Task.ConvertCLIOptionsToConfig! Unrecognized error: {:badconfig, "/Users/j/Code/gondor/.credo.exs", %FunctionClauseError{module: System, function: :get_env, arity: 2, kind: nil, args: nil, clauses: nil}}
  (credo 1.6.6) lib/credo/execution/task/convert_cli_options_to_config.ex:20: Credo.Execution.Task.ConvertCLIOptionsToConfig.error/2
  (credo 1.6.6) lib/credo/execution/task.ex:138: Credo.Execution.Task.do_run/3
  (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
  (credo 1.6.6) lib/credo.ex:30: Credo.run/1
  /Users/j/Library/Application Support/.burrito/next_ls_erts-14.0.2_0.14.1/lib/next_ls-0.14.1/priv/monkey/_next_ls_private_credo.ex:6: :_next_ls_private_credo.issues/1
  (kernel 9.1) erpc.erl:589: :erpc.execute_call/4

It looks like the fix is to catch {:badconfig, _} and ideally raise a message to the user, or add an error to the Problems tab showing that .credo.exs cannot be compiled.

tensiondriven avatar Oct 30 '23 14:10 tensiondriven