Cppcheck
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Member Functions | Private Attributes | List of all members
ErrorLogger::ErrorMessage Class Reference

Wrapper for error messages, provided by reportErr() More...

#include <errorlogger.h>

Classes

class  FileLocation
 File name and line number. More...
 

Public Member Functions

 ErrorMessage (const std::list< FileLocation > &callStack, const std::string &file1, Severity::SeverityType severity, const std::string &msg, const std::string &id, bool inconclusive)
 
 ErrorMessage (const std::list< FileLocation > &callStack, const std::string &file1, Severity::SeverityType severity, const std::string &msg, const std::string &id, const CWE &cwe, bool inconclusive)
 
 ErrorMessage (const std::list< const Token *> &callstack, const TokenList *list, Severity::SeverityType severity, const std::string &id, const std::string &msg, bool inconclusive)
 
 ErrorMessage (const std::list< const Token *> &callstack, const TokenList *list, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe, bool inconclusive)
 
 ErrorMessage (const ErrorPath &errorPath, const TokenList *tokenList, Severity::SeverityType severity, const char id[], const std::string &msg, const CWE &cwe, bool inconclusive)
 
 ErrorMessage ()
 
 ErrorMessage (const tinyxml2::XMLElement *const errmsg)
 
std::string toXML () const
 Format the error message in XML format. More...
 
std::string toString (bool verbose, const std::string &templateFormat=emptyString, const std::string &templateLocation=emptyString) const
 Format the error message into a string. More...
 
std::string serialize () const
 
bool deserialize (const std::string &data)
 
void setmsg (const std::string &msg)
 set short and verbose messages More...
 
const std::string & shortMessage () const
 Short message (single line short message) More...
 
const std::string & verboseMessage () const
 Verbose message (may be the same as the short message) More...
 
const std::string & symbolNames () const
 Symbol names. More...
 
Suppressions::ErrorMessage toSuppressionsErrorMessage () const
 

Static Public Member Functions

static std::string getXMLHeader ()
 
static std::string getXMLFooter ()
 

Public Attributes

std::list< FileLocationcallStack
 
std::string id
 
std::string file0
 For GUI rechecking; source file (not header) More...
 
std::string function
 For GUI bug hunting; function name. More...
 
bool incomplete
 For GUI bug hunting; incomplete analysis. More...
 
Severity::SeverityType severity
 
CWE cwe
 
bool inconclusive
 

Static Private Member Functions

static void findAndReplace (std::string &source, const std::string &searchFor, const std::string &replaceWith)
 Replace all occurrences of searchFor with replaceWith in the given source. More...
 
static std::string fixInvalidChars (const std::string &raw)
 

Private Attributes

std::string mShortMessage
 Short message. More...
 
std::string mVerboseMessage
 Verbose message. More...
 
std::string mSymbolNames
 symbol names More...
 

Detailed Description

Wrapper for error messages, provided by reportErr()

Definition at line 149 of file errorlogger.h.

Constructor & Destructor Documentation

◆ ErrorMessage() [1/7]

ErrorLogger::ErrorMessage::ErrorMessage ( const std::list< FileLocation > &  callStack,
const std::string &  file1,
Severity::SeverityType  severity,
const std::string &  msg,
const std::string &  id,
bool  inconclusive 
)

Definition at line 111 of file errorlogger.cpp.

References setmsg().

◆ ErrorMessage() [2/7]

ErrorLogger::ErrorMessage::ErrorMessage ( const std::list< FileLocation > &  callStack,
const std::string &  file1,
Severity::SeverityType  severity,
const std::string &  msg,
const std::string &  id,
const CWE cwe,
bool  inconclusive 
)

Definition at line 126 of file errorlogger.cpp.

References setmsg().

◆ ErrorMessage() [3/7]

ErrorLogger::ErrorMessage::ErrorMessage ( const std::list< const Token *> &  callstack,
const TokenList list,
Severity::SeverityType  severity,
const std::string &  id,
const std::string &  msg,
bool  inconclusive 
)

Definition at line 139 of file errorlogger.cpp.

References callStack, file0, TokenList::getFiles(), and setmsg().

◆ ErrorMessage() [4/7]

ErrorLogger::ErrorMessage::ErrorMessage ( const std::list< const Token *> &  callstack,
const TokenList list,
Severity::SeverityType  severity,
const std::string &  id,
const std::string &  msg,
const CWE cwe,
bool  inconclusive 
)

Definition at line 158 of file errorlogger.cpp.

References callStack, file0, TokenList::getFiles(), and setmsg().

◆ ErrorMessage() [5/7]

ErrorLogger::ErrorMessage::ErrorMessage ( const ErrorPath errorPath,
const TokenList tokenList,
Severity::SeverityType  severity,
const char  id[],
const std::string &  msg,
const CWE cwe,
bool  inconclusive 
)

Definition at line 176 of file errorlogger.cpp.

References callStack, file0, TokenList::getFiles(), and setmsg().

◆ ErrorMessage() [6/7]

ErrorLogger::ErrorMessage::ErrorMessage ( )

Definition at line 106 of file errorlogger.cpp.

◆ ErrorMessage() [7/7]

ErrorLogger::ErrorMessage::ErrorMessage ( const tinyxml2::XMLElement *const  errmsg)
explicit

Member Function Documentation

◆ deserialize()

bool ErrorLogger::ErrorMessage::deserialize ( const std::string &  data)

◆ findAndReplace()

void ErrorLogger::ErrorMessage::findAndReplace ( std::string &  source,
const std::string &  searchFor,
const std::string &  replaceWith 
)
staticprivate

Replace all occurrences of searchFor with replaceWith in the given source.

Parameters
sourceThe string to modify
searchForWhat should be searched for
replaceWithWhat will replace the found item

Definition at line 483 of file errorlogger.cpp.

Referenced by toString().

◆ fixInvalidChars()

std::string ErrorLogger::ErrorMessage::fixInvalidChars ( const std::string &  raw)
staticprivate

Definition at line 421 of file errorlogger.cpp.

Referenced by serialize(), and toXML().

◆ getXMLFooter()

std::string ErrorLogger::ErrorMessage::getXMLFooter ( )
static

◆ getXMLHeader()

std::string ErrorLogger::ErrorMessage::getXMLHeader ( )
static

◆ serialize()

std::string ErrorLogger::ErrorMessage::serialize ( ) const

◆ setmsg()

void ErrorLogger::ErrorMessage::setmsg ( const std::string &  msg)

set short and verbose messages

Definition at line 237 of file errorlogger.cpp.

References endsWith(), mShortMessage, mSymbolNames, mVerboseMessage, and replaceStr().

Referenced by CppCheck::analyseClangTidy(), and ErrorMessage().

◆ shortMessage()

const std::string& ErrorLogger::ErrorMessage::shortMessage ( ) const
inline

Short message (single line short message)

Definition at line 292 of file errorlogger.h.

Referenced by ErrorLogger::plistData().

◆ symbolNames()

const std::string& ErrorLogger::ErrorMessage::symbolNames ( ) const
inline

Symbol names.

Definition at line 302 of file errorlogger.h.

◆ toString()

std::string ErrorLogger::ErrorMessage::toString ( bool  verbose,
const std::string &  templateFormat = emptyString,
const std::string &  templateLocation = emptyString 
) const

Format the error message into a string.

Parameters
verboseuse verbose message
templateFormatEmpty string to use default output format or template to be used. E.g. "{file}:{line},{severity},{id},{message}"
templateLocationFormat Empty string to use default output format or template to be used. E.g. "{file}:{line},{info}"
Returns
formatted string

Definition at line 509 of file errorlogger.cpp.

References callStack, ErrorLogger::callStackToString(), cwe, emptyString, findAndReplace(), CWE::id, inconclusive, mShortMessage, mVerboseMessage, Severity::none, readCode(), severity, MathLib::toString(), and Severity::toString().

Referenced by CppCheckExecutor::reportErr(), CppCheck::reportErr(), and ThreadExecutor::~ThreadExecutor().

◆ toSuppressionsErrorMessage()

Suppressions::ErrorMessage ErrorLogger::ErrorMessage::toSuppressionsErrorMessage ( ) const

◆ toXML()

std::string ErrorLogger::ErrorMessage::toXML ( ) const

◆ verboseMessage()

const std::string& ErrorLogger::ErrorMessage::verboseMessage ( ) const
inline

Verbose message (may be the same as the short message)

Definition at line 297 of file errorlogger.h.

Member Data Documentation

◆ callStack

std::list<FileLocation> ErrorLogger::ErrorMessage::callStack

◆ cwe

CWE ErrorLogger::ErrorMessage::cwe

Definition at line 285 of file errorlogger.h.

Referenced by deserialize(), ErrorMessage(), serialize(), toString(), and toXML().

◆ file0

std::string ErrorLogger::ErrorMessage::file0

For GUI rechecking; source file (not header)

Definition at line 278 of file errorlogger.h.

Referenced by CppCheck::analyseClangTidy(), ErrorMessage(), CppCheck::reportErr(), and toXML().

◆ function

std::string ErrorLogger::ErrorMessage::function

For GUI bug hunting; function name.

Definition at line 280 of file errorlogger.h.

Referenced by ExprEngine::runChecks().

◆ id

std::string ErrorLogger::ErrorMessage::id

◆ incomplete

bool ErrorLogger::ErrorMessage::incomplete

For GUI bug hunting; incomplete analysis.

Definition at line 282 of file errorlogger.h.

Referenced by executeAssign(), and ExprEngine::runChecks().

◆ inconclusive

bool ErrorLogger::ErrorMessage::inconclusive

◆ mShortMessage

std::string ErrorLogger::ErrorMessage::mShortMessage
private

Short message.

Definition at line 321 of file errorlogger.h.

Referenced by deserialize(), ErrorMessage(), serialize(), setmsg(), toString(), and toXML().

◆ mSymbolNames

std::string ErrorLogger::ErrorMessage::mSymbolNames
private

symbol names

Definition at line 327 of file errorlogger.h.

Referenced by setmsg(), toSuppressionsErrorMessage(), and toXML().

◆ mVerboseMessage

std::string ErrorLogger::ErrorMessage::mVerboseMessage
private

Verbose message.

Definition at line 324 of file errorlogger.h.

Referenced by deserialize(), ErrorMessage(), serialize(), setmsg(), toString(), and toXML().

◆ severity

Severity::SeverityType ErrorLogger::ErrorMessage::severity

The documentation for this class was generated from the following files: