mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Remove support for passing data via STDIN
Summary: Ref T7674. Remove support for passing data to linters via `STDIN`. This functionality exists primarily for pre-receive workflows (which don't have a working copy to act on), but these workflows are going away soon. Test Plan: `arc unit` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7674 Differential Revision: https://secure.phabricator.com/D12696
This commit is contained in:
parent
0a711315f8
commit
4330b27c07
12 changed files with 5 additions and 117 deletions
|
@ -144,8 +144,8 @@ abstract class ArcanistLintEngine {
|
||||||
$this->fileData[$path] = $this->getHookAPI()
|
$this->fileData[$path] = $this->getHookAPI()
|
||||||
->getCurrentFileData($path);
|
->getCurrentFileData($path);
|
||||||
} else {
|
} else {
|
||||||
$disk_path = $this->getFilePathOnDisk($path);
|
$disk_path = $this->getFilePathOnDisk($path);
|
||||||
$this->fileData[$path] = Filesystem::readFile($disk_path);
|
$this->fileData[$path] = Filesystem::readFile($disk_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->fileData[$path];
|
return $this->fileData[$path];
|
||||||
|
|
|
@ -37,10 +37,6 @@ final class ArcanistClosureLinter extends ArcanistExternalLinter {
|
||||||
'files/closure_linter-latest.tar.gz');
|
'files/closure_linter-latest.tar.gz');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
||||||
$lines = phutil_split_lines($stdout, false);
|
$lines = phutil_split_lines($stdout, false);
|
||||||
$messages = array();
|
$messages = array();
|
||||||
|
|
|
@ -47,14 +47,6 @@ final class ArcanistCoffeeLintLinter extends ArcanistExternalLinter {
|
||||||
'npm install -g coffeelint');
|
'npm install -g coffeelint');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getReadDataFromStdinFilename() {
|
|
||||||
return '--stdin';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getMandatoryFlags() {
|
protected function getMandatoryFlags() {
|
||||||
$options = array(
|
$options = array(
|
||||||
'--reporter=raw',
|
'--reporter=raw',
|
||||||
|
|
|
@ -29,14 +29,6 @@ final class ArcanistCpplintLinter extends ArcanistExternalLinter {
|
||||||
'googlecode.com/svn/trunk/cpplint/cpplint.py`.');
|
'googlecode.com/svn/trunk/cpplint/cpplint.py`.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getReadDataFromStdinFilename() {
|
|
||||||
return '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDefaultFlags() {
|
protected function getDefaultFlags() {
|
||||||
return $this->getDeprecatedConfiguration('lint.cpplint.options', array());
|
return $this->getDeprecatedConfiguration('lint.cpplint.options', array());
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,50 +59,6 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true to indicate that the external linter can read input from
|
|
||||||
* stdin, rather than requiring a file. If this mode is supported, it is
|
|
||||||
* slightly more flexible and may perform better, and is thus preferable.
|
|
||||||
*
|
|
||||||
* To send data over stdin instead of via a command line parameter, override
|
|
||||||
* this method and return true. If the linter also needs a command line
|
|
||||||
* flag (like `--stdin` or `-`), override
|
|
||||||
* @{method:getReadDataFromStdinFilename} to provide it.
|
|
||||||
*
|
|
||||||
* For example, linters are normally invoked something like this:
|
|
||||||
*
|
|
||||||
* $ linter file.js
|
|
||||||
*
|
|
||||||
* If you override this method, invocation will be more similar to this:
|
|
||||||
*
|
|
||||||
* $ linter < file.js
|
|
||||||
*
|
|
||||||
* If you additionally override @{method:getReadDataFromStdinFilename} to
|
|
||||||
* return `"-"`, invocation will be similar to this:
|
|
||||||
*
|
|
||||||
* $ linter - < file.js
|
|
||||||
*
|
|
||||||
* @return bool True to send data over stdin.
|
|
||||||
* @task bin
|
|
||||||
*/
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the linter can read data over stdin, override
|
|
||||||
* @{method:supportsReadDataFromStdin} and then optionally override this
|
|
||||||
* method to provide any required arguments (like `-` or `--stdin`). See
|
|
||||||
* that method for discussion.
|
|
||||||
*
|
|
||||||
* @return string|null Additional arguments required by the linter when
|
|
||||||
* operating in stdin mode.
|
|
||||||
* @task bin
|
|
||||||
*/
|
|
||||||
public function getReadDataFromStdinFilename() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide mandatory, non-overridable flags to the linter. Generally these
|
* Provide mandatory, non-overridable flags to the linter. Generally these
|
||||||
* are format flags, like `--format=xml`, which must always be given for
|
* are format flags, like `--format=xml`, which must always be given for
|
||||||
|
@ -373,18 +329,9 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
|
||||||
|
|
||||||
$futures = array();
|
$futures = array();
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
if ($this->supportsReadDataFromStdin()) {
|
$disk_path = $this->getEngine()->getFilePathOnDisk($path);
|
||||||
$future = new ExecFuture(
|
$path_argument = $this->getPathArgumentForLinterFuture($disk_path);
|
||||||
'%C %C',
|
$future = new ExecFuture('%C %C', $bin, $path_argument);
|
||||||
$bin,
|
|
||||||
$this->getReadDataFromStdinFilename());
|
|
||||||
$future->write($this->getEngine()->loadData($path));
|
|
||||||
} else {
|
|
||||||
// TODO: In commit hook mode, we need to do more handling here.
|
|
||||||
$disk_path = $this->getEngine()->getFilePathOnDisk($path);
|
|
||||||
$path_argument = $this->getPathArgumentForLinterFuture($disk_path);
|
|
||||||
$future = new ExecFuture('%C %C', $bin, $path_argument);
|
|
||||||
}
|
|
||||||
|
|
||||||
$future->setCWD($this->getEngine()->getWorkingCopy()->getProjectRoot());
|
$future->setCWD($this->getEngine()->getWorkingCopy()->getProjectRoot());
|
||||||
$futures[$path] = $future;
|
$futures[$path] = $future;
|
||||||
|
|
|
@ -33,14 +33,6 @@ final class ArcanistHLintLinter extends ArcanistExternalLinter {
|
||||||
return pht('Install hlint with `cabal install hlint`.');
|
return pht('Install hlint with `cabal install hlint`.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getReadDataFromStdinFilename() {
|
|
||||||
return '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getMandatoryFlags() {
|
protected function getMandatoryFlags() {
|
||||||
return array('--json');
|
return array('--json');
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,6 @@ final class ArcanistJSONLintLinter extends ArcanistExternalLinter {
|
||||||
return pht('Install jsonlint using `npm install -g jsonlint`.');
|
return pht('Install jsonlint using `npm install -g jsonlint`.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getMandatoryFlags() {
|
protected function getMandatoryFlags() {
|
||||||
return array(
|
return array(
|
||||||
'--compact',
|
'--compact',
|
||||||
|
|
|
@ -101,17 +101,6 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter {
|
||||||
return pht('Install lessc using `npm install -g less`.');
|
return pht('Install lessc using `npm install -g less`.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
// Technically `lessc` can read data from standard input however, when doing
|
|
||||||
// so, relative imports cannot be resolved. Therefore, this functionality is
|
|
||||||
// disabled.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getReadDataFromStdinFilename() {
|
|
||||||
return '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getMandatoryFlags() {
|
protected function getMandatoryFlags() {
|
||||||
return array(
|
return array(
|
||||||
'--lint',
|
'--lint',
|
||||||
|
|
|
@ -55,10 +55,6 @@ final class ArcanistPhpLinter extends ArcanistExternalLinter {
|
||||||
return $stdout;
|
return $stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function canCustomizeLintSeverities() {
|
protected function canCustomizeLintSeverities() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,10 +96,6 @@ final class ArcanistPhpcsLinter extends ArcanistExternalLinter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
||||||
// NOTE: Some version of PHPCS after 1.4.6 stopped printing a valid, empty
|
// NOTE: Some version of PHPCS after 1.4.6 stopped printing a valid, empty
|
||||||
// XML document to stdout in the case of no errors. If PHPCS exits with
|
// XML document to stdout in the case of no errors. If PHPCS exits with
|
||||||
|
|
|
@ -53,10 +53,6 @@ final class ArcanistPyFlakesLinter extends ArcanistExternalLinter {
|
||||||
return pht('Install pyflakes with `pip install pyflakes`.');
|
return pht('Install pyflakes with `pip install pyflakes`.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
|
||||||
$lines = phutil_split_lines($stdout, false);
|
$lines = phutil_split_lines($stdout, false);
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,6 @@ final class ArcanistRubyLinter extends ArcanistExternalLinter {
|
||||||
return pht('Install `ruby` from <http://www.ruby-lang.org/>.');
|
return pht('Install `ruby` from <http://www.ruby-lang.org/>.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsReadDataFromStdin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getMandatoryFlags() {
|
protected function getMandatoryFlags() {
|
||||||
// -w: turn on warnings
|
// -w: turn on warnings
|
||||||
// -c: check syntax
|
// -c: check syntax
|
||||||
|
|
Loading…
Reference in a new issue