Some refactorizations
This commit is contained in:
parent
0705dbd34a
commit
4b52df675a
|
@ -25,7 +25,7 @@ PathMatch::PathMatch(const std::vector<std::string> &masks)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathMatch::Match(const std::string &path, bool caseSensitive)
|
bool PathMatch::Match(const std::string &path, bool caseSensitive) const
|
||||||
{
|
{
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
* matching paths?
|
* matching paths?
|
||||||
* @return true if any of the masks match the path, false otherwise.
|
* @return true if any of the masks match the path, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool Match(const std::string &path, bool caseSensitive = true);
|
bool Match(const std::string &path, bool caseSensitive = true) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ protected:
|
||||||
* @param path Path to edit.
|
* @param path Path to edit.
|
||||||
* @return path without filename part.
|
* @return path without filename part.
|
||||||
*/
|
*/
|
||||||
std::string RemoveFilename(const std::string &path);
|
static std::string RemoveFilename(const std::string &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> _masks;
|
std::vector<std::string> _masks;
|
||||||
|
|
|
@ -80,7 +80,7 @@ unsigned int CppCheck::check(const std::string &path, const std::string &content
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CppCheck::replaceAll(std::string code, const std::string &from, const std::string &to)
|
std::string CppCheck::replaceAll(std::string code, const std::string &from, const std::string &to) const
|
||||||
{
|
{
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
while ((pos = code.find(from, pos)) != std::string::npos) {
|
while ((pos = code.find(from, pos)) != std::string::npos) {
|
||||||
|
|
|
@ -173,7 +173,7 @@ private:
|
||||||
* @brief Replace "from" strings with "to" strings in "code"
|
* @brief Replace "from" strings with "to" strings in "code"
|
||||||
* and return it.
|
* and return it.
|
||||||
*/
|
*/
|
||||||
std::string replaceAll(std::string code, const std::string &from, const std::string &to);
|
std::string replaceAll(std::string code, const std::string &from, const std::string &to) const;
|
||||||
|
|
||||||
unsigned int exitcode;
|
unsigned int exitcode;
|
||||||
std::list<std::string> _errorList;
|
std::list<std::string> _errorList;
|
||||||
|
|
|
@ -30,9 +30,8 @@ InternalError::InternalError(const Token *tok, const std::string &errorMsg) :
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorLogger::ErrorMessage::ErrorMessage()
|
ErrorLogger::ErrorMessage::ErrorMessage()
|
||||||
:_severity(Severity::none)
|
: _severity(Severity::none), _inconclusive(false)
|
||||||
{
|
{
|
||||||
_inconclusive = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -327,15 +326,14 @@ std::string ErrorLogger::callStackToString(const std::list<ErrorLogger::ErrorMes
|
||||||
|
|
||||||
std::string ErrorLogger::ErrorMessage::FileLocation::getfile(bool convert) const
|
std::string ErrorLogger::ErrorMessage::FileLocation::getfile(bool convert) const
|
||||||
{
|
{
|
||||||
std::string f = Path::simplifyPath(_file.c_str());
|
|
||||||
|
|
||||||
if (convert)
|
if (convert)
|
||||||
f = Path::toNativeSeparators(f);
|
return Path::toNativeSeparators(_file);
|
||||||
return f;
|
return _file;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorLogger::ErrorMessage::FileLocation::setfile(const std::string &file)
|
void ErrorLogger::ErrorMessage::FileLocation::setfile(const std::string &file)
|
||||||
{
|
{
|
||||||
_file = file;
|
_file = file;
|
||||||
_file = Path::fromNativeSeparators(_file);
|
_file = Path::fromNativeSeparators(_file);
|
||||||
|
_file = Path::simplifyPath(_file.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,12 +162,9 @@ public:
|
||||||
/** Rule */
|
/** Rule */
|
||||||
class Rule {
|
class Rule {
|
||||||
public:
|
public:
|
||||||
Rule() {
|
Rule()
|
||||||
// default id
|
: id("rule") // default id
|
||||||
id = "rule";
|
, severity("style") { // default severity
|
||||||
|
|
||||||
// default severity
|
|
||||||
severity = "style";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string pattern;
|
std::string pattern;
|
||||||
|
|
|
@ -181,11 +181,12 @@ bool Suppressions::FileMatcher::isSuppressed(const std::string &file, unsigned i
|
||||||
|
|
||||||
for (std::map<std::string, std::map<unsigned int, bool> >::iterator g = _globs.begin(); g != _globs.end(); ++g) {
|
for (std::map<std::string, std::map<unsigned int, bool> >::iterator g = _globs.begin(); g != _globs.end(); ++g) {
|
||||||
if (match(g->first, file)) {
|
if (match(g->first, file)) {
|
||||||
if (g->second.find(0U) != g->second.end()) {
|
std::map<unsigned int, bool>::iterator l = g->second.find(0U);
|
||||||
g->second[0U] = true;
|
if (l != g->second.end()) {
|
||||||
|
l->second = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
std::map<unsigned int, bool>::iterator l = g->second.find(line);
|
l = g->second.find(line);
|
||||||
if (l != g->second.end()) {
|
if (l != g->second.end()) {
|
||||||
l->second = true;
|
l->second = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -200,11 +201,12 @@ bool Suppressions::FileMatcher::isSuppressedLocal(const std::string &file, unsig
|
||||||
{
|
{
|
||||||
std::map<std::string, std::map<unsigned int, bool> >::iterator f = _files.find(file);
|
std::map<std::string, std::map<unsigned int, bool> >::iterator f = _files.find(file);
|
||||||
if (f != _files.end()) {
|
if (f != _files.end()) {
|
||||||
if (f->second.find(0U) != f->second.end()) {
|
std::map<unsigned int, bool>::iterator l = f->second.find(0U);
|
||||||
f->second[0U] = true;
|
if (l != f->second.end()) {
|
||||||
|
l->second = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
std::map<unsigned int, bool>::iterator l = f->second.find(line);
|
l = f->second.find(line);
|
||||||
if (l != f->second.end()) {
|
if (l != f->second.end()) {
|
||||||
l->second = true;
|
l->second = true;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -118,7 +118,7 @@ public:
|
||||||
bool isSuppressedLocal(const std::string &errorId, const std::string &file, unsigned int line);
|
bool isSuppressedLocal(const std::string &errorId, const std::string &file, unsigned int line);
|
||||||
|
|
||||||
struct SuppressionEntry {
|
struct SuppressionEntry {
|
||||||
SuppressionEntry(const std::string &aid, const std::string &afile, const unsigned int &aline)
|
SuppressionEntry(const std::string &aid, const std::string &afile, unsigned int aline)
|
||||||
: id(aid), file(afile), line(aline)
|
: id(aid), file(afile), line(aline)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return what would be printed to cout. See also clearOutput() */
|
/** Return what would be printed to cout. See also clearOutput() */
|
||||||
std::string getOutput() {
|
std::string getOutput() const {
|
||||||
return _out.str();
|
return _out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue