You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: man/manual.md
+15-6Lines changed: 15 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,24 +103,25 @@ need to use both approaches. Later chapters will describe this in more detail.
103
103
104
104
### Check files matching a given file filter
105
105
106
-
The option `--file-filter=<str>`is used to specify a file filter pattern. If this is specified then files/paths will be checked only if they match the provided pattern.
106
+
With `--file-filter=<str>`you can configure file filter(s) and then only those files matching the filter will be checked.
107
107
108
-
For example:
108
+
For example, this command below means that `src/test1.cpp` and `src/test/file1.cpp` could be checked, but `src/file2.cpp` will not be checked:
109
109
110
110
cppcheck src/ --file-filter=src/test*
111
111
112
-
This command means for example that `src/test1.cpp` and `src/test/file1.cpp` are checked, but `src/file2.cpp` is not checked.
113
-
114
112
You can use `**`, `*` and `?` in the file filter pattern.
115
113
`**`: matches zero or more characters, including path separators
116
114
`*`: matches zero or more characters, excluding path separators
117
115
`?`: matches zero or one characters, excluding path separators
118
116
119
117
A common use case for `--file-filter` is to check a project, but only check certain files:
Typically a `compile_commands.json` contains absolute paths, but the file filter pattern can match either the relative path or absolute path.
121
+
Typically a `compile_commands.json` contains absolute paths. However no matter if `compile_commands.json` contains absolute paths or relative paths, the option `--file-filter=src/*.c` would mean that:
122
+
* a file with relative path `test1.c` is not checked.
123
+
* a file with relative path `src/test2.c` can be checked.
124
+
* a file with relative path `src/test3.cpp` is not checked.
124
125
125
126
### Excluding a file or folder from checking
126
127
@@ -135,6 +136,14 @@ You can use `**`, `*` and `?` in the pattern to specify excluded folders/files.
135
136
`*`: matches zero or more characters, excluding path separators
136
137
`?`: matches zero or one characters, excluding path separators
137
138
139
+
A use case for `-i` is to check a project, but exclude certain files/folders:
140
+
141
+
cppcheck --project=compile_commands.json -itest
142
+
143
+
Typically a `compile_commands.json` contains absolute paths. However no matter if `compile_commands.json` contains absolute paths or relative paths, the option `-itest` would mean that:
144
+
* a file with relative path `test1.cpp` can be checked.
145
+
* a file with relative path `test/somefile.cpp` is not checked
146
+
138
147
### Clang parser (experimental)
139
148
140
149
By default Cppcheck uses an internal C/C++ parser. However there is an experimental option to use the Clang parser instead.
0 commit comments