private static Audit getCodeReviewAudit ( JSONArray jsonArray , JSONArray global ) { LOGGER . info ( "NFRR Audit Collector auditing CODE_REVIEW" ) ; Audit audit = new Audit ( ) ; audit . setType ( AuditType . CODE_REVIEW ) ; Audit basicAudit ; if ( ( basicAudit = doBasicAuditCheck ( jsonArray , global , AuditType . CODE_REVIEW ) ) != null ) { return basicAudit ; } audit . setAuditStatus ( AuditStatus . OK ) ; audit . setDataStatus ( DataStatus . OK ) ; for ( Object o : jsonArray ) { JSONObject jo = ( JSONObject ) o ; audit . getUrl ( ) . add ( ( String ) jo . get ( STR_URL ) ) ; JSONArray directCommits = ( JSONArray ) jo . get ( STR_DIRECTCOMMITS ) ; if ( ! CollectionUtils . isEmpty ( directCommits ) ) { audit . setAuditStatus ( AuditStatus . FAIL ) ; audit . setDataStatus ( DataStatus . OK ) ; return audit ; } JSONArray pulls = ( JSONArray ) ( ( JSONObject ) o ) . get ( STR_PULLREQUESTS ) ; for ( Object po : pulls ) { JSONArray auditJO = ( JSONArray ) ( ( JSONObject ) po ) . get ( STR_AUDITSTATUSES ) ; boolean reviewed = false ; auditJO . stream ( ) . map ( aj -> audit . getAuditStatusCodes ( ) . add ( ( String ) aj ) ) ; for ( Object s : auditJO ) { String status = ( String ) s ; audit . getAuditStatusCodes ( ) . add ( status ) ; if ( CodeReviewAuditStatus . PEER_REVIEW_GHR . name ( ) . equalsIgnoreCase ( status ) || ( CodeReviewAuditStatus . PEER_REVIEW_LGTM_SUCCESS . name ( ) . equalsIgnoreCase ( status ) ) ) { reviewed = true ; break ; } } if ( ! reviewed ) { audit . setAuditStatus ( AuditStatus . FAIL ) ; audit . setDataStatus ( DataStatus . OK ) ; return audit ; } } } return audit ; }
Get Code Review Audit Results