Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistCSharpLinter.php
| Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | final class ArcanistCSharpLinter extends ArcanistLinter { | ||||
| } | } | ||||
| public function getLintCodeFromLinterConfigurationKey($code) { | public 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( | ||||
| "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 '.arclint'. ". | ||||
| "Instead configure the severity using the StyleCop settings dialog ". | "Instead configure the severity using the StyleCop settings dialog ". | ||||
| "(usually accessible from within your IDE). StyleCop settings ". | "(usually accessible from within your IDE). StyleCop settings ". | ||||
| "for your project will be used when linting for Arcanist."); | "for your project will be used when linting for Arcanist."); | ||||
| } | } | ||||
| Show All 11 Lines | final class ArcanistCSharpLinter extends ArcanistLinter { | ||||
| */ | */ | ||||
| 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('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('Unable to locate 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 ". | 'You are running an old version of cslint. Please '. | ||||
| "upgrade to version ".self::SUPPORTED_VERSION."."); | 'upgrade to version '.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 ". | 'You are running an old version of cslint. Please '. | ||||
| "upgrade to version ".self::SUPPORTED_VERSION."."); | 'upgrade to version '.self::SUPPORTED_VERSION.'.'); | ||||
| } elseif ($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 ". | 'Arcanist does not support this version of cslint (it is '. | ||||
| "newer). You can try upgrading Arcanist with `arc upgrade`."); | 'newer). You can try upgrading Arcanist with `arc upgrade`.'); | ||||
| } | } | ||||
| $this->loaded = true; | $this->loaded = true; | ||||
| } | } | ||||
| public function lintPath($path) { | public function lintPath($path) { | ||||
| } | } | ||||
| Show All 18 Lines | foreach ($paths as $path) { | ||||
| // under Windows. This is probably because not only | // under Windows. This is probably because not only | ||||
| // does the JSON have quotation marks in the content, | // does the JSON have quotation marks in the content, | ||||
| // but because there'll be a lot of escaping and | // but because there'll be a lot of escaping and | ||||
| // double escaping because the JSON also contains | // double escaping because the JSON also contains | ||||
| // regular expressions. cslint supports passing the | // regular expressions. cslint supports passing the | ||||
| // settings JSON through base64-encoded to mitigate | // settings JSON through base64-encoded to mitigate | ||||
| // this issue. | // this issue. | ||||
| $futures[] = new ExecFuture( | $futures[] = new ExecFuture( | ||||
| "%C --settings-base64=%s -r=. %Ls", | '%C --settings-base64=%s -r=. %Ls', | ||||
| $this->runtimeEngine.$this->cslintEngine, | $this->runtimeEngine.$this->cslintEngine, | ||||
| base64_encode(json_encode($this->discoveryMap)), | base64_encode(json_encode($this->discoveryMap)), | ||||
| $current_paths); | $current_paths); | ||||
| $current_paths = array(); | $current_paths = array(); | ||||
| } | } | ||||
| // Append the path to the current paths array. | // Append the path to the current paths array. | ||||
| $current_paths[] = $this->getEngine()->getFilePathOnDisk($path); | $current_paths[] = $this->getEngine()->getFilePathOnDisk($path); | ||||
| } | } | ||||
| // If we still have paths left in current paths, then we need to create | // If we still have paths left in current paths, then we need to create | ||||
| // a future for those too. | // a future for those too. | ||||
| if (count($current_paths) > 0) { | if (count($current_paths) > 0) { | ||||
| $futures[] = new ExecFuture( | $futures[] = new ExecFuture( | ||||
| "%C --settings-base64=%s -r=. %Ls", | '%C --settings-base64=%s -r=. %Ls', | ||||
| $this->runtimeEngine.$this->cslintEngine, | $this->runtimeEngine.$this->cslintEngine, | ||||
| base64_encode(json_encode($this->discoveryMap)), | base64_encode(json_encode($this->discoveryMap)), | ||||
| $current_paths); | $current_paths); | ||||
| $current_paths = array(); | $current_paths = array(); | ||||
| } | } | ||||
| $this->futures = $futures; | $this->futures = $futures; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines | |||||