2011-01-09 15:22:25 -08:00
|
|
|
<?php
|
|
|
|
|
2011-02-19 11:36:08 -08:00
|
|
|
/**
|
|
|
|
* Stifles creativity in choosing imaginative file names.
|
|
|
|
*
|
|
|
|
* @group linter
|
|
|
|
*/
|
2012-01-31 12:07:05 -08:00
|
|
|
final class ArcanistFilenameLinter extends ArcanistLinter {
|
2011-01-09 15:22:25 -08:00
|
|
|
|
|
|
|
const LINT_BAD_FILENAME = 1;
|
|
|
|
|
|
|
|
public function willLintPaths(array $paths) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinterName() {
|
|
|
|
return 'NAM';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLintSeverityMap() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLintNameMap() {
|
|
|
|
return array(
|
|
|
|
self::LINT_BAD_FILENAME => 'Bad Filename',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function lintPath($path) {
|
2012-05-24 10:13:20 +02:00
|
|
|
if (!preg_match('@^[a-z0-9./\\\\_-]+$@i', $path)) {
|
2011-01-09 15:22:25 -08:00
|
|
|
$this->raiseLintAtPath(
|
|
|
|
self::LINT_BAD_FILENAME,
|
|
|
|
'Name files using only letters, numbers, period, hyphen and '.
|
|
|
|
'underscore.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|