Skip to content

Commit 67b4927

Browse files
authored
improved documentation (#82)
* README.md: documented `Show Cppcheck XML Output` action and its limitations * README.md: re-wrote "Known Issues" section * some minor documentation improvements * README.md: use proper capitalization for `Cppcheck` and do not quote it * README.md: rewrote `Installation` section - refs #58
1 parent b8de638 commit 67b4927

File tree

2 files changed

+102
-73
lines changed

2 files changed

+102
-73
lines changed

README.md

+99-33
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,113 @@
1-
# CLion-cppcheck
1+
# clion-cppcheck
22

3-
- Runs `cppcheck` on the fly while you write code.
4-
- Highlights lines and displays `cppcheck` error messages.
5-
- Supports passing options to `cppcheck`.
3+
A plugin for JetBrains IDEs to provide inspections for C/C++ files utilizing the static analyzer [Cppcheck](https://cppcheck.sourceforge.io/).
64

75
This project is supported with a free open source license of CLion from
86
[JetBrains](https://www.jetbrains.com/?from=clion-cppcheck).
97

8+
## Features
9+
10+
- Runs `Cppcheck` on the fly while you write code.
11+
- Highlights lines and displays `Cppcheck` error messages.
12+
- Supports passing options to `Cppcheck`.
13+
1014
## Installation
1115

12-
See
13-
[Installing, Updating and Uninstalling Repository Plugins](https://www.jetbrains.com/help/clion/managing-plugins.html)
16+
- Install the `cppcheck` plugin from the JetBrains Marketplace: https://plugins.jetbrains.com/plugin/8143-cppcheck. See
17+
[Installing, Updating and Uninstalling Repository Plugins](https://www.jetbrains.com/help/clion/managing-plugins.html) for more details.
18+
19+
- Install Cppcheck. Please refer to https://github.com/danmar/cppcheck#packages on how to obtain a version of Cppcheck for your platform.
1420

15-
- [`cppcheck` in JetBrains Plugin Repository][cppcheck_plugin]
21+
- Go to the `Cppcheck Configuration` section in the settings of your respective JetBrains IDE and put the **absolute** path to the Cppcheck executable in the `Cppcheck Path`.
22+
23+
- (Windows) The executable is found in the path you specified during the installation. By default this should be `C:\Program Files\Cppcheck\cppcheck.exe`.
24+
- (Non-Windows) Use `which cppcheck` or `command -v cppcheck` on the command-line to get the location of the executable. The default depends on your system but should usually be `/usr/bin/cppcheck` or `/usr/local/bin/cppcheck`.
1625

1726
## Usage
1827

19-
1. Install the [`cppcheck`](http://cppcheck.sourceforge.net/) tool using the instructions on its homepage. This plugin
20-
does **not** bundle the `cppcheck` tool itself, which must be installed separately.
21-
2. Install the [cppcheck plugin][cppcheck_plugin] into CLion.
22-
3. Configure the plugin with the **absolute** path to the `cppcheck` executable into the `cppcheck path` option.
23-
1. Windows
24-
1. File | Settings | Cppcheck configuration
25-
2. Usually the path is `C:\Program Files (x86)\Cppcheck\cppcheck.exe`
26-
2. macOS:
27-
1. CLion | Preferences | Cppcheck configuration
28-
2. In a terminal run `which cppcheck` to find the path to `cppcheck`. If you installed it with
29-
[Homebrew](https://brew.sh/), the path will be `/usr/local/bin/cppcheck`.
30-
3. Linux
31-
1. File | Settings | Cppcheck configuration
32-
2. In a terminal run `which cppcheck` to find the path to `cppcheck`. If you installed it with your
33-
system's package manager, it is probably located at `/usr/bin/cppcheck`.
34-
35-
[cppcheck_plugin]: https://plugins.jetbrains.com/plugin/8143
36-
37-
## Known Issues
38-
39-
`cppcheck` is not designed to be run on header files (`.h`) directly, as must be done for this
28+
### Provided Actions
29+
30+
The plugin provides the `Show Cppcheck XML Output` action which will show the raw XML output of the latest finished analysis.
31+
32+
## Known Issues/Limitations
33+
34+
See https://github.com/johnthagen/clion-cppcheck/issues for a complete list of tracked issues and enhancements requests.
35+
36+
### Analyzing header files
37+
38+
Cppcheck is not designed to be run on header files (`.h`) directly, as must be done for this
4039
plugin, and as a result may have false positives.
4140

42-
When run on header files directly, `cppcheck` defaults to C as the language, which will generate
43-
false positives for C++ projects. C++ projects should append `--language=c++` to the
44-
`cppcheck` options.
41+
When run on header files directly, Cppcheck defaults to C as the language, which will generate
42+
false positives for C++ projects. So `--language=c++` is implicitly added as option when analyzing header files.
43+
44+
It will also provide `unusedFunction` and `unusedStructMember` false positives so these findings are being suppressed.
45+
46+
Related issues:<br/>
47+
https://github.com/johnthagen/clion-cppcheck/issues/22
48+
https://github.com/johnthagen/clion-cppcheck/issues/52
49+
50+
### Analyzing multiple configurations
51+
52+
By default Cppcheck tries to determine all the available configurations for a file (i.e. all combination of the used
53+
preprocessor defines). As the plugin doesn't get the current list of defines this may lead to findings shown in code
54+
which is shown as disabled in the editor. To check just a specific configuration you can either add defines using `-D`
55+
to the options. Or you can limit the configurations to a single one adding `--max-configs=1`.
56+
57+
By default Limiting the configurations also decreases the time of the analysis.
58+
59+
By default a maximum of 12 configurations is checked. This may lead to some code which might actually be active not to
60+
show any findings. This can also be controlled by the `--max-configs=<n>` option.
61+
62+
Related issues:<br/>
63+
https://github.com/johnthagen/clion-cppcheck/issues/34
64+
https://github.com/johnthagen/clion-cppcheck/issues/52
65+
66+
### Multiple include paths
67+
68+
No additional includes path are being passed to Cppcheck for the analysis which might result in false positives or not
69+
all findings being shown.
70+
71+
You can add additional include path using the `-I <path>` options.
72+
73+
Related issues:<br/>
74+
https://github.com/johnthagen/clion-cppcheck/issues/52
75+
https://github.com/johnthagen/clion-cppcheck/issues/55
76+
77+
### Batch analysis
78+
79+
The batch analysis passes the files individually to Cppcheck just like the highlighting inspections. So if you pass a
80+
folder to the batch analysis it might not show the same findings as when passing a folder to `Cppcheck` itself.
81+
82+
It will also pass all the contents of the folder to the analysis and not just project files. This might lead to
83+
unexpected findings.
84+
85+
Also some findings in headers files triggered by the analysis of a source files are not being shown.
86+
87+
Related issues:<br/>
88+
https://github.com/johnthagen/clion-cppcheck/issues/54
89+
90+
### Showing raw output
91+
92+
`Show Cppcheck XML Output` only shows the XML result of the latest analysis. If you need to view the results for a
93+
specific file make sure it was the last one analyzed.
94+
95+
Related issues:<br/>
96+
https://github.com/johnthagen/clion-cppcheck/issues/53
97+
98+
### External libraries / System includes
99+
100+
Cppcheck does not support analyzing of external library or system includes. It provides profiles for several external
101+
libraries which describe the contents and behavior of the includes which allows it to finding issues with usage of them
102+
in the code. To add such a profile to your analysis you need to specify it via the `--library=<name>` option. The
103+
available profile can be found in the `cfg` folder of your `Cppcheck` installation.
104+
105+
### Global options
106+
107+
Currently the configured options are global and not per project.
108+
109+
Related issues:<br/>
110+
https://github.com/johnthagen/clion-cppcheck/issues/52
45111

46112
## Development
47113

@@ -112,7 +178,7 @@ Support Cppcheck >1.89. (Contribution by @SJ-Innovation)
112178

113179
### 1.2.0 - 2018-04-11
114180

115-
Greatly improve plugin responsiveness to changes by using virtual files to interact with `cppcheck`.
181+
Greatly improve plugin responsiveness to changes by using virtual files to interact with Cppcheck.
116182
(Contribution by @fastasturtle)
117183

118184
### 1.1.0 - 2018-04-02
@@ -158,7 +224,7 @@ Fix execution on Linux.
158224

159225
### 1.0.1 - 2016-01-11
160226

161-
Fix possible out of bounds line number when ``cppcheck`` gets out of sync with in-memory file.
227+
Fix possible out of bounds line number when Cppcheck gets out of sync with in-memory file.
162228

163229
### 1.0.0 - 2016-01-07
164230

resources/META-INF/plugin.xml

+3-40
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<vendor email="[email protected]" url="http://github.com/johnthagen">johnthagen</vendor>
66

77
<description><![CDATA[
8-
Cppcheck plugin for CLion.<br/><br/>
8+
A plugin for JetBrains IDEs to provide inspections for C/C++ files utilizing the static analyzer Cppcheck.<br/><br/>
99
1010
<b>Features:</b><br/>
1111
<ul>
@@ -16,47 +16,10 @@
1616
<br/>
1717
1818
<b>Usage:</b><br/>
19-
<ul>
20-
<li>
21-
Install the <a href="http://cppcheck.sourceforge.net/">cppcheck tool</a> using directions on its homepage.
22-
This plugin does <b>not</b> bundle the Cppcheck tool itself, which must be installed separately.
23-
</li>
24-
<li>Install this Cppcheck plugin into CLion</li>
25-
<li>Configure the plugin with the <b>absolute</b> path to the Cppcheck executable into the
26-
'Cppcheck Path' configuration field</li>
27-
<ul>
28-
<li>Windows
29-
<ul>
30-
<li>File | Settings | Cppcheck Configuration</li>
31-
<li>Usually the path is C:\Program Files (x86)\Cppcheck\cppcheck.exe</li>
32-
</ul>
33-
</li>
34-
<li>macOS
35-
<ul>
36-
<li>CLion | Preferences | Cppcheck Configuration</li>
37-
<li>In a terminal run `which cppcheck` to find the path to Cppcheck.
38-
If you installed it with <a href="https://brew.sh/">Homebrew</a>, the path will be
39-
/usr/local/bin/cppcheck</li>
40-
</ul>
41-
</li>
42-
<li>Linux
43-
<ul>
44-
<li>File | Settings | Cppcheck Configuration</li>
45-
<li>In a terminal run `which cppcheck` to find the path to Cppcheck.
46-
If you installed it with your system's package manager, it is probably located at
47-
/usr/bin/cppcheck</li>
48-
</ul>
49-
</li>
50-
</u1>
51-
</ul>
52-
<br/>
19+
Please refer to <a href="https://github.com/johnthagen/clion-cppcheck#known-issues">Installation</a>.<br/>
5320
5421
<b>Known issues:</b><br/>
55-
Cppcheck is not designed to be run on header files (.h) directly, as must be done for this
56-
plugin, and as a result may have false positives.<br/>
57-
When run on header files directly, Cppcheck defaults to C as the language, which will
58-
generate false positives for C++ projects. C++ projects should leave --language=c++ appended to the
59-
Cppcheck options.<br/>
22+
Please refer to <a href="https://github.com/johnthagen/clion-cppcheck#known-issues">Known Issues</a>.<br/>
6023
]]></description>
6124

6225
<change-notes><![CDATA[

0 commit comments

Comments
 (0)