Repository: terryyin/lizard

Issue:
Wrong PARAM count for void type in C/C++
Taking a file `test.c` with following content:

```c
void f(void) {}
```

Lizard outputs

```txt
================================================
  NLOC    CCN   token  PARAM  length  location  
------------------------------------------------
       1      1      6      1       1 f@2-2@./test.c
```

PARAM is 1 where it should be *zero*... void is considered as a parameter but it denotes in C the absence of any argument.


Discussion:

Patch:
diff --git a/lizard_languages/clike.py b/lizard_languages/clike.py
index c644485..8ddfe6e 100644
--- a/lizard_languages/clike.py
+++ b/lizard_languages/clike.py
@@ -196,7 +196,8 @@ class CLikeStates(CodeStateMachine):
             else:
                 self.next(self._state_global)
         elif len(self.bracket_stack) == 1:
-            self.context.parameter(token)
+            if token != 'void': # void is a reserved keyword, meaning no parameters
+                self.context.parameter(token)
             return
         self.context.add_to_long_function_name(token)
 


Test patch:
diff --git a/test/test_languages/testCAndCPP.py b/test/test_languages/testCAndCPP.py
index 27ee8d1..17646ce 100644
--- a/test/test_languages/testCAndCPP.py
+++ b/test/test_languages/testCAndCPP.py
@@ -93,17 +93,21 @@ class Test_c_cpp_lizard(unittest.TestCase):
         result = get_cpp_function_list("""int fun(){char *a="\\\\";}""")
         self.assertEqual(1, len(result))
 
-    def test_number_with_thousands_seperator_since_cpp14(self):
+    def test_number_with_thousands_separator_since_cpp14(self):
         result = get_cpp_function_list("""int fun(){
             int a= 100'000; if(b) c; return 123'456'789;
         }""")
         self.assertEqual(1, len(result))
         self.assertEqual(2, result[0].cyclomatic_complexity)
 
-    def test_function_with_no_param(self):
+    def test_function_with_no_param_omitted(self):
         result = get_cpp_function_list("int fun(){}")
         self.assertEqual(0, result[0].parameter_count)
 
+    def test_function_with_no_param_void(self):
+        result = get_cpp_function_list("int fun(void){}")
+        self.assertEqual(0, result[0].parameter_count)
+
     def test_function_with_1_param(self):
         result = get_cpp_function_list("int fun(aa bb){}")
         self.assertEqual(1, result[0].parameter_count)