1<?php 2 3/** 4 * Stifles creativity in choosing imaginative file names. 5 */ 6final class ArcanistFilenameLinter extends ArcanistLinter { 7 8 const LINT_BAD_FILENAME = 1; 9 10 public function getInfoName() { 11 return pht('Filename'); 12 } 13 14 public function getInfoDescription() { 15 return pht( 16 'Stifles developer creativity by requiring files have uninspired names '. 17 'containing only letters, numbers, period, hyphen and underscore.'); 18 } 19 20 public function getLinterName() { 21 return 'NAME'; 22 } 23 24 public function getLinterConfigurationName() { 25 return 'filename'; 26 } 27 28 protected function shouldLintBinaryFiles() { 29 return true; 30 } 31 32 public function getLintNameMap() { 33 return array( 34 self::LINT_BAD_FILENAME => pht('Bad Filename'), 35 ); 36 } 37 38 public function lintPath($path) { 39 if (!preg_match('@^[a-z0-9./\\\\_-]+$@i', $path)) { 40 $this->raiseLintAtPath( 41 self::LINT_BAD_FILENAME, 42 pht( 43 'Name files using only letters, numbers, period, hyphen and '. 44 'underscore.')); 45 } 46 } 47 48 protected function shouldLintDirectories() { 49 return true; 50 } 51 52 protected function shouldLintSymbolicLinks() { 53 return true; 54 } 55 56} 57