mcpp 1.3.3__tar.gz → 1.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcpp
3
- Version: 1.3.3
3
+ Version: 1.3.4
4
4
  Summary: McCabe++ (mcpp): cyclomatic complexity and other vulnerability-related code metrics
5
5
  Author-email: Lukas Pirch <lukas.pirch@tu-berlin.de>
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mcpp"
3
- version = "1.3.3"
3
+ version = "1.3.4"
4
4
  description = "McCabe++ (mcpp): cyclomatic complexity and other vulnerability-related code metrics"
5
5
  readme = "README.md"
6
6
  authors = [{name = "Lukas Pirch", email="lukas.pirch@tu-berlin.de"}]
@@ -30,4 +30,4 @@ build-backend = "setuptools.build_meta"
30
30
 
31
31
  [tool.black]
32
32
  target-version = ["py311"]
33
- line-length = 120
33
+ line-length = 120
@@ -1,4 +1,7 @@
1
- from mcpp.queries import Q_CALL_NAME, Q_NEW_EXPRESSION, Q_SUBSCRIPT_EXPR, Q_FIELD_EXPR
1
+ import tree_sitter
2
+
3
+ from mcpp.queries import Q_CALL_NAME, Q_NEW_EXPRESSION, Q_SUBSCRIPT_EXPR, Q_FIELD_EXPR, Q_POINTER_EXPR
4
+
2
5
 
3
6
  def m1(root, sitter, lang, calls=None):
4
7
  """ # memory allocations
@@ -18,20 +21,23 @@ def m1(root, sitter, lang, calls=None):
18
21
  num_allocations += 1
19
22
 
20
23
  # Number of new object instantiations
21
- num_new_expressions = len(sitter.captures("Q_NEW_EXPRESSION", root, lang).get("expr", []))
22
-
24
+ try:
25
+ num_new_expressions = len(sitter.captures("Q_NEW_EXPRESSION", root, lang).get("expr", []))
26
+ except tree_sitter.QueryError:
27
+ num_new_expressions = 0
28
+
23
29
  return {
24
30
  "m1": num_allocations + num_new_expressions,
25
31
  }
26
32
 
33
+
27
34
  def m2(root, sitter, lang, calls=None):
28
35
  """ # ptr dereferences
29
36
  """
30
37
  sitter.add_queries({
31
- "Q_CALL_NAME": Q_CALL_NAME,
32
- "Q_NEW_EXPRESSION": Q_NEW_EXPRESSION,
33
38
  "Q_SUBSCRIPT_EXPR": Q_SUBSCRIPT_EXPR,
34
39
  "Q_FIELD_EXPR": Q_FIELD_EXPR,
40
+ "Q_POINTER_EXPR": Q_POINTER_EXPR,
35
41
  })
36
42
 
37
43
  num_ptr_expressions = 0
@@ -46,7 +52,7 @@ def m2(root, sitter, lang, calls=None):
46
52
 
47
53
  # Number of pointer dereferences using the field expression syntax (ptr->field)
48
54
  num_field_expressions = len(sitter.captures("Q_FIELD_EXPR", root, lang).get("expr", []))
49
-
55
+
50
56
  return {
51
57
  "m2": num_ptr_expressions + num_subscript_expressions + num_field_expressions,
52
58
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcpp
3
- Version: 1.3.3
3
+ Version: 1.3.4
4
4
  Summary: McCabe++ (mcpp): cyclomatic complexity and other vulnerability-related code metrics
5
5
  Author-email: Lukas Pirch <lukas.pirch@tu-berlin.de>
6
6
  License: MIT License
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes