MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / checkRedundantNextPrevious

Method checkRedundantNextPrevious

lib/checkinternal.cpp:285–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285void CheckInternalImpl::checkRedundantNextPrevious()
286{
287 const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
288 for (const Scope* scope : symbolDatabase->functionScopes) {
289 for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
290 if (tok->str() != ".")
291 continue;
292 tok = tok->next();
293
294 if (Token::Match(tok, "previous ( ) . previous|next|tokAt|str|strAt|link|linkAt (") || Token::Match(tok, "next ( ) . previous|next|tokAt|str|strAt|link|linkAt (") ||
295 (Token::simpleMatch(tok, "tokAt (") && Token::Match(tok->linkAt(1), ") . previous|next|tokAt|strAt|linkAt|str|link ("))) {
296 const std::string& func1 = tok->str();
297 const std::string& func2 = tok->linkAt(1)->strAt(2);
298
299 if ((func2 == "previous" || func2 == "next" || func2 == "str" || func2 == "link") && tok->linkAt(1)->strAt(4) != ")")
300 continue;
301
302 redundantNextPreviousError(tok, func1, func2);
303 }
304 }
305 }
306}
307
308void CheckInternalImpl::checkExtraWhitespace()
309{

Callers 1

runChecksMethod · 0.80

Calls 4

nextMethod · 0.80
linkAtMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected