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:
Daniel Marjamäki 2012-01-06 16:08:08 +01:00
parent 05f16a25af
commit 9a102702cb
1 changed files with 16 additions and 0 deletions

View File

@ -138,10 +138,26 @@ bool CppCheck::findError(std::string code, const char FileName[])
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()
{
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
// analysed before any files are checked?
if (_settings.test_2_pass && _settings._jobs == 1) {