Skip to content

Commit 9d2a9a3

Browse files
committed
add: prefix review comments with marker
1 parent 98fbbdc commit 9d2a9a3

File tree

4 files changed

+42
-21
lines changed

4 files changed

+42
-21
lines changed

Diff for: cpp-linter/src/clang_tools/clang_tidy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ pub fn run_clang_tidy(
318318
)?);
319319
if clang_params.tidy_review {
320320
if let Some(tidy_advice) = &mut file.tidy_advice {
321-
// cache file changes in a buffer and restore the original contents for further analysis by clang-format
321+
// cache file changes in a buffer and restore the original contents for further analysis
322322
tidy_advice.patched =
323323
Some(fs::read(&file_name).with_context(|| {
324324
format!("Failed to read changes from clang-tidy: {file_name}")

Diff for: cpp-linter/src/clang_tools/mod.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -95,39 +95,39 @@ fn analyze_single_file(
9595
.lock()
9696
.map_err(|_| anyhow!("Failed to lock file mutex"))?;
9797
let mut logs = vec![];
98-
if clang_params.clang_tidy_command.is_some() {
98+
if clang_params.clang_format_command.is_some() {
9999
if clang_params
100-
.tidy_filter
100+
.format_filter
101101
.as_ref()
102102
.is_some_and(|f| f.is_source_or_ignored(file.name.as_path()))
103-
|| clang_params.tidy_filter.is_none()
103+
|| clang_params.format_filter.is_none()
104104
{
105-
let tidy_result = run_clang_tidy(&mut file, &clang_params)?;
106-
logs.extend(tidy_result);
105+
let format_result = run_clang_format(&mut file, &clang_params)?;
106+
logs.extend(format_result);
107107
} else {
108108
logs.push((
109109
log::Level::Info,
110110
format!(
111-
"{} not scanned by clang-tidy due to `--ignore-tidy`",
111+
"{} not scanned by clang-format due to `--ignore-format`",
112112
file.name.as_os_str().to_string_lossy()
113113
),
114114
));
115115
}
116116
}
117-
if clang_params.clang_format_command.is_some() {
117+
if clang_params.clang_tidy_command.is_some() {
118118
if clang_params
119-
.format_filter
119+
.tidy_filter
120120
.as_ref()
121121
.is_some_and(|f| f.is_source_or_ignored(file.name.as_path()))
122-
|| clang_params.format_filter.is_none()
122+
|| clang_params.tidy_filter.is_none()
123123
{
124-
let format_result = run_clang_format(&mut file, &clang_params)?;
125-
logs.extend(format_result);
124+
let tidy_result = run_clang_tidy(&mut file, &clang_params)?;
125+
logs.extend(tidy_result);
126126
} else {
127127
logs.push((
128128
log::Level::Info,
129129
format!(
130-
"{} not scanned by clang-format due to `--ignore-format`",
130+
"{} not scanned by clang-tidy due to `--ignore-tidy`",
131131
file.name.as_os_str().to_string_lossy()
132132
),
133133
));

Diff for: cpp-linter/src/cli/mod.rs

+27-7
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,33 @@ Further filtering can still be applied (see [Source options](#source-options))."
336336
)
337337
.groups([
338338
ArgGroup::new("Clang-tidy options")
339-
.args(["tidy-checks", "database", "extra-arg", "ignore-tidy"]).multiple(true),
340-
ArgGroup::new("Clang-format options").args(["style", "ignore-format"]).multiple(true),
341-
ArgGroup::new("General options").args(["verbosity", "version"]).multiple(true),
342-
ArgGroup::new("Source options").args(["extensions", "repo-root", "ignore", "lines-changed-only", "files-changed-only"]).multiple(true),
343-
ArgGroup::new("Feedback options").args([
344-
"thread-comments", "no-lgtm", "step-summary", "file-annotations", "tidy-review", "format-review", "passive-reviews"
345-
]).multiple(true),
339+
.args(["tidy-checks", "database", "extra-arg", "ignore-tidy"])
340+
.multiple(true)
341+
.required(false),
342+
ArgGroup::new("Clang-format options")
343+
.args(["style", "ignore-format"])
344+
.multiple(true)
345+
.required(false),
346+
ArgGroup::new("General options")
347+
.args(["verbosity", "version"])
348+
.multiple(true)
349+
.required(false),
350+
ArgGroup::new("Source options")
351+
.args(["extensions", "repo-root", "ignore", "lines-changed-only", "files-changed-only"])
352+
.multiple(true)
353+
.required(false),
354+
ArgGroup::new("Feedback options")
355+
.args([
356+
"thread-comments",
357+
"no-lgtm",
358+
"step-summary",
359+
"file-annotations",
360+
"tidy-review",
361+
"format-review",
362+
"passive-reviews",
363+
])
364+
.multiple(true)
365+
.required(false),
346366
])
347367
.next_line_help(true)
348368
}

Diff for: cpp-linter/src/rest_api/github/serde_structs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use serde::{Deserialize, Serialize};
55

66
use crate::clang_tools::Suggestion;
7+
use crate::rest_api::COMMENT_MARKER;
78

89
#[derive(Debug, Serialize)]
910
pub struct FullReview {
@@ -24,7 +25,7 @@ pub struct ReviewDiffComment {
2425
impl From<Suggestion> for ReviewDiffComment {
2526
fn from(value: Suggestion) -> Self {
2627
Self {
27-
body: value.suggestion,
28+
body: format!("{COMMENT_MARKER}{}", value.suggestion),
2829
line: value.line_end as i64,
2930
start_line: if value.line_end != value.line_start {
3031
Some(value.line_start as i64)

0 commit comments

Comments
 (0)