Changeset View
Changeset View
Standalone View
Standalone View
src/lint/ArcanistLintSeverity.php
| <?php | <?php | ||||
| /** | /** | ||||
| * Describes the severity of an @{class:ArcanistLintMessage}. | * Describes the severity of an @{class:ArcanistLintMessage}. | ||||
| */ | */ | ||||
| final class ArcanistLintSeverity { | final class ArcanistLintSeverity { | ||||
| const SEVERITY_ADVICE = 'advice'; | const SEVERITY_ADVICE = 'advice'; | ||||
| const SEVERITY_AUTOFIX = 'autofix'; | const SEVERITY_AUTOFIX = 'autofix'; | ||||
| const SEVERITY_WARNING = 'warning'; | const SEVERITY_WARNING = 'warning'; | ||||
| const SEVERITY_ERROR = 'error'; | const SEVERITY_ERROR = 'error'; | ||||
| const SEVERITY_DISABLED = 'disabled'; | const SEVERITY_DISABLED = 'disabled'; | ||||
| public static function getLintSeverities() { | public static function getLintSeverities() { | ||||
| return array( | return array( | ||||
| self::SEVERITY_ADVICE => 'Advice', | self::SEVERITY_ADVICE => pht('Advice'), | ||||
| self::SEVERITY_AUTOFIX => 'Auto-Fix', | self::SEVERITY_AUTOFIX => pht('Auto-Fix'), | ||||
| self::SEVERITY_WARNING => 'Warning', | self::SEVERITY_WARNING => pht('Warning'), | ||||
| self::SEVERITY_ERROR => 'Error', | self::SEVERITY_ERROR => pht('Error'), | ||||
| self::SEVERITY_DISABLED => 'Disabled', | self::SEVERITY_DISABLED => pht('Disabled'), | ||||
| ); | ); | ||||
| } | } | ||||
| public static function getStringForSeverity($severity_code) { | public static function getStringForSeverity($severity_code) { | ||||
| $map = self::getLintSeverities(); | $map = self::getLintSeverities(); | ||||
| if (!array_key_exists($severity_code, $map)) { | if (!array_key_exists($severity_code, $map)) { | ||||
| throw new Exception("Unknown lint severity '{$severity_code}'!"); | throw new Exception(pht("Unknown lint severity '%s'!", $severity_code)); | ||||
| } | } | ||||
| return $map[$severity_code]; | return $map[$severity_code]; | ||||
| } | } | ||||
| public static function isAtLeastAsSevere($message_sev, $level) { | public static function isAtLeastAsSevere($message_sev, $level) { | ||||
| static $map = array( | static $map = array( | ||||
| self::SEVERITY_DISABLED => 10, | self::SEVERITY_DISABLED => 10, | ||||
| Show All 14 Lines | |||||