From 4f06c7279817f32b7242d3c659fb65bacf92eac6 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 12 Jan 2020 11:10:51 +0300 Subject: [PATCH] Remove top_evil_rs.py --- src/top_evil_rs.py | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100755 src/top_evil_rs.py diff --git a/src/top_evil_rs.py b/src/top_evil_rs.py deleted file mode 100755 index f21e4190b..000000000 --- a/src/top_evil_rs.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 - - -from pathlib import Path -import os -import re - -if __name__ == "__main__": - if Path('src/top_evil_rs.py').exists(): - os.chdir('src') - filestats = [] - for fn in Path(".").glob("**/*.rs"): - s = fn.read_text() - s = re.sub(r"(?m)///.*$", "", s) # remove comments - unsafe = s.count("unsafe") - free = s.count("free(") - unsafe_fn = s.count("unsafe fn") - chars = s.count("c_char") + s.count("CStr") - libc = s.count("libc") - filestats.append((fn, unsafe, free, unsafe_fn, chars, libc)) - - sum_unsafe, sum_free, sum_unsafe_fn, sum_chars, sum_libc = 0, 0, 0, 0, 0 - - for fn, unsafe, free, unsafe_fn, chars, libc in reversed(sorted(filestats, key=lambda x: sum(x[1:]))): - if unsafe + free + unsafe_fn + chars + libc == 0: - continue - print("{0: <25} unsafe: {1: >3} free: {2: >3} unsafe-fn: {3: >3} chars: {4: >3} libc: {5: >3}".format(str(fn), unsafe, free, unsafe_fn, chars, libc)) - sum_unsafe += unsafe - sum_free += free - sum_unsafe_fn += unsafe_fn - sum_chars += chars - sum_libc += libc - - - print() - print("total unsafe:", sum_unsafe) - print("total free:", sum_free) - print("total unsafe-fn:", sum_unsafe_fn) - print("total c_chars:", sum_chars) - print("total libc:", sum_libc)