2222
2323import javax .annotation .Nullable ;
2424import java .io .*;
25+ import java .nio .file .Paths ;
2526import java .util .stream .Stream ;
2627import java .util .function .Consumer ;
2728
3435
3536public class ClippyJsonReportReader {
3637 private final JSONParser jsonParser = new JSONParser ();
38+ private final String projectDir ;
3739 private final Consumer <ClippyIssue > consumer ;
3840 private static final String RESULTS = "results" ;
3941 private static final String BEGINJSON = "{\" " + RESULTS + "\" : [" ;
@@ -60,12 +62,13 @@ public static class ClippyIssue {
6062 String severity ;
6163 }
6264
63- private ClippyJsonReportReader (Consumer <ClippyIssue > consumer ) {
65+ private ClippyJsonReportReader (String projectDir , Consumer <ClippyIssue > consumer ) {
66+ this .projectDir = projectDir ;
6467 this .consumer = consumer ;
6568 }
6669
67- static void read (InputStream in , Consumer <ClippyIssue > consumer ) throws IOException , ParseException {
68- new ClippyJsonReportReader (consumer ).read (in );
70+ static void read (InputStream in , String projectDir , Consumer <ClippyIssue > consumer ) throws IOException , ParseException {
71+ new ClippyJsonReportReader (projectDir , consumer ).read (in );
6972 }
7073
7174 private void read (InputStream in ) throws IOException , ParseException {
@@ -93,7 +96,7 @@ private void onResult(JSONObject result) {
9396 if ((spans == null ) || spans .isEmpty ()) return ; //Exit silently when JSON is not compliant
9497
9598 JSONObject span = (JSONObject ) spans .get (0 );
96- clippyIssue .filePath = ( String ) span .get ("file_name" );
99+ clippyIssue .filePath = Paths . get ( this . projectDir , ( String ) span .get ("file_name" )). toString ( );
97100 clippyIssue .message = (String ) message .get (MESSAGE );
98101 JSONArray children = (JSONArray ) message .get ("children" );
99102
0 commit comments