Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistCSharpLinter.php
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | final class ArcanistCSharpLinter extends ArcanistLinter { | ||||
| protected function getLintCodeFromLinterConfigurationKey($code) { | protected function getLintCodeFromLinterConfigurationKey($code) { | ||||
| return $code; | return $code; | ||||
| } | } | ||||
| public function setCustomSeverityMap(array $map) { | public function setCustomSeverityMap(array $map) { | ||||
| foreach ($map as $code => $severity) { | foreach ($map as $code => $severity) { | ||||
| if (substr($code, 0, 2) === 'SA' && $severity == 'disabled') { | if (substr($code, 0, 2) === 'SA' && $severity == 'disabled') { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | |||||
| "In order to keep StyleCop integration with IDEs and other tools ". | "In order to keep StyleCop integration with IDEs and other tools ". | ||||
| "consistent with Arcanist results, you aren't permitted to ". | "consistent with Arcanist results, you aren't permitted to ". | ||||
| "disable StyleCop rules within '.arclint'. ". | "disable StyleCop rules within '%s'. Instead configure the ". | ||||
| "Instead configure the severity using the StyleCop settings dialog ". | "severity using the StyleCop settings dialog (usually accessible ". | ||||
| "(usually accessible from within your IDE). StyleCop settings ". | "from within your IDE). StyleCop settings for your project will ". | ||||
| "for your project will be used when linting for Arcanist."); | "be used when linting for Arcanist.", | ||||
| '.arclint')); | |||||
| } | } | ||||
| } | } | ||||
| return parent::setCustomSeverityMap($map); | return parent::setCustomSeverityMap($map); | ||||
| } | } | ||||
| /** | /** | ||||
| * Determines what executables and lint paths to use. Between platforms | * Determines what executables and lint paths to use. Between platforms | ||||
| * this also changes whether the lint engine is run under .NET or Mono. It | * this also changes whether the lint engine is run under .NET or Mono. It | ||||
| * also ensures that all of the required binaries are available for the lint | * also ensures that all of the required binaries are available for the lint | ||||
| * to run successfully. | * to run successfully. | ||||
| * | * | ||||
| * @return void | * @return void | ||||
| */ | */ | ||||
| private function loadEnvironment() { | private function loadEnvironment() { | ||||
| if ($this->loaded) { | if ($this->loaded) { | ||||
| return; | return; | ||||
| } | } | ||||
| // Determine runtime engine (.NET or Mono). | // Determine runtime engine (.NET or Mono). | ||||
| if (phutil_is_windows()) { | if (phutil_is_windows()) { | ||||
| $this->runtimeEngine = ''; | $this->runtimeEngine = ''; | ||||
| } else if (Filesystem::binaryExists('mono')) { | } else if (Filesystem::binaryExists('mono')) { | ||||
| $this->runtimeEngine = 'mono '; | $this->runtimeEngine = 'mono '; | ||||
| } else { | } else { | ||||
| throw new Exception('Unable to find Mono and you are not on Windows!'); | throw new Exception( | ||||
| pht('Unable to find Mono and you are not on Windows!')); | |||||
| } | } | ||||
| // Determine cslint path. | // Determine cslint path. | ||||
| $cslint = $this->cslintHintPath; | $cslint = $this->cslintHintPath; | ||||
| if ($cslint !== null && file_exists($cslint)) { | if ($cslint !== null && file_exists($cslint)) { | ||||
| $this->cslintEngine = Filesystem::resolvePath($cslint); | $this->cslintEngine = Filesystem::resolvePath($cslint); | ||||
| } else if (Filesystem::binaryExists('cslint.exe')) { | } else if (Filesystem::binaryExists('cslint.exe')) { | ||||
| $this->cslintEngine = 'cslint.exe'; | $this->cslintEngine = 'cslint.exe'; | ||||
| } else { | } else { | ||||
| throw new Exception('Unable to locate cslint.'); | throw new Exception(pht('Unable to locate %s.', 'cslint')); | ||||
| } | } | ||||
| // Determine cslint version. | // Determine cslint version. | ||||
| $ver_future = new ExecFuture( | $ver_future = new ExecFuture( | ||||
| '%C -v', | '%C -v', | ||||
| $this->runtimeEngine.$this->cslintEngine); | $this->runtimeEngine.$this->cslintEngine); | ||||
| list($err, $stdout, $stderr) = $ver_future->resolve(); | list($err, $stdout, $stderr) = $ver_future->resolve(); | ||||
| if ($err !== 0) { | if ($err !== 0) { | ||||
| throw new Exception( | throw new Exception( | ||||
| 'You are running an old version of cslint. Please '. | pht( | ||||
| 'upgrade to version '.self::SUPPORTED_VERSION.'.'); | 'You are running an old version of %s. Please '. | ||||
| 'upgrade to version %s.', | |||||
| 'cslint', | |||||
| self::SUPPORTED_VERSION)); | |||||
| } | } | ||||
| $ver = (int)$stdout; | $ver = (int)$stdout; | ||||
| if ($ver < self::SUPPORTED_VERSION) { | if ($ver < self::SUPPORTED_VERSION) { | ||||
| throw new Exception( | throw new Exception( | ||||
| 'You are running an old version of cslint. Please '. | pht( | ||||
| 'upgrade to version '.self::SUPPORTED_VERSION.'.'); | 'You are running an old version of %s. Please '. | ||||
| 'upgrade to version %s.', | |||||
| 'cslint', | |||||
| self::SUPPORTED_VERSION)); | |||||
| } else if ($ver > self::SUPPORTED_VERSION) { | } else if ($ver > self::SUPPORTED_VERSION) { | ||||
| throw new Exception( | throw new Exception( | ||||
| 'Arcanist does not support this version of cslint (it is '. | pht( | ||||
| 'newer). You can try upgrading Arcanist with `arc upgrade`.'); | 'Arcanist does not support this version of %s (it is newer). '. | ||||
| 'You can try upgrading Arcanist with `%s`.', | |||||
| 'cslint', | |||||
| 'arc upgrade')); | |||||
| } | } | ||||
| $this->loaded = true; | $this->loaded = true; | ||||
| } | } | ||||
| public function lintPath($path) {} | public function lintPath($path) {} | ||||
| public function willLintPaths(array $paths) { | public function willLintPaths(array $paths) { | ||||
| ▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines | |||||