metripy 0.2.5__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.

Files changed (71) hide show
  1. metripy-0.2.5/LICENSE +21 -0
  2. metripy-0.2.5/PKG-INFO +112 -0
  3. metripy-0.2.5/README.md +74 -0
  4. metripy-0.2.5/metripy.egg-info/PKG-INFO +112 -0
  5. metripy-0.2.5/metripy.egg-info/SOURCES.txt +69 -0
  6. metripy-0.2.5/metripy.egg-info/dependency_links.txt +1 -0
  7. metripy-0.2.5/metripy.egg-info/entry_points.txt +2 -0
  8. metripy-0.2.5/metripy.egg-info/requires.txt +18 -0
  9. metripy-0.2.5/metripy.egg-info/top_level.txt +1 -0
  10. metripy-0.2.5/pyproject.toml +81 -0
  11. metripy-0.2.5/setup.cfg +4 -0
  12. metripy-0.2.5/src/Application/Analyzer.py +105 -0
  13. metripy-0.2.5/src/Application/Application.py +54 -0
  14. metripy-0.2.5/src/Application/Config/Config.py +13 -0
  15. metripy-0.2.5/src/Application/Config/File/ConfigFileReaderFactory.py +22 -0
  16. metripy-0.2.5/src/Application/Config/File/ConfigFileReaderInterface.py +14 -0
  17. metripy-0.2.5/src/Application/Config/File/JsonConfigFileReader.py +81 -0
  18. metripy-0.2.5/src/Application/Config/GitConfig.py +10 -0
  19. metripy-0.2.5/src/Application/Config/Parser.py +30 -0
  20. metripy-0.2.5/src/Application/Config/ProjectConfig.py +27 -0
  21. metripy-0.2.5/src/Application/Config/ReportConfig.py +10 -0
  22. metripy-0.2.5/src/Application/__init__.py +0 -0
  23. metripy-0.2.5/src/Component/Debug/Debugger.py +20 -0
  24. metripy-0.2.5/src/Component/File/Finder.py +37 -0
  25. metripy-0.2.5/src/Component/Output/CliOutput.py +49 -0
  26. metripy-0.2.5/src/Component/Output/ProgressBar.py +27 -0
  27. metripy-0.2.5/src/Dependency/Composer/Composer.py +30 -0
  28. metripy-0.2.5/src/Dependency/Composer/Packegist.py +55 -0
  29. metripy-0.2.5/src/Dependency/Dependency.py +30 -0
  30. metripy-0.2.5/src/Dependency/Npm/Npm.py +30 -0
  31. metripy-0.2.5/src/Dependency/Npm/NpmOrg.py +47 -0
  32. metripy-0.2.5/src/Dependency/Pip/Pip.py +69 -0
  33. metripy-0.2.5/src/Dependency/Pip/PyPi.py +49 -0
  34. metripy-0.2.5/src/Git/GitAnalyzer.py +86 -0
  35. metripy-0.2.5/src/LangAnalyzer/AbstractLangAnalyzer.py +65 -0
  36. metripy-0.2.5/src/LangAnalyzer/Generic/HalSteadAnalyzer.py +58 -0
  37. metripy-0.2.5/src/LangAnalyzer/Generic/__init__.py +0 -0
  38. metripy-0.2.5/src/LangAnalyzer/Php/PhpAnalyzer.py +193 -0
  39. metripy-0.2.5/src/LangAnalyzer/Php/PhpBasicAstParser.py +56 -0
  40. metripy-0.2.5/src/LangAnalyzer/Php/PhpBasicLocAnalyzer.py +174 -0
  41. metripy-0.2.5/src/LangAnalyzer/Php/PhpHalSteadAnalyzer.py +44 -0
  42. metripy-0.2.5/src/LangAnalyzer/Python/PythonAnalyzer.py +129 -0
  43. metripy-0.2.5/src/LangAnalyzer/Typescript/TypescriptAnalyzer.py +210 -0
  44. metripy-0.2.5/src/LangAnalyzer/Typescript/TypescriptAstParser.py +68 -0
  45. metripy-0.2.5/src/LangAnalyzer/Typescript/TypescriptBasicComplexityAnalyzer.py +114 -0
  46. metripy-0.2.5/src/LangAnalyzer/Typescript/TypescriptBasicLocAnalyzer.py +69 -0
  47. metripy-0.2.5/src/LangAnalyzer/Typescript/TypescriptHalSteadAnalyzer.py +55 -0
  48. metripy-0.2.5/src/LangAnalyzer/__init__.py +0 -0
  49. metripy-0.2.5/src/Metric/Code/AggregatedMetrics.py +42 -0
  50. metripy-0.2.5/src/Metric/Code/FileMetrics.py +33 -0
  51. metripy-0.2.5/src/Metric/Code/ModuleMetrics.py +32 -0
  52. metripy-0.2.5/src/Metric/Code/SegmentedMetrics.py +65 -0
  53. metripy-0.2.5/src/Metric/FileTree/FileTree.py +15 -0
  54. metripy-0.2.5/src/Metric/FileTree/FileTreeParser.py +42 -0
  55. metripy-0.2.5/src/Metric/Git/GitCodeHotspot.py +37 -0
  56. metripy-0.2.5/src/Metric/Git/GitContributor.py +37 -0
  57. metripy-0.2.5/src/Metric/Git/GitKnowledgeSilo.py +27 -0
  58. metripy-0.2.5/src/Metric/Git/GitMetrics.py +148 -0
  59. metripy-0.2.5/src/Metric/ProjectMetrics.py +55 -0
  60. metripy-0.2.5/src/Report/Csv/Reporter.py +12 -0
  61. metripy-0.2.5/src/Report/Html/Reporter.py +210 -0
  62. metripy-0.2.5/src/Report/Json/AbstractJsonReporter.py +10 -0
  63. metripy-0.2.5/src/Report/Json/GitJsonReporter.py +21 -0
  64. metripy-0.2.5/src/Report/Json/JsonReporter.py +12 -0
  65. metripy-0.2.5/src/Report/ReporterFactory.py +22 -0
  66. metripy-0.2.5/src/Report/ReporterInterface.py +17 -0
  67. metripy-0.2.5/src/Tree/ClassNode.py +32 -0
  68. metripy-0.2.5/src/Tree/FunctionNode.py +49 -0
  69. metripy-0.2.5/src/Tree/ModuleNode.py +42 -0
  70. metripy-0.2.5/src/__init__.py +0 -0
  71. metripy-0.2.5/src/codemetrics.py +15 -0
metripy-0.2.5/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 CodeMetrics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
metripy-0.2.5/PKG-INFO ADDED
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: metripy
3
+ Version: 0.2.5
4
+ Summary: A Python tool to generate multi project, multi language code metric reports
5
+ Author-email: Yannick Zimmermann <yannick.zimmermann@proton.me>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/zimmer-yan/codemetrics
8
+ Project-URL: Repository, https://github.com/zimmer-yan/codemetrics
9
+ Project-URL: Documentation, https://github.com/zimmer-yan/codemetrics#readme
10
+ Project-URL: Bug Tracker, https://github.com/zimmer-yan/codemetrics/issues
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
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: lizard==1.18.0
21
+ Requires-Dist: GitPython==3.1.45
22
+ Requires-Dist: py-template-engine>=0.1.0
23
+ Requires-Dist: radon==6.0.1
24
+ Requires-Dist: requests==2.32.5
25
+ Requires-Dist: packaging==25.0
26
+ Requires-Dist: toml==0.10.2
27
+ Requires-Dist: tree-sitter==0.21.3
28
+ Requires-Dist: tree-sitter-languages==1.10.2
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
31
+ Requires-Dist: pytest-cov==7.0.0; extra == "dev"
32
+ Requires-Dist: pytest-mock==3.15.1; extra == "dev"
33
+ Requires-Dist: black>=22.0.0; extra == "dev"
34
+ Requires-Dist: flake8>=5.0.0; extra == "dev"
35
+ Requires-Dist: mypy>=0.991; extra == "dev"
36
+ Requires-Dist: poethepoet==0.37.0; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ # Codemetrics
40
+ A multilanguage, multi project code metrics analysis tool.
41
+
42
+ # Languages
43
+ Supported languages
44
+ - Python (with radon)
45
+ - Php (experimental)
46
+ - Typescript (experimental)
47
+ - TBD
48
+
49
+ # Analysis types
50
+
51
+ ## Code analysis
52
+ Analyses code with cyclomatic complexity, maintainability index, halstead metrics.
53
+
54
+ ## Git analysis
55
+ Analyses git stats of the past months
56
+
57
+ ## Dependeny analysis
58
+ Analyzses composer, npm or pip dependencies
59
+
60
+ More dependencies TBD
61
+
62
+ # Report formats
63
+
64
+ ## Html
65
+ Generates an easy to read dashboard
66
+
67
+ TODO: as this application generates multi project reports, add central dashboard to have project specific insights at first glance
68
+
69
+ ## Csv
70
+ Coming soon...
71
+
72
+ ## Json
73
+ Coming soon...
74
+
75
+ ## Cli
76
+ Coming soon...
77
+
78
+ # Configuration
79
+ Configuration is for the moment only possible with the `--config=<file>.json` option. More TBD
80
+
81
+ Sample configuraiton:
82
+ ```json
83
+ {
84
+ "configs": {
85
+ "funny codemetrics": {
86
+ "base_path": "./", // base path to look at
87
+ "includes": [
88
+ "src/" // paths to include from the base path on
89
+ ],
90
+ "excludes": [
91
+ "__pycache__" // exclude patterns of paths / files
92
+ ],
93
+ "extensions": [
94
+ "py" // file extensions to look at
95
+ ],
96
+ "git": { // if git is set, analyzes git history
97
+ "branch": "main" // git branch to look at
98
+ },
99
+ "composer": true, // looks for base_path/composer.json and analyzes dependencies - for php projects
100
+ "npm": true, // looks for base_path/package.json and analyzes dependencies - for ts/js projects
101
+ "pip": true,
102
+ // looks for base_path/requirements.txt or base_path/pyproject.toml and analyzes dependencies - for python projects
103
+ "reports": {
104
+ "html": "./build/report/codemetrics", // report should be put into this directory
105
+ "json-git": "./build/json-report/codemetrics-git.json" // file where to put git json report
106
+ // more types of reports TBA
107
+ }
108
+ },
109
+ // next project name: { next config... }
110
+ }
111
+ }
112
+ ```
@@ -0,0 +1,74 @@
1
+ # Codemetrics
2
+ A multilanguage, multi project code metrics analysis tool.
3
+
4
+ # Languages
5
+ Supported languages
6
+ - Python (with radon)
7
+ - Php (experimental)
8
+ - Typescript (experimental)
9
+ - TBD
10
+
11
+ # Analysis types
12
+
13
+ ## Code analysis
14
+ Analyses code with cyclomatic complexity, maintainability index, halstead metrics.
15
+
16
+ ## Git analysis
17
+ Analyses git stats of the past months
18
+
19
+ ## Dependeny analysis
20
+ Analyzses composer, npm or pip dependencies
21
+
22
+ More dependencies TBD
23
+
24
+ # Report formats
25
+
26
+ ## Html
27
+ Generates an easy to read dashboard
28
+
29
+ TODO: as this application generates multi project reports, add central dashboard to have project specific insights at first glance
30
+
31
+ ## Csv
32
+ Coming soon...
33
+
34
+ ## Json
35
+ Coming soon...
36
+
37
+ ## Cli
38
+ Coming soon...
39
+
40
+ # Configuration
41
+ Configuration is for the moment only possible with the `--config=<file>.json` option. More TBD
42
+
43
+ Sample configuraiton:
44
+ ```json
45
+ {
46
+ "configs": {
47
+ "funny codemetrics": {
48
+ "base_path": "./", // base path to look at
49
+ "includes": [
50
+ "src/" // paths to include from the base path on
51
+ ],
52
+ "excludes": [
53
+ "__pycache__" // exclude patterns of paths / files
54
+ ],
55
+ "extensions": [
56
+ "py" // file extensions to look at
57
+ ],
58
+ "git": { // if git is set, analyzes git history
59
+ "branch": "main" // git branch to look at
60
+ },
61
+ "composer": true, // looks for base_path/composer.json and analyzes dependencies - for php projects
62
+ "npm": true, // looks for base_path/package.json and analyzes dependencies - for ts/js projects
63
+ "pip": true,
64
+ // looks for base_path/requirements.txt or base_path/pyproject.toml and analyzes dependencies - for python projects
65
+ "reports": {
66
+ "html": "./build/report/codemetrics", // report should be put into this directory
67
+ "json-git": "./build/json-report/codemetrics-git.json" // file where to put git json report
68
+ // more types of reports TBA
69
+ }
70
+ },
71
+ // next project name: { next config... }
72
+ }
73
+ }
74
+ ```
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: metripy
3
+ Version: 0.2.5
4
+ Summary: A Python tool to generate multi project, multi language code metric reports
5
+ Author-email: Yannick Zimmermann <yannick.zimmermann@proton.me>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/zimmer-yan/codemetrics
8
+ Project-URL: Repository, https://github.com/zimmer-yan/codemetrics
9
+ Project-URL: Documentation, https://github.com/zimmer-yan/codemetrics#readme
10
+ Project-URL: Bug Tracker, https://github.com/zimmer-yan/codemetrics/issues
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
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: lizard==1.18.0
21
+ Requires-Dist: GitPython==3.1.45
22
+ Requires-Dist: py-template-engine>=0.1.0
23
+ Requires-Dist: radon==6.0.1
24
+ Requires-Dist: requests==2.32.5
25
+ Requires-Dist: packaging==25.0
26
+ Requires-Dist: toml==0.10.2
27
+ Requires-Dist: tree-sitter==0.21.3
28
+ Requires-Dist: tree-sitter-languages==1.10.2
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
31
+ Requires-Dist: pytest-cov==7.0.0; extra == "dev"
32
+ Requires-Dist: pytest-mock==3.15.1; extra == "dev"
33
+ Requires-Dist: black>=22.0.0; extra == "dev"
34
+ Requires-Dist: flake8>=5.0.0; extra == "dev"
35
+ Requires-Dist: mypy>=0.991; extra == "dev"
36
+ Requires-Dist: poethepoet==0.37.0; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ # Codemetrics
40
+ A multilanguage, multi project code metrics analysis tool.
41
+
42
+ # Languages
43
+ Supported languages
44
+ - Python (with radon)
45
+ - Php (experimental)
46
+ - Typescript (experimental)
47
+ - TBD
48
+
49
+ # Analysis types
50
+
51
+ ## Code analysis
52
+ Analyses code with cyclomatic complexity, maintainability index, halstead metrics.
53
+
54
+ ## Git analysis
55
+ Analyses git stats of the past months
56
+
57
+ ## Dependeny analysis
58
+ Analyzses composer, npm or pip dependencies
59
+
60
+ More dependencies TBD
61
+
62
+ # Report formats
63
+
64
+ ## Html
65
+ Generates an easy to read dashboard
66
+
67
+ TODO: as this application generates multi project reports, add central dashboard to have project specific insights at first glance
68
+
69
+ ## Csv
70
+ Coming soon...
71
+
72
+ ## Json
73
+ Coming soon...
74
+
75
+ ## Cli
76
+ Coming soon...
77
+
78
+ # Configuration
79
+ Configuration is for the moment only possible with the `--config=<file>.json` option. More TBD
80
+
81
+ Sample configuraiton:
82
+ ```json
83
+ {
84
+ "configs": {
85
+ "funny codemetrics": {
86
+ "base_path": "./", // base path to look at
87
+ "includes": [
88
+ "src/" // paths to include from the base path on
89
+ ],
90
+ "excludes": [
91
+ "__pycache__" // exclude patterns of paths / files
92
+ ],
93
+ "extensions": [
94
+ "py" // file extensions to look at
95
+ ],
96
+ "git": { // if git is set, analyzes git history
97
+ "branch": "main" // git branch to look at
98
+ },
99
+ "composer": true, // looks for base_path/composer.json and analyzes dependencies - for php projects
100
+ "npm": true, // looks for base_path/package.json and analyzes dependencies - for ts/js projects
101
+ "pip": true,
102
+ // looks for base_path/requirements.txt or base_path/pyproject.toml and analyzes dependencies - for python projects
103
+ "reports": {
104
+ "html": "./build/report/codemetrics", // report should be put into this directory
105
+ "json-git": "./build/json-report/codemetrics-git.json" // file where to put git json report
106
+ // more types of reports TBA
107
+ }
108
+ },
109
+ // next project name: { next config... }
110
+ }
111
+ }
112
+ ```
@@ -0,0 +1,69 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ metripy.egg-info/PKG-INFO
5
+ metripy.egg-info/SOURCES.txt
6
+ metripy.egg-info/dependency_links.txt
7
+ metripy.egg-info/entry_points.txt
8
+ metripy.egg-info/requires.txt
9
+ metripy.egg-info/top_level.txt
10
+ src/__init__.py
11
+ src/codemetrics.py
12
+ src/Application/Analyzer.py
13
+ src/Application/Application.py
14
+ src/Application/__init__.py
15
+ src/Application/Config/Config.py
16
+ src/Application/Config/GitConfig.py
17
+ src/Application/Config/Parser.py
18
+ src/Application/Config/ProjectConfig.py
19
+ src/Application/Config/ReportConfig.py
20
+ src/Application/Config/File/ConfigFileReaderFactory.py
21
+ src/Application/Config/File/ConfigFileReaderInterface.py
22
+ src/Application/Config/File/JsonConfigFileReader.py
23
+ src/Component/Debug/Debugger.py
24
+ src/Component/File/Finder.py
25
+ src/Component/Output/CliOutput.py
26
+ src/Component/Output/ProgressBar.py
27
+ src/Dependency/Dependency.py
28
+ src/Dependency/Composer/Composer.py
29
+ src/Dependency/Composer/Packegist.py
30
+ src/Dependency/Npm/Npm.py
31
+ src/Dependency/Npm/NpmOrg.py
32
+ src/Dependency/Pip/Pip.py
33
+ src/Dependency/Pip/PyPi.py
34
+ src/Git/GitAnalyzer.py
35
+ src/LangAnalyzer/AbstractLangAnalyzer.py
36
+ src/LangAnalyzer/__init__.py
37
+ src/LangAnalyzer/Generic/HalSteadAnalyzer.py
38
+ src/LangAnalyzer/Generic/__init__.py
39
+ src/LangAnalyzer/Php/PhpAnalyzer.py
40
+ src/LangAnalyzer/Php/PhpBasicAstParser.py
41
+ src/LangAnalyzer/Php/PhpBasicLocAnalyzer.py
42
+ src/LangAnalyzer/Php/PhpHalSteadAnalyzer.py
43
+ src/LangAnalyzer/Python/PythonAnalyzer.py
44
+ src/LangAnalyzer/Typescript/TypescriptAnalyzer.py
45
+ src/LangAnalyzer/Typescript/TypescriptAstParser.py
46
+ src/LangAnalyzer/Typescript/TypescriptBasicComplexityAnalyzer.py
47
+ src/LangAnalyzer/Typescript/TypescriptBasicLocAnalyzer.py
48
+ src/LangAnalyzer/Typescript/TypescriptHalSteadAnalyzer.py
49
+ src/Metric/ProjectMetrics.py
50
+ src/Metric/Code/AggregatedMetrics.py
51
+ src/Metric/Code/FileMetrics.py
52
+ src/Metric/Code/ModuleMetrics.py
53
+ src/Metric/Code/SegmentedMetrics.py
54
+ src/Metric/FileTree/FileTree.py
55
+ src/Metric/FileTree/FileTreeParser.py
56
+ src/Metric/Git/GitCodeHotspot.py
57
+ src/Metric/Git/GitContributor.py
58
+ src/Metric/Git/GitKnowledgeSilo.py
59
+ src/Metric/Git/GitMetrics.py
60
+ src/Report/ReporterFactory.py
61
+ src/Report/ReporterInterface.py
62
+ src/Report/Csv/Reporter.py
63
+ src/Report/Html/Reporter.py
64
+ src/Report/Json/AbstractJsonReporter.py
65
+ src/Report/Json/GitJsonReporter.py
66
+ src/Report/Json/JsonReporter.py
67
+ src/Tree/ClassNode.py
68
+ src/Tree/FunctionNode.py
69
+ src/Tree/ModuleNode.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ codemetrics = src.codemetrics:main
@@ -0,0 +1,18 @@
1
+ lizard==1.18.0
2
+ GitPython==3.1.45
3
+ py-template-engine>=0.1.0
4
+ radon==6.0.1
5
+ requests==2.32.5
6
+ packaging==25.0
7
+ toml==0.10.2
8
+ tree-sitter==0.21.3
9
+ tree-sitter-languages==1.10.2
10
+
11
+ [dev]
12
+ pytest>=7.0.0
13
+ pytest-cov==7.0.0
14
+ pytest-mock==3.15.1
15
+ black>=22.0.0
16
+ flake8>=5.0.0
17
+ mypy>=0.991
18
+ poethepoet==0.37.0
@@ -0,0 +1 @@
1
+ src
@@ -0,0 +1,81 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "metripy"
7
+ version = "0.2.5"
8
+ description = "A Python tool to generate multi project, multi language code metric reports"
9
+ authors = [
10
+ {name = "Yannick Zimmermann", email = "yannick.zimmermann@proton.me"}
11
+ ]
12
+ license = {text = "MIT"}
13
+ readme = "README.md"
14
+ requires-python = ">=3.11"
15
+ keywords = [
16
+ "code metrics",
17
+ "multi-language",
18
+ "code analysis",
19
+ "git metrics",
20
+ "code visualization",
21
+ "software quality",
22
+ "static analysis",
23
+ "repository insights",
24
+ "developer productivity",
25
+ "codebase health",
26
+ "technical debt",
27
+ "language-agnostic"
28
+ ]
29
+ classifiers = [
30
+ "Development Status :: 3 - Alpha",
31
+ "Intended Audience :: Developers",
32
+ "Programming Language :: Python :: 3",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12"
35
+ ]
36
+
37
+ dependencies = [
38
+ "lizard==1.18.0",
39
+ "GitPython==3.1.45",
40
+ "py-template-engine>=0.1.0",
41
+ "radon==6.0.1",
42
+ "requests==2.32.5",
43
+ "packaging==25.0",
44
+ "toml==0.10.2",
45
+ "tree-sitter==0.21.3",
46
+ "tree-sitter-languages==1.10.2"
47
+ ]
48
+
49
+ [project.optional-dependencies]
50
+ dev = [
51
+ "pytest>=7.0.0",
52
+ "pytest-cov==7.0.0",
53
+ "pytest-mock==3.15.1",
54
+ "black>=22.0.0",
55
+ "flake8>=5.0.0",
56
+ "mypy>=0.991",
57
+ "poethepoet==0.37.0"
58
+ ]
59
+
60
+ [project.urls]
61
+ Homepage = "https://github.com/zimmer-yan/codemetrics"
62
+ Repository = "https://github.com/zimmer-yan/codemetrics"
63
+ Documentation = "https://github.com/zimmer-yan/codemetrics#readme"
64
+ "Bug Tracker" = "https://github.com/zimmer-yan/codemetrics/issues"
65
+
66
+ [project.scripts]
67
+ codemetrics="src.codemetrics:main"
68
+
69
+ [tool.setuptools.packages.find]
70
+ where = ["."]
71
+ include = ["src*"]
72
+
73
+ [tool.black]
74
+ line-length = 88
75
+ target-version = ['py39']
76
+
77
+ [tool.poe.tasks]
78
+ format = "black src tests"
79
+ lint = "flake8 src/ tests/"
80
+ ruffy = "ruff check src/ tests/"
81
+ test = "pytest tests/"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,105 @@
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 TypescriptAnalyzer
14
+ from Metric.Code.FileMetrics import FileMetrics
15
+ from Metric.Git.GitMetrics import GitMetrics
16
+ from Metric.ProjectMetrics import ProjectMetrics
17
+
18
+
19
+ class Analyzer:
20
+ def __init__(self, config: ProjectConfig, output: CliOutput, debugger: Debugger):
21
+ self.config = config
22
+ self.output = output
23
+ self.debugger = debugger
24
+ self.runners: list[AbstractLangAnalyzer] = [
25
+ PythonAnalyzer(),
26
+ PhpAnalyzer(),
27
+ TypescriptAnalyzer(),
28
+ ]
29
+
30
+ def analyze_git(self) -> GitMetrics:
31
+ self.output.writeln("<info>Analyzing git history...</info>")
32
+ metrics = GitAnalyzer(self.config.git).analyze()
33
+ self.output.writeln("<success>Git history analyzed</success>")
34
+
35
+ return metrics
36
+
37
+ def analyze_code(self, files: list[str]) -> list[FileMetrics]:
38
+ file_metrics = []
39
+
40
+ # for multi language projects, register runner per language
41
+ runner_sizes = []
42
+ for runner in self.runners:
43
+ runner.set_files(files)
44
+ if not runner.is_needed():
45
+ continue
46
+ runner_sizes.append(len(runner.files))
47
+
48
+ self.debugger.debug(len(files))
49
+ self.output.writeln("<info>Analyzing code...</info>")
50
+ progress_bar = ProgressBar(self.output, sum(runner_sizes))
51
+ for runner in self.runners:
52
+ if not runner.is_needed():
53
+ continue
54
+ runner.before_run()
55
+ runner.run(progress_bar)
56
+ runner.after_run()
57
+
58
+ for metric in runner.get_metrics():
59
+ file_metrics.append(metric)
60
+
61
+ self.output.writeln("")
62
+ self.output.writeln("<success>Code analyzed</success>")
63
+
64
+ return file_metrics
65
+
66
+ def analyze_composer(self) -> list[Dependency]:
67
+ self.output.writeln("<info>Analyzing composer packages...</info>")
68
+ dependencies = Composer().get_composer_dependencies(self.config.base_path)
69
+ self.output.writeln("<success>Composer packages analyzed</success>")
70
+
71
+ return dependencies
72
+
73
+ def analyze_pip(self) -> list[Dependency]:
74
+ self.output.writeln("<info>Analyzing pip packages...</info>")
75
+ dependencies = Pip().get_dependencies(self.config.base_path)
76
+ self.output.writeln("<success>Pip packages analyzed</success>")
77
+
78
+ return dependencies
79
+
80
+ def analyze_npm(self) -> list[Dependency]:
81
+ self.output.writeln("<info>Analyzing npm packages...</info>")
82
+ dependencies = Npm().get_dependencies(self.config.base_path)
83
+ self.output.writeln("<success>Npm packages analyzed</success>")
84
+
85
+ return dependencies
86
+
87
+ def run(self, files: list[str]) -> ProjectMetrics:
88
+ git_stats = None
89
+ if self.config.git:
90
+ git_stats = self.analyze_git()
91
+
92
+ file_metrics = []
93
+ if True:
94
+ file_metrics = self.analyze_code(files)
95
+
96
+ # TODO: analyze dependencies: composer, pip, npm, etc etc
97
+ packages = None
98
+ if self.config.composer:
99
+ packages = self.analyze_composer()
100
+ elif self.config.pip:
101
+ packages = self.analyze_pip()
102
+ elif self.config.npm:
103
+ packages = self.analyze_npm()
104
+
105
+ return ProjectMetrics(file_metrics, git_stats, packages)
@@ -0,0 +1,54 @@
1
+ import json
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
10
+
11
+
12
+ class Application:
13
+ def run(self, argv) -> None:
14
+ output = CliOutput()
15
+
16
+ # issues and debug
17
+ debugger = Debugger(output).enable()
18
+
19
+ config = Parser().parse(argv)
20
+
21
+ finder = Finder()
22
+ files = finder.fetch(config.project_configs)
23
+
24
+ for project_config in config.project_configs:
25
+ debugger.debug(project_config.name)
26
+ project_files = files[project_config.name]
27
+ debugger.debug(f"Found {len(project_files)} files")
28
+ debugger.debug(json.dumps(project_files))
29
+
30
+ output.writeln(f"<info>Analying Project {project_config.name}...</info>")
31
+ project_metrics = Analyzer(project_config, output, debugger).run(
32
+ project_files
33
+ )
34
+ output.writeln(
35
+ f"<success>Done analying Project {project_config.name}</success>"
36
+ )
37
+
38
+ if not project_config.reports:
39
+ output.writeln(
40
+ f"<success>Skipping reports of {project_config.name}!</success>"
41
+ )
42
+ continue
43
+
44
+ output.writeln(
45
+ f"<info>Generating reports for {project_config.name}...</info>"
46
+ )
47
+ for report_config in project_config.reports:
48
+ reporter: ReporterInterface = ReporterFactory.create(
49
+ report_config, output
50
+ )
51
+ reporter.generate(project_metrics)
52
+ output.writeln(
53
+ f"<success>Reports generated for {project_config.name}</success>"
54
+ )
@@ -0,0 +1,13 @@
1
+ from Application.Config.ProjectConfig import ProjectConfig
2
+
3
+
4
+ class Config:
5
+ def __init__(self):
6
+ self.project_configs: list[ProjectConfig] = []
7
+
8
+ def to_dict(self) -> dict:
9
+ return {
10
+ "project_configs": [
11
+ project_config.to_dict() for project_config in self.project_configs
12
+ ],
13
+ }