Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

void foo(int a[3]) not recognized as function #20

Open
fg6hdw opened this issue Nov 17, 2021 · 0 comments
Open

void foo(int a[3]) not recognized as function #20

fg6hdw opened this issue Nov 17, 2021 · 0 comments

Comments

@fg6hdw
Copy link

fg6hdw commented Nov 17, 2021

Functions that takes array arguments like void foo(int a[3]) are not recognized as functions by ravioli.
Adding '[', ']' characters to function_matcher regex fixes the problem.

diff --git a/ravioli/complexity.py b/ravioli/complexity.py
index 87d79b8..20631c8 100644
--- a/ravioli/complexity.py
+++ b/ravioli/complexity.py
@@ -10,7 +10,7 @@ def calculate_complexity(code):
     original_code = code
     code = strip_comments(code)
     results = []
-    function_matcher = re.compile(r'\s+(\w+)\s*\([\w\s,\*]*\)\s*{', re.MULTILINE)
+    function_matcher = re.compile(r'\s+(\w+)\s*\([\w\s,\[\]\*]*\)\s*{', re.MULTILINE)

     for m in function_matcher.finditer(code):
         name = m.group(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant