1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-09-19 16:38:51 +02:00

Apply various linter fixes.

Summary: Applied various linter fixes. Also make the `.editorconfig` file a bit more specific. Unfortunately, `arc lint --apply-patches` currently modifies some test data that it shouldn't, but this should be fixed after T5105.

Test Plan: Ran `arc unit` to make sure things weren't broken.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin, aurelijus

Differential Revision: https://secure.phabricator.com/D9440
This commit is contained in:
Joshua Spence 2014-06-10 11:02:42 -07:00 committed by epriestley
parent b60eaa6487
commit ff1915ecff
19 changed files with 43 additions and 43 deletions

View file

@ -11,11 +11,11 @@ insert_final_newline = true
trim_trailing_whitespace = false trim_trailing_whitespace = false
insert_final_newline = false insert_final_newline = false
[src/parser/__tests__/diff/*] [src/parser/__tests__/diff/*.{git,hg,svn,u}diff]
trim_trailing_whitespace = false trim_trailing_whitespace = false
insert_final_newline = false insert_final_newline = false
[src/parser/__tests__/patches/*] [src/parser/__tests__/patches/*.gitpatch]
trim_trailing_whitespace = false trim_trailing_whitespace = false
insert_final_newline = false insert_final_newline = false

View file

@ -68,8 +68,8 @@ final class ArcanistJSONLintLinter extends ArcanistExternalLinter {
foreach ($lines as $line) { foreach ($lines as $line) {
$matches = null; $matches = null;
$match = preg_match( $match = preg_match(
'/^(?:(?<path>.+): )?' . '/^(?:(?<path>.+): )?'.
'line (?<line>\d+), col (?<column>\d+), ' . 'line (?<line>\d+), col (?<column>\d+), '.
'(?<description>.*)$/', '(?<description>.*)$/',
$line, $line,
$matches); $matches);

View file

@ -131,8 +131,8 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter {
foreach ($lines as $line) { foreach ($lines as $line) {
$matches = null; $matches = null;
$match = preg_match( $match = preg_match(
'/^(?P<name>\w+): (?P<description>.+) ' . '/^(?P<name>\w+): (?P<description>.+) '.
'in (?P<path>.+|-) ' . 'in (?P<path>.+|-) '.
'on line (?P<line>\d+), column (?P<column>\d+):$/', 'on line (?P<line>\d+), column (?P<column>\d+):$/',
$line, $line,
$matches); $matches);

View file

@ -252,7 +252,7 @@ final class ArcanistTextLinter extends ArcanistLinter {
$this->raiseLintAtOffset( $this->raiseLintAtOffset(
$offset, $offset,
self::LINT_BOF_WHITESPACE, self::LINT_BOF_WHITESPACE,
'This file contains leading whitespace at the beginning of the file. ' . 'This file contains leading whitespace at the beginning of the file. '.
'This is unnecessary and should be avoided when possible.', 'This is unnecessary and should be avoided when possible.',
$string, $string,
''); '');
@ -276,7 +276,7 @@ final class ArcanistTextLinter extends ArcanistLinter {
$this->raiseLintAtOffset( $this->raiseLintAtOffset(
$offset, $offset,
self::LINT_EOF_WHITESPACE, self::LINT_EOF_WHITESPACE,
'This file contains trailing whitespace at the end of the file. This ' . 'This file contains trailing whitespace at the end of the file. This '.
'is unnecessary and should be avoided when possible.', 'is unnecessary and should be avoided when possible.',
$string, $string,
''); '');

View file

@ -1081,8 +1081,8 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
$this->raiseLintAtNode( $this->raiseLintAtNode(
$var, $var,
self::LINT_REUSED_ITERATOR_REFERENCE, self::LINT_REUSED_ITERATOR_REFERENCE,
'This variable was used already as a by-reference iterator ' . 'This variable was used already as a by-reference iterator '.
'variable. Such variables survive outside the foreach loop, ' . 'variable. Such variables survive outside the foreach loop, '.
'do not reuse.'); 'do not reuse.');
} }
} }

View file

@ -62,7 +62,7 @@ final class ArcanistLintConsoleRenderer extends ArcanistLintRenderer {
if ($text) { if ($text) {
$prefix = phutil_console_format("**>>>** Lint for __%s__:\n\n\n", $path); $prefix = phutil_console_format("**>>>** Lint for __%s__:\n\n\n", $path);
return $prefix . implode("\n", $text); return $prefix.implode("\n", $text);
} else { } else {
return null; return null;
} }

View file

@ -279,7 +279,7 @@ final class ArcanistDiffParser {
"Expected a hunk header, like 'Index: /path/to/file.ext' (svn), ". "Expected a hunk header, like 'Index: /path/to/file.ext' (svn), ".
"'Property changes on: /path/to/file.ext' (svn properties), ". "'Property changes on: /path/to/file.ext' (svn properties), ".
"'commit 59bcc3ad6775562f845953cf01624225' (git show), ". "'commit 59bcc3ad6775562f845953cf01624225' (git show), ".
"'diff --git' (git diff), '--- filename' (unified diff), or " . "'diff --git' (git diff), '--- filename' (unified diff), or ".
"'diff -r' (hg diff or patch)."); "'diff -r' (hg diff or patch).");
} }

View file

@ -128,7 +128,7 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
foreach ($files as $path => $mask) { foreach ($files as $path => $mask) {
foreach ($externals as $external) { foreach ($externals as $external) {
if (!strncmp($path . '/', $external . '/', strlen($external) + 1)) { if (!strncmp($path.'/', $external.'/', strlen($external) + 1)) {
$files[$path] |= self::FLAG_EXTERNALS; $files[$path] |= self::FLAG_EXTERNALS;
} }
} }

View file

@ -27,7 +27,7 @@ final class ArcanistRepositoryAPIStateTestCase extends ArcanistTestCase {
} }
private function parseState($test) { private function parseState($test) {
$dir = dirname(__FILE__) . '/state/'; $dir = dirname(__FILE__).'/state/';
$fixture = PhutilDirectoryFixture::newFromArchive($dir.'/'.$test); $fixture = PhutilDirectoryFixture::newFromArchive($dir.'/'.$test);
$fixture_path = $fixture->getPath(); $fixture_path = $fixture->getPath();

View file

@ -91,7 +91,7 @@ final class NoseTestEngine extends ArcanistBaseUnitTestEngine {
$xunit_tmp); $xunit_tmp);
if ($this->getEnableCoverage() !== false) { if ($this->getEnableCoverage() !== false) {
$cmd_line .= csprintf(' --with-coverage --cover-xml ' . $cmd_line .= csprintf(' --with-coverage --cover-xml '.
'--cover-xml-file=%s', '--cover-xml-file=%s',
$cover_tmp); $cover_tmp);
} }

View file

@ -56,7 +56,7 @@ final class PhpunitResultParser extends ArcanistBaseTestResultParser {
if ('fail' == $event->status) { if ('fail' == $event->status) {
$status = ArcanistUnitTestResult::RESULT_FAIL; $status = ArcanistUnitTestResult::RESULT_FAIL;
$user_data .= $event->message . "\n"; $user_data .= $event->message."\n";
foreach ($event->trace as $trace) { foreach ($event->trace as $trace) {
$user_data .= sprintf("\n%s:%s", $trace->file, $trace->line); $user_data .= sprintf("\n%s:%s", $trace->file, $trace->line);
} }
@ -150,7 +150,7 @@ final class PhpunitResultParser extends ArcanistBaseTestResultParser {
$coverage .= 'N'; $coverage .= 'N';
} }
$len = strlen($this->projectRoot . DIRECTORY_SEPARATOR); $len = strlen($this->projectRoot.DIRECTORY_SEPARATOR);
$class_path = substr($class_path, $len); $class_path = substr($class_path, $len);
$reports[$class_path] = $coverage; $reports[$class_path] = $coverage;
} }
@ -169,16 +169,16 @@ final class PhpunitResultParser extends ArcanistBaseTestResultParser {
private function getJsonReport($json) { private function getJsonReport($json) {
if (empty($json)) { if (empty($json)) {
throw new Exception('JSON report file is empty, ' throw new Exception('JSON report file is empty, '.
. 'it probably means that phpunit failed to run tests. ' 'it probably means that phpunit failed to run tests. '.
. 'Try running arc unit with --trace option and then run ' 'Try running arc unit with --trace option and then run '.
. 'generated phpunit command yourself, you might get the ' 'generated phpunit command yourself, you might get the '.
. 'answer.' 'answer.'
); );
} }
$json = preg_replace('/}{\s*"/', '},{"', $json); $json = preg_replace('/}{\s*"/', '},{"', $json);
$json = '[' . $json . ']'; $json = '['.$json.']';
$json = json_decode($json); $json = json_decode($json);
if (!is_array($json)) { if (!is_array($json)) {
throw new Exception('JSON could not be decoded'); throw new Exception('JSON could not be decoded');

View file

@ -261,16 +261,16 @@ final class PhpunitTestEngine extends ArcanistBaseUnitTestEngine {
* based on phpunit_config option in .arcconfig * based on phpunit_config option in .arcconfig
*/ */
private function prepareConfigFile() { private function prepareConfigFile() {
$project_root = $this->projectRoot . DIRECTORY_SEPARATOR; $project_root = $this->projectRoot.DIRECTORY_SEPARATOR;
$config = $this->getConfigurationManager()->getConfigFromAnySource( $config = $this->getConfigurationManager()->getConfigFromAnySource(
'phpunit_config'); 'phpunit_config');
if ($config) { if ($config) {
if (Filesystem::pathExists($project_root . $config)) { if (Filesystem::pathExists($project_root.$config)) {
$this->configFile = $project_root . $config; $this->configFile = $project_root.$config;
} else { } else {
throw new Exception('PHPUnit configuration file was not ' . throw new Exception('PHPUnit configuration file was not '.
'found in ' . $project_root . $config); 'found in '.$project_root.$config);
} }
} }
$bin = $this->getConfigurationManager()->getConfigFromAnySource( $bin = $this->getConfigurationManager()->getConfigFromAnySource(

View file

@ -791,7 +791,7 @@ abstract class ArcanistBaseWorkflow extends Phobject {
if ($this->stashed) { if ($this->stashed) {
$api = $this->getRepositoryAPI(); $api = $this->getRepositoryAPI();
$api->unstashChanges(); $api->unstashChanges();
echo pht('Restored stashed changes to the working directory.') . "\n"; echo pht('Restored stashed changes to the working directory.')."\n";
} }
} }

View file

@ -351,7 +351,7 @@ EOTEXT
foreach ($out as &$feature) { foreach ($out as &$feature) {
unset($feature['color'], $feature['ssort'], $feature['esort']); unset($feature['color'], $feature['ssort'], $feature['esort']);
} }
echo json_encode(ipull($out, null, 'name')) . "\n"; echo json_encode(ipull($out, null, 'name'))."\n";
} else { } else {
$console = PhutilConsole::getConsole(); $console = PhutilConsole::getConsole();
foreach ($out as $line) { foreach ($out as $line) {

View file

@ -309,7 +309,7 @@ EOTEXT
$this->branch, $this->branch,
$this->onto); $this->onto);
if (!$this->isHistoryImmutable()) { if (!$this->isHistoryImmutable()) {
$message .= ' ' . pht("You may be able to 'arc amend' instead."); $message .= ' '.pht("You may be able to 'arc amend' instead.");
} }
throw new ArcanistUsageException($message); throw new ArcanistUsageException($message);
} }
@ -571,7 +571,7 @@ EOTEXT
} else if ($this->isHg) { } else if ($this->isHg) {
echo phutil_console_format(pht( echo phutil_console_format(pht(
'Updating **%s**...', 'Updating **%s**...',
$this->onto) . "\n"); $this->onto)."\n");
try { try {
list($out, $err) = $repository_api->execxLocal('pull'); list($out, $err) = $repository_api->execxLocal('pull');
@ -962,7 +962,7 @@ EOTEXT
if ($this->getArgument('hold')) { if ($this->getArgument('hold')) {
echo phutil_console_format(pht( echo phutil_console_format(pht(
'Holding change in **%s**: it has NOT been pushed yet.', 'Holding change in **%s**: it has NOT been pushed yet.',
$this->onto). "\n"); $this->onto)."\n");
} else { } else {
echo pht('Pushing change...'), "\n\n"; echo pht('Pushing change...'), "\n\n";

View file

@ -63,7 +63,7 @@ EOTEXT
return array( return array(
'lintall' => array( 'lintall' => array(
'help' => 'help' =>
'Show all lint warnings, not just those on changed lines. When ' . 'Show all lint warnings, not just those on changed lines. When '.
'paths are specified, this is the default behavior.', 'paths are specified, this is the default behavior.',
'conflicts' => array( 'conflicts' => array(
'only-changed' => true, 'only-changed' => true,
@ -71,9 +71,9 @@ EOTEXT
), ),
'only-changed' => array( 'only-changed' => array(
'help' => 'help' =>
'Show lint warnings just on changed lines. When no paths are ' . 'Show lint warnings just on changed lines. When no paths are '.
'specified, this is the default. This differs from only-new ' . 'specified, this is the default. This differs from only-new '.
'in cases where line modifications introduce lint on other ' . 'in cases where line modifications introduce lint on other '.
'unmodified lines.', 'unmodified lines.',
'conflicts' => array( 'conflicts' => array(
'lintall' => true, 'lintall' => true,

View file

@ -984,12 +984,12 @@ EOTEXT
$source_revision = $this->loadRevisionFromHash($hash); $source_revision = $this->loadRevisionFromHash($hash);
if ($bundle_revision) { if ($bundle_revision) {
$bundle_base_rev_str = $bundle_base_rev . $bundle_base_rev_str = $bundle_base_rev.
' \ D' . $bundle_revision['id']; ' \ D'.$bundle_revision['id'];
} }
if ($source_revision) { if ($source_revision) {
$source_base_rev_str = $source_base_rev . $source_base_rev_str = $source_base_rev.
' \ D' . $source_revision['id']; ' \ D'.$source_revision['id'];
} }
} }
$bundle_base_rev_str = nonempty($bundle_base_rev_str, $bundle_base_rev_str = nonempty($bundle_base_rev_str,