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())
|
||||
return false;
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
* matching paths?
|
||||
* @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:
|
||||
|
||||
|
@ -53,7 +53,7 @@ protected:
|
|||
* @param path Path to edit.
|
||||
* @return path without filename part.
|
||||
*/
|
||||
std::string RemoveFilename(const std::string &path);
|
||||
static std::string RemoveFilename(const std::string &path);
|
||||
|
||||
private:
|
||||
std::vector<std::string> _masks;
|
||||
|
|
|
@ -80,7 +80,7 @@ unsigned int CppCheck::check(const std::string &path, const std::string &content
|
|||
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;
|
||||
while ((pos = code.find(from, pos)) != std::string::npos) {
|
||||
|
|
|
@ -173,7 +173,7 @@ private:
|
|||
* @brief Replace "from" strings with "to" strings in "code"
|
||||
* 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;
|
||||
std::list<std::string> _errorList;
|
||||
|
|
|
@ -30,9 +30,8 @@ InternalError::InternalError(const Token *tok, const std::string &errorMsg) :
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -327,15 +326,14 @@ std::string ErrorLogger::callStackToString(const std::list<ErrorLogger::ErrorMes
|
|||
|
||||
std::string ErrorLogger::ErrorMessage::FileLocation::getfile(bool convert) const
|
||||
{
|
||||
std::string f = Path::simplifyPath(_file.c_str());
|
||||
|
||||
if (convert)
|
||||
f = Path::toNativeSeparators(f);
|
||||
return f;
|
||||
return Path::toNativeSeparators(_file);
|
||||
return _file;
|
||||
}
|
||||
|
||||
void ErrorLogger::ErrorMessage::FileLocation::setfile(const std::string &file)
|
||||
{
|
||||
_file = file;
|
||||
_file = Path::fromNativeSeparators(_file);
|
||||
_file = Path::simplifyPath(_file.c_str());
|
||||
}
|
||||
|
|
|
@ -162,12 +162,9 @@ public:
|
|||
/** Rule */
|
||||
class Rule {
|
||||
public:
|
||||
Rule() {
|
||||
// default id
|
||||
id = "rule";
|
||||
|
||||
// default severity
|
||||
severity = "style";
|
||||
Rule()
|
||||
: id("rule") // default id
|
||||
, severity("style") { // default severity
|
||||
}
|
||||
|
||||
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) {
|
||||
if (match(g->first, file)) {
|
||||
if (g->second.find(0U) != g->second.end()) {
|
||||
g->second[0U] = true;
|
||||
std::map<unsigned int, bool>::iterator l = g->second.find(0U);
|
||||
if (l != g->second.end()) {
|
||||
l->second = true;
|
||||
return true;
|
||||
}
|
||||
std::map<unsigned int, bool>::iterator l = g->second.find(line);
|
||||
l = g->second.find(line);
|
||||
if (l != g->second.end()) {
|
||||
l->second = 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);
|
||||
if (f != _files.end()) {
|
||||
if (f->second.find(0U) != f->second.end()) {
|
||||
f->second[0U] = true;
|
||||
std::map<unsigned int, bool>::iterator l = f->second.find(0U);
|
||||
if (l != f->second.end()) {
|
||||
l->second = true;
|
||||
return true;
|
||||
}
|
||||
std::map<unsigned int, bool>::iterator l = f->second.find(line);
|
||||
l = f->second.find(line);
|
||||
if (l != f->second.end()) {
|
||||
l->second = true;
|
||||
return true;
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
bool isSuppressedLocal(const std::string &errorId, const std::string &file, unsigned int line);
|
||||
|
||||
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)
|
||||
{ }
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
}
|
||||
|
||||
/** Return what would be printed to cout. See also clearOutput() */
|
||||
std::string getOutput() {
|
||||
std::string getOutput() const {
|
||||
return _out.str();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue