当前位置: 首页>>代码示例>>PHP>>正文


PHP ArcanistLintMessage::setCode方法代码示例

本文整理汇总了PHP中ArcanistLintMessage::setCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ArcanistLintMessage::setCode方法的具体用法?PHP ArcanistLintMessage::setCode怎么用?PHP ArcanistLintMessage::setCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArcanistLintMessage的用法示例。


在下文中一共展示了ArcanistLintMessage::setCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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->setDescription($description);
         $message->setSeverity($severity);
         $messages[] = $message;
     }
     return $messages;
 }
开发者ID:lewisf,项目名称:arcanist,代码行数:28,代码来源:ArcanistPyFlakesLinter.php

示例2: 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;
 }
开发者ID:kalbasit,项目名称:arcanist-go,代码行数:34,代码来源:ArcanistGoVetLinter.php

示例3: 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;
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:27,代码来源:ArcanistRubyLinter.php

示例4: 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;
 }
开发者ID:mdesanti,项目名称:arcanist-extensions,代码行数:26,代码来源:ArcanistRubocopLinter.php

示例5: 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);
         }
     }
 }
开发者ID:colindj,项目名称:libphenom,代码行数:28,代码来源:PhenomCLinter.php

示例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);
     }
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:34,代码来源:ArcanistXMLLinter.php

示例7: lintPath

 public function lintPath($path)
 {
     $sbt = $this->getSBTPath();
     // Tell SBT to not use color codes so our regex life is easy.
     // TODO: Should this be "clean compile" instead of "compile"?
     $f = new ExecFuture("%s -Dsbt.log.noformat=true compile", $sbt);
     list($err, $stdout, $stderr) = $f->resolve();
     $lines = explode("\n", $stdout);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match("/\\[(warn|error)\\] (.*?):(\\d+): (.*?)\$/", $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $message = new ArcanistLintMessage();
         $message->setPath($matches[2]);
         $message->setLine($matches[3]);
         $message->setCode($this->getLinterName());
         $message->setDescription($matches[4]);
         $message->setSeverity($this->getMessageCodeSeverity($matches[1]));
         $this->addLintMessage($message);
     }
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:26,代码来源:ArcanistScalaSBTLinter.php

示例8: 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;
 }
开发者ID:vhbit,项目名称:swift-linter,代码行数:27,代码来源:SwiftLintLinter.php

示例9: 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;
 }
开发者ID:nickhutchinson,项目名称:morefas-phabricator,代码行数:26,代码来源:FnCpplintLinter.php

示例10: parseLinterOutput

 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $report_dom = new DOMDocument();
     $ok = @$report_dom->loadXML($stdout);
     if (!$ok) {
         return false;
     }
     $files = $report_dom->getElementsByTagName('file');
     $messages = array();
     foreach ($files as $file) {
         foreach ($file->childNodes as $child) {
             if (!$child instanceof DOMElement) {
                 continue;
             }
             $data = $this->getData($path);
             $lines = explode("\n", $data);
             $name = $child->getAttribute('reason');
             $severity = $child->getAttribute('severity') == 'warning' ? ArcanistLintSeverity::SEVERITY_WARNING : ArcanistLintSeverity::SEVERITY_ERROR;
             $message = new ArcanistLintMessage();
             $message->setPath($path);
             $message->setLine($child->getAttribute('line'));
             $message->setChar($child->getAttribute('char'));
             $message->setCode('CSSLint');
             $message->setDescription($child->getAttribute('reason'));
             $message->setSeverity($severity);
             if ($child->hasAttribute('line') && $child->getAttribute('line') > 0) {
                 $line = $lines[$child->getAttribute('line') - 1];
                 $text = substr($line, $child->getAttribute('char') - 1);
                 $message->setOriginalText($text);
             }
             $messages[] = $message;
         }
     }
     return $messages;
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:35,代码来源:ArcanistCSSLintLinter.php

示例11: 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;
 }
开发者ID:barcelonascience,项目名称:arcanist,代码行数:34,代码来源:ArcanistCppcheckLinter.php

示例12: 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);
     }
 }
开发者ID:michaelsuo,项目名称:rocksdb,代码行数:31,代码来源:ArcanistCpplintLinter.php

示例13: 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;
 }
开发者ID:benchling,项目名称:arcanist,代码行数:29,代码来源:ArcanistFlake8Linter.php

示例14: 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;
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:28,代码来源:ArcanistClosureLinter.php

示例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;
 }
开发者ID:nik-kor,项目名称:arcanist,代码行数:18,代码来源:ArcanistLintMessage.php


注:本文中的ArcanistLintMessage::setCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。