Refactor CppCheck::_fileContents to a function parameter
This commit is contained in:
parent
e6686dfb5b
commit
997c9ce100
|
@ -62,15 +62,12 @@ const char * CppCheck::extraVersion()
|
||||||
|
|
||||||
unsigned int CppCheck::check(const std::string &path)
|
unsigned int CppCheck::check(const std::string &path)
|
||||||
{
|
{
|
||||||
return processFile(path);
|
return processFile(path, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CppCheck::check(const std::string &path, const std::string &content)
|
unsigned int CppCheck::check(const std::string &path, const std::string &content)
|
||||||
{
|
{
|
||||||
_fileContent = content;
|
return processFile(path, content);
|
||||||
const unsigned int retval = processFile(path);
|
|
||||||
_fileContent.clear();
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCheck::replaceAll(std::string& code, const std::string &from, const std::string &to)
|
void CppCheck::replaceAll(std::string& code, const std::string &from, const std::string &to)
|
||||||
|
@ -129,7 +126,7 @@ bool CppCheck::findError(std::string code, const char FileName[])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CppCheck::processFile(const std::string& filename)
|
unsigned int CppCheck::processFile(const std::string& filename, const std::string& fileContent)
|
||||||
{
|
{
|
||||||
exitcode = 0;
|
exitcode = 0;
|
||||||
|
|
||||||
|
@ -151,9 +148,9 @@ unsigned int CppCheck::processFile(const std::string& filename)
|
||||||
std::list<std::string> configurations;
|
std::list<std::string> configurations;
|
||||||
std::string filedata = "";
|
std::string filedata = "";
|
||||||
|
|
||||||
if (!_fileContent.empty()) {
|
if (!fileContent.empty()) {
|
||||||
// File content was given as a string
|
// File content was given as a string (democlient)
|
||||||
std::istringstream iss(_fileContent);
|
std::istringstream iss(fileContent);
|
||||||
preprocessor.preprocess(iss, filedata, configurations, filename, _settings._includePaths);
|
preprocessor.preprocess(iss, filedata, configurations, filename, _settings._includePaths);
|
||||||
} else {
|
} else {
|
||||||
// Only file name was given, read the content from file
|
// Only file name was given, read the content from file
|
||||||
|
|
|
@ -135,8 +135,13 @@ private:
|
||||||
/** @brief There has been a internal error => Report information message */
|
/** @brief There has been a internal error => Report information message */
|
||||||
void internalError(const std::string &filename, const std::string &msg);
|
void internalError(const std::string &filename, const std::string &msg);
|
||||||
|
|
||||||
/** @brief Process one file. */
|
/**
|
||||||
unsigned int processFile(const std::string& filename);
|
* @brief Process one file.
|
||||||
|
* @param filename file name
|
||||||
|
* @param fileContent If this is non-empty then the file will not be loaded
|
||||||
|
* @return amount of errors found
|
||||||
|
*/
|
||||||
|
unsigned int processFile(const std::string& filename, const std::string& fileContent);
|
||||||
|
|
||||||
/** @brief Check file */
|
/** @brief Check file */
|
||||||
void checkFile(const std::string &code, const char FileName[]);
|
void checkFile(const std::string &code, const char FileName[]);
|
||||||
|
@ -179,7 +184,6 @@ private:
|
||||||
|
|
||||||
std::list<std::string> _errorList;
|
std::list<std::string> _errorList;
|
||||||
Settings _settings;
|
Settings _settings;
|
||||||
std::string _fileContent;
|
|
||||||
|
|
||||||
void reportProgress(const std::string &filename, const char stage[], const std::size_t value);
|
void reportProgress(const std::string &filename, const char stage[], const std::size_t value);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue