diff --git a/arcanist/linter/StdintLinter.php b/arcanist/linter/StdintLinter.php index d7bd7581b..fac3c451a 100644 --- a/arcanist/linter/StdintLinter.php +++ b/arcanist/linter/StdintLinter.php @@ -1,57 +1,70 @@ array(self::UNSIGNED_CHAR_FOUND, 'uint8_t'), + 'unsigned short' => array(self::UNSIGNED_SHORT_FOUND, 'uint16_t'), + ); public function getInfoName() { return 'lint-stdint'; } public function getInfoDescription() { return pht('Replace native type by there stdint equivalent when needed.'); } public function getLinterName() { return 'STDINT'; } public function getLinterConfigurationName() { return 'lint-stdint'; } public function getLintSeverityMap() { return array( self::UNSIGNED_CHAR_FOUND => ArcanistLintSeverity::SEVERITY_WARNING, + self::UNSIGNED_SHORT_FOUND => ArcanistLintSeverity::SEVERITY_WARNING, ); } public function getLintNameMap() { return array( self::UNSIGNED_CHAR_FOUND => pht('`uint8_t should be preferred over '. '`unsigned char``.'), + self::UNSIGNED_SHORT_FOUND => pht('`uint16_t should be preferred over '. + '`unsigned short``.'), ); } public function lintPath($path) { $abspath = Filesystem::resolvePath($path, $this->getProjectRoot()); $fileContent = Filesystem::readFile($abspath); - if (preg_match_all('/unsigned char/', $fileContent, $matches, + if (preg_match_all('/unsigned (?:char|short)/', $fileContent, $matches, PREG_OFFSET_CAPTURE)) { foreach ($matches[0] as $match) { - list($unsignedChar, $offset) = $match; + list($unsignedType, $offset) = $match; + list($errorCode, $replacement) = self::TYPE_MAPPING[$unsignedType]; $this->raiseLintAtOffset( $offset, - self::UNSIGNED_CHAR_FOUND, - pht('`uint8_t should be preferred over `unsigned char`'), - $unsignedChar, - 'uint8_t'); + $errorCode, + pht( + '`'.$replacement.'` should be preferred over `'.$unsignedType.'`'), + $unsignedType, + $replacement, + ); } } } }