1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-01-10 06:41:04 +01:00
phorge-arcanist/src/lint/linter/ArcanistMergeConflictLinter.php
Joshua Spence 670dccee47 Minor reordering of functions
Summary: This seems somewhat neater to me, YMMV.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10468
2014-09-22 18:42:41 +10:00

50 lines
1.2 KiB
PHP

<?php
/**
* Checks files for unresolved merge conflicts.
*/
final class ArcanistMergeConflictLinter extends ArcanistLinter {
const LINT_MERGECONFLICT = 1;
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.');
}
public function getLinterName() {
return 'MERGECONFLICT';
}
public function getLinterConfigurationName() {
return 'merge-conflict';
}
public function getLintNameMap() {
return array(
self::LINT_MERGECONFLICT => pht('Unresolved merge conflict'),
);
}
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,
1,
self::LINT_MERGECONFLICT,
pht('This syntax indicates there is an unresolved merge conflict.'));
}
}
}
}