This folder contains standalone scripts for measuring the structure and quality of a Python repository.
extract_architecture.pyextracts classes, functions, modules, internal dependencies, and an architecture graph.radon_metrics.pycomputes cyclomatic complexity, Maintainability Index, and Halstead metrics.coupling.pycomputes a simplified CBO coupling score.cohesion.pycomputes an approximate LCOM cohesion score.repository_summary.pygenerates a repository-wide summary.compare_repositories.pycompares two repositories or two prepared reports and generates comparison charts.generate_report.pyaggregates the outputs and produces CSV, Excel, and charts.run_all.pyruns the full workflow in one command and writes everything to a user-defined output folder.
Optional dependencies used by the evaluation scripts:
radonnetworkxpandasmatplotlibopenpyxl
Use --root when the repository is already available locally.
Use --repo and --branch when you want the script to clone a remote repository first.
If the repository is already cloned internally, pass only the local path with --root.
If you want to run everything at once, use run_all.py and choose the output folder with --output-dir.
Examples:
- Local repository already cloned:
python3 evaluation/repository_summary.py --root /home/amine/HydroModPy-Hackathon- Remote repository to clone on demand:
python3 evaluation/repository_summary.py \
--repo https://github.com/ORG/REPO.git \
--branch mainpython3 evaluation/repository_summary.py \
--root . \
--output evaluation/out/summary.json \
--csv evaluation/out/summary.csvFrom a remote repository:
python3 evaluation/repository_summary.py \
--repo https://github.com/ORG/REPO.git \
--branch main \
--output evaluation/out/summary.json \
--csv evaluation/out/summary.csvpython3 evaluation/radon_metrics.py \
--root . \
--output evaluation/out/radon.jsonFrom a remote repository:
python3 evaluation/radon_metrics.py \
--repo https://github.com/ORG/REPO.git \
--branch main \
--output evaluation/out/radon.jsonpython3 evaluation/coupling.py \
--root . \
--output evaluation/out/coupling.jsonpython3 evaluation/cohesion.py \
--root . \
--output evaluation/out/cohesion.jsonpython3 evaluation/extract_architecture.py \
--root . \
--output evaluation/out/architecture.json \
--graph-output evaluation/out/architecture_graph.pngYou can also export the architecture graph as GraphML or JSON by changing the file extension of --graph-output.
If you already have JSON outputs in one folder:
python3 evaluation/generate_report.py \
--input-dir evaluation/out \
--output-dir evaluation/report \
--excel evaluation/report/evaluation.xlsxDirectly from a remote repository:
python3 evaluation/generate_report.py \
--repo https://github.com/ORG/REPO.git \
--branch main \
--output-dir evaluation/report \
--excel evaluation/report/evaluation.xlsxFor a repository that is already cloned locally:
python3 evaluation/run_all.py \
--root /home/amine/HydroModPy-Hackathon \
--output-dir /home/amine/HydroModPy-Hackathon/hackathonFor a remote repository:
python3 evaluation/run_all.py \
--repo https://github.com/ORG/REPO.git \
--branch main \
--output-dir /home/amine/HydroModPy-Hackathon/hackathonThis creates:
/output-dir/raw/with the JSON outputs and the architecture graph./output-dir/report/with CSV files and charts./output-dir/evaluation.xlsxwith the Excel report.
Generate a JSON comparison and the main bar chart:
python3 evaluation/compare_repositories.py \
--left-repo https://github.com/ORG/REPO-A.git --left-branch main \
--right-repo https://github.com/ORG/REPO-B.git --right-branch develop \
--output evaluation/out/comparison.json \
--chart evaluation/out/comparison_bar_chart.pngGenerate the complete comparison bundle with all requested charts:
python3 evaluation/compare_repositories.py \
--left-repo https://github.com/ORG/REPO-A.git --left-branch main \
--right-repo https://github.com/ORG/REPO-B.git --right-branch develop \
--left-label hackathon \
--right-label legacy \
--output evaluation/out/comparison.json \
--output-dir evaluation/out/chartsYou can use --left-label and --right-label to force the names shown in the charts.
This will generate:
bar_chart.pngfor direct metric comparison.boxplot_complexity.pngfor the cyclomatic complexity distribution.radar_chart.pngfor Complexity, Maintainability, CBO, LCOM, and Halstead.dependency_heatmap.pngfor module dependencies.architecture_graph.pngfor the NetworkX architecture graph.
Run the scripts in this order when you want a complete analysis of one repository:
repository_summary.pyto collect the basic repository structure.radon_metrics.pyto compute complexity, Maintainability Index, and Halstead.coupling.pyto compute the CBO coupling score.cohesion.pyto compute the LCOM approximation.extract_architecture.pyto build the architecture data and graph.generate_report.pyto aggregate the results and create CSV, Excel, and charts.
When comparing two repositories, run:
compare_repositories.pyif you already have two repositories or two summary files.generate_report.pyif you want a complete report folder for one repository.
mkdir -p evaluation/out evaluation/report
python3 evaluation/repository_summary.py --root . --output evaluation/out/summary.json --csv evaluation/out/summary.csv
python3 evaluation/radon_metrics.py --root . --output evaluation/out/radon.json
python3 evaluation/coupling.py --root . --output evaluation/out/coupling.json
python3 evaluation/cohesion.py --root . --output evaluation/out/cohesion.json
python3 evaluation/extract_architecture.py --root . --output evaluation/out/architecture.json --graph-output evaluation/out/architecture_graph.png
python3 evaluation/generate_report.py --input-dir evaluation/out --output-dir evaluation/report --excel evaluation/report/evaluation.xlsx