mirror of
https://github.com/dense-analysis/ale.git
synced 2026-10-25 23:27:27 +08:00
elixir: Fix mix linter and support warnings (#5140)
CI / Build (push) Canceled after 0s
CI / Lint (push) Canceled after 0s
CI / Lua (push) Canceled after 0s
CI / Neovim 0.10 Linux (push) Canceled after 0s
CI / Neovim 0.12 Linux (push) Canceled after 0s
CI / Vim 8.2 Linux (push) Canceled after 0s
CI / Vim 9.2 Linux (push) Canceled after 0s
CI / Neovim 0.10 Windows (push) Canceled after 0s
CI / Neovim 0.12 Windows (push) Canceled after 0s
CI / Vim 8.2 Windows (push) Canceled after 0s
CI / Vim 9.2 Windows (push) Canceled after 0s
CI / Build (push) Canceled after 0s
CI / Lint (push) Canceled after 0s
CI / Lua (push) Canceled after 0s
CI / Neovim 0.10 Linux (push) Canceled after 0s
CI / Neovim 0.12 Linux (push) Canceled after 0s
CI / Vim 8.2 Linux (push) Canceled after 0s
CI / Vim 9.2 Linux (push) Canceled after 0s
CI / Neovim 0.10 Windows (push) Canceled after 0s
CI / Neovim 0.12 Windows (push) Canceled after 0s
CI / Vim 8.2 Windows (push) Canceled after 0s
CI / Vim 9.2 Windows (push) Canceled after 0s
* elixir: Don't use temp dir for mix linter The mix linter sets `MIX_BUILD_PATH` to a temporary directory on every run, which is very slow and inefficient. We can just use the default build path to speed this up. The default directory is `_build` inside the project, this is also automatically added to `.gitignore` by `mix new` so hopefully shouldn't cause any unwanted clutter. The `%s` argument is removed since `mix compile` doesn't actually support passing a filename. The output stream is changed to `stderr` since that's where the errors appear. Other options: - `mix compile` has a `--no-compile` flag, but this misses most errors including basic syntax errors - `mix format` has a `--dry-run` flag, but this only catches basic syntax errors and misses other errors like undefined functions Fixes https://github.com/dense-analysis/ale/issues/3816 * elixir: Fix error parsing for mix linter and support warnings The error parsing stopped working at some point, probably when Elixir introduced its new error formatting in for 1.16 in 2023.
This commit is contained in:
1 parent
ca4a4dd33c
commit
422c0e8ef4
3 files changed
+137
-32
No files matched your search
@@ -1,20 +1,85 @@
|
||||
Before:
|
||||
runtime ale_linters/elixir/mix.vim
|
||||
call ale#test#SetFilename('/testplugin/lib/foo.ex')
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The mix handler should parse lines correctly):
|
||||
let input_lines = [
|
||||
\ ' warning: variable "a" is unused (if the variable is not meant to be used, prefix it with an underscore)',
|
||||
\ ' │',
|
||||
\ ' 16 │ a = missing_var',
|
||||
\ ' │ ~',
|
||||
\ ' │',
|
||||
\ ' └─ /testplugin/lib/foo.ex:16:5: Foo.hello/0',
|
||||
\ '',
|
||||
\ ' warning: variable "b" is unused (if the variable is not meant to be used, prefix it with an underscore)',
|
||||
\ ' │',
|
||||
\ ' 17 │ b = another_missing_var',
|
||||
\ ' │ ~',
|
||||
\ ' │',
|
||||
\ ' └─ /testplugin/lib/foo.ex:17:5: Foo.hello/0',
|
||||
\ '',
|
||||
\ ' error: undefined variable "another_missing_var"',
|
||||
\ ' │',
|
||||
\ ' 17 │ b = another_missing_var',
|
||||
\ ' │ ^^^^^^^^^^^^^^^^^^^',
|
||||
\ ' │',
|
||||
\ ' └─ /testplugin/lib/foo.ex:17:9: Foo.hello/0',
|
||||
\ '',
|
||||
\ ' error: undefined variable "missing_var"',
|
||||
\ ' │',
|
||||
\ ' 16 │ a = missing_var',
|
||||
\ ' │ ^^^^^^^^^^^',
|
||||
\ ' │',
|
||||
\ ' └─ /testplugin/lib/foo.ex:16:9: Foo.hello/0',
|
||||
\ '',
|
||||
\ ' error: undefined variable "unrelated_var"',
|
||||
\ ' │',
|
||||
\ ' 16 │ a = unrelated_var',
|
||||
\ ' │ ^^^^^^^^^^^',
|
||||
\ ' │',
|
||||
\ ' └─ /testplugin/lib/unrelated.ex:16:9: Foo.hello/0',
|
||||
\ '',
|
||||
\ '',
|
||||
\ '== Compilation error in file /testplugin/lib/foo.ex ==',
|
||||
\ '** (CompileError) /testplugin/lib/foo.ex: cannot compile module Foo (errors have been logged)',
|
||||
\ ]
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 87,
|
||||
\ 'col': 0,
|
||||
\ 'text': 'undefined function update_in/4',
|
||||
\ 'bufnr': bufnr(''),
|
||||
\ 'lnum': 16,
|
||||
\ 'col': 5,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'variable "a" is unused (if the variable is not meant to be used, prefix it with an underscore)',
|
||||
\ 'detail': join(input_lines, "\n"),
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': bufnr(''),
|
||||
\ 'lnum': 17,
|
||||
\ 'col': 5,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'variable "b" is unused (if the variable is not meant to be used, prefix it with an underscore)',
|
||||
\ 'detail': join(input_lines, "\n"),
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': bufnr(''),
|
||||
\ 'lnum': 17,
|
||||
\ 'col': 9,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'undefined variable "another_missing_var"',
|
||||
\ 'detail': join(input_lines, "\n"),
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': bufnr(''),
|
||||
\ 'lnum': 16,
|
||||
\ 'col': 9,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'undefined variable "missing_var"',
|
||||
\ 'detail': join(input_lines, "\n"),
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#elixir#mix#Handle(347, [
|
||||
\ '** (CompileError) apps/sim/lib/sim/server.ex:87: undefined function update_in/4'
|
||||
\ ])
|
||||
\ ale_linters#elixir#mix#Handle(bufnr(''), input_lines)
|
||||
Reference in new issue
Block a user