johnthagen / johnthagen/clion-cppcheck
Override errors with virtual functions not shown
- Dominant language
- Java
- Stars
- 35
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
### Environment
* Operating System (e.g. Ubuntu 16.04 x64): win7
* IDE Version (e.g. CLion 2016.3.2): clion 2016.2.3
* Cppcheck executable version (`cppcheck --version`): 1.8.4
* Cppcheck plugin version: .12.0
* Exact strings used in cppcheck plugin options:
* **cppcheck options**: --enable=all --language=c++ --std=c++11
### Expected behaviour
Report all errors from cppcheck.
### Actual behaviour
Errors about missing c++11 `override` are not shown.
### Steps to reproduce the behaviour
1. Create files
* file `a.h`:
```c++
class a {
public:
virtual int testfunc()=0;
};
class b : public a {
public:
virtual int testfunc() {
int i = 0;
return i;
};
};
```
* file `c.h`:
```c++
#include "a.h"
class c : public a {
public:
virtual int testfunc() {
int i = 0;
return i;
};
};
```
2. Run normal code inspection.
3. On `a.h` the override error is shown. On `c.h` the error is not shown.
### Analysis
**Look at cppcheck**
Run `cppcheck` manually on `a.h`:
> [a.h:3] -> [a.h:8]: (style) The function 'testfunc' overrides a function in a base class but is not marked with a 'override' specifier.
Run `cppcheck` manually on `c.h`:
> [a.h:3] -> [a.h:8]: (style) The function 'testfunc' overrides a function in a base class but is not marked with a 'override' specifier.
> [a.h:3] -> [c.h:4]: (style) The function 'testfunc' overrides a function in a base class but is not marked with a 'override' specifier.
**Result: `cppcheck` recognizes the error. -> somehow filtered by the plugin**
**Look into plugin**
Problem: Pattern only filters first file name. Second file name is not analyzed.
> [a.h:3] -> [c.h:4]: (style) The function 'testfunc' overrides a function in a base class but is not marked with a 'override' specifier.
Means `a.h` is detected and filtered by line:
https://github.com/johnthagen/clion-cppcheck/blob/master/src/com/github/johnthagen/cppcheck/CppcheckInspection.java#L140
### Solution
Extend pattern/regex to get second file name and filter against this file.
### Why no fix or pr?
I am not good at regex writing :(.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.