Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elvis configuration errors are not correctly handled #1067

Closed
josephDunne opened this issue Jul 30, 2021 · 2 comments
Closed

Elvis configuration errors are not correctly handled #1067

josephDunne opened this issue Jul 30, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@josephDunne
Copy link

Describe the bug
I get the following error in the erlang_ls server log while running on OTP 24:

[2021-07-30T16:52:56.742371+01:00] [warning] Background job aborted. [reason={function_clause,[{els_elvis_diagnostics,format_rules,["src/file.erl",[#{error_msg => "'~p' while applying rule '~p'.",info => [undef,line_length]}]],[{file,"src/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,68}]},{els_elvis_diagnostics,format_diagnostics,1,[{file,"src/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,62}]},{lists,flatmap,2,[{file,"lists.erl"},{line,1254}]},{els_background_job,handle_info,2,[{file,"src/erlang_ls/apps/els_lsp/src/els_background_job.erl"},{line,160}]},{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,695}]},{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,771}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}] [els_background_job:terminate/2 L196] <0.213.0>
[2021-07-30T16:52:56.757527+01:00] [error] Generic server <0.213.0> terminating. Reason: {function_clause,[{els_elvis_diagnostics,format_rules,["src/file.erl",[#{error_msg => "'~p' while applying rule '~p'.",info => [undef,line_length]}]],[{file,"src/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,68}]},{els_elvis_diagnostics,format_diagnostics,1,[{file,"src/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,62}]},{lists,flatmap,2,[{file,"lists.erl"},{line,1254}]},{els_background_job,handle_info,2,[{file,"src/erlang_ls/apps/els_lsp/src/els_background_job.erl"},{line,160}]},{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,695}]},{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,771}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}. Last message: exec. State: #{config => #{entries => [<<"file://src/file.erl">>],on_complete => #Fun<els_diagnostics.1.67775306>,on_error => #Fun<els_background_job.0.71521734>,task => #Fun<els_diagnostics.0.67775306>,title => <<"Elvis (file)">>},current => 0,internal_state => undefined,progress_enabled => true,show_percentages => true,spinning_wheel => undefined,step => 100.0,token => <<"297b1d81-706f-4d74-b76b-b635f87b861e">>,total => 1}. [gen_server:error_info/7 L949] <0.213.0>
[2021-07-30T16:52:56.758508+01:00] [error] crasher: initial call: els_background_job:init/1, pid: <0.213.0>, registered_name: [], error: {function_clause,[{els_elvis_diagnostics,format_rules,["src/file.erl",[#{error_msg => "'~p' while applying rule '~p'.",info => [undef,line_length]}]],[{file,"src/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,68}]},{els_elvis_diagnostics,format_diagnostics,1,[{file,"src/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,62}]},{lists,flatmap,2,[{file,"lists.erl"},{line,1254}]},{els_background_job,handle_info,2,[{file,"src/erlang_ls/apps/els_lsp/src/els_background_job.erl"},{line,160}]},{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,695}]},{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,771}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}, ancestors: [els_background_job_sup,els_sup,<0.157.0>], message_queue_len: 1, messages: [{'EXIT',<0.416.0>,normal}], links: [<0.179.0>], dictionary: [], trap_exit: true, status: running, heap_size: 75113, stack_size: 29, reductions: 4846283; neighbours: [proc_lib:crash_report/4 L525] <0.213.0>
[2021-07-30T16:52:56.759133+01:00] [error] Supervisor: {local,els_background_job_sup}. Context: child_terminated. Reason: {function_clause,[{els_elvis_diagnostics,format_rules,["src/file.erl",[#{error_msg => "'~p' while applying rule '~p'.",info => [undef,line_length]}]],[{file,"src/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,68}]},{els_elvis_diagnostics,format_diagnostics,1,[{file,"src/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,62}]},{lists,flatmap,2,[{file,"lists.erl"},{line,1254}]},{els_background_job,handle_info,2,[{file,"src/erlang_ls/apps/els_lsp/src/els_background_job.erl"},{line,160}]},{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,695}]},{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,771}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}. Offender: id=els_background_job,pid=<0.213.0>. [supervisor:do_restart/3 L751] <0.179.0>

looks like a function clause in els_elvis_diagnostics to do with the change in line lengths in the compiler

To Reproduce
Use the language server with OTP 24 on any erlang file

Context

  • erlang_ls version (tag/sha): 35efe6e
  • Editor used: vscode
  • LSP client used: vscode
@josephDunne josephDunne added the bug Something isn't working label Jul 30, 2021
@robertoaloi robertoaloi self-assigned this Sep 20, 2021
@robertoaloi
Copy link
Member

Hi @josephDunne and thanks for the report!

I believe this is not an OTP 24 specific issue. What you are experiencing seems to be the combination of two issues:

  1. elvis_core was recently updated in a backward-incompatible manner and your elvis.config still follows the old format. To fix your config, simply replace {elvis_style, line_length... with {elvis_text_style, line_length. You can also check here the full migration guide for Elvis.

  2. Erlang LS does not handle configuration errors correctly and crashes (as in your case). I will shortly push a fix so that config errors are treated as regular diagnostics.

@robertoaloi robertoaloi changed the title undef applying rule line_length on OTP 24 Elvis configuration errors are not correctly handled Sep 20, 2021
robertoaloi added a commit that referenced this issue Sep 20, 2021
@robertoaloi
Copy link
Member

Closing as solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants