diff --git a/arcanist/linter/FileNameLinter.php b/arcanist/linter/FileNameLinter.php index b0ce8401d..ea7a8bc36 100644 --- a/arcanist/linter/FileNameLinter.php +++ b/arcanist/linter/FileNameLinter.php @@ -1,51 +1,60 @@ ArcanistLintSeverity::SEVERITY_ERROR, ); } public function getLintNameMap() { return array( self::INVALID_FILENAME_FOUND => pht('The file name violates the naming '. 'conventions'), ); } public function lintPath($path) { + // If file is in the exception list, let it go + if (in_array($path, self::EXCEPTIONS)) { + return; + } + $abspath = Filesystem::resolvePath($path, $this->getProjectRoot()); $fileContent = Filesystem::readFile($abspath); if(preg_match('/[^a-z0-9_-]/', pathinfo($path, PATHINFO_FILENAME))) { $this->raiseLintAtPath( self::INVALID_FILENAME_FOUND, pht('Source code file names should only contain [a-z0-9_-] chars (see '. 'doc/developer-notes.md).')); } } } diff --git a/arcanist/linter/IncludeGuardLinter.php b/arcanist/linter/IncludeGuardLinter.php index 849157552..17e617932 100644 --- a/arcanist/linter/IncludeGuardLinter.php +++ b/arcanist/linter/IncludeGuardLinter.php @@ -1,72 +1,81 @@ ArcanistLintSeverity::SEVERITY_ERROR, ); } public function getLintNameMap() { return array( self::INCLUDE_GUARD_INVALID => pht('Include guard malformed or missing.'), ); } public function lintPath($path) { + // If file is in list of exceptions, let it go + if (in_array($path, self::EXCEPTIONS)) { + return; + } + $abspath = Filesystem::resolvePath($path, $this->getProjectRoot()); $fileContent = Filesystem::readFile($abspath); $pathInfo = pathinfo($path); // Get the path components. They are relative to project root. $guard = explode('/', $pathInfo['dirname']); // Add the file name (without extension) to the path components. $guard[] = $pathInfo['filename']; // Skip the upper 'src' directory $guard = array_slice($guard, 1); // Join to a string using an underscore ('_') as the delimiter. $guard = implode('_', $guard); // Transform the whole string to uppercase. $guard = strtoupper($guard); // Surround with prefix and suffix. $guard = self::GUARD_PREFIX.$guard.self::GUARD_SUFFIX; if (preg_match_all('@#(?:ifndef|define|endif //) '.$guard.'@', $fileContent) != 3) { return $this->raiseLintAtPath( self::INCLUDE_GUARD_INVALID, pht("Include guard is malformed or missing. Expected format:\n". "\t#ifndef %s\n". "\t#define %s\n". "\t...\n". "\t#endif // %s", $guard, $guard, $guard)); } } }