Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2895942
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
8 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/lint/linter/ArcanistClosureLinter.php b/src/lint/linter/ArcanistClosureLinter.php
index 75eb1511..6a6bbc1d 100644
--- a/src/lint/linter/ArcanistClosureLinter.php
+++ b/src/lint/linter/ArcanistClosureLinter.php
@@ -1,63 +1,62 @@
<?php
/**
* Uses `gjslint` to detect errors and potential problems in JavaScript code.
*/
final class ArcanistClosureLinter extends ArcanistExternalLinter {
public function getInfoName() {
return pht('Closure Linter');
}
public function getInfoURI() {
return 'https://developers.google.com/closure/utilities/';
}
public function getInfoDescription() {
return pht("Uses Google's Closure Linter to check JavaScript code.");
}
public function getLinterName() {
return 'GJSLINT';
}
public function getLinterConfigurationName() {
return 'gjslint';
}
public function getDefaultBinary() {
return 'gjslint';
}
public function getInstallInstructions() {
return pht(
'Install %s using `%s`.',
'gjslint',
- 'sudo easy_install http://closure-linter.googlecode.com/'.
- 'files/closure_linter-latest.tar.gz');
+ 'pip install closure-linter');
}
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match('/^Line (\d+), E:(\d+): (.*)/', $line, $matches)) {
continue;
}
$message = id(new ArcanistLintMessage())
->setPath($path)
->setLine($matches[1])
->setName('GJSLINT'.$matches[2])
->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR)
->setCode($this->getLinterName().$matches[2])
->setDescription($matches[3]);
$messages[] = $message;
}
return $messages;
}
}
diff --git a/src/lint/linter/ArcanistFlake8Linter.php b/src/lint/linter/ArcanistFlake8Linter.php
index 6f93ef8c..19d57432 100644
--- a/src/lint/linter/ArcanistFlake8Linter.php
+++ b/src/lint/linter/ArcanistFlake8Linter.php
@@ -1,115 +1,115 @@
<?php
/**
* Uses "flake8" to detect various errors in Python code.
* Requires version 1.7.0 or newer of flake8.
*/
final class ArcanistFlake8Linter extends ArcanistExternalLinter {
public function getInfoName() {
return 'Python Flake8 multi-linter';
}
public function getInfoURI() {
return 'https://pypi.python.org/pypi/flake8';
}
public function getInfoDescription() {
return pht(
'Uses `%s` to run several linters (PyFlakes, pep8, and a McCabe '.
'complexity checker) on Python source files.',
'flake8');
}
public function getLinterName() {
return 'flake8';
}
public function getLinterConfigurationName() {
return 'flake8';
}
public function getDefaultBinary() {
return 'flake8';
}
public function getVersion() {
list($stdout) = execx('%C --version', $this->getExecutableCommand());
$matches = array();
if (preg_match('/^(?P<version>\d+\.\d+(?:\.\d+)?)\b/', $stdout, $matches)) {
return $matches['version'];
} else {
return false;
}
}
public function getInstallInstructions() {
- return pht('Install flake8 using `%s`.', 'easy_install flake8');
+ return pht('Install flake8 using `%s`.', 'pip install flake8');
}
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
// stdin:2: W802 undefined name 'foo' # pyflakes
// stdin:3:1: E302 expected 2 blank lines, found 1 # pep8
$regexp = '/^(.*?):(\d+):(?:(\d+):)? (\S+) (.*)$/';
if (!preg_match($regexp, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
if (!empty($matches[3])) {
$message->setChar($matches[3]);
}
$message->setCode($matches[4]);
$message->setName($this->getLinterName().' '.$matches[3]);
$message->setDescription($matches[5]);
$message->setSeverity($this->getLintMessageSeverity($matches[4]));
$messages[] = $message;
}
return $messages;
}
protected function getDefaultMessageSeverity($code) {
if (preg_match('/^C/', $code)) {
// "C": Cyclomatic complexity
return ArcanistLintSeverity::SEVERITY_ADVICE;
} else if (preg_match('/^W/', $code)) {
// "W": PEP8 Warning
return ArcanistLintSeverity::SEVERITY_WARNING;
} else {
// "E": PEP8 Error
// "F": PyFlakes Error
// or: Flake8 Extension Message
return ArcanistLintSeverity::SEVERITY_ERROR;
}
}
protected function getLintCodeFromLinterConfigurationKey($code) {
if (!preg_match('/^[A-Z]\d+$/', $code)) {
throw new Exception(
pht(
'Unrecognized lint message code "%s". Expected a valid flake8 '.
'lint code like "%s", or "%s", or "%s", or "%s".',
$code,
'E225',
'W291',
'F811',
'C901'));
}
return $code;
}
}
diff --git a/src/lint/linter/ArcanistPEP8Linter.php b/src/lint/linter/ArcanistPEP8Linter.php
index 682ac6a8..6e47e395 100644
--- a/src/lint/linter/ArcanistPEP8Linter.php
+++ b/src/lint/linter/ArcanistPEP8Linter.php
@@ -1,98 +1,98 @@
<?php
/**
* Uses "pep8.py" to enforce PEP8 rules for Python.
*/
final class ArcanistPEP8Linter extends ArcanistExternalLinter {
public function getInfoName() {
return 'Python PEP 8';
}
public function getInfoURI() {
return 'https://pypi.python.org/pypi/pep8';
}
public function getInfoDescription() {
return pht(
'pep8 is a tool to check your Python code against some of the '.
'style conventions in PEP 8.');
}
public function getLinterName() {
return 'PEP8';
}
public function getLinterConfigurationName() {
return 'pep8';
}
public function getDefaultBinary() {
return 'pep8';
}
public function getVersion() {
list($stdout) = execx('%C --version', $this->getExecutableCommand());
$matches = array();
if (preg_match('/^(?P<version>\d+\.\d+(?:\.\d+)?)\b/', $stdout, $matches)) {
return $matches['version'];
} else {
return false;
}
}
public function getInstallInstructions() {
- return pht('Install PEP8 using `%s`.', 'easy_install pep8');
+ return pht('Install PEP8 using `%s`.', 'pip install pep8');
}
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match('/^(.*?):(\d+):(\d+): (\S+) (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
$message->setChar($matches[3]);
$message->setCode($matches[4]);
$message->setName('PEP8 '.$matches[4]);
$message->setDescription($matches[5]);
$message->setSeverity($this->getLintMessageSeverity($matches[4]));
$messages[] = $message;
}
return $messages;
}
protected function getDefaultMessageSeverity($code) {
if (preg_match('/^W/', $code)) {
return ArcanistLintSeverity::SEVERITY_WARNING;
} else {
return ArcanistLintSeverity::SEVERITY_ERROR;
}
}
protected function getLintCodeFromLinterConfigurationKey($code) {
if (!preg_match('/^(E|W)\d+$/', $code)) {
throw new Exception(
pht(
'Unrecognized lint message code "%s". Expected a valid PEP8 '.
'lint code like "%s" or "%s".',
$code,
'E101',
'W291'));
}
return $code;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jan 19 2025, 22:20 (6 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129317
Default Alt Text
(8 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment