2013-02-20 23:19:55 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks files for unresolved merge conflicts.
|
|
|
|
*/
|
|
|
|
final class ArcanistMergeConflictLinter extends ArcanistLinter {
|
2014-05-12 01:16:45 +02:00
|
|
|
|
2013-02-20 23:19:55 +01:00
|
|
|
const LINT_MERGECONFLICT = 1;
|
|
|
|
|
2014-05-12 01:16:45 +02:00
|
|
|
public function getInfoName() {
|
|
|
|
return pht('Merge Conflicts');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInfoDescription() {
|
|
|
|
return pht(
|
|
|
|
'Raises errors on unresolved merge conflicts in source files, to catch '.
|
|
|
|
'mistakes where a conflicted file is accidentally marked as resolved.');
|
|
|
|
}
|
|
|
|
|
2014-05-10 10:55:47 +02:00
|
|
|
public function getLinterName() {
|
|
|
|
return 'MERGECONFLICT';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinterConfigurationName() {
|
|
|
|
return 'merge-conflict';
|
|
|
|
}
|
|
|
|
|
2013-02-20 23:19:55 +01:00
|
|
|
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,
|
2014-06-19 23:59:12 +02:00
|
|
|
1,
|
2013-02-20 23:19:55 +01:00
|
|
|
self::LINT_MERGECONFLICT,
|
2014-05-12 01:16:45 +02:00
|
|
|
pht('This syntax indicates there is an unresolved merge conflict.'));
|
2013-02-20 23:19:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLintNameMap() {
|
|
|
|
return array(
|
2014-05-12 01:16:45 +02:00
|
|
|
self::LINT_MERGECONFLICT => pht('Unresolved merge conflict'),
|
2013-02-20 23:19:55 +01:00
|
|
|
);
|
|
|
|
}
|
2014-07-09 01:12:13 +02:00
|
|
|
|
2013-02-20 23:19:55 +01:00
|
|
|
}
|