Refactoring: Disable debug warnings when file extension is neither .c nor .cpp. To somewhat prevent that people fix java/c# specific debug warnings.
This commit is contained in:
parent
05f16a25af
commit
9a102702cb
|
@ -138,10 +138,26 @@ bool CppCheck::findError(std::string code, const char FileName[])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable debug warnings?
|
||||||
|
static bool no_debug_warnings(const std::string &filename) {
|
||||||
|
const std::string::size_type pos = filename.rfind(".");
|
||||||
|
if (pos == std::string::npos)
|
||||||
|
return false;
|
||||||
|
const std::string ext = filename.substr(pos);
|
||||||
|
|
||||||
|
// Only allow debug warnings if file extension is c or cpp so people
|
||||||
|
// won't be tempted to fix java / c# problems spotted this way.
|
||||||
|
return bool(ext != ".c" && ext != ".cpp");
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int CppCheck::processFile()
|
unsigned int CppCheck::processFile()
|
||||||
{
|
{
|
||||||
exitcode = 0;
|
exitcode = 0;
|
||||||
|
|
||||||
|
// disable debug warnings?
|
||||||
|
if (no_debug_warnings(_filename))
|
||||||
|
_settings.debugwarnings = false;
|
||||||
|
|
||||||
// TODO: Should this be moved out to its own function so all the files can be
|
// TODO: Should this be moved out to its own function so all the files can be
|
||||||
// analysed before any files are checked?
|
// analysed before any files are checked?
|
||||||
if (_settings.test_2_pass && _settings._jobs == 1) {
|
if (_settings.test_2_pass && _settings._jobs == 1) {
|
||||||
|
|
Loading…
Reference in New Issue