metripy 0.3.6__py3-none-any.whl → 0.3.7__py3-none-any.whl
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.
Potentially problematic release.
This version of metripy might be problematic. Click here for more details.
- metripy/LangAnalyzer/Php/PhpAnalyzer.py +25 -0
- metripy/templates/html_report/dependencies.html +1 -0
- metripy/templates/html_report/files.html +1 -0
- metripy/templates/html_report/git_analysis.html +1 -0
- metripy/templates/html_report/index.html +1 -0
- metripy/templates/html_report/top_offenders.html +1 -0
- metripy/templates/html_report/trends.html +1 -0
- {metripy-0.3.6.dist-info → metripy-0.3.7.dist-info}/METADATA +1 -1
- {metripy-0.3.6.dist-info → metripy-0.3.7.dist-info}/RECORD +13 -13
- {metripy-0.3.6.dist-info → metripy-0.3.7.dist-info}/WHEEL +0 -0
- {metripy-0.3.6.dist-info → metripy-0.3.7.dist-info}/entry_points.txt +0 -0
- {metripy-0.3.6.dist-info → metripy-0.3.7.dist-info}/licenses/LICENSE +0 -0
- {metripy-0.3.6.dist-info → metripy-0.3.7.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import math
|
|
2
|
+
import os
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
|
|
4
5
|
import lizard
|
|
6
|
+
import tempfile
|
|
7
|
+
import re
|
|
5
8
|
|
|
6
9
|
from metripy.Component.Output.ProgressBar import ProgressBar
|
|
7
10
|
from metripy.LangAnalyzer.AbstractLangAnalyzer import AbstractLangAnalyzer
|
|
@@ -46,10 +49,29 @@ class PhpAnalyzer(AbstractLangAnalyzer):
|
|
|
46
49
|
return f"{filename}:{item_name}"
|
|
47
50
|
return f"{filename}:{class_name}:{item_name}"
|
|
48
51
|
|
|
52
|
+
def _create_lizard_analyzable_file(self, filename: str) -> str:
|
|
53
|
+
"""
|
|
54
|
+
Because of a bug in lizard it cannot correctly analyze traits.
|
|
55
|
+
See https://github.com/terryyin/lizard/issues/441
|
|
56
|
+
"""
|
|
57
|
+
tmp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.php')
|
|
58
|
+
with open(filename, "r") as f:
|
|
59
|
+
code = f.readlines()
|
|
60
|
+
code = [re.sub(r'^(\s*)trait\s+', r'\1class ', line) for line in code]
|
|
61
|
+
tmp_file.writelines(code)
|
|
62
|
+
tmp_file.close()
|
|
63
|
+
return tmp_file.name
|
|
64
|
+
|
|
49
65
|
def analyze(self, code: str, filename: str) -> None:
|
|
50
66
|
file_stem = Path(filename).stem
|
|
51
67
|
structure = PhpBasicAstParser.parse_php_structure(code)
|
|
52
68
|
|
|
69
|
+
|
|
70
|
+
is_tmp_file = False
|
|
71
|
+
if "trait" in filename.lower():
|
|
72
|
+
filename = self._create_lizard_analyzable_file(filename)
|
|
73
|
+
is_tmp_file = True
|
|
74
|
+
|
|
53
75
|
lizard_result = lizard.analyze_file(filename)
|
|
54
76
|
complexity_data = {
|
|
55
77
|
func.name: {
|
|
@@ -60,6 +82,9 @@ class PhpAnalyzer(AbstractLangAnalyzer):
|
|
|
60
82
|
for func in lizard_result.function_list
|
|
61
83
|
}
|
|
62
84
|
|
|
85
|
+
if is_tmp_file:
|
|
86
|
+
os.unlink(filename)
|
|
87
|
+
|
|
63
88
|
classes: dict[str, ClassNode] = {}
|
|
64
89
|
functions: dict[str, FunctionNode] = {}
|
|
65
90
|
for obj in structure:
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<link rel="stylesheet" href="css/styles.css">
|
|
8
8
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
9
9
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
10
|
+
<link rel="icon" href="images/logo.svg" sizes="any" type="image/svg+xml">
|
|
10
11
|
<style>
|
|
11
12
|
.dependency-list {
|
|
12
13
|
max-width: 100%;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<link rel="stylesheet" href="css/styles.css">
|
|
8
8
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
9
9
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
10
|
+
<link rel="icon" href="images/logo.svg" sizes="any" type="image/svg+xml">
|
|
10
11
|
<style>
|
|
11
12
|
/* File Tree Styling */
|
|
12
13
|
.file-tree {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<link rel="stylesheet" href="css/styles.css">
|
|
8
8
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
9
9
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
10
|
+
<link rel="icon" href="images/logo.svg" sizes="any" type="image/svg+xml">
|
|
10
11
|
</head>
|
|
11
12
|
<body>
|
|
12
13
|
<div class="dashboard">
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<link rel="stylesheet" href="css/styles.css">
|
|
8
8
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
9
9
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
10
|
+
<link rel="icon" href="images/logo.svg" sizes="any" type="image/svg+xml">
|
|
10
11
|
</head>
|
|
11
12
|
<body>
|
|
12
13
|
<div class="dashboard">
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<link rel="stylesheet" href="css/styles.css">
|
|
8
8
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
9
9
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
10
|
+
<link rel="icon" href="images/logo.svg" sizes="any" type="image/svg+xml">
|
|
10
11
|
<style>.cc-offenders {
|
|
11
12
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
12
13
|
background-color: #f9f9f9;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<link rel="stylesheet" href="css/styles.css">
|
|
8
8
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
9
9
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
10
|
+
<link rel="icon" href="images/logo.svg" sizes="any" type="image/svg+xml">
|
|
10
11
|
</head>
|
|
11
12
|
<body>
|
|
12
13
|
<div class="dashboard">
|
|
@@ -30,7 +30,7 @@ metripy/LangAnalyzer/AbstractLangAnalyzer.py,sha256=YOnpWAKJqm3eyj-FJc2iCUUXAnfh
|
|
|
30
30
|
metripy/LangAnalyzer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
metripy/LangAnalyzer/Generic/HalSteadAnalyzer.py,sha256=z8h3V7mud5NnzQ67I9G3YhTFKHjO6Z-e_ida2d32YZ4,1845
|
|
32
32
|
metripy/LangAnalyzer/Generic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
-
metripy/LangAnalyzer/Php/PhpAnalyzer.py,sha256=
|
|
33
|
+
metripy/LangAnalyzer/Php/PhpAnalyzer.py,sha256=lQ0hGqseuZi7OxS1Qm3asjTm-5g6-PY5lLNhGg_0Q2g,8310
|
|
34
34
|
metripy/LangAnalyzer/Php/PhpBasicAstParser.py,sha256=T717e7hM67HBOZ7mvl7Jr4RkCF-Hq-sUMzk__UTheeU,1874
|
|
35
35
|
metripy/LangAnalyzer/Php/PhpBasicLocAnalyzer.py,sha256=2Vt3pbU0BEy2p8em3ZW_qOe9eGigtpZzVoEhe11S2O8,6229
|
|
36
36
|
metripy/LangAnalyzer/Php/PhpHalSteadAnalyzer.py,sha256=XgEo1dXSpIYWBWt9wEQxigpNdLWs-BteX2U2lVLVpl8,1037
|
|
@@ -77,20 +77,20 @@ metripy/Tree/ClassNode.py,sha256=gsoVTKF2iC5yxksI23fIvYakfElzF-NA43Lj0wDW9OM,162
|
|
|
77
77
|
metripy/Tree/FunctionNode.py,sha256=EcoAdjeMC9XB7NE6BGJLqDuTO6r-YlwBQfsyl_AupLU,3540
|
|
78
78
|
metripy/Tree/ModuleNode.py,sha256=YHlkAJKWWjy1oAhg7IdrvYnTOxpBYnq_VJS_ykey5_Y,1238
|
|
79
79
|
metripy/Trend/TrendAnalyzer.py,sha256=Rm0VfxjN61O2-FxhIP8CFO6OT4j9JI7f7kRhJ0GLmBM,6926
|
|
80
|
-
metripy/templates/html_report/dependencies.html,sha256=
|
|
81
|
-
metripy/templates/html_report/files.html,sha256=
|
|
82
|
-
metripy/templates/html_report/git_analysis.html,sha256=
|
|
83
|
-
metripy/templates/html_report/index.html,sha256=
|
|
84
|
-
metripy/templates/html_report/top_offenders.html,sha256=
|
|
85
|
-
metripy/templates/html_report/trends.html,sha256=
|
|
80
|
+
metripy/templates/html_report/dependencies.html,sha256=VtYpzQNuQfyMPHkJEA4NuBWh6P8XHHUmXINgZh_YZAo,13890
|
|
81
|
+
metripy/templates/html_report/files.html,sha256=ZBNNac90Oc3gUwNEqsKC7KEFvkI8xXZLOvy1tIgBI_c,36176
|
|
82
|
+
metripy/templates/html_report/git_analysis.html,sha256=9OiDsRzk3-hkcz8pcIRqAOWMpFZdRSWBYcZQwYO9ZlA,15422
|
|
83
|
+
metripy/templates/html_report/index.html,sha256=xTdkOTZE_oKZxQaOUbglMDdl3UM3RJY1eqBrh2gCJS0,18536
|
|
84
|
+
metripy/templates/html_report/top_offenders.html,sha256=DVptk2JhX5Lu4WqB8SgVMfjkV2R94Qd9RqvYLwjA6aI,9643
|
|
85
|
+
metripy/templates/html_report/trends.html,sha256=1YyZJImaEs5XVFQoitd7lOdIEa7AKTdzK8t2SsT8k1c,30110
|
|
86
86
|
metripy/templates/html_report/css/styles.css,sha256=cN3ZFN5SdXw9IFBGvybILcUy9FGEZqGghcr4763ZLtQ,29227
|
|
87
87
|
metripy/templates/html_report/images/logo.svg,sha256=59gZXNLrZdKaefBoZMog8UPyyNj_TuNEZQKrO01fqf0,1071
|
|
88
88
|
metripy/templates/html_report/js/charts.js,sha256=1L3me_UVWBjLVyNyKQ9v19etd0u31jnCvbpyGaX-0Go,10127
|
|
89
89
|
metripy/templates/html_report/js/dashboard.js,sha256=RdV2GTFEm5Cc7oqGPxfsYUCt3lTmOzaZ9sUN60Vl1mE,19965
|
|
90
90
|
metripy/templates/html_report/js/git_analysis.js,sha256=GxtmRyouS55bgKPvdko4-AxywFvx1V7x3HuCjRZczk4,12798
|
|
91
|
-
metripy-0.3.
|
|
92
|
-
metripy-0.3.
|
|
93
|
-
metripy-0.3.
|
|
94
|
-
metripy-0.3.
|
|
95
|
-
metripy-0.3.
|
|
96
|
-
metripy-0.3.
|
|
91
|
+
metripy-0.3.7.dist-info/licenses/LICENSE,sha256=7I-LBXpo2Lveofzf06uDAmq0wPN7zbMwInrQZiQCiwc,1063
|
|
92
|
+
metripy-0.3.7.dist-info/METADATA,sha256=4dABg_5vgZaQyAUpKlfAwn56oLmM8_4cqomnBAy7BNk,4190
|
|
93
|
+
metripy-0.3.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
94
|
+
metripy-0.3.7.dist-info/entry_points.txt,sha256=vZI1vreNyXX9XGDUQlOnE2cSBRWNyXOlXXFnEBsVNIA,49
|
|
95
|
+
metripy-0.3.7.dist-info/top_level.txt,sha256=Z-tn-27QGcxzNrsRq7BNPQv2BlXJnMCp8bp2sPdde1Y,8
|
|
96
|
+
metripy-0.3.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|