aboutsummaryrefslogtreecommitdiffstats
path: root/src/_cppcheck
blob: e8ab3fee28b425b2ca61ada78d852d6dcd60bfbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#compdef cppcheck
# ------------------------------------------------------------------------------
# Copyright (c) 2019 Github zsh-users - https://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the zsh-users nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
#  Completion script for cppcheck -- a tool for static C/C++ code analysis (https://cppcheck.sourceforge.io/)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
#  * Georgy Komarov (https://github.com/jubnzv)
#
# ------------------------------------------------------------------------------
# Notes
# -----
#
#  Created for Cppcheck version 2.12 (https://github.com/danmar/cppcheck)
#
# ------------------------------------------------------------------------------

_cppcheck_files() {
  _path_files -/ -g "*.(c|cpp|cxx|h|hpp|C)"
}

_cppcheck() {
  local curcontext="$curcontext" state line
  typeset -A opt_args

  local check_ids='(all warning style performance portability information unusedFunction missingInclude)'

  _arguments -C \
    "--addon=[Execute addon]" \
    "--addon-python=[Specify the python interpreter]: :_files" \
    "--cppcheck-build-dir=[Analysis output directory]:directory:_files -/" \
    "--check-config[Check cppcheck configuration]" \
    "--check-library[Show information when library files have incomplete info]" \
    "--clang=[Use clang parser instead of the builtin Cppcheck parser]: :_files" \
    "--config-exclude=[Path to be excluded from configuration checking]:directory:_files -/" \
    "--config-exclude-files=[A file that contains a list of config-excludes]:file:_files" \
    "--doc[Print a list of all available checks]" \
    "*--disable=[Disable indivisual checks]:id:$check_ids" \
    "--dump[Dump xml data for each translation unit]" \
    "-D[Define preprocessor symbol]" \
    "-U[Undefine preprocessor symbol]" \
    "-E[Print preprocessor output on stdout and don't do any further processing]" \
    "--enable=[Enable additional checks]:id:$check_ids" \
    "--error-exitcode=[Integer to return if errors are found]" \
    "--errorlist[Print a list of all the error messages in XML format]" \
    "--exitcode-suppressions=[Used when certain messages should be displayed but should not cause a non-zero exitcode]:_files" \
    "*--file-filter=[Analyze only those files matching the given filter str]:filter" \
    "--file-list=[Specify the files to check in a text file]:_files" \
    '(-f --force)'{-f,--force}"[Force checking of all configurations in files]" \
    '(- 1 *)'{-h,--help}"[Print this help]" \
    "-I[A file that contains a list of config-excludes]:directory:_files -/" \
    "--include-file=[Specify directory paths to search for included header files in a text file]:file:_files" \
    "--include=[Force inclusion of a file before the checked file]:file:_files" \
    "-i[Give a source file or source file directory to exclude from the check]:directory or file:_files" \
    "--inconclusive[Report even though the analysis is inconclusive]" \
    "--inline-suppr[Enable inline suppressions]" \
    "-j[Number of threads to do the checking simultaneously]::num" \
    "-l[No new threads should be started if the load average is exceeds this value]::load_avg" \
    {-x,--language=}"[Forces cppcheck to check all files as the given language]:language:(c c++)" \
    "--max-configs=[Maximum number of configurations to check in a file]" \
    "--max-ctu-depth=[Maximum depth in whole program analysis]:num" \
    "--output-file=[File to save results]:file:_files" \
    "--plist-output=[Generate Clang-plist output files in folder]:_files" \
    "--project=[Run Cppcheck on project]:file:_files" \
    "--project-configuration=[Limit the configuration cppcheck should check]:configuration" \
    "--platform=[Set platform specific types and sizes]:platforms:(unix32 unix64 win32A win32W win64 avr8 elbrus-e1cp pic8 pic8-enhanced pic16 mips32 native unspecified)" \
    '(-q --quiet)'{-q,--quiet}"[Do not show progress reports]" \
    {-rp,--relative-paths}"=[Use relative paths in output (separated with ;)]:_files" \
    "--report-progress[Report progress messages while checking a file]" \
    "--std=[Set standard]:std:(c89 c99 c11 c++03 c++11 c++14 c++17 c++20)" \
    "--suppress=[Suppress warnings (format: \[error id\]:\[filename\]:\[line\])]" \
    "--suppressions-list=[Suppress warnings listed in the file]:_files" \
    "--suppress-xml=[Suppress warnings listed in a xml file]:_files" \
    "--template=[Format the error messages]" \
    "--template-location=[Format the error message location]" \
    "(-v --verbose)"{-v,--verbose}"[Output more detailed error information]" \
    "--version[Print out version number]" \
    "--xml[Write results in xml format to stderr]" \
    '*: :_cppcheck_files'
}

_cppcheck "$@"

# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et