本文整理汇总了PHP中ArcanistLintMessage::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP ArcanistLintMessage::setName方法的具体用法?PHP ArcanistLintMessage::setName怎么用?PHP ArcanistLintMessage::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArcanistLintMessage
的用法示例。
在下文中一共展示了ArcanistLintMessage::setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
// Each line looks like this:
// Line 46, E:0110: Line too long (87 characters).
$regex = '/^Line (\\d+), (E:\\d+): (.*)/';
$severity_code = ArcanistLintSeverity::SEVERITY_ERROR;
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$line = trim($line);
$matches = null;
if (!preg_match($regex, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[1]);
$message->setName($matches[2]);
$message->setCode($this->getLinterName());
$message->setDescription($matches[3]);
$message->setSeverity($severity_code);
$messages[] = $message;
}
return $messages;
}
示例2: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match('/^(.*?):(\\d+): (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$severity = ArcanistLintSeverity::SEVERITY_WARNING;
$description = $matches[3];
$error_regexp = '/(^undefined|^duplicate|before assignment$)/';
if (preg_match($error_regexp, $description)) {
$severity = ArcanistLintSeverity::SEVERITY_ERROR;
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
$message->setCode($this->getLinterName());
$message->setName($this->getLinterName());
$message->setDescription($description);
$message->setSeverity($severity);
$messages[] = $message;
}
return $messages;
}
示例3: parseLinterOutput
protected function parseLinterOutput($output)
{
$json = json_decode($output, true);
$files = $json['files'];
$severityMap = array();
$severityMap['refactor'] = 'warning';
$severityMap['convention'] = 'warning';
$severityMap['warning'] = 'warning';
$severityMap['error'] = 'error';
$severityMap['fatal'] = 'error';
$messages = array();
foreach ($files as $file) {
foreach ($file['offenses'] as $offense) {
$message = new ArcanistLintMessage();
$message->setPath($file['path']);
$message->setLine($offense['location']['line']);
$message->setChar($offense['location']['column']);
$message->setCode('RUBY');
$message->setName($offense['cop_name']);
$message->setDescription($offense['message']);
$message->setseverity('error');
$messages[] = $message;
}
}
return $messages;
}
示例4: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = explode("\n", $stderr);
$messages = array();
foreach ($lines as $line) {
$line = trim($line);
$matches = null;
$regex = '/^.+?:(\\d+):\\s*(.*)\\s*\\[(.*)\\] \\[(\\d+)\\]$/';
if (!preg_match($regex, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$severity = $this->getLintMessageSeverity($matches[3]);
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[1]);
$message->setCode($matches[3]);
$message->setName($matches[3]);
$message->setDescription($matches[2]);
$message->setSeverity($severity);
$messages[] = $message;
}
return $messages;
}
示例5: lintPath
public function lintPath($path)
{
$rubyp = $this->getRubyPath();
$f = new ExecFuture("%s -wc", $rubyp);
$f->write($this->getData($path));
list($err, $stdout, $stderr) = $f->resolve();
if ($err === 0) {
return;
}
$lines = explode("\n", $stderr);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match("/(.*?):(\\d+): (.*?)\$/", $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$code = head(explode(',', $matches[3]));
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
$message->setName($this->getLinterName() . " " . $code);
$message->setDescription($matches[3]);
$message->setSeverity($this->getMessageCodeSeverity($code));
$this->addLintMessage($message);
}
}
示例6: lintPath
public function lintPath($path)
{
libxml_use_internal_errors(true);
libxml_clear_errors();
if (simplexml_load_string($this->getData($path))) {
// XML appears to be valid.
return;
}
foreach (libxml_get_errors() as $error) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($error->line);
$message->setChar($error->column ? $error->column : null);
$message->setCode($this->getLintMessageFullCode($error->code));
$message->setName('LibXML Error');
$message->setDescription(trim($error->message));
switch ($error->level) {
case LIBXML_ERR_NONE:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_DISABLED);
break;
case LIBXML_ERR_WARNING:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
break;
case LIBXML_ERR_ERROR:
case LIBXML_ERR_FATAL:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
break;
default:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
break;
}
$this->addLintMessage($message);
}
}
示例7: parseLinterOutput
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('Cppcheck');
$message->setName($error->getAttribute('id'));
$message->setDescription($error->getAttribute('msg'));
switch ($error->getAttribute('severity')) {
case 'error':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
break;
default:
if ($error->getAttribute('inconclusive')) {
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
} else {
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
}
break;
}
$messages[] = $message;
}
}
return $messages;
}
示例8: lintPath
public function lintPath($path)
{
$bin = $this->getLintPath();
$path = $this->rocksdbDir() . '/' . $path;
$f = new ExecFuture("%C {$path}", $bin);
list($err, $stdout, $stderr) = $f->resolve();
if ($err === 2) {
throw new Exception("cpplint failed to run correctly:\n" . $stderr);
}
$lines = explode("\n", $stderr);
$messages = array();
foreach ($lines as $line) {
$line = trim($line);
$matches = null;
$regex = '/^[^:]+:(\\d+):\\s*(.*)\\s*\\[(.*)\\] \\[(\\d+)\\]$/';
if (!preg_match($regex, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[1]);
$message->setCode($matches[3]);
$message->setName($matches[3]);
$message->setDescription($matches[2]);
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
$this->addLintMessage($message);
}
}
示例9: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = phutil_split_lines($stderr, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match('/(.*?):(\\d+): (.*?)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$code = head(explode(',', $matches[3]));
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
$message->setCode($this->getLinterName());
$message->setName(pht('Syntax Error'));
$message->setDescription($matches[3]);
$message->setSeverity($this->getLintMessageSeverity($code));
$messages[] = $message;
}
if ($err && !$messages) {
return false;
}
return $messages;
}
示例10: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = phutil_split_lines($stderr, false);
$messages = array();
foreach ($lines as $line) {
$matches = explode(':', $line, 6);
if (count($matches) === 6) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[3]);
$message->setChar($matches[4]);
$code = "E00";
$message->setCode($code);
$message->setName($this->getLinterName());
$message->setDescription(ucfirst(trim($matches[5])));
$severity = $this->getLintMessageSeverity($code);
$message->setSeverity($severity);
$messages[] = $message;
}
if (count($matches) === 3) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[1]);
$code = "E01";
$message->setCode($code);
$message->setName($this->getLinterName());
$message->setDescription(ucfirst(trim($matches[2])));
$severity = $this->getLintMessageSeverity($code);
$message->setSeverity($severity);
$messages[] = $message;
}
}
return $messages;
}
示例11: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
// stdin:2: W802 undefined name 'foo' # pyflakes
// stdin:3:1: E302 expected 2 blank lines, found 1 # pep8
$regexp = '/^(.*?):(\\d+):(?:(\\d+):)? (\\S+) (.*)$/';
if (!preg_match($regexp, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
if (!empty($matches[3])) {
$message->setChar($matches[3]);
}
$message->setCode($matches[4]);
$message->setName($this->getLinterName() . ' ' . $matches[3]);
$message->setDescription($matches[5]);
$message->setSeverity($this->getLintMessageSeverity($matches[4]));
$messages[] = $message;
}
return $messages;
}
示例12: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$ok = $err == 0;
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match('/^(.*?):(\\d+):((\\d+):)? (\\S+): ((\\s|\\w)+): (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
if ($matches[4] != '') {
$message->setChar($matches[4]);
}
$message->setCode($this->getLinterName());
$message->setName($matches[6]);
$message->setDescription($matches[8]);
$message->setSeverity($this->getLintMessageSeverity($matches[5]));
$messages[] = $message;
}
return $messages;
}
示例13: collectResults
private function collectResults()
{
while ($this->futures) {
$f = array_shift($this->futures);
list($err, $stdout, $stderr) = $f->resolve();
$lines = explode("\n", $stderr);
$messages = array();
foreach ($lines as $line) {
$line = trim($line);
$matches = null;
$regex = '/^([^:]+):(\\d+):\\s*(.*)\\s*\\[(.*)\\] \\[(\\d+)\\]$/';
if (!preg_match($regex, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($matches[1]);
$message->setLine($matches[2]);
$message->setCode($matches[4]);
$message->setName($matches[4]);
$message->setDescription($matches[3]);
$message->setSeverity($matches[5] >= 4 ? ArcanistLintSeverity::SEVERITY_ERROR : ArcanistLintSeverity::SEVERITY_WARNING);
$this->addLintMessage($message);
}
}
}
示例14: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$xml_result = new SimpleXMLElement($stdout);
$messages = array();
foreach ($xml_result->file->issue as $issue) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($this->intValOrNull($issue['line']));
$message->setChar($this->intValOrNull($issue['char']));
$message->setName($issue['reason']);
$message->setDescription("Evidence: " . $issue['evidence']);
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
$message->setCode(ArcanistLintSeverity::SEVERITY_ERROR);
$messages[] = $message;
}
return $messages;
}
示例15: newFromDictionary
public static function newFromDictionary(array $dict)
{
$message = new ArcanistLintMessage();
$message->setPath($dict['path']);
$message->setLine($dict['line']);
$message->setChar($dict['char']);
$message->setCode($dict['code']);
$message->setSeverity($dict['severity']);
$message->setName($dict['name']);
$message->setDescription($dict['description']);
if (isset($dict['original'])) {
$message->setOriginalText($dict['original']);
}
if (isset($dict['replacement'])) {
$message->setReplacementText($dict['replacement']);
}
return $message;
}