Page MenuHomePhabricator

D18511.id44465.diff
No OneTemporary

D18511.id44465.diff

diff --git a/src/lint/renderer/ArcanistConsoleLintRenderer.php b/src/lint/renderer/ArcanistConsoleLintRenderer.php
--- a/src/lint/renderer/ArcanistConsoleLintRenderer.php
+++ b/src/lint/renderer/ArcanistConsoleLintRenderer.php
@@ -90,6 +90,7 @@
$old = $data;
$old_lines = phutil_split_lines($old);
+ $start = $line;
if ($message->isPatchable()) {
$patch_offset = $line_map[$line] + ($char - 1);
@@ -107,8 +108,6 @@
$old_impact = substr_count($original, "\n") + 1;
$new_impact = substr_count($replacement, "\n") + 1;
- $start = $line;
-
// If lines at the beginning of the changed line range are actually the
// same, shrink the range. This happens when a patch just adds a line.
do {
@@ -214,6 +213,14 @@
$spec['text'],
$chevron,
idx($spec, 'type'));
+
+ // If this is just a message and does not have a patch, put a little
+ // caret underneath the line to point out where the issue is.
+ if ($chevron) {
+ if (!$message->isPatchable() && !strlen($original)) {
+ $result[] = $this->renderCaret($char)."\n";
+ }
+ }
}
return implode('', $result);
diff --git a/src/lint/renderer/__tests__/ArcanistConsoleLintRendererTestCase.php b/src/lint/renderer/__tests__/ArcanistConsoleLintRendererTestCase.php
--- a/src/lint/renderer/__tests__/ArcanistConsoleLintRendererTestCase.php
+++ b/src/lint/renderer/__tests__/ArcanistConsoleLintRendererTestCase.php
@@ -54,6 +54,13 @@
'original' => '',
'replacement' => "\n",
),
+
+ 'caret' => array(
+ 'line' => 2,
+ 'char' => 13,
+ 'name' => 'Fruit Misinformation',
+ 'description' => 'Arguably untrue.',
+ ),
);
$defaults = array(
diff --git a/src/lint/renderer/__tests__/data/caret.expect b/src/lint/renderer/__tests__/data/caret.expect
new file mode 100644
--- /dev/null
+++ b/src/lint/renderer/__tests__/data/caret.expect
@@ -0,0 +1,11 @@
+>>> Lint for path/to/example.c:
+
+
+ Warning (WARN123) Fruit Misinformation
+ Arguably untrue.
+
+ 1 Apples are round.
+ >>> 2 Bananas are round.
+ ^
+ 3 Cherries are round.
+ 4 Dates are round.
diff --git a/src/lint/renderer/__tests__/data/caret.txt b/src/lint/renderer/__tests__/data/caret.txt
new file mode 100644
--- /dev/null
+++ b/src/lint/renderer/__tests__/data/caret.txt
@@ -0,0 +1,4 @@
+Apples are round.
+Bananas are round.
+Cherries are round.
+Dates are round.

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 26, 3:06 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7595175
Default Alt Text
D18511.id44465.diff (2 KB)

Event Timeline