metripy 0.2.7__py3-none-any.whl → 0.3.6__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.

Files changed (67) hide show
  1. metripy/Application/Analyzer.py +23 -3
  2. metripy/Application/Application.py +16 -2
  3. metripy/Application/Config/Config.py +34 -0
  4. metripy/Application/Config/File/ConfigFileReaderFactory.py +6 -5
  5. metripy/Application/Config/File/ConfigFileReaderInterface.py +70 -3
  6. metripy/Application/Config/File/JsonConfigFileReader.py +5 -70
  7. metripy/Application/Config/File/YamlConfigFileReader.py +17 -0
  8. metripy/Application/Config/Parser.py +24 -11
  9. metripy/Application/Config/ProjectConfig.py +64 -0
  10. metripy/Application/Info.py +61 -0
  11. metripy/Dependency/Dependency.py +17 -1
  12. metripy/Dependency/Pip/Pip.py +21 -31
  13. metripy/Dependency/Pip/PyPi.py +1 -0
  14. metripy/Git/GitAnalyzer.py +0 -3
  15. metripy/Import/Json/JsonImporter.py +17 -0
  16. metripy/LangAnalyzer/AbstractLangAnalyzer.py +4 -3
  17. metripy/LangAnalyzer/Php/PhpAnalyzer.py +2 -1
  18. metripy/LangAnalyzer/Python/PythonAnalyzer.py +31 -9
  19. metripy/LangAnalyzer/Python/PythonHalSteadAnalyzer.py +55 -0
  20. metripy/LangAnalyzer/Typescript/TypescriptAnalyzer.py +12 -9
  21. metripy/LangAnalyzer/Typescript/TypescriptAstParser.py +1 -1
  22. metripy/Metric/Code/AggregatedMetrics.py +12 -5
  23. metripy/Metric/Code/FileMetrics.py +32 -1
  24. metripy/Metric/Code/ModuleMetrics.py +5 -5
  25. metripy/Metric/Code/SegmentedMetrics.py +72 -36
  26. metripy/Metric/Code/Segmentor.py +44 -0
  27. metripy/Metric/FileTree/FileTreeParser.py +0 -4
  28. metripy/Metric/Git/GitMetrics.py +1 -1
  29. metripy/Metric/ProjectMetrics.py +29 -0
  30. metripy/Metric/Trend/AggregatedTrendMetric.py +101 -0
  31. metripy/Metric/Trend/ClassTrendMetric.py +20 -0
  32. metripy/Metric/Trend/FileTrendMetric.py +46 -0
  33. metripy/Metric/Trend/FunctionTrendMetric.py +28 -0
  34. metripy/Metric/Trend/SegmentedTrendMetric.py +29 -0
  35. metripy/Report/Html/DependencyPageRenderer.py +21 -0
  36. metripy/Report/Html/FilesPageRenderer.py +28 -0
  37. metripy/Report/Html/GitAnalysisPageRenderer.py +55 -0
  38. metripy/Report/Html/IndexPageRenderer.py +47 -0
  39. metripy/Report/Html/PageRenderer.py +43 -0
  40. metripy/Report/Html/PageRendererFactory.py +37 -0
  41. metripy/Report/Html/Reporter.py +78 -137
  42. metripy/Report/Html/TopOffendersPageRenderer.py +84 -0
  43. metripy/Report/Html/TrendsPageRenderer.py +137 -0
  44. metripy/Report/Json/GitJsonReporter.py +3 -0
  45. metripy/Report/Json/JsonReporter.py +6 -2
  46. metripy/Report/ReporterFactory.py +6 -3
  47. metripy/Tree/ClassNode.py +21 -0
  48. metripy/Tree/FunctionNode.py +66 -1
  49. metripy/Trend/TrendAnalyzer.py +150 -0
  50. metripy/templates/html_report/css/styles.css +1386 -0
  51. metripy/templates/html_report/dependencies.html +411 -0
  52. metripy/templates/html_report/files.html +1080 -0
  53. metripy/templates/html_report/git_analysis.html +325 -0
  54. metripy/templates/html_report/images/logo.svg +31 -0
  55. metripy/templates/html_report/index.html +374 -0
  56. metripy/templates/html_report/js/charts.js +313 -0
  57. metripy/templates/html_report/js/dashboard.js +546 -0
  58. metripy/templates/html_report/js/git_analysis.js +383 -0
  59. metripy/templates/html_report/top_offenders.html +267 -0
  60. metripy/templates/html_report/trends.html +468 -0
  61. {metripy-0.2.7.dist-info → metripy-0.3.6.dist-info}/METADATA +27 -9
  62. metripy-0.3.6.dist-info/RECORD +96 -0
  63. {metripy-0.2.7.dist-info → metripy-0.3.6.dist-info}/licenses/LICENSE +1 -1
  64. metripy-0.2.7.dist-info/RECORD +0 -66
  65. {metripy-0.2.7.dist-info → metripy-0.3.6.dist-info}/WHEEL +0 -0
  66. {metripy-0.2.7.dist-info → metripy-0.3.6.dist-info}/entry_points.txt +0 -0
  67. {metripy-0.2.7.dist-info → metripy-0.3.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,150 @@
1
+ from metripy.Metric.Code.AggregatedMetrics import AggregatedMetrics
2
+ from metripy.Metric.Code.FileMetrics import FileMetrics
3
+ from metripy.Metric.ProjectMetrics import ProjectMetrics
4
+ from metripy.Metric.Trend.AggregatedTrendMetric import AggregatedTrendMetric
5
+ from metripy.Metric.Trend.ClassTrendMetric import ClassTrendMetric
6
+ from metripy.Metric.Trend.FileTrendMetric import FileTrendMetric
7
+ from metripy.Metric.Trend.FunctionTrendMetric import FunctionTrendMetric
8
+ from metripy.Tree.ClassNode import ClassNode
9
+ from metripy.Tree.FunctionNode import FunctionNode
10
+
11
+
12
+ class TrendAnalyzer:
13
+ def create_file_trend_metric(
14
+ self, file_metric: FileMetrics, historical_file_metric: FileMetrics
15
+ ) -> FileTrendMetric:
16
+ return FileTrendMetric(
17
+ historical_loc=historical_file_metric.loc,
18
+ loc=file_metric.loc,
19
+ historical_totalCc=historical_file_metric.totalCc,
20
+ totalCc=file_metric.totalCc,
21
+ historical_avgCcPerFunction=historical_file_metric.avgCcPerFunction,
22
+ avgCcPerFunction=file_metric.avgCcPerFunction,
23
+ historical_maintainabilityIndex=historical_file_metric.maintainabilityIndex,
24
+ maintainabilityIndex=file_metric.maintainabilityIndex,
25
+ historical_avgLocPerFunction=historical_file_metric.avgLocPerFunction,
26
+ avgLocPerFunction=file_metric.avgLocPerFunction,
27
+ )
28
+
29
+ def create_class_trend_metric(
30
+ self, class_metric: ClassNode, historical_class_metric: ClassNode
31
+ ) -> ClassTrendMetric:
32
+ return ClassTrendMetric(
33
+ historical_lineno=historical_class_metric.lineno,
34
+ lineno=class_metric.lineno,
35
+ historical_real_complexity=historical_class_metric.real_complexity,
36
+ real_complexity=class_metric.real_complexity,
37
+ )
38
+
39
+ def create_function_trend_metric(
40
+ self, function_metric: FunctionNode, historical_function_metric: FunctionNode
41
+ ) -> FunctionTrendMetric:
42
+ return FunctionTrendMetric(
43
+ historical_loc=historical_function_metric.get_loc(),
44
+ loc=function_metric.get_loc(),
45
+ historical_complexity=historical_function_metric.complexity,
46
+ complexity=function_metric.complexity,
47
+ historical_maintainability_index=historical_function_metric.maintainability_index,
48
+ maintainability_index=function_metric.maintainability_index,
49
+ )
50
+
51
+ def add_historical_file_trends(
52
+ self,
53
+ file_metrics: list[FileMetrics],
54
+ historical_file_metrics: list[FileMetrics],
55
+ ):
56
+ indexed_file_metrics = {m.full_name: m for m in file_metrics}
57
+ indexed_historical_file_metrics = {
58
+ m.full_name: m for m in historical_file_metrics
59
+ }
60
+
61
+ for full_name, file_metric in indexed_file_metrics.items():
62
+ historical_file_metric = indexed_historical_file_metrics.get(full_name)
63
+ if not historical_file_metric:
64
+ continue
65
+ file_metric.trend = self.create_file_trend_metric(
66
+ file_metric, historical_file_metric
67
+ )
68
+
69
+ indexed_class_nodes = {
70
+ n.full_name: n for n in historical_file_metric.class_nodes
71
+ }
72
+ for class_node in file_metric.class_nodes:
73
+ historical_class_node = indexed_class_nodes.get(class_node.full_name)
74
+ if not historical_class_node:
75
+ continue
76
+ class_node.trend = self.create_class_trend_metric(
77
+ class_node, historical_class_node
78
+ )
79
+
80
+ indexed_function_nodes = {
81
+ n.full_name: n for n in historical_class_node.functions
82
+ }
83
+ for function_node in class_node.functions:
84
+ historical_function_node = indexed_function_nodes.get(
85
+ function_node.full_name
86
+ )
87
+ if not historical_function_node:
88
+ continue
89
+ function_node.trend = self.create_function_trend_metric(
90
+ function_node, historical_function_node
91
+ )
92
+
93
+ indexed_function_nodes = {
94
+ n.full_name: n for n in historical_file_metric.function_nodes
95
+ }
96
+ for function_node in file_metric.function_nodes:
97
+ historical_function_node = indexed_function_nodes.get(
98
+ function_node.full_name
99
+ )
100
+ if not historical_function_node:
101
+ continue
102
+ function_node.trend = self.create_function_trend_metric(
103
+ function_node, historical_function_node
104
+ )
105
+
106
+ def create_aggregated_trend_metric(
107
+ self,
108
+ aggregated_metric: AggregatedMetrics,
109
+ historical_aggregated_metric: AggregatedMetrics,
110
+ ) -> AggregatedTrendMetric:
111
+ return AggregatedTrendMetric(
112
+ historical_loc=historical_aggregated_metric.loc,
113
+ loc=aggregated_metric.loc,
114
+ historical_avgCcPerFunction=historical_aggregated_metric.avgCcPerFunction,
115
+ avgCcPerFunction=aggregated_metric.avgCcPerFunction,
116
+ historical_maintainabilityIndex=historical_aggregated_metric.maintainabilityIndex,
117
+ maintainabilityIndex=aggregated_metric.maintainabilityIndex,
118
+ historical_avgLocPerFunction=historical_aggregated_metric.avgLocPerFunction,
119
+ avgLocPerFunction=aggregated_metric.avgLocPerFunction,
120
+ historical_num_files=historical_aggregated_metric.num_files,
121
+ num_files=aggregated_metric.num_files,
122
+ historical_segmented_loc=historical_aggregated_metric.segmentation_data[
123
+ "loc"
124
+ ],
125
+ segmented_loc=aggregated_metric.segmentation_data["loc"],
126
+ historical_segmented_complexity=historical_aggregated_metric.segmentation_data[
127
+ "complexity"
128
+ ],
129
+ segmented_complexity=aggregated_metric.segmentation_data["complexity"],
130
+ historical_segmented_maintainability=historical_aggregated_metric.segmentation_data[
131
+ "maintainability"
132
+ ],
133
+ segmented_maintainability=aggregated_metric.segmentation_data[
134
+ "maintainability"
135
+ ],
136
+ historical_segmented_method_size=historical_aggregated_metric.segmentation_data[
137
+ "methodSize"
138
+ ],
139
+ segmented_method_size=aggregated_metric.segmentation_data["methodSize"],
140
+ )
141
+
142
+ def add_historical_project_trends(
143
+ self,
144
+ project_metrics: ProjectMetrics,
145
+ historical_project_metrics: ProjectMetrics,
146
+ ):
147
+ project_metrics.total_code_metrics.trend = self.create_aggregated_trend_metric(
148
+ project_metrics.total_code_metrics,
149
+ historical_project_metrics.total_code_metrics,
150
+ )