mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-25 14:08:18 +01:00
edd85a0e9d
Summary: The only real change here is adding a `getLinterConfigurationName` method so that this linter can be used with an `.arclint` file. Everything else is just some minor tidying. Test Plan: N/A Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9039
50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Checks files for unresolved merge conflicts.
|
|
*
|
|
* @group linter
|
|
*/
|
|
final class ArcanistMergeConflictLinter extends ArcanistLinter {
|
|
const LINT_MERGECONFLICT = 1;
|
|
|
|
public function getLinterName() {
|
|
return 'MERGECONFLICT';
|
|
}
|
|
|
|
public function getLinterConfigurationName() {
|
|
return 'merge-conflict';
|
|
}
|
|
|
|
public function willLintPaths(array $paths) {
|
|
return;
|
|
}
|
|
|
|
public function lintPath($path) {
|
|
$lines = phutil_split_lines($this->getData($path), false);
|
|
|
|
foreach ($lines as $lineno => $line) {
|
|
// An unresolved merge conflict will contain a series of seven
|
|
// '<', '=', or '>'.
|
|
if (preg_match('/^(>{7}|<{7}|={7})$/', $line)) {
|
|
$this->raiseLintAtLine(
|
|
$lineno + 1,
|
|
0,
|
|
self::LINT_MERGECONFLICT,
|
|
'This syntax indicates there is an unresolved merge conflict.');
|
|
}
|
|
}
|
|
}
|
|
|
|
public function getLintSeverityMap() {
|
|
return array(
|
|
self::LINT_MERGECONFLICT => ArcanistLintSeverity::SEVERITY_ERROR,
|
|
);
|
|
}
|
|
|
|
public function getLintNameMap() {
|
|
return array(
|
|
self::LINT_MERGECONFLICT => 'Unresolved merge conflict',
|
|
);
|
|
}
|
|
}
|