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; } }
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(); $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) { $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; } }