fixed some "Declaration and assignment can be joined" Rider warnings (#5569)
This commit is contained in:
parent
b40d36a09e
commit
bfe19af6b2
|
@ -388,10 +388,9 @@ QString ProjectFile::readString(QXmlStreamReader &reader)
|
||||||
|
|
||||||
void ProjectFile::readIncludeDirs(QXmlStreamReader &reader)
|
void ProjectFile::readIncludeDirs(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType type;
|
|
||||||
bool allRead = false;
|
bool allRead = false;
|
||||||
do {
|
do {
|
||||||
type = reader.readNext();
|
QXmlStreamReader::TokenType type = reader.readNext();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::StartElement:
|
case QXmlStreamReader::StartElement:
|
||||||
|
|
||||||
|
@ -426,10 +425,9 @@ void ProjectFile::readIncludeDirs(QXmlStreamReader &reader)
|
||||||
|
|
||||||
void ProjectFile::readDefines(QXmlStreamReader &reader)
|
void ProjectFile::readDefines(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType type;
|
|
||||||
bool allRead = false;
|
bool allRead = false;
|
||||||
do {
|
do {
|
||||||
type = reader.readNext();
|
QXmlStreamReader::TokenType type = reader.readNext();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::StartElement:
|
case QXmlStreamReader::StartElement:
|
||||||
// Read define-elements
|
// Read define-elements
|
||||||
|
@ -463,10 +461,9 @@ void ProjectFile::readDefines(QXmlStreamReader &reader)
|
||||||
|
|
||||||
void ProjectFile::readCheckPaths(QXmlStreamReader &reader)
|
void ProjectFile::readCheckPaths(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType type;
|
|
||||||
bool allRead = false;
|
bool allRead = false;
|
||||||
do {
|
do {
|
||||||
type = reader.readNext();
|
QXmlStreamReader::TokenType type = reader.readNext();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::StartElement:
|
case QXmlStreamReader::StartElement:
|
||||||
|
|
||||||
|
@ -501,10 +498,9 @@ void ProjectFile::readCheckPaths(QXmlStreamReader &reader)
|
||||||
|
|
||||||
void ProjectFile::readExcludes(QXmlStreamReader &reader)
|
void ProjectFile::readExcludes(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType type;
|
|
||||||
bool allRead = false;
|
bool allRead = false;
|
||||||
do {
|
do {
|
||||||
type = reader.readNext();
|
QXmlStreamReader::TokenType type = reader.readNext();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::StartElement:
|
case QXmlStreamReader::StartElement:
|
||||||
// Read exclude-elements
|
// Read exclude-elements
|
||||||
|
@ -547,9 +543,8 @@ void ProjectFile::readExcludes(QXmlStreamReader &reader)
|
||||||
|
|
||||||
void ProjectFile::readVsConfigurations(QXmlStreamReader &reader)
|
void ProjectFile::readVsConfigurations(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType type;
|
|
||||||
do {
|
do {
|
||||||
type = reader.readNext();
|
QXmlStreamReader::TokenType type = reader.readNext();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::StartElement:
|
case QXmlStreamReader::StartElement:
|
||||||
// Read library-elements
|
// Read library-elements
|
||||||
|
@ -611,9 +606,8 @@ void ProjectFile::readPlatform(QXmlStreamReader &reader)
|
||||||
|
|
||||||
void ProjectFile::readSuppressions(QXmlStreamReader &reader)
|
void ProjectFile::readSuppressions(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType type;
|
|
||||||
do {
|
do {
|
||||||
type = reader.readNext();
|
QXmlStreamReader::TokenType type = reader.readNext();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::StartElement:
|
case QXmlStreamReader::StartElement:
|
||||||
// Read library-elements
|
// Read library-elements
|
||||||
|
@ -658,9 +652,8 @@ void ProjectFile::readSuppressions(QXmlStreamReader &reader)
|
||||||
|
|
||||||
void ProjectFile::readTagWarnings(QXmlStreamReader &reader, const QString &tag)
|
void ProjectFile::readTagWarnings(QXmlStreamReader &reader, const QString &tag)
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType type;
|
|
||||||
do {
|
do {
|
||||||
type = reader.readNext();
|
QXmlStreamReader::TokenType type = reader.readNext();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::StartElement:
|
case QXmlStreamReader::StartElement:
|
||||||
// Read library-elements
|
// Read library-elements
|
||||||
|
@ -693,10 +686,9 @@ void ProjectFile::readTagWarnings(QXmlStreamReader &reader, const QString &tag)
|
||||||
|
|
||||||
void ProjectFile::readStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[])
|
void ProjectFile::readStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[])
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType type;
|
|
||||||
bool allRead = false;
|
bool allRead = false;
|
||||||
do {
|
do {
|
||||||
type = reader.readNext();
|
QXmlStreamReader::TokenType type = reader.readNext();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::StartElement:
|
case QXmlStreamReader::StartElement:
|
||||||
// Read library-elements
|
// Read library-elements
|
||||||
|
|
|
@ -221,12 +221,11 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
||||||
line.file = e.file;
|
line.file = e.file;
|
||||||
line.line = e.line;
|
line.line = e.line;
|
||||||
line.message = line.summary = e.info;
|
line.message = line.summary = e.info;
|
||||||
QStandardItem *child_item;
|
QStandardItem *child_item = addBacktraceFiles(stditem,
|
||||||
child_item = addBacktraceFiles(stditem,
|
line,
|
||||||
line,
|
hide,
|
||||||
hide,
|
":images/go-down.png",
|
||||||
":images/go-down.png",
|
true);
|
||||||
true);
|
|
||||||
if (!child_item)
|
if (!child_item)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1140,11 +1139,10 @@ QString ResultsTree::getFilePath(const QStandardItem *target, bool fullPath)
|
||||||
target = target->parent()->child(target->row(), 0);
|
target = target->parent()->child(target->row(), 0);
|
||||||
|
|
||||||
QVariantMap data = target->data().toMap();
|
QVariantMap data = target->data().toMap();
|
||||||
QString pathStr;
|
|
||||||
|
|
||||||
//Replace (file) with filename
|
//Replace (file) with filename
|
||||||
QString file = data[FILENAME].toString();
|
QString file = data[FILENAME].toString();
|
||||||
pathStr = QDir::toNativeSeparators(file);
|
QString pathStr = QDir::toNativeSeparators(file);
|
||||||
if (!fullPath) {
|
if (!fullPath) {
|
||||||
QFileInfo fi(pathStr);
|
QFileInfo fi(pathStr);
|
||||||
pathStr = fi.fileName();
|
pathStr = fi.fileName();
|
||||||
|
|
|
@ -113,8 +113,7 @@ void StatsDialog::setProject(const ProjectFile* projectFile)
|
||||||
}
|
}
|
||||||
mUI->mLblHistoryFile->setText(tr("File: ") + (statsFile.isEmpty() ? tr("No cppcheck build dir") : statsFile));
|
mUI->mLblHistoryFile->setText(tr("File: ") + (statsFile.isEmpty() ? tr("No cppcheck build dir") : statsFile));
|
||||||
if (!statsFile.isEmpty()) {
|
if (!statsFile.isEmpty()) {
|
||||||
QChartView *chartView;
|
QChartView *chartView = createChart(statsFile, "cppcheck");
|
||||||
chartView = createChart(statsFile, "cppcheck");
|
|
||||||
mUI->mTabHistory->layout()->addWidget(chartView);
|
mUI->mTabHistory->layout()->addWidget(chartView);
|
||||||
if (projectFile->getClangAnalyzer()) {
|
if (projectFile->getClangAnalyzer()) {
|
||||||
chartView = createChart(statsFile, CLANG_ANALYZER);
|
chartView = createChart(statsFile, CLANG_ANALYZER);
|
||||||
|
|
|
@ -452,8 +452,7 @@ void CheckNullPointer::nullPointerError(const Token *tok, const std::string &var
|
||||||
} else if (value->defaultArg) {
|
} else if (value->defaultArg) {
|
||||||
reportError(errorPath, Severity::warning, "nullPointerDefaultArg", errmsgdefarg, CWE_NULL_POINTER_DEREFERENCE, inconclusive || value->isInconclusive() ? Certainty::inconclusive : Certainty::normal);
|
reportError(errorPath, Severity::warning, "nullPointerDefaultArg", errmsgdefarg, CWE_NULL_POINTER_DEREFERENCE, inconclusive || value->isInconclusive() ? Certainty::inconclusive : Certainty::normal);
|
||||||
} else {
|
} else {
|
||||||
std::string errmsg;
|
std::string errmsg = std::string(value->isKnown() ? "Null" : "Possible null") + " pointer dereference";
|
||||||
errmsg = std::string(value->isKnown() ? "Null" : "Possible null") + " pointer dereference";
|
|
||||||
if (!varname.empty())
|
if (!varname.empty())
|
||||||
errmsg = "$symbol:" + varname + '\n' + errmsg + ": $symbol";
|
errmsg = "$symbol:" + varname + '\n' + errmsg + ": $symbol";
|
||||||
|
|
||||||
|
|
|
@ -2492,8 +2492,7 @@ void CheckStl::dereferenceInvalidIteratorError(const Token* tok, const ValueFlow
|
||||||
if (value->condition) {
|
if (value->condition) {
|
||||||
reportError(errorPath, Severity::warning, "derefInvalidIteratorRedundantCheck", errmsgcond, CWE825, (inconclusive || value->isInconclusive()) ? Certainty::inconclusive : Certainty::normal);
|
reportError(errorPath, Severity::warning, "derefInvalidIteratorRedundantCheck", errmsgcond, CWE825, (inconclusive || value->isInconclusive()) ? Certainty::inconclusive : Certainty::normal);
|
||||||
} else {
|
} else {
|
||||||
std::string errmsg;
|
std::string errmsg = std::string(value->isKnown() ? "Dereference" : "Possible dereference") + " of an invalid iterator";
|
||||||
errmsg = std::string(value->isKnown() ? "Dereference" : "Possible dereference") + " of an invalid iterator";
|
|
||||||
if (!varname.empty())
|
if (!varname.empty())
|
||||||
errmsg = "$symbol:" + varname + '\n' + errmsg + ": $symbol";
|
errmsg = "$symbol:" + varname + '\n' + errmsg + ": $symbol";
|
||||||
|
|
||||||
|
|
|
@ -231,9 +231,7 @@ void Variables::clearAliases(nonneg int varid)
|
||||||
|
|
||||||
if (usage) {
|
if (usage) {
|
||||||
// remove usage from all aliases
|
// remove usage from all aliases
|
||||||
std::set<nonneg int>::const_iterator i;
|
for (std::set<nonneg int>::const_iterator i = usage->_aliases.cbegin(); i != usage->_aliases.cend(); ++i) {
|
||||||
|
|
||||||
for (i = usage->_aliases.cbegin(); i != usage->_aliases.cend(); ++i) {
|
|
||||||
VariableUsage *temp = find(*i);
|
VariableUsage *temp = find(*i);
|
||||||
|
|
||||||
if (temp)
|
if (temp)
|
||||||
|
|
|
@ -3214,10 +3214,8 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
|
||||||
path.insert(0, ":: ");
|
path.insert(0, ":: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<Scope>::iterator it1;
|
|
||||||
|
|
||||||
// search for match
|
// search for match
|
||||||
for (it1 = scopeList.begin(); it1 != scopeList.end(); ++it1) {
|
for (std::list<Scope>::iterator it1 = scopeList.begin(); it1 != scopeList.end(); ++it1) {
|
||||||
Scope *scope1 = &(*it1);
|
Scope *scope1 = &(*it1);
|
||||||
|
|
||||||
bool match = false;
|
bool match = false;
|
||||||
|
|
|
@ -1889,8 +1889,7 @@ const ValueFlow::Value * Token::getInvalidValue(const Token *ftok, nonneg int ar
|
||||||
if (!mImpl->mValues || !settings)
|
if (!mImpl->mValues || !settings)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
const ValueFlow::Value *ret = nullptr;
|
const ValueFlow::Value *ret = nullptr;
|
||||||
std::list<ValueFlow::Value>::const_iterator it;
|
for (std::list<ValueFlow::Value>::const_iterator it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
|
||||||
for (it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
|
|
||||||
if (it->isImpossible())
|
if (it->isImpossible())
|
||||||
continue;
|
continue;
|
||||||
if ((it->isIntValue() && !settings->library.isIntArgValid(ftok, argnr, it->intvalue)) ||
|
if ((it->isIntValue() && !settings->library.isIntArgValid(ftok, argnr, it->intvalue)) ||
|
||||||
|
@ -1916,8 +1915,7 @@ const Token *Token::getValueTokenMinStrSize(const Settings *settings, MathLib::b
|
||||||
return nullptr;
|
return nullptr;
|
||||||
const Token *ret = nullptr;
|
const Token *ret = nullptr;
|
||||||
int minsize = INT_MAX;
|
int minsize = INT_MAX;
|
||||||
std::list<ValueFlow::Value>::const_iterator it;
|
for (std::list<ValueFlow::Value>::const_iterator it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
|
||||||
for (it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
|
|
||||||
if (it->isTokValue() && it->tokvalue && it->tokvalue->tokType() == Token::eString) {
|
if (it->isTokValue() && it->tokvalue && it->tokvalue->tokType() == Token::eString) {
|
||||||
const int size = getStrSize(it->tokvalue, settings);
|
const int size = getStrSize(it->tokvalue, settings);
|
||||||
if (!ret || size < minsize) {
|
if (!ret || size < minsize) {
|
||||||
|
@ -1937,8 +1935,7 @@ const Token *Token::getValueTokenMaxStrLength() const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
const Token *ret = nullptr;
|
const Token *ret = nullptr;
|
||||||
int maxlength = 0;
|
int maxlength = 0;
|
||||||
std::list<ValueFlow::Value>::const_iterator it;
|
for (std::list<ValueFlow::Value>::const_iterator it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
|
||||||
for (it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
|
|
||||||
if (it->isTokValue() && it->tokvalue && it->tokvalue->tokType() == Token::eString) {
|
if (it->isTokValue() && it->tokvalue && it->tokvalue->tokType() == Token::eString) {
|
||||||
const int length = getStrLength(it->tokvalue);
|
const int length = getStrLength(it->tokvalue);
|
||||||
if (!ret || length > maxlength) {
|
if (!ret || length > maxlength) {
|
||||||
|
|
Loading…
Reference in New Issue