コード例 #1
0
ファイル: ArcanistLinter.php プロジェクト: milindc2031/Test
 public function setLinterConfigurationValue($key, $value)
 {
     $sev_map = array('error' => ArcanistLintSeverity::SEVERITY_ERROR, 'warning' => ArcanistLintSeverity::SEVERITY_WARNING, 'autofix' => ArcanistLintSeverity::SEVERITY_AUTOFIX, 'advice' => ArcanistLintSeverity::SEVERITY_ADVICE, 'disabled' => ArcanistLintSeverity::SEVERITY_DISABLED);
     switch ($key) {
         case 'severity':
             if (!$this->canCustomizeLintSeverities()) {
                 break;
             }
             $custom = array();
             foreach ($value as $code => $severity) {
                 if (empty($sev_map[$severity])) {
                     $valid = implode(', ', array_keys($sev_map));
                     throw new Exception(pht('Unknown lint severity "%s". Valid severities are: %s.', $severity, $valid));
                 }
                 $code = $this->getLintCodeFromLinterConfigurationKey($code);
                 $custom[$code] = $severity;
             }
             $this->setCustomSeverityMap($custom);
             return;
         case 'severity.rules':
             if (!$this->canCustomizeLintSeverities()) {
                 break;
             }
             foreach ($value as $rule => $severity) {
                 if (@preg_match($rule, '') === false) {
                     throw new Exception(pht('Severity rule "%s" is not a valid regular expression.', $rule));
                 }
                 if (empty($sev_map[$severity])) {
                     $valid = implode(', ', array_keys($sev_map));
                     throw new Exception(pht('Unknown lint severity "%s". Valid severities are: %s.', $severity, $valid));
                 }
             }
             $this->setCustomSeverityRules($value);
             return;
         case 'standard':
             $standards = (array) $value;
             foreach ($standards as $standard) {
                 $standard = ArcanistLinterStandard::getStandard($value, $this);
                 foreach ($standard->getLinterConfiguration() as $k => $v) {
                     $this->setLinterConfigurationValue($k, $v);
                 }
                 $this->addCustomSeverityMap($standard->getLinterSeverityMap());
             }
             return;
     }
     throw new Exception(pht('Incomplete implementation: %s!', $key));
 }
コード例 #2
0
 public function testLoadAllStandards()
 {
     ArcanistLinterStandard::loadAllStandards();
     $this->assertTrue(true);
 }