31
31
32
32
diagnostics = []
33
33
34
- for hit in data ['hits' ]:
35
- diagnostic = {}
36
- diagnostic ['location' ] = {
37
- 'path' : hit ['filename' ].replace (f'{ ws } /' ,'' ),
38
- 'range' : {
39
- 'start' : {
40
- 'line' : hit ['line' ],
41
- 'column' : 1
34
+ HITS = 'hits'
35
+ if data and (HITS in data ) :
36
+ for hit in data [HITS ]:
37
+ diagnostic = {}
38
+ diagnostic ['location' ] = {
39
+ 'path' : hit ['filename' ].replace (f'{ ws } /' ,'' ),
40
+ 'range' : {
41
+ 'start' : {
42
+ 'line' : hit ['line' ],
43
+ 'column' : 1
44
+ }
42
45
}
43
46
}
44
- }
45
- diagnostic ['severity' ] = "ERROR"
46
- diagnostic ['code' ] = {
47
- "value" : "hit['code']"
48
- }
49
-
50
- diagnostic ['message' ] = f"""{ hit ['caption' ]}
51
- solution={ hit ['solution' ]}
52
- category={ hit ['category' ]}
53
- code={ hit ['code' ]}
54
- confidence={ hit ['confidence' ]}
55
- cwe={ hit ['cwe' ]}
56
- labels={ hit ['labels' ]}
57
- """
58
- diagnostics .append (diagnostic )
59
-
60
- rd ['diagnostics' ]= diagnostics
61
-
62
- json_formatted_str = json .dumps (rd , indent = 4 )
63
- print (json_formatted_str )
47
+ diagnostic ['severity' ] = "ERROR"
48
+ diagnostic ['code' ] = {
49
+ "value" : "hit['code']"
50
+ }
51
+
52
+ diagnostic ['message' ] = f"""{ hit ['caption' ]}
53
+ solution={ hit ['solution' ]}
54
+ category={ hit ['category' ]}
55
+ code={ hit ['code' ]}
56
+ confidence={ hit ['confidence' ]}
57
+ cwe={ hit ['cwe' ]}
58
+ labels={ hit ['labels' ]}
59
+ """
60
+ diagnostics .append (diagnostic )
61
+
62
+ rd ['diagnostics' ]= diagnostics
63
+
64
+ json_formatted_str = json .dumps (rd , indent = 4 )
65
+ print (json_formatted_str )
0 commit comments