Skip to content

Commit

Permalink
Refactoring: Disable debug warnings when file extension is neither .c…
Browse files Browse the repository at this point in the history
… nor .cpp. To somewhat prevent that people fix java/c# specific debug warnings.
  • Loading branch information
danmar committed Jan 6, 2012
1 parent 05f16a2 commit 9a10270
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9a10270

Please sign in to comment.