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}. | ||||
| * | |||||
| * @group lint | |||||
| */ | */ | ||||
| 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'; | ||||
| Show All 14 Lines | public static function getStringForSeverity($severity_code) { | ||||
| 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("Unknown lint severity '{$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, | ||||
| self::SEVERITY_ADVICE => 20, | self::SEVERITY_ADVICE => 20, | ||||
| self::SEVERITY_AUTOFIX => 25, | self::SEVERITY_AUTOFIX => 25, | ||||
| self::SEVERITY_WARNING => 30, | self::SEVERITY_WARNING => 30, | ||||
| self::SEVERITY_ERROR => 40, | self::SEVERITY_ERROR => 40, | ||||
| ); | ); | ||||
| if (empty($map[$message_sev])) { | if (empty($map[$message_sev])) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return $map[$message_sev] >= idx($map, $level, 0); | return $map[$message_sev] >= idx($map, $level, 0); | ||||
| } | } | ||||
| } | } | ||||