dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.57k stars 1.44k forks source link

cppcheck does not find file + solution #4251

Open Spixmaster opened 2 years ago

Spixmaster commented 2 years ago

Information

VIM version

VIM - Vi IMproved 9.0

Operating System: Arch Linux

What went wrong

cppcheck does not work although the other linters and fixers for C++ projects work. The command ALEInfo shows the following relevant error message.

(executable check - success) cppcheck
(finished - exit code 1) ['/bin/zsh', '-c', 'cd ''/home/matheus/c++/tools-cpp'' && ''cppcheck'' -q --language=c++ --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'' --project=''build/compile_commands.json'' --file-filter=''Tools.cpp'' --enable=style ''/tmp/vDHHcxp/2/Tools.cpp''']

<<<OUTPUT STARTS>>>
cppcheck: error: could not find any files matching the filter.
<<<OUTPUT ENDS>>>

Solution

I even found the solution but am not able of writing Vim Script. --file-filter needs to contain the relative path. The following command works.

cppcheck -q --language=c++ --template="{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}" --project="build/compile_commands.json" --file-filter="src/Tools.cpp" --enable=style /tmp/

Reproducing the bug

  1. Install this plugin.
  2. Create a C++ project and the suitable compile_commands.json.
  3. Open a file.

:ALEInfo

 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', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck']
  Ignored Linters: []
 Suggested Fixers: 
  'astyle' - Fix C/C++ with astyle.
  'clang-format' - Fix C/C++ and cuda 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:

let g:ale_cpp_cc_executable = '<auto>'
let g:ale_cpp_cc_options = '-std=c++14 -Wall'
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_options = ''
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'
 Global Variables:

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 = 0
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 = 1
let g:ale_fixers = {'bib': ['bibclean', 'remove_trailing_lines', 'trim_whitespace'], '*': ['remove_trailing_lines', 'trim_whitespace'], 'cpp': ['clang-format', 'clangtidy', 'remove_trailing_lines', 'trim_whitespace']}
let g:ale_history_enabled = 1
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 = {'typescript': ['dprint', 'eslint', 'prettier', 'tsserver'], 'sh': ['shellcheck'], 'cmake': ['cmake-format', 'cmake-lint'], 'html': ['prettier', 'tidy'], 'cpp': ['cc', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck'], 'latex': ['texlab'], 'markdown': ['prettier'], 'yaml': ['prettier'], 'python': ['bandit', 'black', 'python-isort', 'mypy', 'python-pylint', 'pyre', 'pyright', 'yapf'], 'po': ['msgfmt'], 'bib': ['bibclean'], 'xml': ['xmllint'], 'toml': ['dprint'], 'javascript': ['dprint', 'eslint', 'prettier', 'tsserver'], 'make': ['checkmake'], 'json': ['dprint', 'eslint', 'prettier'], 'css': ['prettier', 'stylelint'], 'desktop': ['desktop-file-validate']}
let g:ale_linters_explicit = 1
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 = 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 = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
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 0) ['/bin/zsh', '-c', '''clang++'' -S -x c++ -o /dev/null -iquote ''/home/matheus/c++/tools-cpp/src'' -I ''/home/matheus/c++/tools-cpp/./include'' -Wall -Wextra -O3 -std=gnu++20  -Wall - < ''/tmp/vDHHcxp/1/Tools.cpp''']

<<<NO OUTPUT RETURNED>>>

(executable check - success) clang-check
(started) ['/bin/zsh', '-c', '''clang-check'' -analyze ''/home/matheus/c++/tools-cpp/src/Tools.cpp'' -p ''/home/matheus/c++/tools-cpp/build''']
(executable check - success) clangd
(executable check - success) clang-tidy
(started) ['/bin/zsh', '-c', '''clang-tidy'' ''/home/matheus/c++/tools-cpp/src/Tools.cpp'' -p ''/home/matheus/c++/tools-cpp/build''']
(executable check - success) clazy-standalone
(finished - exit code 0) ['/bin/zsh', '-c', '''clazy-standalone'' -checks=''level1'' -p ''/home/matheus/c++/tools-cpp/build'' ''/home/matheus/c++/tools-cpp/src/Tools.cpp''']

<<<NO OUTPUT RETURNED>>>

(executable check - success) cppcheck
(finished - exit code 1) ['/bin/zsh', '-c', 'cd ''/home/matheus/c++/tools-cpp'' && ''cppcheck'' -q --language=c++ --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'' --project=''build/compile_commands.json'' --file-filter=''Tools.cpp'' --enable=style ''/tmp/vDHHcxp/2/Tools.cpp''']

<<<OUTPUT STARTS>>>
cppcheck: error: could not find any files matching the filter.
<<<OUTPUT ENDS>>>

(started) ['/bin/zsh', '-c', '''clangd'' -compile-commands-dir=''/home/matheus/c++/tools-cpp/build''']
stocktonslack commented 1 year ago

Any progress on this? I'm experiencing the same issue.

juanmitaboada commented 1 year ago

I just sent a PR that resolved this: https://github.com/dense-analysis/ale/pull/4639

The problem happens because of using "--file-filter", it doesn't seem to be necessary in the latest versions.

cgkantidis commented 9 months ago

Any update on this?