From d3afa9cc31d182b7673955ffdfa19bf29d549b3e Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 21 Nov 2012 17:16:52 -0800 Subject: [PATCH] Fix some arcanist warnings Summary: - Rename some very old variables. - Wrap some contributed lines. Test Plan: `arc lint` / `arc unit`. Viewed a diff in an uncacheable mode to verify intraline behavior. Reviewers: vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D4018 --- src/difference/ArcanistDiffUtils.php | 32 +++++++++++----------- src/lint/linter/ArcanistJSHintLinter.php | 18 ++++++++---- src/lint/linter/ArcanistPyFlakesLinter.php | 4 ++- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/difference/ArcanistDiffUtils.php b/src/difference/ArcanistDiffUtils.php index 38207ff5..4006235e 100644 --- a/src/difference/ArcanistDiffUtils.php +++ b/src/difference/ArcanistDiffUtils.php @@ -242,10 +242,10 @@ final class ArcanistDiffUtils { $m = array_fill(0, $ol + 1, array_fill(0, $nl + 1, array())); - $T_D = 'd'; - $T_I = 'i'; - $T_S = 's'; - $T_X = 'x'; + $t_d = 'd'; + $t_i = 'i'; + $t_s = 's'; + $t_x = 'x'; $m[0][0] = array( 0, @@ -254,13 +254,13 @@ final class ArcanistDiffUtils { for ($ii = 1; $ii <= $ol; $ii++) { $m[$ii][0] = array( $ii * 1000, - $T_D); + $t_d); } for ($jj = 1; $jj <= $nl; $jj++) { $m[0][$jj] = array( $jj * 1000, - $T_I); + $t_i); } $ii = 1; @@ -269,10 +269,10 @@ final class ArcanistDiffUtils { do { if ($o[$ii - 1] == $n[$jj - 1]) { $sub_t_cost = $m[$ii - 1][$jj - 1][0] + 0; - $sub_t = $T_S; + $sub_t = $t_s; } else { $sub_t_cost = $m[$ii - 1][$jj - 1][0] + 2000; - $sub_t = $T_X; + $sub_t = $t_x; } if ($m[$ii - 1][$jj - 1][1] != $sub_t) { @@ -280,12 +280,12 @@ final class ArcanistDiffUtils { } $del_t_cost = $m[$ii - 1][$jj][0] + 1000; - if ($m[$ii - 1][$jj][1] != $T_D) { + if ($m[$ii - 1][$jj][1] != $t_d) { $del_t_cost += 1; } $ins_t_cost = $m[$ii][$jj - 1][0] + 1000; - if ($m[$ii][$jj - 1][1] != $T_I) { + if ($m[$ii][$jj - 1][1] != $t_i) { $ins_t_cost += 1; } @@ -296,11 +296,11 @@ final class ArcanistDiffUtils { } else if ($ins_t_cost <= $del_t_cost) { $m[$ii][$jj] = array( $ins_t_cost, - $T_I); + $t_i); } else { $m[$ii][$jj] = array( $del_t_cost, - $T_D); + $t_d); } } while ($jj++ < $nl); } while ($ii++ < $ol); @@ -312,15 +312,15 @@ final class ArcanistDiffUtils { $r = $m[$ii][$jj][1]; $result .= $r; switch ($r) { - case $T_S: - case $T_X: + case $t_s: + case $t_x: $ii--; $jj--; break; - case $T_I: + case $t_i: $jj--; break; - case $T_D: + case $t_d: $ii--; break; } diff --git a/src/lint/linter/ArcanistJSHintLinter.php b/src/lint/linter/ArcanistJSHintLinter.php index e01e43cd..7aa9c561 100644 --- a/src/lint/linter/ArcanistJSHintLinter.php +++ b/src/lint/linter/ArcanistJSHintLinter.php @@ -62,12 +62,14 @@ final class ArcanistJSHintLinter extends ArcanistLinter { $config = $working_copy->getConfig('lint.jshint.config'); if ($config !== null) { - $config = Filesystem::resolvePath($config, $working_copy->getProjectRoot()); + $config = Filesystem::resolvePath( + $config, + $working_copy->getProjectRoot()); if (!Filesystem::pathExists($config)) { throw new ArcanistUsageException( - "Unable to find custom options file defined by 'lint.jshint.config'. ". - "Make sure that the path is correct."); + "Unable to find custom options file defined by ". + "'lint.jshint.config'. Make sure that the path is correct."); } $options .= ' --config '.$config; @@ -92,8 +94,8 @@ final class ArcanistJSHintLinter extends ArcanistLinter { throw new ArcanistUsageException( "Unable to find JSHint binary in a specified directory. Make sure ". "that 'lint.jshint.prefix' and 'lint.jshint.bin' keys are set ". - "correctly. If you'd rather use a copy of JSHint installed globally, ". - "you can just remove these keys from your .arcconfig"); + "correctly. If you'd rather use a copy of JSHint installed ". + "globally, you can just remove these keys from your .arcconfig"); } return $bin; @@ -120,7 +122,11 @@ final class ArcanistJSHintLinter extends ArcanistLinter { foreach ($paths as $path) { $filepath = $this->getEngine()->getFilePathOnDisk($path); - $futures[$path] = new ExecFuture("{$jshint_bin} {$filepath} ${jshint_options}"); + $futures[$path] = new ExecFuture( + "%s %s %C", + $jshint_bin, + $filepath, + $jshint_options); } foreach (Futures($futures)->limit(8) as $path => $future) { diff --git a/src/lint/linter/ArcanistPyFlakesLinter.php b/src/lint/linter/ArcanistPyFlakesLinter.php index 87054330..7f9bb842 100644 --- a/src/lint/linter/ArcanistPyFlakesLinter.php +++ b/src/lint/linter/ArcanistPyFlakesLinter.php @@ -87,7 +87,9 @@ final class ArcanistPyFlakesLinter extends ArcanistLinter { $severity = ArcanistLintSeverity::SEVERITY_WARNING; $description = $matches[3]; - if (preg_match('/(^undefined|^duplicate|before assignment$)/', $description)) { + + $error_regexp = '/(^undefined|^duplicate|before assignment$)/'; + if (preg_match($error_regexp, $description)) { $severity = ArcanistLintSeverity::SEVERITY_ERROR; } -- 2.43.0