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

Method checkExtraWhitespace

lib/checkinternal.cpp:308–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void CheckInternalImpl::checkExtraWhitespace()
309{
310 const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
311 for (const Scope* scope : symbolDatabase->functionScopes) {
312 for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
313 if (!Token::Match(tok, "Token :: simpleMatch|findsimplematch|Match|findmatch ("))
314 continue;
315
316 const std::string& funcname = tok->strAt(2);
317
318 // Get pattern string
319 const Token *patternTok = tok->tokAt(4)->nextArgument();
320 if (!patternTok || patternTok->tokType() != Token::eString)
321 continue;
322
323 const std::string pattern = patternTok->strValue();
324 if (!pattern.empty() && (pattern[0] == ' ' || *pattern.crbegin() == ' '))
325 extraWhitespaceError(tok, pattern, funcname);
326
327 // two whitespaces or more
328 if (pattern.find(" ") != std::string::npos)
329 extraWhitespaceError(tok, pattern, funcname);
330 }
331 }
332}
333
334void CheckInternalImpl::simplePatternError(const Token* tok, const std::string& pattern, const std::string &funcname)
335{

Callers 1

runChecksMethod · 0.80

Calls 6

nextMethod · 0.80
nextArgumentMethod · 0.45
tokAtMethod · 0.45
strValueMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected