Refactorizations:
- Added forgotten initialization of Settings::_relativePaths - Some PCRE-Rules specific code hidden behind HAVE_RULES - Use initialization list in ErrorLogger::ErrorMessage::ErrorMessage() and CppCheck::CppCheck - Avoided unnecessary copies of std::strings in cppcheck.cpp - Moved "// Alert only about unique errors"-code to make it work in debugFalsePositive mode
This commit is contained in:
parent
6643e14d3c
commit
7de545f0fe
|
@ -39,9 +39,8 @@ static const char ExtraVersion[] = "";
|
|||
static TimerResults S_timerResults;
|
||||
|
||||
CppCheck::CppCheck(ErrorLogger &errorLogger, bool useGlobalSuppressions)
|
||||
: _useGlobalSuppressions(useGlobalSuppressions), _errorLogger(errorLogger)
|
||||
: _useGlobalSuppressions(useGlobalSuppressions), _errorLogger(errorLogger), exitcode(0)
|
||||
{
|
||||
exitcode = 0;
|
||||
}
|
||||
|
||||
CppCheck::~CppCheck()
|
||||
|
@ -154,8 +153,7 @@ unsigned int CppCheck::processFile(const std::string& filename)
|
|||
return exitcode;
|
||||
|
||||
if (_settings._errorsOnly == false) {
|
||||
std::string fixedpath(filename);
|
||||
fixedpath = Path::simplifyPath(fixedpath.c_str());
|
||||
std::string fixedpath = Path::simplifyPath(filename.c_str());
|
||||
fixedpath = Path::toNativeSeparators(fixedpath);
|
||||
_errorLogger.reportOut(std::string("Checking ") + fixedpath + std::string("..."));
|
||||
}
|
||||
|
@ -460,20 +458,20 @@ Settings &CppCheck::settings()
|
|||
|
||||
void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
|
||||
{
|
||||
const std::string errmsg = msg.toString(_settings._verbose);
|
||||
std::string errmsg = msg.toString(_settings._verbose);
|
||||
if (errmsg.empty())
|
||||
return;
|
||||
|
||||
// Alert only about unique errors
|
||||
if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end())
|
||||
return;
|
||||
|
||||
if (_settings.debugFalsePositive) {
|
||||
// Don't print out error
|
||||
_errorList.push_back(errmsg);
|
||||
return;
|
||||
}
|
||||
|
||||
// Alert only about unique errors
|
||||
if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end())
|
||||
return;
|
||||
|
||||
std::string file;
|
||||
unsigned int line(0);
|
||||
if (!msg._callStack.empty()) {
|
||||
|
@ -493,14 +491,14 @@ void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
|
|||
exitcode = 1;
|
||||
|
||||
_errorList.push_back(errmsg);
|
||||
std::string errmsg2(errmsg);
|
||||
|
||||
if (_settings._verbose) {
|
||||
errmsg2 += "\n Defines=\'" + cfg + "\'\n";
|
||||
errmsg += "\n Defines=\'" + cfg + "\'\n";
|
||||
}
|
||||
|
||||
_errorLogger.reportErr(msg);
|
||||
|
||||
_errout << errmsg2 << std::endl;
|
||||
_errout << errmsg << std::endl;
|
||||
}
|
||||
|
||||
void CppCheck::reportOut(const std::string &outmsg)
|
||||
|
|
|
@ -34,21 +34,14 @@ ErrorLogger::ErrorMessage::ErrorMessage()
|
|||
{
|
||||
}
|
||||
|
||||
ErrorLogger::ErrorMessage::ErrorMessage(const std::list<FileLocation> &callStack, Severity::SeverityType severity, const std::string &msg, const std::string &id, bool inconclusive)
|
||||
ErrorLogger::ErrorMessage::ErrorMessage(const std::list<FileLocation> &callStack, Severity::SeverityType severity, const std::string &msg, const std::string &id, bool inconclusive) :
|
||||
_callStack(callStack), // locations for this error message
|
||||
_severity(severity), // severity for this error message
|
||||
_id(id), // set the message id
|
||||
_inconclusive(inconclusive)
|
||||
{
|
||||
// locations for this error message
|
||||
_callStack = callStack;
|
||||
|
||||
// severity for this error message
|
||||
_severity = severity;
|
||||
|
||||
// set the summary and verbose messages
|
||||
setmsg(msg);
|
||||
|
||||
// set the message id
|
||||
_id = id;
|
||||
|
||||
_inconclusive = inconclusive;
|
||||
}
|
||||
|
||||
void ErrorLogger::ErrorMessage::setmsg(const std::string &msg)
|
||||
|
|
|
@ -31,6 +31,7 @@ Settings::Settings()
|
|||
_inlineSuppressions(false),
|
||||
_verbose(false),
|
||||
_force(false),
|
||||
_relativePaths(false),
|
||||
_xml(false), _xml_version(1),
|
||||
_jobs(1),
|
||||
_exitCode(0),
|
||||
|
|
|
@ -166,6 +166,7 @@ public:
|
|||
/** @brief --report-progress */
|
||||
bool reportProgress;
|
||||
|
||||
#ifdef HAVE_RULES
|
||||
/** Rule */
|
||||
class Rule {
|
||||
public:
|
||||
|
@ -184,6 +185,7 @@ public:
|
|||
* @brief Extra rules
|
||||
*/
|
||||
std::list<Rule> rules;
|
||||
#endif
|
||||
|
||||
/** Is the 'configuration checking' wanted? */
|
||||
bool checkConfiguration;
|
||||
|
|
Loading…
Reference in New Issue