Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistTextLinter.php
Context not available. | |||||
public function lintPath($path) { | public function lintPath($path) { | ||||
$this->lintEmptyFile($path); | $this->lintEmptyFile($path); | ||||
if (!strlen($this->getData($path))) { | if (!@strlen($this->getData($path))) { | ||||
// If the file is empty, don't bother; particularly, don't require | // If the file is empty, don't bother; particularly, don't require | ||||
// the user to add a newline. | // the user to add a newline. | ||||
return; | return; | ||||
Context not available. | |||||
return; | return; | ||||
default: | default: | ||||
if (strlen($filename) && $filename[0] == '.') { | if (@strlen($filename) && $filename[0] == '.') { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
if (preg_match('/^\s*$/', $data)) { | if (@preg_match('/^\s*$/', $data)) { | ||||
$this->raiseLintAtPath( | $this->raiseLintAtPath( | ||||
self::LINT_EMPTY_FILE, | self::LINT_EMPTY_FILE, | ||||
pht("Empty files usually don't serve any useful purpose.")); | pht("Empty files usually don't serve any useful purpose.")); | ||||
Context not available. | |||||
protected function lintNewlines($path) { | protected function lintNewlines($path) { | ||||
$data = $this->getData($path); | $data = $this->getData($path); | ||||
$pos = strpos($this->getData($path), "\r"); | $pos = @strpos($this->getData($path), "\r"); | ||||
if ($pos !== false) { | if ($pos !== false) { | ||||
$this->raiseLintAtOffset( | $this->raiseLintAtOffset( | ||||
Context not available. | |||||
} | } | ||||
protected function lintTabs($path) { | protected function lintTabs($path) { | ||||
$pos = strpos($this->getData($path), "\t"); | $pos = @strpos($this->getData($path), "\t"); | ||||
if ($pos !== false) { | if ($pos !== false) { | ||||
$this->raiseLintAtOffset( | $this->raiseLintAtOffset( | ||||
$pos, | $pos, | ||||
Context not available. | |||||
} | } | ||||
protected function lintLineLength($path) { | protected function lintLineLength($path) { | ||||
$lines = explode("\n", $this->getData($path)); | $lines = @explode("\n", $this->getData($path)); | ||||
$width = $this->maxLineLength; | $width = $this->maxLineLength; | ||||
foreach ($lines as $line_idx => $line) { | foreach ($lines as $line_idx => $line) { | ||||
if (strlen($line) > $width) { | if (@strlen($line) > $width) { | ||||
$this->raiseLintAtLine( | $this->raiseLintAtLine( | ||||
$line_idx + 1, | $line_idx + 1, | ||||
1, | 1, | ||||
Context not available. | |||||
pht( | pht( | ||||
'This line is %s characters long, but the '. | 'This line is %s characters long, but the '. | ||||
'convention is %s characters.', | 'convention is %s characters.', | ||||
new PhutilNumber(strlen($line)), | new PhutilNumber(@strlen($line)), | ||||
$width), | $width), | ||||
$line); | $line); | ||||
} | } | ||||
Context not available. | |||||
protected function lintEOFNewline($path) { | protected function lintEOFNewline($path) { | ||||
$data = $this->getData($path); | $data = $this->getData($path); | ||||
if (!strlen($data) || $data[strlen($data) - 1] != "\n") { | if (!@strlen($data) || $data[@strlen($data) - 1] != "\n") { | ||||
$this->raiseLintAtOffset( | $this->raiseLintAtOffset( | ||||
strlen($data), | @strlen($data), | ||||
self::LINT_EOF_NEWLINE, | self::LINT_EOF_NEWLINE, | ||||
pht('Files must end in a newline.'), | pht('Files must end in a newline.'), | ||||
'', | '', | ||||
Context not available. | |||||
$data = $this->getData($path); | $data = $this->getData($path); | ||||
$matches = null; | $matches = null; | ||||
$preg = preg_match( | $preg = @preg_match( | ||||
'/^\s*\n/', | '/^\s*\n/', | ||||
$data, | $data, | ||||
$matches, | $matches, | ||||
Context not available. | |||||
$data = $this->getData($path); | $data = $this->getData($path); | ||||
$matches = null; | $matches = null; | ||||
$preg = preg_match( | $preg = @preg_match( | ||||
'/(?<=\n)\s+$/', | '/(?<=\n)\s+$/', | ||||
$data, | $data, | ||||
$matches, | $matches, | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0