public ReviewResult parseResults ( ) throws IOException { ReviewResult result = new ReviewResult ( ) ; ObjectMapper mapper = new ObjectMapper ( ) ; JsonNode rootNode = mapper . readTree ( new FileReader ( resultFile ) ) ; JsonNode issues = rootNode . path ( "issues" ) ; Iterator < JsonNode > issuesIterator = issues . iterator ( ) ; Map < String , Component > components = getComponents ( rootNode . path ( "components" ) ) ; while ( issuesIterator . hasNext ( ) ) { JsonNode issue = issuesIterator . next ( ) ; boolean isNew = issue . path ( "isNew" ) . asBoolean ( ) ; if ( ! isNew ) { log . debug ( "Skipping already indexed issue: {}" , issue . toString ( ) ) ; continue ; } JsonNode lineNode = issue . path ( "line" ) ; if ( lineNode . isMissingNode ( ) ) { log . debug ( "Skipping an issue with no line information: {}" , issue . toString ( ) ) ; continue ; } int line = lineNode . asInt ( ) ; String message = issue . path ( "message" ) . asText ( ) ; String file = getIssueFilePath ( issue . path ( "component" ) . asText ( ) , components ) ; String severity = issue . path ( "severity" ) . asText ( ) ; String rule = issue . path ( "rule" ) . asText ( ) ; result . add ( new Violation ( file , line , String . format ( "%s (Rule: %s)" , message , rule ) , getSeverity ( severity ) ) ) ; } return result ; }
Parses the file and returns all the issues as a ReviewResult .