Refactoring: Use range for loops

This commit is contained in:
Daniel Marjamäki 2018-07-15 14:51:33 +02:00
parent 1c4fb47582
commit 518dd8bfa3
1 changed files with 4 additions and 8 deletions

View File

@ -269,8 +269,7 @@ std::string Suppressions::Suppression::getText() const
bool Suppressions::isSuppressed(const Suppressions::ErrorMessage &errmsg) bool Suppressions::isSuppressed(const Suppressions::ErrorMessage &errmsg)
{ {
const bool unmatchedSuppression(errmsg.errorId == "unmatchedSuppression"); const bool unmatchedSuppression(errmsg.errorId == "unmatchedSuppression");
for (std::list<Suppression>::iterator it = mSuppressions.begin(); it != mSuppressions.end(); ++it) { for (Suppression &s : mSuppressions) {
Suppression &s = *it;
if (unmatchedSuppression && s.errorId != errmsg.errorId) if (unmatchedSuppression && s.errorId != errmsg.errorId)
continue; continue;
if (s.isMatch(errmsg)) if (s.isMatch(errmsg))
@ -282,8 +281,7 @@ bool Suppressions::isSuppressed(const Suppressions::ErrorMessage &errmsg)
bool Suppressions::isSuppressedLocal(const Suppressions::ErrorMessage &errmsg) bool Suppressions::isSuppressedLocal(const Suppressions::ErrorMessage &errmsg)
{ {
const bool unmatchedSuppression(errmsg.errorId == "unmatchedSuppression"); const bool unmatchedSuppression(errmsg.errorId == "unmatchedSuppression");
for (std::list<Suppression>::iterator it = mSuppressions.begin(); it != mSuppressions.end(); ++it) { for (Suppression &s : mSuppressions) {
Suppression &s = *it;
if (!s.isLocal()) if (!s.isLocal())
continue; continue;
if (unmatchedSuppression && s.errorId != errmsg.errorId) if (unmatchedSuppression && s.errorId != errmsg.errorId)
@ -316,8 +314,7 @@ void Suppressions::dump(std::ostream & out)
std::list<Suppressions::Suppression> Suppressions::getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const std::list<Suppressions::Suppression> Suppressions::getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const
{ {
std::list<Suppression> result; std::list<Suppression> result;
for (std::list<Suppression>::const_iterator it = mSuppressions.begin(); it != mSuppressions.end(); ++it) { for (const Suppression &s : mSuppressions) {
const Suppression &s = *it;
if (s.matched) if (s.matched)
continue; continue;
if (!unusedFunctionChecking && s.errorId == "unusedFunction") if (!unusedFunctionChecking && s.errorId == "unusedFunction")
@ -332,8 +329,7 @@ std::list<Suppressions::Suppression> Suppressions::getUnmatchedLocalSuppressions
std::list<Suppressions::Suppression> Suppressions::getUnmatchedGlobalSuppressions(const bool unusedFunctionChecking) const std::list<Suppressions::Suppression> Suppressions::getUnmatchedGlobalSuppressions(const bool unusedFunctionChecking) const
{ {
std::list<Suppression> result; std::list<Suppression> result;
for (std::list<Suppression>::const_iterator it = mSuppressions.begin(); it != mSuppressions.end(); ++it) { for (const Suppression &s : mSuppressions) {
const Suppression &s = *it;
if (s.matched) if (s.matched)
continue; continue;
if (!unusedFunctionChecking && s.errorId == "unusedFunction") if (!unusedFunctionChecking && s.errorId == "unusedFunction")