Skip to content

Commit a58e65a

Browse files
committed
compare lines-changed-only with OG src
mistakenly compared to tidy patch instead of the original src that tidy had patched.
1 parent e48fbfc commit a58e65a

3 files changed

Lines changed: 82 additions & 87 deletions

File tree

cpp-linter/src/clang_tools/clang_format.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,19 @@ pub fn run_clang_format(
157157
cmd.args(["--style", &clang_params.style, "-i"]);
158158
// if ranges is empty, then we're just formatting the entire file.
159159
if !ranges.is_empty() {
160-
// We're concerned about formatting what clang-tidy changed (tidy_diff.hunks().after),
160+
// We're concerned about formatting what clang-tidy changed (tidy_diff.hunks().before),
161161
// but we also want to include any clang-format changes that do not overlap clang-tidy fixes.
162162
let mut joint_ranges = tidy_diff
163163
.hunks()
164164
// hunk is partially inclusive: [start, end),
165165
// but clang-format expects fully inclusive line ranges.
166-
// subtract 1 from hunk.after.end
167-
.map(|hunk| RangeInclusive::new(hunk.after.start, hunk.after.end.saturating_sub(1)))
166+
// subtract 1 from hunk.before.end
167+
.map(|hunk| RangeInclusive::new(hunk.before.start, hunk.before.end.saturating_sub(1)))
168168
.collect::<Vec<_>>();
169169
for range in &ranges {
170170
let mut contained = false;
171171
for hunk in tidy_diff.hunks() {
172-
if hunk.after.contains(range.start()) && hunk.after.contains(range.end()) {
172+
if hunk.before.contains(range.start()) && hunk.before.contains(range.end()) {
173173
contained = true;
174174
break;
175175
}
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
{
2-
"event": "REQUEST_CHANGES",
3-
"body": "<!-- cpp linter action -->\n## Cpp-linter Review\n### Used clang-format v16.0.0\n### Used clang-tidy v16.0.0\n\nOnly 8 out of 9 concerns fit within this pull request's diff.\n\n1 suggestions were duplicates of previous reviews.\n\n<details><summary>Click here for a patch of fixes outside the diff</summary><p>\n\n```diff\n--- a/src/demo.hpp\n+++ b/src/demo.hpp\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n```\n\n</p></details>\n\n\nHave any feedback or feature suggestions? [Share it here.](https://github.com/cpp-linter/cpp-linter-action/issues)",
4-
"comments": [
5-
{
6-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n for (;;)\n break;\n```\n",
7-
"line": 6,
8-
"path": "src/demo.cpp"
9-
},
10-
{
11-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n printf(\"Hello world!\\n\");\n```\n",
12-
"line": 9,
13-
"path": "src/demo.cpp"
14-
},
15-
{
16-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n return 0;\n}\n```\n",
17-
"line": 17,
18-
"start_line": 7,
19-
"path": "src/demo.cpp"
20-
},
21-
{
22-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n Dummy() : useless(\"\\0\"), numb(0) {}\n```\n",
23-
"line": 7,
24-
"path": "src/demo.hpp"
25-
},
26-
{
27-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n public:\n auto not_useful(char *str) -> void * { useless = str; }\n```\n",
28-
"line": 10,
29-
"start_line": 9,
30-
"path": "src/demo.hpp"
31-
},
32-
{
33-
"body": "<!-- cpp linter action -->\n### clang-tidy diagnostic\n**src/demo.hpp:8:31** error: [clang-diagnostic-writable-strings]\n\n> ISO C++11 does not allow conversion from string literal to 'char *'\n\n```hpp\n Dummy() :numb(0), useless(\"\\0\"){}\n ^\n```\n",
34-
"line": 8,
35-
"path": "src/demo.hpp"
36-
},
37-
{
38-
"body": "<!-- cpp linter action -->\n### clang-tidy diagnostic\n**src/demo.hpp:11:47** error: [clang-diagnostic-return-type]\n\n> non-void function does not return a value\n\n```hpp\n void *not_useful(char *str){useless = str;}\n ^\n```\n",
39-
"line": 11,
40-
"path": "src/demo.hpp"
41-
}
42-
]
43-
}
2+
"event": "REQUEST_CHANGES",
3+
"body": "<!-- cpp linter action -->\n## Cpp-linter Review\n### Used clang-format v16.0.0\n### Used clang-tidy v16.0.0\n\nOnly 8 out of 9 concerns fit within this pull request's diff.\n\n1 suggestions were duplicates of previous reviews.\n\n<details><summary>Click here for a patch of fixes outside the diff</summary><p>\n\n```diff\n--- a/src/demo.hpp\n+++ b/src/demo.hpp\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n-\n```\n\n</p></details>\n\n\nHave any feedback or feature suggestions? [Share it here.](https://github.com/cpp-linter/cpp-linter-action/issues)",
4+
"comments": [
5+
{
6+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n for (;;)\n break;\n```\n",
7+
"line": 6,
8+
"path": "src/demo.cpp"
9+
},
10+
{
11+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n printf(\"Hello world!\\n\");\n```\n",
12+
"line": 9,
13+
"path": "src/demo.cpp"
14+
},
15+
{
16+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n return 0;\n}\n```\n",
17+
"line": 17,
18+
"start_line": 7,
19+
"path": "src/demo.cpp"
20+
},
21+
{
22+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n Dummy() : useless(\"\\0\"), numb(0) {}\n```\n",
23+
"line": 7,
24+
"path": "src/demo.hpp"
25+
},
26+
{
27+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n public:\n auto not_useful(char *str) -> void * { useless = str; }\n```\n",
28+
"line": 10,
29+
"start_line": 9,
30+
"path": "src/demo.hpp"
31+
},
32+
{
33+
"body": "<!-- cpp linter action -->\n### clang-tidy diagnostic\n**src/demo.hpp:8:31** error: [clang-diagnostic-writable-strings]\n\n> ISO C++11 does not allow conversion from string literal to 'char *'\n\n```hpp\n Dummy() :numb(0), useless(\"\\0\"){}\n ^\n```\n",
34+
"line": 8,
35+
"path": "src/demo.hpp"
36+
},
37+
{
38+
"body": "<!-- cpp linter action -->\n### clang-tidy diagnostic\n**src/demo.hpp:11:47** error: [clang-diagnostic-return-type]\n\n> non-void function does not return a value\n\n```hpp\n void *not_useful(char *str){useless = str;}\n ^\n```\n",
39+
"line": 11,
40+
"path": "src/demo.hpp"
41+
}
42+
]
43+
}
Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
11
{
2-
"event": "REQUEST_CHANGES",
3-
"body": "<!-- cpp linter action -->\n## Cpp-linter Review\n### Used clang-format v18.1.8\n### Used clang-tidy v18.1.8\n\n\nHave any feedback or feature suggestions? [Share it here.](https://github.com/cpp-linter/cpp-linter-action/issues)",
4-
"comments": [
5-
{
6-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n Dummy() : numb(0), useless(\"\\0\") {}\n```\n",
7-
"line": 7,
8-
"path": "src/demo.hpp"
9-
},
10-
{
11-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n public:\n auto not_useful(char *str) -> void * { useless = str; }\n```\n",
12-
"line": 10,
13-
"start_line": 9,
14-
"path": "src/demo.hpp"
15-
},
16-
{
17-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n#include <cstdio>\n```\n",
18-
"line": 2,
19-
"path": "src/demo.cpp"
20-
},
21-
{
22-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\nauto main() -> int {\n```\n",
23-
"line": 4,
24-
"path": "src/demo.cpp"
25-
},
26-
{
27-
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n for (;;) {\n break;\n }\n```\n",
28-
"line": 6,
29-
"path": "src/demo.cpp"
30-
},
31-
{
32-
"body": "<!-- cpp linter action -->\n### clang-tidy diagnostic(s)\n- statement should be inside braces [[readability-braces-around-statements](https://clang.llvm.org/extra/clang-tidy/checks/readability/braces-around-statements.html)]\n\n```suggestion\n printf(\"Hello world!\\n\");\n```\n",
33-
"line": 10,
34-
"path": "src/demo.cpp"
35-
},
36-
{
37-
"body": "<!-- cpp linter action -->\n### clang-tidy diagnostic(s)\n- use a trailing return type for this function [[modernize-use-trailing-return-type](https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-trailing-return-type.html)]\n- statement should be inside braces [[readability-braces-around-statements](https://clang.llvm.org/extra/clang-tidy/checks/readability/braces-around-statements.html)]\n\n```suggestion\n return 0;\n}\n```\n",
38-
"line": 17,
39-
"start_line": 7,
40-
"path": "src/demo.cpp"
41-
}
42-
]
2+
"event": "COMMENT",
3+
"body": "<!-- cpp linter action -->\n## Cpp-linter Review\n### Used clang-format v18.1.8\n### Used clang-tidy v18.1.8\n\n\nHave any feedback or feature suggestions? [Share it here.](https://github.com/cpp-linter/cpp-linter-action/issues)",
4+
"comments": [
5+
{
6+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n#include <cstdio>\n```\n",
7+
"line": 2,
8+
"path": "src/demo.cpp"
9+
},
10+
{
11+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\nauto main() -> int\n{\n```\n",
12+
"line": 4,
13+
"path": "src/demo.cpp"
14+
},
15+
{
16+
"body": "<!-- cpp linter action -->\n### clang-tidy diagnostic(s)\n- use a trailing return type for this function [[modernize-use-trailing-return-type](https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-trailing-return-type.html)]\n- statement should be inside braces [[readability-braces-around-statements](https://clang.llvm.org/extra/clang-tidy/checks/readability/braces-around-statements.html)]\n\n```suggestion\n for (;;) {\n break;\n }\n```\n",
17+
"line": 10,
18+
"start_line": 5,
19+
"path": "src/demo.cpp"
20+
},
21+
{
22+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n return 0;\n}\n```\n",
23+
"line": 17,
24+
"path": "src/demo.cpp"
25+
},
26+
{
27+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n Dummy() : numb(0), useless(\"\\0\") {}\n```\n",
28+
"line": 7,
29+
"path": "src/demo.hpp"
30+
},
31+
{
32+
"body": "<!-- cpp linter action -->\n### clang-tidy suggestion\n\n```suggestion\n public:\n auto not_useful(char *str) -> void * { useless = str; }\n```\n",
33+
"line": 10,
34+
"start_line": 9,
35+
"path": "src/demo.hpp"
36+
}
37+
]
4338
}

0 commit comments

Comments
 (0)