1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 00:32:41 +01:00

Apply new whitespace lint rules to arcanist/

Summary: Automated changes from `arc lint`.

Test Plan: Looked them over.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D5017
This commit is contained in:
epriestley 2013-02-19 14:09:20 -08:00
parent 157184e01d
commit 7a67173b97
17 changed files with 45 additions and 81 deletions

View file

@ -92,8 +92,9 @@ final class ArcanistDiffUtilsTestCase extends ArcanistTestCase {
foreach ($tests as $test) { foreach ($tests as $test) {
$this->assertEqual( $this->assertEqual(
$test[2], $test[2],
ArcanistDiffUtils::buildLevenshteinDifferenceString($test[0], $test[1]) ArcanistDiffUtils::buildLevenshteinDifferenceString(
); $test[0],
$test[1]));
} }
} }
} }

View file

@ -56,8 +56,7 @@ final class ArcanistConduitLinter extends ArcanistLinter {
self::CONDUIT_METHOD, self::CONDUIT_METHOD,
array( array(
'file_contents' => $this->data, 'file_contents' => $this->data,
) ));
);
} }
public function lintPath($path) { public function lintPath($path) {

View file

@ -23,8 +23,7 @@ final class ArcanistCppcheckLinter extends ArcanistLinter {
// You will for sure want some options. The below default tends to be ok // You will for sure want some options. The below default tends to be ok
$options = $working_copy->getConfig( $options = $working_copy->getConfig(
'lint.cppcheck.options', 'lint.cppcheck.options',
'-j2 --inconclusive --enable=performance,style,portability,information' '-j2 --inconclusive --enable=performance,style,portability,information');
);
return $options; return $options;
} }
@ -70,8 +69,7 @@ final class ArcanistCppcheckLinter extends ArcanistLinter {
"%C %C --inline-suppr --xml-version=2 -q %s", "%C %C --inline-suppr --xml-version=2 -q %s",
$bin, $bin,
$options, $options,
$this->getEngine()->getFilePathOnDisk($path) $this->getEngine()->getFilePathOnDisk($path));
);
if ($rc === 1) { if ($rc === 1) {
throw new Exception("cppcheck failed to run correctly:\n".$stderr); throw new Exception("cppcheck failed to run correctly:\n".$stderr);

View file

@ -14,7 +14,7 @@ final class ArcanistFilenameLinter extends ArcanistLinter {
} }
public function getLinterName() { public function getLinterName() {
return 'NAM'; return 'NAME';
} }
public function getLintSeverityMap() { public function getLintSeverityMap() {

View file

@ -110,11 +110,9 @@ final class ArcanistSpellingLinter extends ArcanistLinter {
sprintf( sprintf(
"Possible spelling error. You wrote '%s', but did you mean '%s'?", "Possible spelling error. You wrote '%s', but did you mean '%s'?",
$word, $word,
$correct_word $correct_word),
),
$original, $original,
$replacement $replacement);
);
$pos = $next + 1; $pos = $next + 1;
} }
} }
@ -126,8 +124,7 @@ final class ArcanistSpellingLinter extends ArcanistLinter {
'#\b' . preg_quote($word, '#') . '\b#i', '#\b' . preg_quote($word, '#') . '\b#i',
$text, $text,
$matches, $matches,
PREG_OFFSET_CAPTURE PREG_OFFSET_CAPTURE);
);
if (!$num_matches) { if (!$num_matches) {
return; return;
} }
@ -140,11 +137,9 @@ final class ArcanistSpellingLinter extends ArcanistLinter {
sprintf( sprintf(
"Possible spelling error. You wrote '%s', but did you mean '%s'?", "Possible spelling error. You wrote '%s', but did you mean '%s'?",
$word, $word,
$correct_word $correct_word),
),
$original, $original,
$replacement $replacement);
);
} }
} }

View file

@ -1903,8 +1903,7 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
$decl_name, $decl_name,
self::LINT_CLASS_FILENAME_MISMATCH, self::LINT_CLASS_FILENAME_MISMATCH,
"The name of this file differs from the name of the class or interface ". "The name of this file differs from the name of the class or interface ".
"it declares. Rename the file to '{$rename}'." "it declares. Rename the file to '{$rename}'.");
);
} }
private function lintPlusOperatorOnStrings($root) { private function lintPlusOperatorOnStrings($root) {

View file

@ -126,13 +126,11 @@ final class ArcanistLintConsoleRenderer implements ArcanistLintRenderer {
$text = substr( $text = substr(
$text, $text,
$same_at_front, $same_at_front,
$text_strlen - $same_at_end - $same_at_front $text_strlen - $same_at_end - $same_at_front);
);
$patch = substr( $patch = substr(
$patch, $patch,
$same_at_front, $same_at_front,
$patch_strlen - $same_at_end - $same_at_front $patch_strlen - $same_at_end - $same_at_front);
);
} }
// Print out the impacted region itself. // Print out the impacted region itself.
$diff = $message->isPatchable() ? '-' : null; $diff = $message->isPatchable() ? '-' : null;
@ -191,8 +189,7 @@ final class ArcanistLintConsoleRenderer implements ArcanistLintRenderer {
foreach (array_slice($patch_lines, 1) as $patch_line) { foreach (array_slice($patch_lines, 1) as $patch_line) {
$out[] = $this->renderLine( $out[] = $this->renderLine(
null, null,
phutil_console_format('##%s##', $patch_line), false, '+' phutil_console_format('##%s##', $patch_line), false, '+');
);
} }
} }

View file

@ -23,8 +23,7 @@ final class ArcanistLintLikeCompilerRenderer implements ArcanistLintRenderer {
$line, $line,
$severity, $severity,
$code, $code,
$description $description);
);
} }
return implode('', $lines); return implode('', $lines);

View file

@ -108,8 +108,7 @@ EOCORPUS;
array( array(
'duck' => 'quack', 'duck' => 'quack',
), ),
$change->getNewProperties() $change->getNewProperties());
);
break; break;
case 'svn-property-modify.svndiff': case 'svn-property-modify.svndiff':
$this->assertEqual(2, count($changes)); $this->assertEqual(2, count($changes));
@ -120,14 +119,12 @@ EOCORPUS;
array( array(
'svn:ignore' => '*.phpz', 'svn:ignore' => '*.phpz',
), ),
$change->getOldProperties() $change->getOldProperties());
);
$this->assertEqual( $this->assertEqual(
array( array(
'svn:ignore' => '*.php', 'svn:ignore' => '*.php',
), ),
$change->getNewProperties() $change->getNewProperties());
);
$change = array_shift($changes); $change = array_shift($changes);
$this->assertEqual(0, count($change->getHunks())); $this->assertEqual(0, count($change->getHunks()));
@ -135,14 +132,12 @@ EOCORPUS;
array( array(
'svn:special' => '*', 'svn:special' => '*',
), ),
$change->getOldProperties() $change->getOldProperties());
);
$this->assertEqual( $this->assertEqual(
array( array(
'svn:special' => 'moo', 'svn:special' => 'moo',
), ),
$change->getNewProperties() $change->getNewProperties());
);
break; break;
case 'svn-property-delete.svndiff': case 'svn-property-delete.svndiff':
$this->assertEqual(1, count($changes)); $this->assertEqual(1, count($changes));
@ -219,8 +214,7 @@ EOTEXT
array( array(
'svn:mime-type' => 'application/octet-stream', 'svn:mime-type' => 'application/octet-stream',
), ),
$change->getNewProperties() $change->getNewProperties());
);
break; break;
case 'svn-binary-diff.svndiff': case 'svn-binary-diff.svndiff':
$this->assertEqual(1, count($changes)); $this->assertEqual(1, count($changes));
@ -257,14 +251,12 @@ EOTEXT
array( array(
'unix:filemode' => '100644', 'unix:filemode' => '100644',
), ),
$change->getOldProperties() $change->getOldProperties());
);
$this->assertEqual( $this->assertEqual(
array( array(
'unix:filemode' => '100755', 'unix:filemode' => '100755',
), ),
$change->getNewProperties() $change->getNewProperties());
);
break; break;
case 'git-filemode-change-only.gitdiff': case 'git-filemode-change-only.gitdiff':
$this->assertEqual(count($changes), 2); $this->assertEqual(count($changes), 2);
@ -274,14 +266,12 @@ EOTEXT
array( array(
'unix:filemode' => '100644', 'unix:filemode' => '100644',
), ),
$change->getOldProperties() $change->getOldProperties());
);
$this->assertEqual( $this->assertEqual(
array( array(
'unix:filemode' => '100755', 'unix:filemode' => '100755',
), ),
$change->getNewProperties() $change->getNewProperties());
);
break; break;
case 'svn-empty-file.svndiff': case 'svn-empty-file.svndiff':
$this->assertEqual(2, count($changes)); $this->assertEqual(2, count($changes));
@ -331,8 +321,7 @@ EOTEXT
$this->assertEqual(0, count($change->getHunks())); $this->assertEqual(0, count($change->getHunks()));
$this->assertEqual( $this->assertEqual(
ArcanistDiffChangeType::TYPE_MOVE_AWAY, ArcanistDiffChangeType::TYPE_MOVE_AWAY,
$change->getType() $change->getType());
);
$this->assertEqual( $this->assertEqual(
$change->getCurrentPath(), $change->getCurrentPath(),
@ -410,14 +399,12 @@ EOTEXT
array( array(
'svn:ignore' => 'tags', 'svn:ignore' => 'tags',
), ),
$change->getOldProperties() $change->getOldProperties());
);
$this->assertEqual( $this->assertEqual(
array( array(
'svn:ignore' => "tags\nasdf\nlol\nwhat", 'svn:ignore' => "tags\nasdf\nlol\nwhat",
), ),
$change->getNewProperties() $change->getNewProperties());
);
break; break;
case 'git-empty-files.gitdiff': case 'git-empty-files.gitdiff':
$this->assertEqual(2, count($changes)); $this->assertEqual(2, count($changes));
@ -472,8 +459,7 @@ DiffCamp Revision: 94064
git-svn-id: svn+ssh://tubbs/svnroot/tfb/trunk/www@223593 2c7ba8d8 git-svn-id: svn+ssh://tubbs/svnroot/tfb/trunk/www@223593 2c7ba8d8
EOTEXT EOTEXT
, $change->getMetadata('message') , $change->getMetadata('message'));
);
break; break;
case 'git-binary.gitdiff': case 'git-binary.gitdiff':
$this->assertEqual(1, count($changes)); $this->assertEqual(1, count($changes));

View file

@ -733,8 +733,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
case 'outgoing': case 'outgoing':
list($err, $outgoing_base) = $this->execManualLocal( list($err, $outgoing_base) = $this->execManualLocal(
'log --template={node} --rev %s', 'log --template={node} --rev %s',
'limit(reverse(ancestors(.) - outgoing()), 1)' 'limit(reverse(ancestors(.) - outgoing()), 1)');
);
if (!$err) { if (!$err) {
$this->setBaseCommitExplanation( $this->setBaseCommitExplanation(
"it is the first ancestor of the working copy that is not ". "it is the first ancestor of the working copy that is not ".

View file

@ -127,8 +127,7 @@ abstract class ArcanistPhutilTestCase {
array('assertException' => array()), array('assertException' => array()),
array(false), array(false),
$callable, $callable,
$expected_exception_class $expected_exception_class);
);
} }
/** /**

View file

@ -123,8 +123,7 @@ EOTEXT
array( array(
'revision_id' => $revision_id, 'revision_id' => $revision_id,
'edit' => false, 'edit' => false,
) ));
);
} catch (ConduitClientException $ex) { } catch (ConduitClientException $ex) {
if (strpos($ex->getMessage(), 'ERR_NOT_FOUND') === false) { if (strpos($ex->getMessage(), 'ERR_NOT_FOUND') === false) {
throw $ex; throw $ex;

View file

@ -94,7 +94,7 @@ EOTEXT
$browser = $this->getBrowserCommand(); $browser = $this->getBrowserCommand();
foreach ($paths as $path) { foreach ($paths as $path) {
$ret_code = phutil_passthru("%s %s", $browser, $base_uri . $path ); $ret_code = phutil_passthru("%s %s", $browser, $base_uri . $path);
if ($ret_code) { if ($ret_code) {
throw new ArcanistUsageException( throw new ArcanistUsageException(
"It seems we failed to open the browser; Perhaps you should try to ". "It seems we failed to open the browser; Perhaps you should try to ".
@ -124,7 +124,7 @@ EOTEXT
$branch = $this->getArgument('branch', 'master'); $branch = $this->getArgument('branch', 'master');
return $repo_info[$repo_phid]['uri'] . 'browse/' . $branch .'/'; return $repo_info[$repo_phid]['uri'].'browse/'.$branch.'/';
} }
private function getBrowserCommand() { private function getBrowserCommand() {

View file

@ -85,8 +85,7 @@ EOTEXT
'differential.getrevision', 'differential.getrevision',
array( array(
'revision_id' => $revision_id, 'revision_id' => $revision_id,
) ));
);
} catch (Exception $ex) { } catch (Exception $ex) {
if (!$is_finalize) { if (!$is_finalize) {
throw new ArcanistUsageException( throw new ArcanistUsageException(

View file

@ -168,8 +168,7 @@ EOTEXT
} }
$flag = $conduit->callMethodSynchronous( $flag = $conduit->callMethodSynchronous(
'flag.edit', 'flag.edit',
$flag_params $flag_params);
);
self::flagWasEdited($flag, $flag['new'] ? 'created' : 'edited'); self::flagWasEdited($flag, $flag['new'] ? 'created' : 'edited');
} else { } else {
// Okay, list mode. Let's find the flags, which we didn't need to do // Okay, list mode. Let's find the flags, which we didn't need to do

View file

@ -260,8 +260,7 @@ EOTEXT
// no error means git rev-parse found a branch // no error means git rev-parse found a branch
if (!$err) { if (!$err) {
echo phutil_console_format( echo phutil_console_format(
"Branch name {$proposed_name} already exists; trying a new name.\n" "Branch name {$proposed_name} already exists; trying a new name.\n");
);
continue; continue;
} else { } else {
$branch_name = $proposed_name; $branch_name = $proposed_name;
@ -299,8 +298,8 @@ EOTEXT
// no error means hg log found a bookmark // no error means hg log found a bookmark
if (!$err) { if (!$err) {
echo phutil_console_format( echo phutil_console_format(
"Bookmark name {$proposed_name} already exists; trying a new name.\n" "Bookmark name %s already exists; trying a new name.\n",
); $proposed_name);
continue; continue;
} else { } else {
$bookmark_name = $proposed_name; $bookmark_name = $proposed_name;
@ -870,8 +869,7 @@ EOTEXT
} }
$ok = phutil_console_confirm( $ok = phutil_console_confirm(
"{$issue} Still try to apply the patch?", "{$issue} Still try to apply the patch?",
$default_no = false $default_no = false);
);
if (!$ok) { if (!$ok) {
throw new ArcanistUserAbortException(); throw new ArcanistUserAbortException();
} }
@ -931,8 +929,7 @@ EOTEXT
"This diff is against commit {$bundle_base_rev_str}, but the ". "This diff is against commit {$bundle_base_rev_str}, but the ".
"commit is nowhere in the working copy. Try to apply it against ". "commit is nowhere in the working copy. Try to apply it against ".
"the current working copy state? ({$source_base_rev_str})", "the current working copy state? ({$source_base_rev_str})",
$default_no = false $default_no = false);
);
if (!$ok) { if (!$ok) {
throw new ArcanistUserAbortException(); throw new ArcanistUserAbortException();
} }
@ -979,8 +976,7 @@ EOTEXT
'differential.query', 'differential.query',
array( array(
'commitHashes' => array($hash), 'commitHashes' => array($hash),
) ));
);
// grab the latest closed revision only // grab the latest closed revision only

View file

@ -234,8 +234,7 @@ EOTEXT
$tasks = $conduit->callMethodSynchronous( $tasks = $conduit->callMethodSynchronous(
'maniphest.find', 'maniphest.find',
$find_params $find_params);
);
return $tasks; return $tasks;
} }