| 306 | } |
| 307 | |
| 308 | void 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 | |
| 334 | void CheckInternalImpl::simplePatternError(const Token* tok, const std::string& pattern, const std::string &funcname) |
| 335 | { |