top_evil_rs.py: remove comments before counting

For example, constants.rs is completely safe now, but has "free()" in the comments.
This commit is contained in:
Alexander Krotov
2019-07-28 20:28:04 +03:00
committed by Floris Bruynooghe
parent 0cffbaf1e9
commit 3eaab07b0b

View File

@@ -2,12 +2,14 @@
import os
import re
if __name__ == "__main__":
filestats = []
for fn in os.listdir():
if fn.endswith(".rs"):
s = open(fn).read()
s = re.sub(r'(?m)///.*$', '', s) # remove comments
unsafe = s.count("unsafe")
free = s.count("free(")
gotoblocks = s.count("current_block =")