~ubuntu-branches/ubuntu/vivid/phabricator/vivid-proposed

« back to all changes in this revision

Viewing changes to arcanist/src/lint/linter/ArcanistMergeConflictLinter.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2014-10-23 20:49:26 UTC
  • mfrom: (0.2.1) (0.1.1)
  • Revision ID: package-import@ubuntu.com-20141023204926-vq80u1op4df44azb
Tags: 0~git20141023-1
Initial release (closes: #703046)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Checks files for unresolved merge conflicts.
 
5
 */
 
6
final class ArcanistMergeConflictLinter extends ArcanistLinter {
 
7
 
 
8
  const LINT_MERGECONFLICT = 1;
 
9
 
 
10
  public function getInfoName() {
 
11
    return pht('Merge Conflicts');
 
12
  }
 
13
 
 
14
  public function getInfoDescription() {
 
15
    return pht(
 
16
      'Raises errors on unresolved merge conflicts in source files, to catch '.
 
17
      'mistakes where a conflicted file is accidentally marked as resolved.');
 
18
  }
 
19
 
 
20
  public function getLinterName() {
 
21
    return 'MERGECONFLICT';
 
22
  }
 
23
 
 
24
  public function getLinterConfigurationName() {
 
25
    return 'merge-conflict';
 
26
  }
 
27
 
 
28
  public function getLintNameMap() {
 
29
    return array(
 
30
      self::LINT_MERGECONFLICT => pht('Unresolved merge conflict'),
 
31
    );
 
32
  }
 
33
 
 
34
  public function lintPath($path) {
 
35
    $lines = phutil_split_lines($this->getData($path), false);
 
36
 
 
37
    foreach ($lines as $lineno => $line) {
 
38
      // An unresolved merge conflict will contain a series of seven
 
39
      // '<', '=', or '>'.
 
40
      if (preg_match('/^(>{7}|<{7}|={7})$/', $line)) {
 
41
        $this->raiseLintAtLine(
 
42
          $lineno + 1,
 
43
          1,
 
44
          self::LINT_MERGECONFLICT,
 
45
          pht('This syntax indicates there is an unresolved merge conflict.'));
 
46
      }
 
47
    }
 
48
  }
 
49
 
 
50
}