mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-26 07:20:56 +01:00
Split ArcanistXHPASTLinter::LINT_FORMATTING_CONVENTIONS into seperate lint names
Summary: Split ArcanistXHPASTLinter::LINT_FORMATTING_CONVENTIONS into seperate lint names so that each linting rule can be controled sperately Test Plan: This shouldn't break anything, if it does we'll know soon enough. <epriestley> Better things break loudly/obviously I think. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1495
This commit is contained in:
parent
c46dbbf61c
commit
08a1219d11
1 changed files with 72 additions and 55 deletions
|
@ -25,56 +25,64 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
|
||||
protected $trees = array();
|
||||
|
||||
const LINT_PHP_SYNTAX_ERROR = 1;
|
||||
const LINT_UNABLE_TO_PARSE = 2;
|
||||
const LINT_VARIABLE_VARIABLE = 3;
|
||||
const LINT_EXTRACT_USE = 4;
|
||||
const LINT_UNDECLARED_VARIABLE = 5;
|
||||
const LINT_PHP_SHORT_TAG = 6;
|
||||
const LINT_PHP_ECHO_TAG = 7;
|
||||
const LINT_PHP_CLOSE_TAG = 8;
|
||||
const LINT_NAMING_CONVENTIONS = 9;
|
||||
const LINT_IMPLICIT_CONSTRUCTOR = 10;
|
||||
const LINT_FORMATTING_CONVENTIONS = 11;
|
||||
const LINT_DYNAMIC_DEFINE = 12;
|
||||
const LINT_STATIC_THIS = 13;
|
||||
const LINT_PREG_QUOTE_MISUSE = 14;
|
||||
const LINT_PHP_OPEN_TAG = 15;
|
||||
const LINT_TODO_COMMENT = 16;
|
||||
const LINT_EXIT_EXPRESSION = 17;
|
||||
const LINT_COMMENT_STYLE = 18;
|
||||
const LINT_CLASS_FILENAME_MISMATCH = 19;
|
||||
const LINT_TAUTOLOGICAL_EXPRESSION = 20;
|
||||
const LINT_PLUS_OPERATOR_ON_STRINGS = 21;
|
||||
const LINT_DUPLICATE_KEYS_IN_ARRAY = 22;
|
||||
const LINT_REUSED_ITERATORS = 23;
|
||||
const LINT_PHP_SYNTAX_ERROR = 1;
|
||||
const LINT_UNABLE_TO_PARSE = 2;
|
||||
const LINT_VARIABLE_VARIABLE = 3;
|
||||
const LINT_EXTRACT_USE = 4;
|
||||
const LINT_UNDECLARED_VARIABLE = 5;
|
||||
const LINT_PHP_SHORT_TAG = 6;
|
||||
const LINT_PHP_ECHO_TAG = 7;
|
||||
const LINT_PHP_CLOSE_TAG = 8;
|
||||
const LINT_NAMING_CONVENTIONS = 9;
|
||||
const LINT_IMPLICIT_CONSTRUCTOR = 10;
|
||||
const LINT_DYNAMIC_DEFINE = 12;
|
||||
const LINT_STATIC_THIS = 13;
|
||||
const LINT_PREG_QUOTE_MISUSE = 14;
|
||||
const LINT_PHP_OPEN_TAG = 15;
|
||||
const LINT_TODO_COMMENT = 16;
|
||||
const LINT_EXIT_EXPRESSION = 17;
|
||||
const LINT_COMMENT_STYLE = 18;
|
||||
const LINT_CLASS_FILENAME_MISMATCH = 19;
|
||||
const LINT_TAUTOLOGICAL_EXPRESSION = 20;
|
||||
const LINT_PLUS_OPERATOR_ON_STRINGS = 21;
|
||||
const LINT_DUPLICATE_KEYS_IN_ARRAY = 22;
|
||||
const LINT_REUSED_ITERATORS = 23;
|
||||
const LINT_BRACE_FORMATTING = 24;
|
||||
const LINT_PARENTHESES_SPACING = 25;
|
||||
const LINT_CONTROL_STATEMENT_SPACING = 26;
|
||||
const LINT_BINARY_EXPRESSION_SPACING = 27;
|
||||
const LINT_ARRAY_INDEX_SPACING = 27;
|
||||
|
||||
|
||||
public function getLintNameMap() {
|
||||
return array(
|
||||
self::LINT_PHP_SYNTAX_ERROR => 'PHP Syntax Error!',
|
||||
self::LINT_UNABLE_TO_PARSE => 'Unable to Parse',
|
||||
self::LINT_VARIABLE_VARIABLE => 'Use of Variable Variable',
|
||||
self::LINT_EXTRACT_USE => 'Use of extract()',
|
||||
self::LINT_UNDECLARED_VARIABLE => 'Use of Undeclared Variable',
|
||||
self::LINT_PHP_SHORT_TAG => 'Use of Short Tag "<?"',
|
||||
self::LINT_PHP_ECHO_TAG => 'Use of Echo Tag "<?="',
|
||||
self::LINT_PHP_CLOSE_TAG => 'Use of Close Tag "?>"',
|
||||
self::LINT_NAMING_CONVENTIONS => 'Naming Conventions',
|
||||
self::LINT_IMPLICIT_CONSTRUCTOR => 'Implicit Constructor',
|
||||
self::LINT_FORMATTING_CONVENTIONS => 'Formatting Conventions',
|
||||
self::LINT_DYNAMIC_DEFINE => 'Dynamic define()',
|
||||
self::LINT_STATIC_THIS => 'Use of $this in Static Context',
|
||||
self::LINT_PREG_QUOTE_MISUSE => 'Misuse of preg_quote()',
|
||||
self::LINT_PHP_OPEN_TAG => 'Expected Open Tag',
|
||||
self::LINT_TODO_COMMENT => 'TODO Comment',
|
||||
self::LINT_EXIT_EXPRESSION => 'Exit Used as Expression',
|
||||
self::LINT_COMMENT_STYLE => 'Comment Style',
|
||||
self::LINT_CLASS_FILENAME_MISMATCH => 'Class-Filename Mismatch',
|
||||
self::LINT_TAUTOLOGICAL_EXPRESSION => 'Tautological Expression',
|
||||
self::LINT_PLUS_OPERATOR_ON_STRINGS => 'Not String Concatenation',
|
||||
self::LINT_DUPLICATE_KEYS_IN_ARRAY => 'Duplicate Keys in Array',
|
||||
self::LINT_REUSED_ITERATORS => 'Reuse of Iterator Variable',
|
||||
self::LINT_PHP_SYNTAX_ERROR => 'PHP Syntax Error!',
|
||||
self::LINT_UNABLE_TO_PARSE => 'Unable to Parse',
|
||||
self::LINT_VARIABLE_VARIABLE => 'Use of Variable Variable',
|
||||
self::LINT_EXTRACT_USE => 'Use of extract()',
|
||||
self::LINT_UNDECLARED_VARIABLE => 'Use of Undeclared Variable',
|
||||
self::LINT_PHP_SHORT_TAG => 'Use of Short Tag "<?"',
|
||||
self::LINT_PHP_ECHO_TAG => 'Use of Echo Tag "<?="',
|
||||
self::LINT_PHP_CLOSE_TAG => 'Use of Close Tag "?>"',
|
||||
self::LINT_NAMING_CONVENTIONS => 'Naming Conventions',
|
||||
self::LINT_IMPLICIT_CONSTRUCTOR => 'Implicit Constructor',
|
||||
self::LINT_DYNAMIC_DEFINE => 'Dynamic define()',
|
||||
self::LINT_STATIC_THIS => 'Use of $this in Static Context',
|
||||
self::LINT_PREG_QUOTE_MISUSE => 'Misuse of preg_quote()',
|
||||
self::LINT_PHP_OPEN_TAG => 'Expected Open Tag',
|
||||
self::LINT_TODO_COMMENT => 'TODO Comment',
|
||||
self::LINT_EXIT_EXPRESSION => 'Exit Used as Expression',
|
||||
self::LINT_COMMENT_STYLE => 'Comment Style',
|
||||
self::LINT_CLASS_FILENAME_MISMATCH => 'Class-Filename Mismatch',
|
||||
self::LINT_TAUTOLOGICAL_EXPRESSION => 'Tautological Expression',
|
||||
self::LINT_PLUS_OPERATOR_ON_STRINGS => 'Not String Concatenation',
|
||||
self::LINT_DUPLICATE_KEYS_IN_ARRAY => 'Duplicate Keys in Array',
|
||||
self::LINT_REUSED_ITERATORS => 'Reuse of Iterator Variable',
|
||||
self::LINT_BRACE_FORMATTING => 'Brace placement',
|
||||
self::LINT_PARENTHESES_SPACING => 'Spaces Inside Parentheses',
|
||||
self::LINT_CONTROL_STATEMENT_SPACING => 'Space After Control Statement',
|
||||
self::LINT_BINARY_EXPRESSION_SPACING => 'Space Around Binary Operator',
|
||||
self::LINT_ARRAY_INDEX_SPACING => 'Spacing Before Array Index',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -87,12 +95,21 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
self::LINT_TODO_COMMENT => ArcanistLintSeverity::SEVERITY_ADVICE,
|
||||
self::LINT_UNABLE_TO_PARSE
|
||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||
self::LINT_FORMATTING_CONVENTIONS
|
||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||
self::LINT_NAMING_CONVENTIONS
|
||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||
self::LINT_PREG_QUOTE_MISUSE
|
||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||
self::LINT_BRACE_FORMATTING
|
||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||
self::LINT_PARENTHESES_SPACING
|
||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||
self::LINT_CONTROL_STATEMENT_SPACING
|
||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||
self::LINT_BINARY_EXPRESSION_SPACING
|
||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||
self::LINT_ARRAY_INDEX_SPACING
|
||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -181,7 +198,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
|
||||
$this->raiseLintAtToken(
|
||||
$first,
|
||||
self::LINT_FORMATTING_CONVENTIONS,
|
||||
self::LINT_BRACE_FORMATTING,
|
||||
'Put opening braces on the same line as control statements and '.
|
||||
'declarations, with a single space before them.',
|
||||
' '.$first->getValue());
|
||||
|
@ -190,7 +207,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
if ($before->getValue() != ' ') {
|
||||
$this->raiseLintAtToken(
|
||||
$before,
|
||||
self::LINT_FORMATTING_CONVENTIONS,
|
||||
self::LINT_BRACE_FORMATTING,
|
||||
'Put opening braces on the same line as control statements and '.
|
||||
'declarations, with a single space before them.',
|
||||
' ');
|
||||
|
@ -946,7 +963,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
list($tokens, $string) = $warning;
|
||||
$this->raiseLintAtOffset(
|
||||
reset($tokens)->getOffset(),
|
||||
self::LINT_FORMATTING_CONVENTIONS,
|
||||
self::LINT_PARENTHESES_SPACING,
|
||||
'Parentheses should hug their contents.',
|
||||
$string,
|
||||
'');
|
||||
|
@ -968,7 +985,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
if (empty($after)) {
|
||||
$this->raiseLintAtToken(
|
||||
$token,
|
||||
self::LINT_FORMATTING_CONVENTIONS,
|
||||
self::LINT_CONTROL_STATEMENT_SPACING,
|
||||
'Convention: put a space after control statements.',
|
||||
$token->getValue().' ');
|
||||
} else if (count($after) == 1) {
|
||||
|
@ -991,7 +1008,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
if ($space->isAnyWhitespace() && $space->getValue() != ' ') {
|
||||
$this->raiseLintAtToken(
|
||||
$space,
|
||||
self::LINT_FORMATTING_CONVENTIONS,
|
||||
self::LINT_CONTROL_STATEMENT_SPACING,
|
||||
'Convention: put a single space after control statements.',
|
||||
' ');
|
||||
}
|
||||
|
@ -1024,7 +1041,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
if ($replace !== null) {
|
||||
$this->raiseLintAtNode(
|
||||
$operator,
|
||||
self::LINT_FORMATTING_CONVENTIONS,
|
||||
self::LINT_BINARY_EXPRESSION_SPACING,
|
||||
'Convention: logical and arithmetic operators should be '.
|
||||
'surrounded by whitespace.',
|
||||
$replace);
|
||||
|
@ -1158,7 +1175,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
if (preg_match('/^ +$/', $trailing_text)) {
|
||||
$this->raiseLintAtOffset(
|
||||
$last->getOffset() + strlen($last->getValue()),
|
||||
self::LINT_FORMATTING_CONVENTIONS,
|
||||
self::LINT_ARRAY_INDEX_SPACING,
|
||||
'Convention: no spaces before index access.',
|
||||
$trailing_text,
|
||||
'');
|
||||
|
|
Loading…
Reference in a new issue