google / google/keep-sorted

Feature request: output diff

Open
#111 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
403
Forks
36
Avg merge
4h 24m
Merged PRs (30d)
1

Description

The current json output for `--mode lint` is not human-readable. It would be great to be able to print a diff instead of json.

It can be a new `--diff` flag, or `--format json/diff`, or `--mode diff`.

For example, instead of
```json
[
{
"path": "separator.in",
"lines": {
"start": 4,
"end": 6
},
"message": "These lines are out of order.",
"fixes": [
{
"replacements": [
{
"lines": {
"start": 4,
"end": 6
},
"new_content": " \"Bar\",\n \"Baz\",\n \"Foo\"\n"
}
]
}
]
},
{
"path": "separator.in",
"lines": {
"start": 12,
"end": 16
},
"message": "These lines are out of order.",
"fixes": [
{
"replacements": [
{
"lines": {
"start": 12,
"end": 16
},
"new_content": "// Sticky comment\n\"Bar\",\n\"Baz\",\n\"Foo\"\n// Trailing comments\n"
}
]
}
]
}
]
```
I'd like to see
```diff
--- goldens/separator.in
+++ goldens/separator.in
@@ -1,17 +1,17 @@
Comma separator:
static class Foo {
// keep-sorted-test start
- "Foo",
+ "Bar",
- "Bar",
+ "Baz",
- "Baz"
+ "Foo"
// keep-sorted-test end
}

Comma separator with comments:
-// keep-sorted-test start sticky_comments=yes
-"Foo",
+// keep-sorted-test start sticky_comments=yes
// Sticky comment
"Bar",
-"Baz"
+"Baz",
+"Foo"
// Trailing comments
// keep-sorted-test end
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.