Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15483925
D11330.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D11330.diff
View Options
diff --git a/src/lint/linter/ArcanistPhutilLibraryLinter.php b/src/lint/linter/ArcanistPhutilLibraryLinter.php
--- a/src/lint/linter/ArcanistPhutilLibraryLinter.php
+++ b/src/lint/linter/ArcanistPhutilLibraryLinter.php
@@ -20,26 +20,32 @@
public function getInfoDescription() {
return pht(
- 'Make sure all the symbols use in a libphutil library are defined and '.
- 'known. This linter is specific to PHP source in libphutil libraries.');
+ 'Make sure all the symbols used in a %s library are defined and known. '.
+ 'This linter is specific to PHP source in %s libraries.',
+ 'libphutil',
+ 'libphutil');
+ }
+
+ public function getLinterName() {
+ return 'PHL';
}
public function getLinterConfigurationName() {
return 'phutil-library';
}
+ public function getCacheGranularity() {
+ return self::GRANULARITY_GLOBAL;
+ }
+
public function getLintNameMap() {
return array(
- self::LINT_UNKNOWN_SYMBOL => pht('Unknown Symbol'),
- self::LINT_DUPLICATE_SYMBOL => pht('Duplicate Symbol'),
- self::LINT_ONE_CLASS_PER_FILE => pht('One Class Per File'),
+ self::LINT_UNKNOWN_SYMBOL => pht('Unknown Symbol'),
+ self::LINT_DUPLICATE_SYMBOL => pht('Duplicate Symbol'),
+ self::LINT_ONE_CLASS_PER_FILE => pht('One Class Per File'),
);
}
- public function getLinterName() {
- return 'PHL';
- }
-
public function getLinterPriority() {
return 2.0;
}
@@ -55,18 +61,19 @@
// caches.
$bootloader = PhutilBootloader::getInstance();
- $libs = $bootloader->getAllLibraries();
+ $libraries = $bootloader->getAllLibraries();
// Load the up-to-date map for each library, without loading the library
// itself. This means lint results will accurately reflect the state of
// the working copy.
$symbols = array();
- foreach ($libs as $lib) {
- $root = phutil_get_library_root($lib);
+
+ foreach ($libraries as $library) {
+ $root = phutil_get_library_root($library);
try {
- $symbols[$lib] = id(new PhutilLibraryMapBuilder($root))
+ $symbols[$library] = id(new PhutilLibraryMapBuilder($root))
->buildFileSymbolMap();
} catch (XHPASTSyntaxErrorException $ex) {
// If the library contains a syntax error then there isn't much that we
@@ -97,10 +104,13 @@
$file,
end($have_functions),
self::LINT_ONE_CLASS_PER_FILE,
- "File '{$file}' mixes function ({$function_list}) and ".
- "class/interface ({$class_list}) definitions in the same file. ".
- "A file which declares a class or an interface MUST ".
- "declare nothing else.");
+ pht(
+ "File '%s' mixes function (%s) and class/interface (%s) ".
+ "definitions in the same file. A file which declares a class ".
+ "or an interface MUST declare nothing else.",
+ $file,
+ $function_list,
+ $class_list));
} else if (count($have_classes) > 1) {
$class_list = implode(', ', array_keys($have_classes));
$this->raiseLintInLibrary(
@@ -108,9 +118,12 @@
$file,
end($have_classes),
self::LINT_ONE_CLASS_PER_FILE,
- "File '{$file}' declares more than one class or interface ".
- "({$class_list}). A file which declares a class or interface MUST ".
- "declare nothing else.");
+ pht(
+ "File '%s' declares more than one class or interface (%s). ".
+ "A file which declares a class or interface MUST declare ".
+ "nothing else.",
+ $file,
+ $class_list));
}
}
@@ -138,9 +151,15 @@
$file,
$offset,
self::LINT_DUPLICATE_SYMBOL,
- "Definition of {$type} '{$symbol}' in '{$file}' in library ".
- "'{$library}' duplicates prior definition in '{$osrc}' in ".
- "library '{$olib}'.");
+ pht(
+ "Definition of %s '%s' in '%s' in library '%s' duplicates ".
+ "prior definition in '%s' in library '%s'.",
+ $type,
+ $symbol,
+ $file,
+ $library,
+ $osrc,
+ $olib));
}
}
}
@@ -171,26 +190,29 @@
$file,
$offset,
self::LINT_UNKNOWN_SYMBOL,
- "Use of unknown {$type} '{$symbol}'. Common causes are:\n\n".
- " - Your libphutil/ is out of date.\n".
- " This is the most common cause.\n".
- " Update this copy of libphutil: {$libphutil_root}\n".
- "\n".
- " - Some other library is out of date.\n".
- " Update the library this symbol appears in.\n".
- "\n".
- " - This symbol is misspelled.\n".
- " Spell the symbol name correctly.\n".
- " Symbol name spelling is case-sensitive.\n".
- "\n".
- " - This symbol was added recently.\n".
- " Run `arc liberate` on the library it was added to.\n".
- "\n".
- " - This symbol is external. Use `@phutil-external-symbol`.\n".
- " Use `grep` to find usage examples of this directive.\n".
- "\n".
- "*** ALTHOUGH USUALLY EASY TO FIX, THIS IS A SERIOUS ERROR.\n".
- "*** THIS ERROR IS YOUR FAULT. YOU MUST RESOLVE IT.");
+ pht(
+ "Use of unknown %s '%s'. Common causes are:\n\n".
+ " - Your %s is out of date.\n".
+ " This is the most common cause.\n".
+ " Update this copy of libphutil: %s\n\n".
+ " - Some other library is out of date.\n".
+ " Update the library this symbol appears in.\n\n".
+ " - This symbol is misspelled.\n".
+ " Spell the symbol name correctly.\n".
+ " Symbol name spelling is case-sensitive.\n\n".
+ " - This symbol was added recently.\n".
+ " Run `%s` on the library it was added to.\n\n".
+ " - This symbol is external. Use `%s`.\n".
+ " Use `%s` to find usage examples of this directive.\n\n".
+ "*** ALTHOUGH USUALLY EASY TO FIX, THIS IS A SERIOUS ERROR.\n".
+ "*** THIS ERROR IS YOUR FAULT. YOU MUST RESOLVE IT.",
+ $type,
+ $symbol,
+ 'libphutil/',
+ $libphutil_root,
+ 'arc liberate',
+ '@phutil-external-symbol',
+ 'grep'));
}
}
}
@@ -208,8 +230,4 @@
return;
}
- public function getCacheGranularity() {
- return self::GRANULARITY_GLOBAL;
- }
-
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 10, 3:21 PM (6 d, 6 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7571619
Default Alt Text
D11330.diff (6 KB)
Attached To
Mode
D11330: Minor tidying of `ArcanistPhutilLibraryLinter`
Attached
Detach File
Event Timeline
Log In to Comment