@@ -13,11 +13,11 @@ use serde::Deserialize;
13
13
use serde_json;
14
14
15
15
// project specific modules/crates
16
- use crate :: clang_tools:: { clang_format:: FormatAdvice , clang_tidy:: TidyNotification } ;
16
+ use crate :: clang_tools:: { clang_format:: FormatAdvice , clang_tidy:: TidyAdvice } ;
17
17
use crate :: common_fs:: FileObj ;
18
18
use crate :: git:: { get_diff, open_repo, parse_diff, parse_diff_from_buf} ;
19
19
20
- use super :: RestApiClient ;
20
+ use super :: { FeedbackInput , RestApiClient , COMMENT_MARKER } ;
21
21
22
22
static USER_AGENT : & str =
23
23
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0" ;
@@ -186,16 +186,12 @@ impl RestApiClient for GithubApiClient {
186
186
& self ,
187
187
files : & [ FileObj ] ,
188
188
format_advice : & [ FormatAdvice ] ,
189
- tidy_advice : & [ Vec < TidyNotification > ] ,
190
- thread_comments : & str ,
191
- no_lgtm : bool ,
192
- step_summary : bool ,
193
- file_annotations : bool ,
194
- style : & str ,
189
+ tidy_advice : & [ TidyAdvice ] ,
190
+ user_inputs : FeedbackInput ,
195
191
) {
196
192
let ( comment, format_checks_failed, tidy_checks_failed) =
197
193
self . make_comment ( files, format_advice, tidy_advice) ;
198
- if thread_comments != "false" {
194
+ if user_inputs . thread_comments . as_str ( ) != "false" {
199
195
// post thread comment for PR or push event
200
196
if let Some ( repo) = & self . repo {
201
197
let is_pr = self . event_name == "pull_request" ;
@@ -222,15 +218,13 @@ impl RestApiClient for GithubApiClient {
222
218
} else {
223
219
json[ "commit" ] [ "comment_count" ] . as_u64 ( ) . unwrap ( )
224
220
} ;
225
- let user_id: u64 = 41898282 ;
226
221
self . update_comment (
227
222
& format ! ( "{}/comments" , & comments_url) ,
228
223
& comment,
229
224
count,
230
- user_id,
231
- no_lgtm,
225
+ user_inputs. no_lgtm ,
232
226
format_checks_failed + tidy_checks_failed == 0 ,
233
- thread_comments == "update" ,
227
+ user_inputs . thread_comments . as_str ( ) == "update" ,
234
228
) ;
235
229
} else {
236
230
let error = request. unwrap_err ( ) ;
@@ -245,10 +239,15 @@ impl RestApiClient for GithubApiClient {
245
239
}
246
240
}
247
241
}
248
- if file_annotations {
249
- self . post_annotations ( files, format_advice, tidy_advice, style) ;
242
+ if user_inputs. file_annotations {
243
+ self . post_annotations (
244
+ files,
245
+ format_advice,
246
+ tidy_advice,
247
+ user_inputs. style . as_str ( ) ,
248
+ ) ;
250
249
}
251
- if step_summary {
250
+ if user_inputs . step_summary {
252
251
self . post_step_summary ( & comment) ;
253
252
}
254
253
self . set_exit_code (
@@ -276,7 +275,7 @@ impl GithubApiClient {
276
275
& self ,
277
276
files : & [ FileObj ] ,
278
277
format_advice : & [ FormatAdvice ] ,
279
- tidy_advice : & [ Vec < TidyNotification > ] ,
278
+ tidy_advice : & [ TidyAdvice ] ,
280
279
style : & str ,
281
280
) {
282
281
if !format_advice. is_empty ( ) {
@@ -321,7 +320,7 @@ impl GithubApiClient {
321
320
// The tidy_advice vector is parallel to the files vector; meaning it serves as a file filterer.
322
321
// lines are already filter as specified to clang-tidy CLI.
323
322
for ( index, advice) in tidy_advice. iter ( ) . enumerate ( ) {
324
- for note in advice {
323
+ for note in & advice. notes {
325
324
if note. filename == files[ index] . name . to_string_lossy ( ) . replace ( '\\' , "/" ) {
326
325
println ! (
327
326
"::{severity} file={file},line={line},title={file}:{line}:{cols} [{diag}]::{info}" ,
@@ -344,13 +343,12 @@ impl GithubApiClient {
344
343
url : & String ,
345
344
comment : & String ,
346
345
count : u64 ,
347
- user_id : u64 ,
348
346
no_lgtm : bool ,
349
347
is_lgtm : bool ,
350
348
update_only : bool ,
351
349
) {
352
350
let comment_url =
353
- self . remove_bot_comments ( url, user_id , count, !update_only || ( is_lgtm && no_lgtm) ) ;
351
+ self . remove_bot_comments ( url, count, !update_only || ( is_lgtm && no_lgtm) ) ;
354
352
#[ allow( clippy:: nonminimal_bool) ] // an inaccurate assessment
355
353
if ( is_lgtm && !no_lgtm) || !is_lgtm {
356
354
let payload = HashMap :: from ( [ ( "body" , comment) ] ) ;
@@ -383,13 +381,7 @@ impl GithubApiClient {
383
381
}
384
382
}
385
383
386
- fn remove_bot_comments (
387
- & self ,
388
- url : & String ,
389
- count : u64 ,
390
- user_id : u64 ,
391
- delete : bool ,
392
- ) -> Option < String > {
384
+ fn remove_bot_comments ( & self , url : & String , count : u64 , delete : bool ) -> Option < String > {
393
385
let mut page = 1 ;
394
386
let mut comment_url = None ;
395
387
let mut total = count;
@@ -402,9 +394,7 @@ impl GithubApiClient {
402
394
let payload: JsonCommentsPayload = response. json ( ) . unwrap ( ) ;
403
395
let mut comment_count = 0 ;
404
396
for comment in payload. comments {
405
- if comment. body . starts_with ( "<!-- cpp linter action -->" )
406
- && comment. user . id == user_id
407
- {
397
+ if comment. body . starts_with ( COMMENT_MARKER ) {
408
398
log:: debug!(
409
399
"comment id {} from user {} ({})" ,
410
400
comment. id,
0 commit comments