erlang-ls / erlang_ls

The Erlang Language Server
https://erlang-ls.github.io/
Apache License 2.0
626 stars 136 forks source link

Elvis crashes when the line is "unknown" #1525

Closed zsoci closed 3 months ago

zsoci commented 3 months ago

Describe the bug [2024-06-07T17:13:29.167149+02:00] [info] (find_me_here): {export_used_types,"Type ~p/~p, defined on line ~p, is used by an exported function but not exported itself",unknown,[arda_obj,0,unknown],2,1,[84,121,112,101,32,"the_type",47,"0",44,32,100,101,102,105,110,101,100,32,111,110,32,108,105,110,101,32,"unknown",44,32,105,115,32,117,115,101,100,32,98,121,32,97,110,32,101,120,112,111,114,116,101,100,32,102,117,110,99,116,105,111,110,32,98,117,116,32,110,111,116,32,101,120,112,111,114,116,101,100,32,105,116,115,101,108,102]} [els_elvis_diagnostics:diagnostic/5 L109] <0.192.0>

To Reproduce Include an unexported type in the .erl

Expected behavior The warning should use line nr 0.

Actual behavior [2024-06-07T17:19:44.010006+02:00] [error] crasher: initial call: els_background_job:init/1, pid: <0.191.0>, registered_name: [], exit: {{badarith,[{els_elvis_diagnostics,diagnostic,5,[{file,"/Users/zsoci/Projects/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,112}]},{els_elvis_diagnostics,format_item,2,[{file,"/Users/zsoci/Projects/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,91}]},{els_elvis_diagnostics,format_rules,1,[{file,"/Users/zsoci/Projects/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,85}]},{els_elvis_diagnostics,format_diagnostics,1,[{file,"/Users/zsoci/Projects/erlang_ls/apps/els_lsp/src/els_elvis_diagnostics.erl"},{line,65}]},{lists,flatmap_1,2,[{file,"lists.erl"},{line,1579}]},{els_background_job,'-handle_info/2-fun-0-',10,[{file,"/Users/zsoci/Projects/erlang_ls/apps/els_lsp/src/els_background_job.erl"},{line,205}]}]},[{gen_server,handle_common_reply,8,[{file,"gen_server.erl"},{line,1226}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]}, ancestors: [els_background_job_sup,els_sup,<0.140.0>], message_queue_len: 0, messages: [], links: [<0.145.0>], dictionary: [], trap_exit: true, status: running, heap_size: 28690, stack_size: 28, reductions: 73638; neighbours: [proc_lib:crash_report/4 L584] <0.191.0>

Context