metripy 0.2.5__tar.gz → 0.2.8__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.
Potentially problematic release.
This version of metripy might be problematic. Click here for more details.
- {metripy-0.2.5 → metripy-0.2.8}/LICENSE +1 -1
- {metripy-0.2.5 → metripy-0.2.8}/PKG-INFO +28 -10
- {metripy-0.2.5 → metripy-0.2.8}/README.md +22 -5
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Analyzer.py +17 -16
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Application.py +7 -7
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Config/Config.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Config/File/ConfigFileReaderFactory.py +4 -2
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Config/File/ConfigFileReaderInterface.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Config/File/JsonConfigFileReader.py +6 -5
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Config/Parser.py +5 -4
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Config/ProjectConfig.py +2 -2
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Component/Debug/Debugger.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Component/File/Finder.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Component/Output/ProgressBar.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Dependency/Composer/Composer.py +2 -2
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Dependency/Composer/Packegist.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Dependency/Dependency.py +16 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Dependency/Npm/Npm.py +2 -2
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Dependency/Npm/NpmOrg.py +1 -1
- metripy-0.2.8/metripy/Dependency/Pip/Pip.py +60 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Dependency/Pip/PyPi.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Git/GitAnalyzer.py +2 -2
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/AbstractLangAnalyzer.py +2 -2
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Php/PhpAnalyzer.py +10 -10
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Php/PhpHalSteadAnalyzer.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Python/PythonAnalyzer.py +6 -6
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Typescript/TypescriptAnalyzer.py +14 -16
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Typescript/TypescriptAstParser.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Typescript/TypescriptBasicComplexityAnalyzer.py +3 -3
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Typescript/TypescriptHalSteadAnalyzer.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/Code/AggregatedMetrics.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/Code/FileMetrics.py +2 -2
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/Code/ModuleMetrics.py +2 -2
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/FileTree/FileTreeParser.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/Git/GitMetrics.py +3 -3
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/ProjectMetrics.py +19 -5
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Report/Csv/Reporter.py +3 -3
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Report/Html/Reporter.py +12 -17
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Report/Json/AbstractJsonReporter.py +2 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Report/Json/GitJsonReporter.py +3 -2
- metripy-0.2.8/metripy/Report/Json/JsonReporter.py +13 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Report/ReporterFactory.py +7 -6
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Report/ReporterInterface.py +3 -3
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Tree/ClassNode.py +1 -1
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Tree/ModuleNode.py +2 -2
- metripy-0.2.5/src/codemetrics.py → metripy-0.2.8/metripy/metripy.py +1 -1
- {metripy-0.2.5 → metripy-0.2.8}/metripy.egg-info/PKG-INFO +28 -10
- metripy-0.2.8/metripy.egg-info/SOURCES.txt +69 -0
- metripy-0.2.8/metripy.egg-info/entry_points.txt +2 -0
- {metripy-0.2.5 → metripy-0.2.8}/metripy.egg-info/requires.txt +1 -0
- metripy-0.2.8/metripy.egg-info/top_level.txt +1 -0
- {metripy-0.2.5 → metripy-0.2.8}/pyproject.toml +14 -11
- metripy-0.2.5/metripy.egg-info/SOURCES.txt +0 -69
- metripy-0.2.5/metripy.egg-info/entry_points.txt +0 -2
- metripy-0.2.5/metripy.egg-info/top_level.txt +0 -1
- metripy-0.2.5/src/Dependency/Pip/Pip.py +0 -69
- metripy-0.2.5/src/Report/Json/JsonReporter.py +0 -12
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Config/GitConfig.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Config/ReportConfig.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/__init__.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Component/Output/CliOutput.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Generic/HalSteadAnalyzer.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Generic/__init__.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Php/PhpBasicAstParser.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Php/PhpBasicLocAnalyzer.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/Typescript/TypescriptBasicLocAnalyzer.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/LangAnalyzer/__init__.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/Code/SegmentedMetrics.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/FileTree/FileTree.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/Git/GitCodeHotspot.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/Git/GitContributor.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Metric/Git/GitKnowledgeSilo.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/Tree/FunctionNode.py +0 -0
- {metripy-0.2.5/src → metripy-0.2.8/metripy}/__init__.py +0 -0
- {metripy-0.2.5 → metripy-0.2.8}/metripy.egg-info/dependency_links.txt +0 -0
- {metripy-0.2.5 → metripy-0.2.8}/setup.cfg +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: metripy
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: A Python tool to generate multi project, multi language code metric reports
|
|
5
5
|
Author-email: Yannick Zimmermann <yannick.zimmermann@proton.me>
|
|
6
6
|
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/zimmer-yan/
|
|
8
|
-
Project-URL: Repository, https://github.com/zimmer-yan/
|
|
9
|
-
Project-URL: Documentation, https://github.com/zimmer-yan/
|
|
10
|
-
Project-URL: Bug Tracker, https://github.com/zimmer-yan/
|
|
7
|
+
Project-URL: Homepage, https://github.com/zimmer-yan/metripy
|
|
8
|
+
Project-URL: Repository, https://github.com/zimmer-yan/metripy
|
|
9
|
+
Project-URL: Documentation, https://github.com/zimmer-yan/metripy#readme
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/zimmer-yan/metripy/issues
|
|
11
11
|
Keywords: code metrics,multi-language,code analysis,git metrics,code visualization,software quality,static analysis,repository insights,developer productivity,codebase health,technical debt,language-agnostic
|
|
12
12
|
Classifier: Development Status :: 3 - Alpha
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -34,9 +34,10 @@ Requires-Dist: black>=22.0.0; extra == "dev"
|
|
|
34
34
|
Requires-Dist: flake8>=5.0.0; extra == "dev"
|
|
35
35
|
Requires-Dist: mypy>=0.991; extra == "dev"
|
|
36
36
|
Requires-Dist: poethepoet==0.37.0; extra == "dev"
|
|
37
|
+
Requires-Dist: isort==7.0.0; extra == "dev"
|
|
37
38
|
Dynamic: license-file
|
|
38
39
|
|
|
39
|
-
#
|
|
40
|
+
# Metripy
|
|
40
41
|
A multilanguage, multi project code metrics analysis tool.
|
|
41
42
|
|
|
42
43
|
# Languages
|
|
@@ -82,10 +83,10 @@ Sample configuraiton:
|
|
|
82
83
|
```json
|
|
83
84
|
{
|
|
84
85
|
"configs": {
|
|
85
|
-
"
|
|
86
|
+
"metripy": {
|
|
86
87
|
"base_path": "./", // base path to look at
|
|
87
88
|
"includes": [
|
|
88
|
-
"
|
|
89
|
+
"metripy/" // paths to include from the base path on
|
|
89
90
|
],
|
|
90
91
|
"excludes": [
|
|
91
92
|
"__pycache__" // exclude patterns of paths / files
|
|
@@ -101,8 +102,8 @@ Sample configuraiton:
|
|
|
101
102
|
"pip": true,
|
|
102
103
|
// looks for base_path/requirements.txt or base_path/pyproject.toml and analyzes dependencies - for python projects
|
|
103
104
|
"reports": {
|
|
104
|
-
"html": "./build/report/
|
|
105
|
-
"json-git": "./build/json-report/
|
|
105
|
+
"html": "./build/report/metripy", // report should be put into this directory
|
|
106
|
+
"json-git": "./build/json-report/metripy-git.json" // file where to put git json report
|
|
106
107
|
// more types of reports TBA
|
|
107
108
|
}
|
|
108
109
|
},
|
|
@@ -110,3 +111,20 @@ Sample configuraiton:
|
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
```
|
|
114
|
+
|
|
115
|
+
## Configuration for only git stats
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"configs": {
|
|
119
|
+
"metripy-git": {
|
|
120
|
+
"base_path": "./",
|
|
121
|
+
"git": {
|
|
122
|
+
"branch": "main"
|
|
123
|
+
},
|
|
124
|
+
"reports": {
|
|
125
|
+
"json-git": "./build/json-report/metripy-git.json"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Metripy
|
|
2
2
|
A multilanguage, multi project code metrics analysis tool.
|
|
3
3
|
|
|
4
4
|
# Languages
|
|
@@ -44,10 +44,10 @@ Sample configuraiton:
|
|
|
44
44
|
```json
|
|
45
45
|
{
|
|
46
46
|
"configs": {
|
|
47
|
-
"
|
|
47
|
+
"metripy": {
|
|
48
48
|
"base_path": "./", // base path to look at
|
|
49
49
|
"includes": [
|
|
50
|
-
"
|
|
50
|
+
"metripy/" // paths to include from the base path on
|
|
51
51
|
],
|
|
52
52
|
"excludes": [
|
|
53
53
|
"__pycache__" // exclude patterns of paths / files
|
|
@@ -63,8 +63,8 @@ Sample configuraiton:
|
|
|
63
63
|
"pip": true,
|
|
64
64
|
// looks for base_path/requirements.txt or base_path/pyproject.toml and analyzes dependencies - for python projects
|
|
65
65
|
"reports": {
|
|
66
|
-
"html": "./build/report/
|
|
67
|
-
"json-git": "./build/json-report/
|
|
66
|
+
"html": "./build/report/metripy", // report should be put into this directory
|
|
67
|
+
"json-git": "./build/json-report/metripy-git.json" // file where to put git json report
|
|
68
68
|
// more types of reports TBA
|
|
69
69
|
}
|
|
70
70
|
},
|
|
@@ -72,3 +72,20 @@ Sample configuraiton:
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
|
+
|
|
76
|
+
## Configuration for only git stats
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"configs": {
|
|
80
|
+
"metripy-git": {
|
|
81
|
+
"base_path": "./",
|
|
82
|
+
"git": {
|
|
83
|
+
"branch": "main"
|
|
84
|
+
},
|
|
85
|
+
"reports": {
|
|
86
|
+
"json-git": "./build/json-report/metripy-git.json"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
from Application.Config.ProjectConfig import ProjectConfig
|
|
2
|
-
from Component.Debug.Debugger import Debugger
|
|
3
|
-
from Component.Output.CliOutput import CliOutput
|
|
4
|
-
from Component.Output.ProgressBar import ProgressBar
|
|
5
|
-
from Dependency.Composer.Composer import Composer
|
|
6
|
-
from Dependency.Dependency import Dependency
|
|
7
|
-
from Dependency.Npm.Npm import Npm
|
|
8
|
-
from Dependency.Pip.Pip import Pip
|
|
9
|
-
from Git.GitAnalyzer import GitAnalyzer
|
|
10
|
-
from LangAnalyzer.AbstractLangAnalyzer import AbstractLangAnalyzer
|
|
11
|
-
from LangAnalyzer.Php.PhpAnalyzer import PhpAnalyzer
|
|
12
|
-
from LangAnalyzer.Python.PythonAnalyzer import PythonAnalyzer
|
|
13
|
-
from LangAnalyzer.Typescript.TypescriptAnalyzer import
|
|
14
|
-
|
|
15
|
-
from Metric.
|
|
16
|
-
from Metric.
|
|
1
|
+
from metripy.Application.Config.ProjectConfig import ProjectConfig
|
|
2
|
+
from metripy.Component.Debug.Debugger import Debugger
|
|
3
|
+
from metripy.Component.Output.CliOutput import CliOutput
|
|
4
|
+
from metripy.Component.Output.ProgressBar import ProgressBar
|
|
5
|
+
from metripy.Dependency.Composer.Composer import Composer
|
|
6
|
+
from metripy.Dependency.Dependency import Dependency
|
|
7
|
+
from metripy.Dependency.Npm.Npm import Npm
|
|
8
|
+
from metripy.Dependency.Pip.Pip import Pip
|
|
9
|
+
from metripy.Git.GitAnalyzer import GitAnalyzer
|
|
10
|
+
from metripy.LangAnalyzer.AbstractLangAnalyzer import AbstractLangAnalyzer
|
|
11
|
+
from metripy.LangAnalyzer.Php.PhpAnalyzer import PhpAnalyzer
|
|
12
|
+
from metripy.LangAnalyzer.Python.PythonAnalyzer import PythonAnalyzer
|
|
13
|
+
from metripy.LangAnalyzer.Typescript.TypescriptAnalyzer import \
|
|
14
|
+
TypescriptAnalyzer
|
|
15
|
+
from metripy.Metric.Code.FileMetrics import FileMetrics
|
|
16
|
+
from metripy.Metric.Git.GitMetrics import GitMetrics
|
|
17
|
+
from metripy.Metric.ProjectMetrics import ProjectMetrics
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
class Analyzer:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import json
|
|
2
2
|
|
|
3
|
-
from Application.Analyzer import Analyzer
|
|
4
|
-
from Application.Config.Parser import Parser
|
|
5
|
-
from Component.Debug.Debugger import Debugger
|
|
6
|
-
from Component.File.Finder import Finder
|
|
7
|
-
from Component.Output.CliOutput import CliOutput
|
|
8
|
-
from Report.ReporterFactory import ReporterFactory
|
|
9
|
-
from Report.ReporterInterface import ReporterInterface
|
|
3
|
+
from metripy.Application.Analyzer import Analyzer
|
|
4
|
+
from metripy.Application.Config.Parser import Parser
|
|
5
|
+
from metripy.Component.Debug.Debugger import Debugger
|
|
6
|
+
from metripy.Component.File.Finder import Finder
|
|
7
|
+
from metripy.Component.Output.CliOutput import CliOutput
|
|
8
|
+
from metripy.Report.ReporterFactory import ReporterFactory
|
|
9
|
+
from metripy.Report.ReporterInterface import ReporterInterface
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class Application:
|
{metripy-0.2.5/src → metripy-0.2.8/metripy}/Application/Config/File/ConfigFileReaderFactory.py
RENAMED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import pathlib
|
|
3
3
|
|
|
4
|
-
from Application.Config.File.ConfigFileReaderInterface import
|
|
5
|
-
|
|
4
|
+
from metripy.Application.Config.File.ConfigFileReaderInterface import \
|
|
5
|
+
ConfigFileReaderInterface
|
|
6
|
+
from metripy.Application.Config.File.JsonConfigFileReader import \
|
|
7
|
+
JsonConfigFileReader
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class ConfigFileReaderFactory:
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
|
-
from Application.Config.Config import Config
|
|
5
|
-
from Application.Config.File.ConfigFileReaderInterface import
|
|
6
|
-
|
|
7
|
-
from Application.Config.
|
|
8
|
-
from Application.Config.
|
|
4
|
+
from metripy.Application.Config.Config import Config
|
|
5
|
+
from metripy.Application.Config.File.ConfigFileReaderInterface import \
|
|
6
|
+
ConfigFileReaderInterface
|
|
7
|
+
from metripy.Application.Config.GitConfig import GitConfig
|
|
8
|
+
from metripy.Application.Config.ProjectConfig import ProjectConfig
|
|
9
|
+
from metripy.Application.Config.ReportConfig import ReportConfig
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class JsonConfigFileReader(ConfigFileReaderInterface):
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import re
|
|
2
2
|
|
|
3
|
-
from Application.Config.Config import Config
|
|
4
|
-
from Application.Config.File.ConfigFileReaderFactory import
|
|
3
|
+
from metripy.Application.Config.Config import Config
|
|
4
|
+
from metripy.Application.Config.File.ConfigFileReaderFactory import \
|
|
5
|
+
ConfigFileReaderFactory
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class Parser:
|
|
8
9
|
def parse(self, argv: list[str]) -> Config:
|
|
9
10
|
config = Config()
|
|
10
11
|
|
|
11
|
-
if argv[0] == "
|
|
12
|
-
# TODO, fix when path ends with
|
|
12
|
+
if argv[0] == "metripy.py" or argv[0] == "metripy":
|
|
13
|
+
# TODO, fix when path ends with metripy.py
|
|
13
14
|
pass
|
|
14
15
|
argv.pop(0)
|
|
15
16
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
|
-
from Dependency.Composer.Packegist import Packegist
|
|
5
|
-
from Dependency.Dependency import Dependency
|
|
4
|
+
from metripy.Dependency.Composer.Packegist import Packegist
|
|
5
|
+
from metripy.Dependency.Dependency import Dependency
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class Composer:
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
from typing import Self
|
|
2
|
+
|
|
1
3
|
class Dependency:
|
|
2
|
-
def __init__(self, name: str, version: str):
|
|
4
|
+
def __init__(self, name: str, version: str|None):
|
|
3
5
|
self.name = name
|
|
4
6
|
self.version = version
|
|
5
7
|
self.latest: str = ""
|
|
@@ -28,3 +30,16 @@ class Dependency:
|
|
|
28
30
|
"downloads_monthly": self.downloads_monthly,
|
|
29
31
|
"licenses": ",".join(self.license),
|
|
30
32
|
}
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def get_lisence_distribution(dependencies: list[Self]) -> dict[str, int]:
|
|
36
|
+
license_by_type = {}
|
|
37
|
+
|
|
38
|
+
dependency: Dependency
|
|
39
|
+
for dependency in dependencies:
|
|
40
|
+
for license_name in dependency.license:
|
|
41
|
+
if license_name not in license_by_type.keys():
|
|
42
|
+
license_by_type[license_name] = 0
|
|
43
|
+
license_by_type[license_name] += 1
|
|
44
|
+
|
|
45
|
+
return license_by_type
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
|
|
4
|
+
import toml
|
|
5
|
+
|
|
6
|
+
from metripy.Dependency.Dependency import Dependency
|
|
7
|
+
from metripy.Dependency.Pip.PyPi import PyPi
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Pip:
|
|
11
|
+
def get_dependencies(self, path: str) -> list[Dependency]:
|
|
12
|
+
try:
|
|
13
|
+
requirements = self.get_from_requirements_txt(path)
|
|
14
|
+
except FileNotFoundError:
|
|
15
|
+
requirements = self.get_from_pyproject_toml(path)
|
|
16
|
+
|
|
17
|
+
pypi = PyPi()
|
|
18
|
+
packages = []
|
|
19
|
+
for dependency in requirements:
|
|
20
|
+
package = pypi.get_info(dependency)
|
|
21
|
+
packages.append(package)
|
|
22
|
+
|
|
23
|
+
return [item for item in packages if item is not None]
|
|
24
|
+
|
|
25
|
+
def get_from_requirements_txt(self, path: str) -> list[Dependency]:
|
|
26
|
+
with open(os.path.join(path, "requirements.txt"), "r") as file:
|
|
27
|
+
lines = file.readlines()
|
|
28
|
+
return self._parse_dependencies(lines)
|
|
29
|
+
|
|
30
|
+
return []
|
|
31
|
+
|
|
32
|
+
def get_from_pyproject_toml(self, path: str) -> list[Dependency]:
|
|
33
|
+
with open(os.path.join(path, "pyproject.toml"), "r") as f:
|
|
34
|
+
data = toml.load(f)
|
|
35
|
+
|
|
36
|
+
# For PEP 621 / setuptools projects
|
|
37
|
+
if "project" in data:
|
|
38
|
+
deps = data["project"].get("dependencies", [])
|
|
39
|
+
return self._parse_dependencies(deps)
|
|
40
|
+
|
|
41
|
+
return []
|
|
42
|
+
|
|
43
|
+
def _parse_dependencies(self, lines: list[str]) -> list[Dependency]:
|
|
44
|
+
dependencies = []
|
|
45
|
+
for dep in lines:
|
|
46
|
+
dep = dep.strip()
|
|
47
|
+
if not dep or dep.startswith("#"):
|
|
48
|
+
continue
|
|
49
|
+
# dep is a string like "requests>=2.32.5"
|
|
50
|
+
if "==" in dep:
|
|
51
|
+
name, version = dep.split("==")
|
|
52
|
+
elif ">=" in dep:
|
|
53
|
+
name, version = dep.split(">=")
|
|
54
|
+
else:
|
|
55
|
+
name, version = dep, None
|
|
56
|
+
dependencies.append(
|
|
57
|
+
Dependency(name.strip(), version.strip() if version else None)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
return dependencies
|
|
@@ -3,8 +3,8 @@ from datetime import datetime
|
|
|
3
3
|
|
|
4
4
|
from git import Repo
|
|
5
5
|
|
|
6
|
-
from Application.Config.GitConfig import GitConfig
|
|
7
|
-
from Metric.Git.GitMetrics import GitMetrics
|
|
6
|
+
from metripy.Application.Config.GitConfig import GitConfig
|
|
7
|
+
from metripy.Metric.Git.GitMetrics import GitMetrics
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class GitAnalyzer:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
|
|
3
|
-
from Metric.Code.FileMetrics import FileMetrics
|
|
4
|
-
from Tree.ModuleNode import ModuleNode
|
|
3
|
+
from metripy.Metric.Code.FileMetrics import FileMetrics
|
|
4
|
+
from metripy.Tree.ModuleNode import ModuleNode
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class AbstractLangAnalyzer(ABC):
|
|
@@ -3,15 +3,15 @@ from pathlib import Path
|
|
|
3
3
|
|
|
4
4
|
import lizard
|
|
5
5
|
|
|
6
|
-
from Component.Output.ProgressBar import ProgressBar
|
|
7
|
-
from LangAnalyzer.AbstractLangAnalyzer import AbstractLangAnalyzer
|
|
8
|
-
from LangAnalyzer.Php.PhpBasicAstParser import PhpBasicAstParser
|
|
9
|
-
from LangAnalyzer.Php.PhpBasicLocAnalyzer import PhpBasicLocAnalyzer
|
|
10
|
-
from LangAnalyzer.Php.PhpHalSteadAnalyzer import PhpHalSteadAnalyzer
|
|
11
|
-
from Metric.Code.FileMetrics import FileMetrics
|
|
12
|
-
from Tree.ClassNode import ClassNode
|
|
13
|
-
from Tree.FunctionNode import FunctionNode
|
|
14
|
-
from Tree.ModuleNode import ModuleNode
|
|
6
|
+
from metripy.Component.Output.ProgressBar import ProgressBar
|
|
7
|
+
from metripy.LangAnalyzer.AbstractLangAnalyzer import AbstractLangAnalyzer
|
|
8
|
+
from metripy.LangAnalyzer.Php.PhpBasicAstParser import PhpBasicAstParser
|
|
9
|
+
from metripy.LangAnalyzer.Php.PhpBasicLocAnalyzer import PhpBasicLocAnalyzer
|
|
10
|
+
from metripy.LangAnalyzer.Php.PhpHalSteadAnalyzer import PhpHalSteadAnalyzer
|
|
11
|
+
from metripy.Metric.Code.FileMetrics import FileMetrics
|
|
12
|
+
from metripy.Tree.ClassNode import ClassNode
|
|
13
|
+
from metripy.Tree.FunctionNode import FunctionNode
|
|
14
|
+
from metripy.Tree.ModuleNode import ModuleNode
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class PhpAnalyzer(AbstractLangAnalyzer):
|
|
@@ -131,7 +131,7 @@ class PhpAnalyzer(AbstractLangAnalyzer):
|
|
|
131
131
|
|
|
132
132
|
code_lines = code.split("\n")
|
|
133
133
|
for func_name, function_node in functions.items():
|
|
134
|
-
lines = code_lines[function_node.lineno
|
|
134
|
+
lines = code_lines[function_node.lineno:function_node.line_end]
|
|
135
135
|
function_metrics = self.halstead_analyzer.calculate_halstead_metrics(
|
|
136
136
|
"\n".join(lines)
|
|
137
137
|
)
|
|
@@ -3,12 +3,12 @@ from radon.metrics import Halstead, HalsteadReport, h_visit, mi_visit
|
|
|
3
3
|
from radon.raw import analyze
|
|
4
4
|
from radon.visitors import Class, Function
|
|
5
5
|
|
|
6
|
-
from Component.Output.ProgressBar import ProgressBar
|
|
7
|
-
from LangAnalyzer.AbstractLangAnalyzer import AbstractLangAnalyzer
|
|
8
|
-
from Metric.Code.FileMetrics import FileMetrics
|
|
9
|
-
from Tree.ClassNode import ClassNode
|
|
10
|
-
from Tree.FunctionNode import FunctionNode
|
|
11
|
-
from Tree.ModuleNode import ModuleNode
|
|
6
|
+
from metripy.Component.Output.ProgressBar import ProgressBar
|
|
7
|
+
from metripy.LangAnalyzer.AbstractLangAnalyzer import AbstractLangAnalyzer
|
|
8
|
+
from metripy.Metric.Code.FileMetrics import FileMetrics
|
|
9
|
+
from metripy.Tree.ClassNode import ClassNode
|
|
10
|
+
from metripy.Tree.FunctionNode import FunctionNode
|
|
11
|
+
from metripy.Tree.ModuleNode import ModuleNode
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class PythonAnalyzer(AbstractLangAnalyzer):
|
|
@@ -2,21 +2,19 @@ import math
|
|
|
2
2
|
|
|
3
3
|
import lizard
|
|
4
4
|
|
|
5
|
-
from Component.Output.ProgressBar import ProgressBar
|
|
6
|
-
from LangAnalyzer.AbstractLangAnalyzer import AbstractLangAnalyzer
|
|
7
|
-
from LangAnalyzer.Typescript.TypescriptAstParser import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
from LangAnalyzer.Typescript.TypescriptBasicLocAnalyzer import
|
|
12
|
-
TypescriptBasicLocAnalyzer
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
from Tree.
|
|
18
|
-
from Tree.FunctionNode import FunctionNode
|
|
19
|
-
from Tree.ModuleNode import ModuleNode
|
|
5
|
+
from metripy.Component.Output.ProgressBar import ProgressBar
|
|
6
|
+
from metripy.LangAnalyzer.AbstractLangAnalyzer import AbstractLangAnalyzer
|
|
7
|
+
from metripy.LangAnalyzer.Typescript.TypescriptAstParser import \
|
|
8
|
+
TypescriptAstParser
|
|
9
|
+
from metripy.LangAnalyzer.Typescript.TypescriptBasicComplexityAnalyzer import \
|
|
10
|
+
TypescriptBasicComplexityAnalzyer
|
|
11
|
+
from metripy.LangAnalyzer.Typescript.TypescriptBasicLocAnalyzer import \
|
|
12
|
+
TypescriptBasicLocAnalyzer
|
|
13
|
+
from metripy.LangAnalyzer.Typescript.TypescriptHalSteadAnalyzer import \
|
|
14
|
+
TypeScriptHalSteadAnalyzer
|
|
15
|
+
from metripy.Tree.ClassNode import ClassNode
|
|
16
|
+
from metripy.Tree.FunctionNode import FunctionNode
|
|
17
|
+
from metripy.Tree.ModuleNode import ModuleNode
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
class TypescriptAnalyzer(AbstractLangAnalyzer):
|
|
@@ -148,7 +146,7 @@ class TypescriptAnalyzer(AbstractLangAnalyzer):
|
|
|
148
146
|
|
|
149
147
|
code_lines = code.split("\n")
|
|
150
148
|
for func_name, function_node in functions.items():
|
|
151
|
-
lines = code_lines[function_node.lineno
|
|
149
|
+
lines = code_lines[function_node.lineno:function_node.line_end]
|
|
152
150
|
function_metrics = self.halstead_analyzer.calculate_halstead_metrics(
|
|
153
151
|
"\n".join(lines)
|
|
154
152
|
)
|
|
@@ -8,7 +8,7 @@ class TypescriptAstParser:
|
|
|
8
8
|
self.parser = get_parser("typescript")
|
|
9
9
|
|
|
10
10
|
def _get_node_text(self, code: str, node) -> str:
|
|
11
|
-
return code[node.start_byte
|
|
11
|
+
return code[node.start_byte:node.end_byte].decode("utf-8")
|
|
12
12
|
|
|
13
13
|
def extract_structure(self, code: str) -> dict:
|
|
14
14
|
tree = self.parser.parse(bytes(code, "utf8"))
|
|
@@ -71,18 +71,18 @@ class TypescriptBasicComplexityAnalzyer:
|
|
|
71
71
|
|
|
|
72
72
|
(
|
|
73
73
|
(export\s+)?(async\s+)?function\s+{re.escape(function_name)}\s*
|
|
74
|
-
\(\s*.*?\s*\)\s*\{{
|
|
74
|
+
\(\s*.*?\s*\)\s*\{{
|
|
75
75
|
)
|
|
76
76
|
|
|
|
77
77
|
(
|
|
78
78
|
(?:public|private|protected)?\s*
|
|
79
79
|
(?:static\s+)?(?:async\s+)?{re.escape(function_name)}\s*
|
|
80
80
|
(<[^>]+>)?\s*\(\s*.*?\s*\)\s*
|
|
81
|
-
(:\s*[^\{{]+)?\s*\{{
|
|
81
|
+
(:\s*[^\{{]+)?\s*\{{
|
|
82
82
|
)
|
|
83
83
|
|
|
|
84
84
|
(
|
|
85
|
-
{re.escape(function_name)}\s*\(\s*.*?\s*\)\s*\{{
|
|
85
|
+
{re.escape(function_name)}\s*\(\s*.*?\s*\)\s*\{{
|
|
86
86
|
)
|
|
87
87
|
""",
|
|
88
88
|
re.MULTILINE | re.DOTALL | re.VERBOSE,
|