Changeset View
Changeset View
Standalone View
Standalone View
arcanist/linter/CheckNonFatalOverAssertInRpc.php
Show All 39 Lines | return array( | ||||
pht('Use CHECK_NONFATAL(condition) over assert(condition) in RPC code.'), | pht('Use CHECK_NONFATAL(condition) over assert(condition) in RPC code.'), | ||||
); | ); | ||||
} | } | ||||
public function lintPath($path) { | public function lintPath($path) { | ||||
$absPath = Filesystem::resolvePath($path, $this->getProjectRoot()); | $absPath = Filesystem::resolvePath($path, $this->getProjectRoot()); | ||||
$fileContent = Filesystem::readFile($absPath); | $fileContent = Filesystem::readFile($absPath); | ||||
if (!preg_match_all("/(assert\((.*)\);)/", $fileContent, | if (!preg_match_all("/((A|a)ssert\((.*)\);)/", $fileContent, | ||||
$matches, PREG_OFFSET_CAPTURE)) { | $matches, PREG_OFFSET_CAPTURE)) { | ||||
return; | return; | ||||
} | } | ||||
foreach ($matches[1] as $match) { | foreach ($matches[1] as $match) { | ||||
list($cpp, $offset) = $match; | list($cpp, $offset) = $match; | ||||
$this->raiseLintAtOffset( | $this->raiseLintAtOffset( | ||||
$offset, | $offset, | ||||
self::BAD_ASSERT_IN_RPC, | self::BAD_ASSERT_IN_RPC, | ||||
pht(self::RATIONALE_MSG), | pht(self::RATIONALE_MSG), | ||||
$cpp, | $cpp, | ||||
null); | null); | ||||
} | } | ||||
} | } | ||||
} | } |