mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +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
|
@ -35,7 +35,6 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
const LINT_PHP_CLOSE_TAG = 8;
|
const LINT_PHP_CLOSE_TAG = 8;
|
||||||
const LINT_NAMING_CONVENTIONS = 9;
|
const LINT_NAMING_CONVENTIONS = 9;
|
||||||
const LINT_IMPLICIT_CONSTRUCTOR = 10;
|
const LINT_IMPLICIT_CONSTRUCTOR = 10;
|
||||||
const LINT_FORMATTING_CONVENTIONS = 11;
|
|
||||||
const LINT_DYNAMIC_DEFINE = 12;
|
const LINT_DYNAMIC_DEFINE = 12;
|
||||||
const LINT_STATIC_THIS = 13;
|
const LINT_STATIC_THIS = 13;
|
||||||
const LINT_PREG_QUOTE_MISUSE = 14;
|
const LINT_PREG_QUOTE_MISUSE = 14;
|
||||||
|
@ -48,6 +47,11 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
const LINT_PLUS_OPERATOR_ON_STRINGS = 21;
|
const LINT_PLUS_OPERATOR_ON_STRINGS = 21;
|
||||||
const LINT_DUPLICATE_KEYS_IN_ARRAY = 22;
|
const LINT_DUPLICATE_KEYS_IN_ARRAY = 22;
|
||||||
const LINT_REUSED_ITERATORS = 23;
|
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() {
|
public function getLintNameMap() {
|
||||||
|
@ -62,7 +66,6 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
self::LINT_PHP_CLOSE_TAG => 'Use of Close Tag "?>"',
|
self::LINT_PHP_CLOSE_TAG => 'Use of Close Tag "?>"',
|
||||||
self::LINT_NAMING_CONVENTIONS => 'Naming Conventions',
|
self::LINT_NAMING_CONVENTIONS => 'Naming Conventions',
|
||||||
self::LINT_IMPLICIT_CONSTRUCTOR => 'Implicit Constructor',
|
self::LINT_IMPLICIT_CONSTRUCTOR => 'Implicit Constructor',
|
||||||
self::LINT_FORMATTING_CONVENTIONS => 'Formatting Conventions',
|
|
||||||
self::LINT_DYNAMIC_DEFINE => 'Dynamic define()',
|
self::LINT_DYNAMIC_DEFINE => 'Dynamic define()',
|
||||||
self::LINT_STATIC_THIS => 'Use of $this in Static Context',
|
self::LINT_STATIC_THIS => 'Use of $this in Static Context',
|
||||||
self::LINT_PREG_QUOTE_MISUSE => 'Misuse of preg_quote()',
|
self::LINT_PREG_QUOTE_MISUSE => 'Misuse of preg_quote()',
|
||||||
|
@ -75,6 +78,11 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
self::LINT_PLUS_OPERATOR_ON_STRINGS => 'Not String Concatenation',
|
self::LINT_PLUS_OPERATOR_ON_STRINGS => 'Not String Concatenation',
|
||||||
self::LINT_DUPLICATE_KEYS_IN_ARRAY => 'Duplicate Keys in Array',
|
self::LINT_DUPLICATE_KEYS_IN_ARRAY => 'Duplicate Keys in Array',
|
||||||
self::LINT_REUSED_ITERATORS => 'Reuse of Iterator Variable',
|
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_TODO_COMMENT => ArcanistLintSeverity::SEVERITY_ADVICE,
|
||||||
self::LINT_UNABLE_TO_PARSE
|
self::LINT_UNABLE_TO_PARSE
|
||||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||||
self::LINT_FORMATTING_CONVENTIONS
|
|
||||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
|
||||||
self::LINT_NAMING_CONVENTIONS
|
self::LINT_NAMING_CONVENTIONS
|
||||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
||||||
self::LINT_PREG_QUOTE_MISUSE
|
self::LINT_PREG_QUOTE_MISUSE
|
||||||
=> ArcanistLintSeverity::SEVERITY_WARNING,
|
=> 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(
|
$this->raiseLintAtToken(
|
||||||
$first,
|
$first,
|
||||||
self::LINT_FORMATTING_CONVENTIONS,
|
self::LINT_BRACE_FORMATTING,
|
||||||
'Put opening braces on the same line as control statements and '.
|
'Put opening braces on the same line as control statements and '.
|
||||||
'declarations, with a single space before them.',
|
'declarations, with a single space before them.',
|
||||||
' '.$first->getValue());
|
' '.$first->getValue());
|
||||||
|
@ -190,7 +207,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
if ($before->getValue() != ' ') {
|
if ($before->getValue() != ' ') {
|
||||||
$this->raiseLintAtToken(
|
$this->raiseLintAtToken(
|
||||||
$before,
|
$before,
|
||||||
self::LINT_FORMATTING_CONVENTIONS,
|
self::LINT_BRACE_FORMATTING,
|
||||||
'Put opening braces on the same line as control statements and '.
|
'Put opening braces on the same line as control statements and '.
|
||||||
'declarations, with a single space before them.',
|
'declarations, with a single space before them.',
|
||||||
' ');
|
' ');
|
||||||
|
@ -946,7 +963,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
list($tokens, $string) = $warning;
|
list($tokens, $string) = $warning;
|
||||||
$this->raiseLintAtOffset(
|
$this->raiseLintAtOffset(
|
||||||
reset($tokens)->getOffset(),
|
reset($tokens)->getOffset(),
|
||||||
self::LINT_FORMATTING_CONVENTIONS,
|
self::LINT_PARENTHESES_SPACING,
|
||||||
'Parentheses should hug their contents.',
|
'Parentheses should hug their contents.',
|
||||||
$string,
|
$string,
|
||||||
'');
|
'');
|
||||||
|
@ -968,7 +985,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
if (empty($after)) {
|
if (empty($after)) {
|
||||||
$this->raiseLintAtToken(
|
$this->raiseLintAtToken(
|
||||||
$token,
|
$token,
|
||||||
self::LINT_FORMATTING_CONVENTIONS,
|
self::LINT_CONTROL_STATEMENT_SPACING,
|
||||||
'Convention: put a space after control statements.',
|
'Convention: put a space after control statements.',
|
||||||
$token->getValue().' ');
|
$token->getValue().' ');
|
||||||
} else if (count($after) == 1) {
|
} else if (count($after) == 1) {
|
||||||
|
@ -991,7 +1008,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
if ($space->isAnyWhitespace() && $space->getValue() != ' ') {
|
if ($space->isAnyWhitespace() && $space->getValue() != ' ') {
|
||||||
$this->raiseLintAtToken(
|
$this->raiseLintAtToken(
|
||||||
$space,
|
$space,
|
||||||
self::LINT_FORMATTING_CONVENTIONS,
|
self::LINT_CONTROL_STATEMENT_SPACING,
|
||||||
'Convention: put a single space after control statements.',
|
'Convention: put a single space after control statements.',
|
||||||
' ');
|
' ');
|
||||||
}
|
}
|
||||||
|
@ -1024,7 +1041,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
if ($replace !== null) {
|
if ($replace !== null) {
|
||||||
$this->raiseLintAtNode(
|
$this->raiseLintAtNode(
|
||||||
$operator,
|
$operator,
|
||||||
self::LINT_FORMATTING_CONVENTIONS,
|
self::LINT_BINARY_EXPRESSION_SPACING,
|
||||||
'Convention: logical and arithmetic operators should be '.
|
'Convention: logical and arithmetic operators should be '.
|
||||||
'surrounded by whitespace.',
|
'surrounded by whitespace.',
|
||||||
$replace);
|
$replace);
|
||||||
|
@ -1158,7 +1175,7 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
||||||
if (preg_match('/^ +$/', $trailing_text)) {
|
if (preg_match('/^ +$/', $trailing_text)) {
|
||||||
$this->raiseLintAtOffset(
|
$this->raiseLintAtOffset(
|
||||||
$last->getOffset() + strlen($last->getValue()),
|
$last->getOffset() + strlen($last->getValue()),
|
||||||
self::LINT_FORMATTING_CONVENTIONS,
|
self::LINT_ARRAY_INDEX_SPACING,
|
||||||
'Convention: no spaces before index access.',
|
'Convention: no spaces before index access.',
|
||||||
$trailing_text,
|
$trailing_text,
|
||||||
'');
|
'');
|
||||||
|
|
Loading…
Reference in a new issue