From da206314cf59f71334b187283e18823bddc16ddd Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 25 Apr 2022 12:49:46 -0700 Subject: [PATCH] Catch more product names in "pht()", and replace newly matched Arcanist product names Summary: Ref T13658. The lint rule called "getStringLiteralValue()", which produces string literals for fewer nodes than "evalStatic()". Switch to "evalStatic()", then fix new warnings. Test Plan: This test plan is non-exhaustive. - Ran "arc lint --everything --output summary" to generate new warnings. Maniphest Tasks: T13658 Differential Revision: https://secure.phabricator.com/D21776 --- src/__tests__/PhutilLibraryTestCase.php | 4 ++-- src/configuration/ArcanistSettings.php | 19 +++++++++---------- .../ArcanistDifferentialCommitMessage.php | 4 ++-- src/lint/linter/ArcanistCSharpLinter.php | 8 ++++---- .../linter/ArcanistPhutilLibraryLinter.php | 6 ++++-- ...nistProductNameLiteralXHPASTLinterRule.php | 2 +- src/runtime/ArcanistRuntime.php | 18 +++++++++--------- src/unit/engine/PhutilUnitTestEngine.php | 14 ++++++-------- src/workflow/ArcanistPatchWorkflow.php | 4 ++-- src/workflow/ArcanistUpgradeWorkflow.php | 6 +++--- 10 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/__tests__/PhutilLibraryTestCase.php b/src/__tests__/PhutilLibraryTestCase.php index 0e5c6261..ba849a52 100644 --- a/src/__tests__/PhutilLibraryTestCase.php +++ b/src/__tests__/PhutilLibraryTestCase.php @@ -125,8 +125,8 @@ class PhutilLibraryTestCase extends PhutilTestCase { $failures[] = pht( 'Class "%s" implements method "%s" with the wrong visibility. '. 'The method has visibility "%s", but it is defined in parent '. - '"%s" with visibility "%s". In Phabricator, a method which '. - 'overrides another must always have the same visibility.', + '"%s" with visibility "%s". A method which overrides another '. + 'must always have the same visibility.', $class_name, $method_name, $this->getVisibility($method), diff --git a/src/configuration/ArcanistSettings.php b/src/configuration/ArcanistSettings.php index 67081703..8f67bf7e 100644 --- a/src/configuration/ArcanistSettings.php +++ b/src/configuration/ArcanistSettings.php @@ -7,11 +7,11 @@ final class ArcanistSettings extends Phobject { 'default' => array( 'type' => 'string', 'help' => pht( - 'The URI of a Phabricator install to connect to by default, if '. - '%s is run in a project without a Phabricator URI or run outside '. + 'The URI of a server to connect to by default, if '. + '%s is run in a project without a configured URI or run outside '. 'of a project.', 'arc'), - 'example' => '"http://phabricator.example.com/"', + 'example' => '"http://devtools.example.com/"', ), 'base' => array( 'type' => 'string', @@ -35,7 +35,7 @@ final class ArcanistSettings extends Phobject { 'type' => 'string', 'example' => '"X"', 'help' => pht( - 'Associate the working copy with a specific Phabricator repository. '. + 'Associate the working copy with a specific repository. '. 'Normally, %s can figure this association out on its own, but if '. 'your setup is unusual you can use this option to tell it what the '. 'desired value is.', @@ -44,10 +44,9 @@ final class ArcanistSettings extends Phobject { 'phabricator.uri' => array( 'type' => 'string', 'legacy' => 'conduit_uri', - 'example' => '"https://phabricator.mycompany.com/"', + 'example' => '"https://devtools.example.com/"', 'help' => pht( - 'Associates this working copy with a specific installation of '. - 'Phabricator.'), + 'Associates this working copy with a specific server.'), ), 'lint.engine' => array( 'type' => 'string', @@ -96,8 +95,8 @@ final class ArcanistSettings extends Phobject { 'https.cabundle' => array( 'type' => 'string', 'help' => pht( - "Path to a custom CA bundle file to be used for arcanist's cURL ". - "calls. This is used primarily when your conduit endpoint is ". + "Path to a custom CA bundle file to be used for cURL calls. ". + "This is used primarily when your conduit endpoint is ". "behind HTTPS signed by your organization's internal CA."), 'example' => 'support/yourca.pem', ), @@ -118,7 +117,7 @@ final class ArcanistSettings extends Phobject { 'Whether %s should permit the automatic stashing of changes in the '. 'working directory when requiring a clean working copy. This option '. 'should only be used when users understand how to restore their '. - 'working directory from the local stash if an Arcanist operation '. + 'working directory from the local stash if an operation '. 'causes an unrecoverable error.', 'arc'), 'default' => false, diff --git a/src/differential/ArcanistDifferentialCommitMessage.php b/src/differential/ArcanistDifferentialCommitMessage.php index 912ee4be..cada4895 100644 --- a/src/differential/ArcanistDifferentialCommitMessage.php +++ b/src/differential/ArcanistDifferentialCommitMessage.php @@ -139,10 +139,10 @@ final class ArcanistDifferentialCommitMessage extends Phobject { throw new ArcanistUsageException( pht( 'Invalid "Differential Revision" field in commit message. This field '. - 'should have a revision identifier like "%s" or a Phabricator URI '. + 'should have a revision identifier like "%s" or a server URI '. 'like "%s", but has "%s".', 'D123', - 'https://phabricator.example.com/D123', + 'https://devtools.example.com/D123', $revision_value)); } diff --git a/src/lint/linter/ArcanistCSharpLinter.php b/src/lint/linter/ArcanistCSharpLinter.php index 6120a07b..e2b00b5a 100644 --- a/src/lint/linter/ArcanistCSharpLinter.php +++ b/src/lint/linter/ArcanistCSharpLinter.php @@ -64,11 +64,11 @@ final class ArcanistCSharpLinter extends ArcanistLinter { throw new Exception( pht( "In order to keep StyleCop integration with IDEs and other tools ". - "consistent with Arcanist results, you aren't permitted to ". + "consistent with lint results, you aren't permitted to ". "disable StyleCop rules within '%s'. Instead configure the ". "severity using the StyleCop settings dialog (usually accessible ". "from within your IDE). StyleCop settings for your project will ". - "be used when linting for Arcanist.", + "be used when linting.", '.arclint')); } } @@ -132,8 +132,8 @@ final class ArcanistCSharpLinter extends ArcanistLinter { } else if ($ver > self::SUPPORTED_VERSION) { throw new Exception( pht( - 'Arcanist does not support this version of %s (it is newer). '. - 'You can try upgrading Arcanist with `%s`.', + 'This version of %s is not supported (it is too new). '. + 'You can try upgrading with `%s`.', 'cslint', 'arc upgrade')); } diff --git a/src/lint/linter/ArcanistPhutilLibraryLinter.php b/src/lint/linter/ArcanistPhutilLibraryLinter.php index 3cef927b..955e2073 100644 --- a/src/lint/linter/ArcanistPhutilLibraryLinter.php +++ b/src/lint/linter/ArcanistPhutilLibraryLinter.php @@ -304,9 +304,9 @@ final class ArcanistPhutilLibraryLinter extends ArcanistLinter { $details = pht( "Common causes are:\n". "\n". - " - Your copy of Arcanist is out of date.\n". + " - Your copy of %s is out of date.\n". " This is the most common cause.\n". - " Update this copy of Arcanist:\n". + " Update this copy of %s:\n". "\n". " %s\n". "\n". @@ -324,6 +324,8 @@ final class ArcanistPhutilLibraryLinter extends ArcanistLinter { " - This symbol is defined in an external library.\n". " Use \"@phutil-external-symbol\" to annotate it.\n". " Use \"grep\" to find examples of usage.", + PlatformSymbols::getPlatformClientName(), + PlatformSymbols::getPlatformClientName(), $arcanist_root); $message = implode( diff --git a/src/lint/linter/xhpast/rules/ArcanistProductNameLiteralXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistProductNameLiteralXHPASTLinterRule.php index 70b57486..20f3e453 100644 --- a/src/lint/linter/xhpast/rules/ArcanistProductNameLiteralXHPASTLinterRule.php +++ b/src/lint/linter/xhpast/rules/ArcanistProductNameLiteralXHPASTLinterRule.php @@ -41,7 +41,7 @@ final class ArcanistProductNameLiteralXHPASTLinterRule continue; } - $literal_value = $identifier->getStringLiteralValue(); + $literal_value = $identifier->evalStatic(); $matches = phutil_preg_match_all($search_pattern, $literal_value); if (!$matches[0]) { diff --git a/src/runtime/ArcanistRuntime.php b/src/runtime/ArcanistRuntime.php index 35099b2c..8e3d220f 100644 --- a/src/runtime/ArcanistRuntime.php +++ b/src/runtime/ArcanistRuntime.php @@ -270,9 +270,9 @@ final class ArcanistRuntime { $problems[] = sprintf( 'The build of PHP you are running was compiled with the configure '. 'flag "%s", which means it does not support the function "%s()". '. - 'This function is required for Arcanist to run. Install a standard '. - 'build of PHP or rebuild it without this flag. You may also be '. - 'able to build or install the relevant extension separately.', + 'This function is required for this software to run. Install a '. + 'standard build of PHP or rebuild it without this flag. You may '. + 'also be able to build or install the relevant extension separately.', $which, $fname); continue; @@ -477,8 +477,8 @@ final class ArcanistRuntime { $log->writeWarn( pht('VERY META'), pht( - 'You are running one copy of Arcanist (at path "%s") against '. - 'another copy of Arcanist (at path "%s"). Code in the current '. + 'You are running one copy of this software (at path "%s") against '. + 'another copy of this software (at path "%s"). Code in the current '. 'working directory will not be loaded or executed.', $executing_directory, $working_directory)); @@ -519,10 +519,10 @@ final class ArcanistRuntime { if (!isset($toolsets[$binary])) { throw new PhutilArgumentUsageException( pht( - 'Arcanist toolset "%s" is unknown. The Arcanist binary should '. - 'be executed so that "argv[0]" identifies a supported toolset. '. - 'Rename the binary or install the library that provides the '. - 'desired toolset. Current available toolsets: %s.', + 'Toolset "%s" is unknown. The binary should be executed so that '. + '"argv[0]" identifies a supported toolset. Rename the binary or '. + 'install the library that provides the desired toolset. Current '. + 'available toolsets: %s.', $binary, implode(', ', array_keys($toolsets)))); } diff --git a/src/unit/engine/PhutilUnitTestEngine.php b/src/unit/engine/PhutilUnitTestEngine.php index 42481434..dc88db4a 100644 --- a/src/unit/engine/PhutilUnitTestEngine.php +++ b/src/unit/engine/PhutilUnitTestEngine.php @@ -170,16 +170,14 @@ final class PhutilUnitTestEngine extends ArcanistUnitTestEngine { if (!$library_name) { throw new Exception( pht( - "Attempting to run unit tests on a libphutil library which has ". + "Attempting to run unit tests on a library which has ". "not been loaded, at:\n\n". " %s\n\n". - "This probably means one of two things:\n\n". - " - You may need to add this library to %s.\n". - " - You may be running tests on a copy of libphutil or ". - "arcanist using a different copy of libphutil or arcanist. ". - "This operation is not supported.\n", - $library_root, - '.arcconfig.')); + "Make sure this library is configured to load.\n\n". + "(In rare cases, this may be because you are attempting to run ". + "one copy of this software against a different copy of this ". + "software. This operation is not supported.)", + $library_root)); } $path = Filesystem::resolvePath($path, $root); diff --git a/src/workflow/ArcanistPatchWorkflow.php b/src/workflow/ArcanistPatchWorkflow.php index 66d5c32c..acfb06ee 100644 --- a/src/workflow/ArcanistPatchWorkflow.php +++ b/src/workflow/ArcanistPatchWorkflow.php @@ -890,8 +890,8 @@ EOTEXT 'revision_id' => $revision_id, )); $prompt_message = pht( - ' Note arcanist failed to load the commit message '. - 'from differential for revision %s.', + ' NOTE: Failed to load the commit message from Differential (for '. + 'revision "%s".)', "D{$revision_id}"); } diff --git a/src/workflow/ArcanistUpgradeWorkflow.php b/src/workflow/ArcanistUpgradeWorkflow.php index 2013a201..14f45af9 100644 --- a/src/workflow/ArcanistUpgradeWorkflow.php +++ b/src/workflow/ArcanistUpgradeWorkflow.php @@ -51,9 +51,9 @@ EOTEXT if (!$is_git) { throw new PhutilArgumentUsageException( pht( - 'The "arc upgrade" workflow uses "git pull" to upgrade, but '. - 'the "arcanist/" directory (in "%s") is not a Git working '. - 'copy. You must leave "arcanist/" as a Git working copy to '. + 'The "upgrade" workflow uses "git pull" to upgrade, but '. + 'the software directory (in "%s") is not a Git working '. + 'copy. You must leave this directory as a Git working copy to '. 'use "arc upgrade".', $root)); }