Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistCSharpLinter.php
| Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | final class ArcanistCSharpLinter extends ArcanistLinter { | ||||
| } | } | ||||
| 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."); | ||||
| } | } | ||||
| } | } | ||||
| 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; | ||||
| Show All 20 Lines | private function loadEnvironment() { | ||||
| // 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.'.'); | ||||
| } 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 '. | '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) {} | ||||
| public function willLintPaths(array $paths) { | public function willLintPaths(array $paths) { | ||||
| Show All 9 Lines | foreach ($paths as $path) { | ||||
| // is greater than 6000 characters (less than the Windows | // is greater than 6000 characters (less than the Windows | ||||
| // command line limit), then finalize this future and add it. | // command line limit), then finalize this future and add it. | ||||
| $total = 0; | $total = 0; | ||||
| foreach ($current_paths as $current_path) { | foreach ($current_paths as $current_path) { | ||||
| $total += strlen($current_path) + 3; // Quotes and space. | $total += strlen($current_path) + 3; // Quotes and space. | ||||
| } | } | ||||
| if ($total + strlen($path) > 6000) { | if ($total + strlen($path) > 6000) { | ||||
| // %s won't pass through the JSON correctly | // %s won't pass through the JSON correctly | ||||
| // 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(); | ||||
| ▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines | |||||