MCPcopy Create free account
hub / github.com/Tencent/CodeAnalysis / _large_json_handle

Method _large_json_handle

client/tool/util/infer.py:251–320  ·  view source on GitHub ↗

流式处理过大Json文件 [ { "bug_class": "PROVER", "kind": "ERROR", "bug_type": "NULL_DEREFERENCE", "qualifier": "pointer `s` last assigned on line 12 could be null and is dereferenced at line 13, column 3.", "severity": "HI

(self, error_output, rules, issues)

Source from the content-addressed store, hash-verified

249 return issues
250
251 def _large_json_handle(self, error_output, rules, issues):
252 """
253 流式处理过大Json文件
254 [
255 {
256 "bug_class": "PROVER",
257 "kind": "ERROR",
258 "bug_type": "NULL_DEREFERENCE",
259 "qualifier": "pointer `s` last assigned on line 12 could be null and is dereferenced at line 13, column 3.",
260 "severity": "HIGH",
261 "visibility": "user",
262 "line": 13,
263 "column": 3,
264 "procedure": "test",
265 "procedure_id": "test.098f6bcd4621d373cade4e832627b4f6",
266 "procedure_start_line": 11,
267 "file": "hello.c",
268 "bug_trace": [
269 {
270 "level": 0,
271 "filename": "hello.c",
272 "line_number": 11,
273 "column_number": 1,
274 "description": "start of procedure test()"
275 },
276 ...
277 ],
278 "key": "hello.c|test|NULL_DEREFERENCE",
279 "node_key": "df5c83dfdfb79926d42976bfa5b88b70",
280 "hash": "4facc3dcd927de905b07688d040f0139",
281 "bug_type_hum": "Null Dereference",
282 "censored_reason": ""
283 },
284 ...
285 ]
286 :return:
287 """
288 import ijson
289
290 f = open(error_output, "r")
291 parser = ijson.parse(f)
292 is_in_issue = False
293 is_in_trace = False
294 refs = []
295 for prefix, event, value in parser:
296 if is_in_issue: # 在一个issue的范围内
297 if prefix == "item.bug_type":
298 if value in rules:
299 rule = value
300 else:
301 is_in_issue = False
302 continue
303 if prefix == "item.qualifier":
304 msg = value
305 if prefix == "item.line":
306 line = value
307 if prefix == "item.file":
308 path = value

Callers 1

analyzeMethod · 0.95

Calls 2

_bug_trace_handleMethod · 0.95
parseMethod · 0.45

Tested by

no test coverage detected