Skip to content
Snippets Groups Projects
Commit 371ea65c authored by George Kadianakis's avatar George Kadianakis
Browse files

Improve #include counting func and move it to metrics.py.

parent a7684fcb
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,14 @@ def file_len(f):
pass
return i + 1
def get_include_count(f):
"""Get number of #include statements in the file"""
include_count = 0
for line in f:
if re.match(r' *# *include', line):
include_count += 1
return include_count
def function_lines(f):
"""
Return iterator which iterates over functions and returns (function name, function lines)
......
......@@ -57,10 +57,7 @@ def consider_file_size(fname, f, exceptions_str):
print_violation_if_not_exception(violation_str, exceptions_str)
def consider_includes(fname, f, exceptions_str):
include_count = 0
for _, line in enumerate(f):
if line.startswith("#include "):
include_count += 1
include_count = metrics.get_include_count(f)
if include_count > MAX_INCLUDE_COUNT:
violation_str = "violation include-count %s %d" % (fname, include_count)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment