本文整理汇总了PHP中ArcanistLintMessage类的典型用法代码示例。如果您正苦于以下问题:PHP ArcanistLintMessage类的具体用法?PHP ArcanistLintMessage怎么用?PHP ArcanistLintMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArcanistLintMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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+):(\\d+): (\\S+) (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
$message->setChar($matches[3]);
$message->setCode($matches[4]);
$message->setName('PEP8 ' . $matches[4]);
$message->setDescription($matches[5]);
$message->setSeverity($this->getLintMessageSeverity($matches[4]));
$messages[] = $message;
}
if ($err && !$messages) {
return false;
}
return $messages;
}
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:27,代码来源:ArcanistPEP8Linter.php
示例2: 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
示例3: addLintMessage
public function addLintMessage(ArcanistLintMessage $msg)
{
$original = $msg->getOriginalText();
if (!preg_match("/{$this->holder}/", $original)) {
foreach ($this->valid_holders as $holder) {
if (preg_match("/{$holder}/", $original)) {
// Suppress this one
return;
}
}
}
parent::addLintMessage($msg);
}
开发者ID:colindj,项目名称:libphenom,代码行数:13,代码来源:PhenomLicenseLinter.php
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9: lintPath
public function lintPath($path)
{
$bin = $this->getLintPath();
$options = $this->getLintOptions();
list($rc, $stdout, $stderr) = exec_manual("%C %C --inline-suppr --xml-version=2 -q %s", $bin, $options, $this->getEngine()->getFilePathOnDisk($path));
if ($rc === 1) {
throw new Exception("cppcheck failed to run correctly:\n" . $stderr);
}
$dom = new DOMDocument();
libxml_clear_errors();
if ($dom->loadXML($stderr) === false || libxml_get_errors()) {
throw new ArcanistUsageException('cppcheck Linter failed to load ' . 'output. Something happened when running cppcheck. ' . "Output:\n{$stderr}" . "\nTry running lint with --trace flag to get more details.");
}
$errors = $dom->getElementsByTagName('error');
foreach ($errors as $error) {
$loc_node = $error->getElementsByTagName('location');
if (!$loc_node) {
continue;
}
$location = $loc_node->item(0);
if (!$location) {
continue;
}
$file = $location->getAttribute('file');
$line = $location->getAttribute('line');
$id = $error->getAttribute('id');
$severity = $error->getAttribute('severity');
$msg = $error->getAttribute('msg');
$inconclusive = $error->getAttribute('inconclusive');
$verbose_msg = $error->getAttribute('verbose');
$severity_code = ArcanistLintSeverity::SEVERITY_WARNING;
if ($inconclusive) {
$severity_code = ArcanistLintSeverity::SEVERITY_ADVICE;
} else {
if (stripos($severity, 'error') !== false) {
$severity_code = ArcanistLintSeverity::SEVERITY_ERROR;
}
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($line);
$message->setCode($severity);
$message->setName($id);
$message->setDescription($msg);
$message->setSeverity($severity_code);
$this->addLintMessage($message);
}
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:48,代码来源:ArcanistCppcheckLinter.php
示例10: willLintPaths
public function willLintPaths(array $paths)
{
$program = false;
$ret_value = 0;
$last_line = system("which checkCpp", $ret_value);
if ($ret_value == 0) {
$program = $last_line;
} else {
if (file_exists(self::PROGRAM)) {
$program = self::PROGRAM;
}
}
if ($program) {
$futures = array();
foreach ($paths as $p) {
$futures[$p] = new ExecFuture("%s --lint %s 2>&1", $program, $this->getEngine()->getFilePathOnDisk($p));
}
foreach (Futures($futures)->limit(8) as $p => $f) {
list($stdout, $stderr) = $f->resolvex();
$raw = json_decode($stdout, true);
if (!is_array($raw)) {
throw new Exception("checkCpp returned invalid JSON!" . "Stdout: {$stdout} Stderr: {$stderr}");
}
foreach ($raw as $err) {
$this->addLintMessage(ArcanistLintMessage::newFromDictionary(array('path' => $err['file'], 'line' => $err['line'], 'char' => 0, 'name' => $err['name'], 'description' => $err['info'], 'code' => $this->getLinterName(), 'severity' => ArcanistLintSeverity::SEVERITY_WARNING)));
}
}
}
return;
}
开发者ID:peersafe,项目名称:rippled,代码行数:30,代码来源:PfffCppLinter.php
示例11: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$report_dom = new DOMDocument();
$ok = @$report_dom->loadXML($stdout);
if (!$ok) {
return false;
}
$messages = array();
foreach ($report_dom->getElementsByTagName('file') as $file) {
foreach ($file->getElementsByTagName('error') as $error) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($error->getAttribute('line'));
$message->setChar($error->getAttribute('column'));
$message->setCode('JSCS');
$message->setName('JSCS');
$message->setDescription($error->getAttribute('message'));
switch ($error->getAttribute('severity')) {
case 'error':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
break;
case 'warning':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
break;
default:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
break;
}
$messages[] = $message;
}
}
return $messages;
}
开发者ID:barcelonascience,项目名称:arcanist,代码行数:33,代码来源:ArcanistJscsLinter.php
示例12: 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
示例13: 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
示例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: 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;
}
开发者ID:barcelonascience,项目名称:arcanist,代码行数:29,代码来源:ArcanistPyFlakesLinter.php
示例16: 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
示例17: 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);
}
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:29,代码来源:ArcanistRubyLinter.php
示例18: lintPath
public function lintPath($path)
{
$lint_for_path = idx($this->lintByPath, $path);
if (!$lint_for_path) {
return;
}
foreach ($lint_for_path as $lint) {
$this->addLintMessage(ArcanistLintMessage::newFromDictionary($lint));
}
}
开发者ID:nik-kor,项目名称:arcanist,代码行数:10,代码来源:ArcanistConduitLinter.php
示例19: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$json = phutil_json_decode($stdout);
$messages = array();
foreach ($json as $fix) {
if ($fix === null) {
return;
}
$message = new ArcanistLintMessage();
$message->setCode($this->getLinterName());
$message->setPath($path);
$message->setLine($fix['startLine']);
$message->setChar($fix['startColumn']);
$message->setName($fix['hint']);
$message->setOriginalText($fix['from']);
$message->setReplacementText($fix['to']);
/* Some improvements may slightly change semantics, so attach
all necessary notes too. */
$notes = '';
foreach ($fix['note'] as $note) {
$notes .= ' **NOTE**: ' . trim($note, '"') . '.';
}
$message->setDescription(pht('In module `%s`, declaration `%s`.%s', $fix['module'], $fix['decl'], $notes));
switch ($fix['severity']) {
case 'Error':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
break;
case 'Warning':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
break;
default:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
break;
}
$messages[] = $message;
}
return $messages;
}
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:38,代码来源:ArcanistHLintLinter.php
示例20: lintPath
public function lintPath($path)
{
$flake8_bin = $this->getFlake8Path();
$options = $this->getFlake8Options();
$f = new ExecFuture("%C %C -", $flake8_bin, $options);
$f->write($this->getData($path));
list($err, $stdout, $stderr) = $f->resolve();
if ($err === 2) {
throw new Exception("flake8 failed to run correctly:\n" . $stderr);
}
$lines = explode("\n", $stdout);
$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
if (!preg_match('/^(.*?):(\\d+):(?:(\\d+):)? (\\S+) (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
if (substr($matches[4], 0, 1) == 'E') {
$severity = ArcanistLintSeverity::SEVERITY_ERROR;
} else {
$severity = ArcanistLintSeverity::SEVERITY_WARNING;
}
$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($severity);
$this->addLintMessage($message);
}
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:40,代码来源:ArcanistFlake8Linter.php
注:本文中的ArcanistLintMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论