public function renderLintResult(ArcanistLintResult $result)
 {
     $messages = $result->getMessages();
     $path = $result->getPath();
     $lines = explode("\n", $result->getData());
     $text = array();
     foreach ($messages as $message) {
         if (!$this->showAutofixPatches && $message->isAutofix()) {
             continue;
         }
         if ($message->isError()) {
             $color = 'red';
         } else {
             $color = 'yellow';
         }
         $severity = ArcanistLintSeverity::getStringForSeverity($message->getSeverity());
         $code = $message->getCode();
         $name = $message->getName();
         $description = phutil_console_wrap($message->getDescription(), 4);
         $text[] = phutil_console_format("  **<bg:{$color}> %s </bg>** (%s) __%s__\n%s\n", $severity, $code, $name, $description);
         if ($message->hasFileContext()) {
             $text[] = $this->renderContext($message, $lines);
         }
     }
     if ($text) {
         $prefix = phutil_console_format("**>>>** Lint for __%s__:\n\n\n", $path);
         return $prefix . implode("\n", $text);
     } else {
         return null;
     }
 }
예제 #2
0
 public function renderLintResult(ArcanistLintResult $result)
 {
     $messages = $result->getMessages();
     $path = $result->getPath();
     $data = explode("\n", $result->getData());
     array_unshift($data, '');
     // make the line numbers work as array indices
     $output = array($path => array());
     foreach ($messages as $message) {
         $output[$path][] = array('code' => $message->getCode(), 'name' => $message->getName(), 'severity' => $message->getSeverity(), 'line' => $message->getLine(), 'char' => $message->getChar(), 'context' => implode("\n", array_slice($data, $message->getLine() - self::LINES_OF_CONTEXT, self::LINES_OF_CONTEXT * 2 + 1)), 'description' => $message->getDescription());
     }
     return json_encode($output) . "\n";
 }
 public function renderLintResult(ArcanistLintResult $result)
 {
     $messages = $result->getMessages();
     $path = $result->getPath();
     $text = array();
     foreach ($messages as $message) {
         $name = $message->getName();
         $severity = ArcanistLintSeverity::getStringForSeverity($message->getSeverity());
         $line = $message->getLine();
         $text[] = "{$path}:{$line}:{$severity}: {$name}\n";
     }
     return implode('', $text);
 }
 public function renderLintResult(ArcanistLintResult $result)
 {
     $lines = array();
     $messages = $result->getMessages();
     $path = $result->getPath();
     foreach ($messages as $message) {
         $severity = ArcanistLintSeverity::getStringForSeverity($message->getSeverity());
         $line = $message->getLine();
         $code = $message->getCode();
         $description = $message->getDescription();
         $lines[] = sprintf("%s:%d:%s (%s) %s\n", $path, $line, $severity, $code, $description);
     }
     return implode('', $lines);
 }
 public function renderLintResult(ArcanistLintResult $result)
 {
     $messages = $result->getMessages();
     $path = $result->getPath();
     $data = explode("\n", $result->getData());
     array_unshift($data, '');
     // make the line numbers work as array indices
     $output = array($path => array());
     foreach ($messages as $message) {
         $dictionary = $message->toDictionary();
         $dictionary['context'] = implode("\n", array_slice($data, max(1, $message->getLine() - self::LINES_OF_CONTEXT), self::LINES_OF_CONTEXT * 2 + 1));
         unset($dictionary['path']);
         $output[$path][] = $dictionary;
     }
     return json_encode($output) . "\n";
 }
 public function renderLintResult(ArcanistLintResult $result)
 {
     $this->writer->startElement('file');
     $this->writer->writeAttribute('name', $result->getPath());
     foreach ($result->getMessages() as $message) {
         $this->writer->startElement('error');
         $this->writer->writeAttribute('line', $message->getLine());
         $this->writer->writeAttribute('column', $message->getChar());
         $this->writer->writeAttribute('severity', $this->getStringForSeverity($message->getSeverity()));
         $this->writer->writeAttribute('message', $message->getDescription());
         $this->writer->writeAttribute('source', $message->getCode());
         $this->writer->endElement();
     }
     $this->writer->endElement();
     return $this->writer->flush();
 }
 public function renderLintResult(ArcanistLintResult $result)
 {
     $messages = $result->getMessages();
     $path = $result->getPath();
     $lines = explode("\n", $result->getData());
     $text = array();
     foreach ($messages as $message) {
         if (!$this->showAutofixPatches && $message->isAutofix()) {
             continue;
         }
         if ($message->isError()) {
             $color = 'red';
         } else {
             $color = 'yellow';
         }
         $severity = ArcanistLintSeverity::getStringForSeverity($message->getSeverity());
         $code = $message->getCode();
         $name = $message->getName();
         $description = $message->getDescription();
         if ($message->getOtherLocations()) {
             $locations = array();
             foreach ($message->getOtherLocations() as $location) {
                 $locations[] = idx($location, 'path', $path) . (!empty($location['line']) ? ":{$location['line']}" : '');
             }
             $description .= "\n" . pht('Other locations: %s', implode(', ', $locations));
         }
         $text[] = phutil_console_format("  **<bg:{$color}> %s </bg>** (%s) __%s__\n%s\n", $severity, $code, $name, phutil_console_wrap($description, 4));
         if ($message->hasFileContext()) {
             $text[] = $this->renderContext($message, $lines);
         }
     }
     if ($text) {
         $prefix = phutil_console_format("**>>>** %s\n\n\n", pht('Lint for %s:', phutil_console_format('__%s__', $path)));
         return $prefix . implode("\n", $text);
     } else {
         return null;
     }
 }