getExecutableCommand()); $matches = array(); $regex = '/^Cppcheck (?P\d+\.\d+)$/'; if (preg_match($regex, $stdout, $matches)) { return $matches['version']; } else { return false; } } public function getInstallInstructions() { return pht('Install Cppcheck using `apt-get install cppcheck` for Ubuntu'. ' or `brew install cppcheck` for Mac OS X'); } protected function getMandatoryFlags() { return array( '--quiet', '--inline-suppr', '--xml', '--xml-version=2', ); } protected function getDefaultFlags() { return array('-j2', '--enable=performance,style,portability,information', '--library=tools/arc/linting/tintin.cfg,std', '--rule-file=tools/arc/linting/tintin.rule', '--enable=all', '--suppress=passedByValue', '--suppress=selfAssignment', '--suppress=toomanyconfigs', '--suppress=uninitStructMember', '--suppress=unnecessaryForwardDeclaration', '--suppress=unusedFunction', '--suppress=variableScope', '--suppress=unusedStructMember', '--suppress=varFuncNullUB', '--suppress=ConfigurationNotChecked'); } protected function getDefaultMessageSeverity($code) { return ArcanistLintSeverity::SEVERITY_WARNING; } protected function parseLinterOutput($path, $err, $stdout, $stderr) { $dom = new DOMDocument(); $ok = @$dom->loadXML($stderr); if (!$ok) { return false; } $errors = $dom->getElementsByTagName('error'); $messages = array(); foreach ($errors as $error) { foreach ($error->getElementsByTagName('location') as $location) { $message = new ArcanistLintMessage(); $message->setPath($location->getAttribute('file')); $message->setLine($location->getAttribute('line')); $message->setCode($error->getAttribute('id')); $message->setName($error->getAttribute('id')); $message->setDescription($error->getAttribute('msg')); $message->setSeverity($this->getLintMessageSeverity($error->getAttribute('id'))); $messages[] = $message; } } return $messages; } protected function getLintCodeFromLinterConfigurationKey($code) { if (!preg_match('@^[a-z_]+$@', $code)) { throw new Exception( pht( 'Unrecognized severity code "%s". Expected a valid cppcheck '. 'severity code like "%s" or "%s".', $code, 'unreadVariable', 'memleak')); } return $code; } }