MCPcopy Create free account
hub / github.com/argotorg/solidity / main

Function main

scripts/error_codes.py:349–439  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

347
348
349def main(argv):
350 check = False
351 fix = False
352 no_confirm = False
353 examine_coverage = False
354 next_id = False
355 opts, _args = getopt.getopt(argv, "", ["check", "fix", "no-confirm", "examine-coverage", "next"])
356
357 for opt, _arg in opts:
358 if opt == "--check":
359 check = True
360 elif opt == "--fix":
361 fix = True
362 elif opt == "--no-confirm":
363 no_confirm = True
364 elif opt == "--examine-coverage":
365 examine_coverage = True
366 elif opt == "--next":
367 next_id = True
368
369 if [check, fix, examine_coverage, next_id].count(True) != 1:
370 print("usage: python error_codes.py --check | --fix [--no-confirm] | --examine-coverage | --next")
371 sys.exit(1)
372
373 cwd = os.getcwd()
374
375 source_file_names = find_files(
376 cwd,
377 ["libevmasm", "liblangutil", "libsolc", "libsolidity", "libsolutil", "libyul", "solc"],
378 [".h", ".cpp"]
379 )
380 source_id_to_file_names = find_ids_in_source_files(source_file_names)
381
382 ok = True
383 for error_id in sorted(source_id_to_file_names):
384 if len(error_id) != 4:
385 print(f"ID {error_id} length != 4")
386 ok = False
387 if error_id[0] == "0":
388 print(f"ID {error_id} starts with zero")
389 ok = False
390 if len(source_id_to_file_names[error_id]) > 1:
391 print(f"ID {error_id} appears {len(source_id_to_file_names[error_id])} times")
392 ok = False
393
394 if examine_coverage:
395 if not ok:
396 print("Incorrect IDs have to be fixed before applying --examine-coverage")
397 sys.exit(1)
398 res = 0 if examine_id_coverage(cwd, source_id_to_file_names) else 1
399 sys.exit(res)
400
401 ok &= examine_id_coverage(cwd, source_id_to_file_names, new_ids_only=True)
402
403 random.seed()
404
405 if next_id:
406 if not ok:

Callers 1

error_codes.pyFile · 0.70

Calls 6

find_filesFunction · 0.85
find_ids_in_source_filesFunction · 0.85
examine_id_coverageFunction · 0.85
get_next_idFunction · 0.85
fix_ids_in_source_filesFunction · 0.85
countMethod · 0.45

Tested by

no test coverage detected