private function renderSeverity($severity) { $names = ArcanistLintSeverity::getLintSeverities(); $name = idx($names, $severity, $severity); // TODO: Add some color here? return $name; }
public function getArguments() { return array('lintall' => array('help' => pht('Show all lint warnings, not just those on changed lines. When ' . 'paths are specified, this is the default behavior.'), 'conflicts' => array('only-changed' => true)), 'only-changed' => array('help' => pht('Show lint warnings just on changed lines. When no paths are ' . 'specified, this is the default. This differs from only-new ' . 'in cases where line modifications introduce lint on other ' . 'unmodified lines.'), 'conflicts' => array('lintall' => true)), 'rev' => array('param' => 'revision', 'help' => pht('Lint changes since a specific revision.'), 'supports' => array('git', 'hg'), 'nosupport' => array('svn' => pht('Lint does not currently support %s in SVN.', '--rev'))), 'output' => array('param' => 'format', 'help' => pht("With 'summary', show lint warnings in a more compact format. " . "With 'json', show lint warnings in machine-readable JSON format. " . "With 'none', show no lint warnings. " . "With 'compiler', show lint warnings in suitable for your editor. " . "With 'xml', show lint warnings in the Checkstyle XML format.")), 'outfile' => array('param' => 'path', 'help' => pht('Output the linter results to a file. Defaults to stdout.')), 'only-new' => array('param' => 'bool', 'supports' => array('git', 'hg'), 'help' => pht('Display only messages not present in the original code.')), 'engine' => array('param' => 'classname', 'help' => pht('Override configured lint engine for this project.')), 'apply-patches' => array('help' => pht('Apply patches suggested by lint to the working copy without ' . 'prompting.'), 'conflicts' => array('never-apply-patches' => true)), 'never-apply-patches' => array('help' => pht('Never apply patches suggested by lint.'), 'conflicts' => array('apply-patches' => true)), 'amend-all' => array('help' => pht('When linting git repositories, amend HEAD with all patches ' . 'suggested by lint without prompting.')), 'amend-autofixes' => array('help' => pht('When linting git repositories, amend HEAD with autofix ' . 'patches suggested by lint without prompting.')), 'everything' => array('help' => pht('Lint all files in the project.'), 'conflicts' => array('cache' => pht('%s lints all files', '--everything'), 'rev' => pht('%s lints all files', '--everything'))), 'severity' => array('param' => 'string', 'help' => pht("Set minimum message severity. One of: %s. Defaults to '%s'.", sprintf("'%s'", implode("', '", array_keys(ArcanistLintSeverity::getLintSeverities()))), self::DEFAULT_SEVERITY)), 'cache' => array('param' => 'bool', 'help' => pht("%d to disable cache, %d to enable. The default value is determined " . "by '%s' in configuration, which defaults to off. See notes in '%s'.", 0, 1, 'arc.lint.cache', 'arc.lint.cache')), '*' => 'paths'); }
public function getMethodDescription() { $messages = HarbormasterMessageType::getAllMessages(); $head_type = pht('Constant'); $head_desc = pht('Description'); $head_key = pht('Key'); $head_type = pht('Type'); $head_name = pht('Name'); $rows = array(); $rows[] = "| {$head_type} | {$head_desc} |"; $rows[] = '|--------------|--------------|'; foreach ($messages as $message) { $description = HarbormasterMessageType::getMessageDescription($message); $rows[] = "| `{$message}` | {$description} |"; } $message_table = implode("\n", $rows); $rows = array(); $rows[] = "| {$head_key} | {$head_type} | {$head_desc} |"; $rows[] = '|-------------|--------------|--------------|'; $unit_spec = HarbormasterBuildUnitMessage::getParameterSpec(); foreach ($unit_spec as $key => $parameter) { $type = idx($parameter, 'type'); $type = str_replace('|', ' ' . pht('or') . ' ', $type); $description = idx($parameter, 'description'); $rows[] = "| `{$key}` | //{$type}// | {$description} |"; } $unit_table = implode("\n", $rows); $rows = array(); $rows[] = "| {$head_key} | {$head_name} | {$head_desc} |"; $rows[] = '|-------------|--------------|--------------|'; $results = ArcanistUnitTestResult::getAllResultCodes(); foreach ($results as $result_code) { $name = ArcanistUnitTestResult::getResultCodeName($result_code); $description = ArcanistUnitTestResult::getResultCodeDescription($result_code); $rows[] = "| `{$result_code}` | **{$name}** | {$description} |"; } $result_table = implode("\n", $rows); $rows = array(); $rows[] = "| {$head_key} | {$head_type} | {$head_desc} |"; $rows[] = '|-------------|--------------|--------------|'; $lint_spec = HarbormasterBuildLintMessage::getParameterSpec(); foreach ($lint_spec as $key => $parameter) { $type = idx($parameter, 'type'); $type = str_replace('|', ' ' . pht('or') . ' ', $type); $description = idx($parameter, 'description'); $rows[] = "| `{$key}` | //{$type}// | {$description} |"; } $lint_table = implode("\n", $rows); $rows = array(); $rows[] = "| {$head_key} | {$head_name} |"; $rows[] = '|-------------|--------------|'; $severities = ArcanistLintSeverity::getLintSeverities(); foreach ($severities as $key => $name) { $rows[] = "| `{$key}` | **{$name}** |"; } $severity_table = implode("\n", $rows); $valid_unit = array(array('name' => 'PassingTest', 'result' => ArcanistUnitTestResult::RESULT_PASS), array('name' => 'FailingTest', 'result' => ArcanistUnitTestResult::RESULT_FAIL)); $valid_lint = array(array('name' => pht('Syntax Error'), 'code' => 'EXAMPLE1', 'severity' => ArcanistLintSeverity::SEVERITY_ERROR, 'path' => 'path/to/example.c', 'line' => 17, 'char' => 3), array('name' => pht('Not A Haiku'), 'code' => 'EXAMPLE2', 'severity' => ArcanistLintSeverity::SEVERITY_ERROR, 'path' => 'path/to/source.cpp', 'line' => 23, 'char' => 1, 'description' => pht('This function definition is not a haiku.'))); $json = new PhutilJSON(); $valid_unit = $json->encodeAsList($valid_unit); $valid_lint = $json->encodeAsList($valid_lint); return pht("Send a message about the status of a build target to Harbormaster, " . "notifying the application of build results in an external system." . "\n\n" . "Sending Messages\n" . "================\n" . "If you run external builds, you can use this method to publish build " . "results back into Harbormaster after the external system finishes work " . "or as it makes progress." . "\n\n" . "The simplest way to use this method is to call it once after the " . "build finishes with a `pass` or `fail` message. This will record the " . "build result, and continue the next step in the build if the build was " . "waiting for a result." . "\n\n" . "When you send a status message about a build target, you can " . "optionally include detailed `lint` or `unit` results alongside the " . "message. See below for details." . "\n\n" . "If you want to report intermediate results but a build hasn't " . "completed yet, you can use the `work` message. This message doesn't " . "have any direct effects, but allows you to send additional data to " . "update the progress of the build target. The target will continue " . "waiting for a completion message, but the UI will update to show the " . "progress which has been made." . "\n\n" . "Message Types\n" . "=============\n" . "When you send Harbormaster a message, you must include a `type`, " . "which describes the overall state of the build. For example, use " . "`pass` to tell Harbomaster that a build completed successfully." . "\n\n" . "Supported message types are:" . "\n\n" . "%s" . "\n\n" . "Unit Results\n" . "============\n" . "You can report test results alongside a message. The simplest way to " . "do this is to report all the results alongside a `pass` or `fail` " . "message, but you can also send a `work` message to report intermediate " . "results.\n\n" . "To provide unit test results, pass a list of results in the `unit` " . "parameter. Each result shoud be a dictionary with these keys:" . "\n\n" . "%s" . "\n\n" . "The `result` parameter recognizes these test results:" . "\n\n" . "%s" . "\n\n" . "This is a simple, valid value for the `unit` parameter. It reports " . "one passing test and one failing test:\n\n" . "\n\n" . "```lang=json\n" . "%s" . "```" . "\n\n" . "Lint Results\n" . "============\n" . "Like unit test results, you can report lint results alongside a " . "message. The `lint` parameter should contain results as a list of " . "dictionaries with these keys:" . "\n\n" . "%s" . "\n\n" . "The `severity` parameter recognizes these severity levels:" . "\n\n" . "%s" . "\n\n" . "This is a simple, valid value for the `lint` parameter. It reports one " . "error and one warning:" . "\n\n" . "```lang=json\n" . "%s" . "```" . "\n\n", $message_table, $unit_table, $result_table, $valid_unit, $lint_table, $severity_table, $valid_lint); }
public function getArguments() { return array('lintall' => array('help' => "Show all lint warnings, not just those on changed lines."), 'rev' => array('param' => 'revision', 'help' => "Lint changes since a specific revision.", 'supports' => array('git', 'hg'), 'nosupport' => array('svn' => "Lint does not currently support --rev in SVN.")), 'output' => array('param' => 'format', 'help' => "With 'summary', show lint warnings in a more compact format. " . "With 'json', show lint warnings in machine-readable JSON format. " . "With 'none', show no lint warnings. " . "With 'compiler', show lint warnings in suitable for your editor."), 'only-new' => array('param' => 'bool', 'supports' => array('git', 'hg'), 'help' => 'Display only messages not present in the original code.'), 'engine' => array('param' => 'classname', 'help' => "Override configured lint engine for this project."), 'apply-patches' => array('help' => 'Apply patches suggested by lint to the working copy without ' . 'prompting.', 'conflicts' => array('never-apply-patches' => true)), 'never-apply-patches' => array('help' => 'Never apply patches suggested by lint.', 'conflicts' => array('apply-patches' => true)), 'amend-all' => array('help' => 'When linting git repositories, amend HEAD with all patches ' . 'suggested by lint without prompting.'), 'amend-autofixes' => array('help' => 'When linting git repositories, amend HEAD with autofix ' . 'patches suggested by lint without prompting.'), 'severity' => array('param' => 'string', 'help' => "Set minimum message severity. One of: '" . implode("', '", array_keys(ArcanistLintSeverity::getLintSeverities())) . "'. Defaults to '" . self::DEFAULT_SEVERITY . "'."), 'cache' => array('param' => 'bool', 'help' => "0 to disable cache, 1 to enable (default)."), '*' => 'paths'); }