ale icon indicating copy to clipboard operation
ale copied to clipboard

ALEFix with clangtidy not updating the buffer

Open rksouthee opened this issue 1 year ago • 1 comments

Information

VIM version

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Nov 19 2023 18:05:09) MS-Windows 64-bit GUI version

Operating System: Windows 10

What went wrong

When using the clangtidy fixer and trying to run :ALEFix with fixes available the current buffer is not being updated. I can see that clangtidy is being run with a temporary file. If I run the same command but replace the temporar file with the actual file then the contents are correctly being updated. I can see that in ale#fix#ApplyFixes we check the for changes_made and I can see that the l:data.lines_before is equal to the l:data.output.

Reproducing the bug

  1. Set g:ale_fixers = {'cpp': ['clangtidy']}
  2. Run :ALEFix on file with fix available
  3. File is not updated, expected the buffer to update with the fixes applied.

:ALEInfo

Expand Current Filetype: cpp Available Linters: ['cc', 'ccls', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'cspell', 'flawfinder'] Linter Aliases: 'cc' -> ['gcc', 'clang', 'g++', 'clang++'] Enabled Linters: ['cc', 'ccls', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'cspell', 'flawfinder'] Ignored Linters: [] Suggested Fixers: 'astyle' - Fix C/C++ with astyle. 'clang-format' - Fix C, C++, C#, CUDA, Java, JavaScript, JSON, ObjectiveC and Protobuf files with clang-format. 'clangtidy' - Fix C/C++ and ObjectiveC files with clang-tidy. 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. 'uncrustify' - Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.

Linter Variables: " Press Space to read :help for a setting let g:ale_cpp_cc_executable = '' let g:ale_cpp_cc_header_exts = ['h', 'hpp'] let g:ale_cpp_cc_options = '-std=c++14 -Wall' let g:ale_cpp_cc_use_header_lang_flag = -1 let g:ale_cpp_ccls_executable = 'ccls' let g:ale_cpp_ccls_init_options = {} let g:ale_cpp_clangcheck_executable = 'clang-check' let g:ale_cpp_clangcheck_options = '' let g:ale_cpp_clangd_executable = 'clangd' let g:ale_cpp_clangd_options = '' let g:ale_cpp_clangtidy_checks = [] let g:ale_cpp_clangtidy_executable = 'clang-tidy' let g:ale_cpp_clangtidy_extra_options = '' let g:ale_cpp_clangtidy_fix_errors = 1 let g:ale_cpp_clangtidy_options = '' let g:ale_cpp_clangtidy_use_global = 0 let g:ale_cpp_clazy_checks = ['level1'] let g:ale_cpp_clazy_executable = 'clazy-standalone' let g:ale_cpp_clazy_options = '' let g:ale_cpp_cppcheck_executable = 'cppcheck' let g:ale_cpp_cppcheck_options = '--enable=style' let g:ale_cpp_cpplint_executable = 'cpplint' let g:ale_cpp_cpplint_options = '' let g:ale_cpp_cquery_cache_directory = 'C:\Users\rksou.cache\cquery' let g:ale_cpp_cquery_executable = 'cquery' let g:ale_cpp_flawfinder_executable = 'flawfinder' let g:ale_cpp_flawfinder_minlevel = 1 let g:ale_cpp_flawfinder_options = ''

Global Variables: " Press Space to read :help for a setting let g:ale_cache_executable_check_failures = v:null 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 = 'auto' let g:ale_echo_cursor = 1 let g:ale_echo_msg_error_str = 'Error' let g:ale_echo_msg_format = '%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 = 0 let g:ale_fixers = {'cpp': ['clangtidy']} 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 = {} 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 = '%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 = 1 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) clang++ (finished - exit code 1) 'cmd /s/c "clang++ -S -x c++-header -o nul -iquote D:\Learning\RayTracing\source -DCMAKE_INTDIR="Debug" -O0 -D_DEBUG -D_DLL -D_MT -std=c++14 -Wall - < C:\Users\rksou\AppData\Local\Temp\V2M54D0.tmp\ray.h"'

<<<OUTPUT STARTS>>> In file included from :4: ./vec3.h:32:14: warning: expression result unused [-Wunused-value] 32 | e[0] * t; | ~~~~ ^ ~ ./vec3.h:33:14: warning: expression result unused [-Wunused-value] 33 | e[1] * t; | ~~~~ ^ ~ ./vec3.h:34:14: warning: expression result unused [-Wunused-value] 34 | e[2] * t; | ~~~~ ^ ~ :10:13: error: unknown type name 'point'; did you mean 'point3'? 10 | ray(const point &origin, const vec3 &direction) | ^~~~~ | point3 ./vec3.h:51:7: note: 'point3' declared here 51 | using point3 = vec3; | ^ 3 warnings and 1 error generated. <<<OUTPUT ENDS>>>

(executable check - failure) ccls (executable check - success) clang-check (finished - exit code 1) 'cmd /s/c "clang-check -analyze D:\Learning\RayTracing\source\ray.h -p D:\Learning\RayTracing\build"'

<<<OUTPUT STARTS>>> In file included from D:\Learning\RayTracing\source\ray.h:4: D:\Learning\RayTracing\source/vec3.h:32:14: warning: expression result unused [-Wunused-value] 32 | e[0] * t; | ~~~~ ^ ~ D:\Learning\RayTracing\source/vec3.h:33:14: warning: expression result unused [-Wunused-value] 33 | e[1] * t; | ~~~~ ^ ~ D:\Learning\RayTracing\source/vec3.h:34:14: warning: expression result unused [-Wunused-value] 34 | e[2] * t; | ~~~~ ^ ~ D:\Learning\RayTracing\source\ray.h:10:13: error: unknown type name 'point'; did you mean 'point3'? 10 | ray(const point &origin, const vec3 &direction) | ^~~~~ | point3 D:\Learning\RayTracing\source/vec3.h:51:7: note: 'point3' declared here 51 | using point3 = vec3; | ^ 3 warnings and 1 error generated. Error while processing D:\Learning\RayTracing\source\ray.h. <<<OUTPUT ENDS>>>

(executable check - success) clangd (executable check - success) clang-tidy (finished - exit code 1) 'cmd /s/c "clang-tidy D:\Learning\RayTracing\source\ray.h -p D:\Learning\RayTracing\build"'

<<<OUTPUT STARTS>>> D:\Learning\RayTracing\source\ray.h:10:13: error: unknown type name 'point'; did you mean 'point3'? [clang-diagnostic-error] 10 | ray(const point &origin, const vec3 &direction) | ^~~~~ | point3 D:\Learning\RayTracing\source/vec3.h:51:7: note: 'point3' declared here 51 | using point3 = vec3; | ^ <<<OUTPUT ENDS>>>

(executable check - failure) clazy-standalone (executable check - failure) cppcheck (executable check - failure) cpplint (executable check - failure) cquery (executable check - failure) cspell (executable check - failure) flawfinder (started) 'cmd /s/c "clangd -compile-commands-dir=D:\Learning\RayTracing\build"' (executable check - failure) ccls (executable check - failure) cquery (finished - exit code 0) 'cmd /s/c "clang-tidy -fix -fix-errors -p D:\Learning\RayTracing\build C:\Users\rksou\AppData\Local\Temp\V3F603B.tmp\ray.h"'

rksouthee avatar May 18 '24 16:05 rksouthee

注意这一行代码:(finished - exit code 1) 'cmd /s/c "clang++ -S -x c++-header -o nul -iquote D:\Learning\RayTracing\source -DCMAKE_INTDIR="Debug" -O0 -D_DEBUG -D_DLL -D_MT -std=c++14 -Wall - < C:\Users\rksou\AppData\Local\Temp\V2M54D0.tmp\ray.h"'

在Windows 上的cmd中运行 clang命令,我在py环境遇到了同样的问题只需要按照错误运行pip install pylint

而你我的朋友你需要安装clang

John-Smiths avatar Jun 20 '24 22:06 John-Smiths