Open ferdinandyb opened 2 months ago
The json output from your linter does indeed appear to not have any end_line_no key of your violation dict.
Would applying this patch make things look correct?
diff --git a/ale_linters/sql/sqlfluff.vim b/ale_linters/sql/sqlfluff.vim
index 4381e1ab..ec26512b 100644
--- a/ale_linters/sql/sqlfluff.vim
+++ b/ale_linters/sql/sqlfluff.vim
@@ -55,9 +55,11 @@ function! ale_linters#sql#sqlfluff#Handle(buffer, version, lines) abort
call add(l:output, {
\ 'filename': l:json.filepath,
\ 'lnum': l:violation.start_line_no,
- \ 'end_lnum': l:violation.end_line_no,
+ \ 'end_lnum': get(l:violation, 'end_line_no',
+ \ l:violation.start_line_no),
\ 'col': l:violation.start_line_pos,
- \ 'end_col': l:violation.end_line_pos,
+ \ 'end_col': get(l:violation, 'end_line_pos',
+ \ l:violation.start_line_pos),
\ 'text': l:violation.description,
\ 'code': l:violation.code,
\ 'type': 'W',
I assume a proper fix should likely just leave out the end values if they are not present?
On Tue Sep 10, 2024 at 18:10, nospam2998 @.***> wrote:
The json output from your linter does indeed appear to not have any end_line_no key of your violation dict.
Would applying this patch make things look correct?
diff --git a/ale_linters/sql/sqlfluff.vim b/ale_linters/sql/sqlfluff.vim index 4381e1ab..ec26512b 100644 --- a/ale_linters/sql/sqlfluff.vim +++ b/ale_linters/sql/sqlfluff.vim @@ -55,9 +55,11 @@ function! ale_linters#sql#sqlfluff#Handle(buffer, version, lines) abort call add(l:output, { \ 'filename': l:json.filepath, \ 'lnum': l:violation.start_line_no, - \ 'end_lnum': l:violation.end_line_no, + \ 'end_lnum': get(l:violation, 'end_line_no', + \ l:violation.start_line_no), \ 'col': l:violation.start_line_pos, - \ 'end_col': l:violation.end_line_pos, + \ 'end_col': get(l:violation, 'end_line_pos', + \ l:violation.start_line_pos), \ 'text': l:violation.description, \ 'code': l:violation.code, \ 'type': 'W',
Thanks this works!
I assume a proper fix should likely just leave out the end values if they are not present?
I'm not sure, but I'll run with the patch until there is a fix :)
I'm not sure, but I'll run with the patch until there is a fix :)
I was under the impression that the patch provided should unblock you, allowing you to proceed with submitting a PR for your issue...
I was under the impression that the patch provided should unblock you, allowing you to proceed with submitting a PR for your issue...
Right :) Could you assign me this issue so I can track it as a task? I'll probably not have free time for this for a couple weeks, but I'll be able to get to it at some point.
Thanks!
Information
VIM version
Operating System: WSL2 running Ubuntu 22.04
What went wrong
I'm constantly getting this error:
Reproducing the bug
Just opened an sql file with ALE enabled.
:ALEInfo
Expand
Current Filetype: sql Available Linters: ['sqlfluff', 'sqlint', 'sqllint'] Linter Aliases: 'sqllint' -> ['sql-lint'] Enabled Linters: ['sqlfluff', 'sqlint', 'sqllint'] Ignored Linters: [] Suggested Fixers: 'pgformatter' - A PostgreSQL SQL syntax beautifier 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'sqlfluff' - Fix SQL files with sqlfluff. 'sqlfmt' - Fix SQL files with sqlfmt. 'sqlformat' - Fix SQL files with sqlformat. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. Linter Variables: " Press Space to read :help for a setting let g:ale_sql_sqlfluff_executable = 'sqlfluff' let g:ale_sql_sqlfluff_options = '' Global Variables: " Press Space to read :help for a setting let g:ale_cache_executable_check_failures = 1 let g:ale_change_sign_column_color = 0 let g:ale_command_wrapper = '' let g:ale_completion_delay = v:null let g:ale_completion_enabled = 0 let g:ale_completion_max_suggestions = v:null let g:ale_disable_lsp = 1 let g:ale_echo_cursor = 1 let g:ale_echo_msg_error_str = 'Error' let g:ale_echo_msg_format = '%linter% - %code: %%s' let g:ale_echo_msg_info_str = 'Info' let g:ale_echo_msg_warning_str = 'Warning' let g:ale_enabled = 1 let g:ale_fix_on_save = 1 let g:ale_fixers = {'go': ['gofumpt'], 'vue': ['prettier', 'eslint'], 'sh': ['shfmt'], '*': ['remove_trailing_lines', 'trim_whitespace'], 'javascript': ['prettier', 'eslint'], 'python': ['black', 'ruff']} let g:ale_history_enabled = 1 let g:ale_info_default_mode = 'preview' let g:ale_history_log_output = 1 let g:ale_keep_list_window_open = 0 let g:ale_lint_delay = 200 let g:ale_lint_on_enter = 1 let g:ale_lint_on_filetype_changed = 1 let g:ale_lint_on_insert_leave = 1 let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'normal' let g:ale_linter_aliases = {} let g:ale_linters = {'javascript': ['eslint'], 'python': ['ruff', 'mypy']} let g:ale_linters_explicit = 0 let g:ale_linters_ignore = {} let g:ale_list_vertical = 0 let g:ale_list_window_size = 10 let g:ale_loclist_msg_format = '%linter% - %code: %%s' let g:ale_max_buffer_history_size = 20 let g:ale_max_signs = -1 let g:ale_maximum_file_size = v:null let g:ale_open_list = 0 let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_root = {} let g:ale_set_balloons = 0 let g:ale_set_highlights = 1 let g:ale_set_loclist = 1 let g:ale_set_quickfix = 0 let g:ale_set_signs = 1 let g:ale_sign_column_always = 0 let g:ale_sign_error = 'E' let g:ale_sign_info = 'I' let g:ale_sign_offset = 1000000 let g:ale_sign_style_error = 'E' let g:ale_sign_style_warning = 'W' let g:ale_sign_warning = 'W' let g:ale_sign_highlight_linenrs = 0 let g:ale_type_map = {} let g:ale_use_neovim_diagnostics_api = 0 let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 'all' let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History: (executable check - success) sqlfluff (finished - exit code 0) ['sh', '-c', '''sqlfluff'' --version'] <<