Skip to content

Commit d17e163

Browse files
authored
Merge pull request #538 from JohT/feature/externa-dependencies-domain
Add external dependencies analysis modularized as domain
2 parents e52d6dd + f036e6a commit d17e163

52 files changed

Lines changed: 1482 additions & 97 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ For all details see: https://github.com/JohT/code-graph-analysis-pipeline/releas
264264

265265
### 📖 Jupyter Notebook Reports
266266

267-
* [External Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/external-dependencies-java/ExternalDependenciesJava.md) contains detailed information about external library usage ([Notebook](./jupyter/ExternalDependenciesJava.ipynb)).
267+
* [External Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/external-dependencies-java/ExternalDependenciesJava.md) contains detailed information about external library usage ([Notebook](./domains/external-dependencies/explore/ExternalDependenciesJava.ipynb)).
268268
* [Object Oriented Design Quality Metrics](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/object-oriented-design-metrics-java/ObjectOrientedDesignMetricsJava.md) is based on [OO Design Quality Metrics by Robert Martin](https://api.semanticscholar.org/CorpusID:18246616) ([Notebook](./jupyter/ObjectOrientedDesignMetricsJava.ipynb)).
269269
* [Overview](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/overview-java/OverviewJava.md) contains overall statistics and details about methods and their complexity. ([Notebook](./jupyter/OverviewJava.ipynb)).
270270
* [Internal Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/internal-dependencies-java/InternalDependenciesJava.md) is based on [Analyze java package metrics in a graph database](https://joht.github.io/johtizen/data/2023/04/21/java-package-metrics-analysis.html) and also includes cyclic dependencies ([Notebook](./jupyter/InternalDependenciesJava.ipynb)).
@@ -281,7 +281,7 @@ Here are some reports that utilize Neo4j's [Graph Data Science Library](https://
281281

282282
### 📖 Other Reports
283283

284-
* [External Dependencies (CSV)](./scripts/reports/ExternalDependenciesCsv.sh) ([Example](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/external-dependencies-csv/External_package_usage_overall.csv))
284+
* [External Dependencies (CSV)](./domains/external-dependencies/externalDependenciesCsv.sh) ([Example](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/external-dependencies-csv/External_package_usage_overall.csv))
285285
* [Object Oriented Design Metrics (CSV)](./scripts/reports/ObjectOrientedDesignMetricsCsv.sh) ([Example](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/object-oriented-design-metrics-csv/MainSequenceAbstractnessInstabilityDistanceJava.csv))
286286
* [Overview (CSV)](./scripts/reports/OverviewCsv.sh) ([Example](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/overview-csv/Cyclomatic_Method_Complexity.csv))
287287
* [Internal Dependencies - Cyclic (CSV)](./scripts/reports/InternalDependenciesCsv.sh) ([Example](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/internal-dependencies-csv/Cyclic_Dependencies_Breakdown_Backward_Only.csv))

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Curious? Explore the examples at [code-graph-analysis-examples](https://github.c
4646

4747
Here is an overview of [Jupyter Notebooks](https://jupyter.org) reports from [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples). For a complete list, see the [Jupyter Notebook Report Reference](#page_with_curl-jupyter-notebook-report-reference).
4848

49-
- [External Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/external-dependencies-java/ExternalDependenciesJava.md) contains detailed information about external library usage ([Notebook](./jupyter/ExternalDependenciesJava.ipynb)).
49+
- [External Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/external-dependencies-java/ExternalDependenciesJava.md) contains detailed information about external library usage ([Notebook](./domains/external-dependencies/explore/ExternalDependenciesJava.ipynb)).
5050
- [Git History](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/git-history-general/GitHistoryGeneral.md) contains information about the git history of the analyzed code ([Notebook](./jupyter/GitHistoryGeneral.ipynb)).
5151
- [Internal Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/internal-dependencies-java/InternalDependenciesJava.md) is based on [Analyze java package metrics in a graph database](https://joht.github.io/johtizen/data/2023/04/21/java-package-metrics-analysis.html) and also includes cyclic dependencies ([Notebook](./jupyter/InternalDependenciesJava.ipynb)).
5252
- [Method Metrics](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/method-metrics-java/MethodMetricsJava.md) shows how the effective number of lines of code and the cyclomatic complexity are distributed across the methods in the code ([Notebook](./jupyter/MethodMetricsJava.ipynb)).

cypher/External_Dependencies/Label_external_types_and_annotations.cypher renamed to cypher/Java/Label_external_types_and_annotations.cypher

File renamed without changes.

cypher/External_Dependencies/Remove_external_type_and_annotation_labels.cypher renamed to cypher/Java/Remove_external_type_and_annotation_labels.cypher

File renamed without changes.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# External Dependencies Domain
2+
3+
This directory contains the implementation and resources for analysing external dependencies within the Code Graph Analysis Pipeline. It follows the vertical-slice domain pattern: all Cypher queries, Python chart scripts, and report templates needed for this analysis live here.
4+
5+
## Entry Points
6+
7+
The following scripts are discovered and invoked automatically by the central compilation scripts in [scripts/reports/compilations/](../../scripts/reports/compilations/). They are found by filename pattern.
8+
9+
- [externalDependenciesCsv.sh](./externalDependenciesCsv.sh): Entry point for CSV reports based on Cypher queries. Discovered by `CsvReports.sh` (`*Csv.sh` pattern).
10+
- [externalDependenciesPython.sh](./externalDependenciesPython.sh): Entry point for Python-based chart generation. Discovered by `PythonReports.sh` (`*Python.sh` pattern).
11+
- [externalDependenciesMarkdown.sh](./externalDependenciesMarkdown.sh): Entry point for the Markdown summary report. Discovered by `MarkdownReports.sh` (`*Markdown.sh` pattern).
12+
13+
## Folder Structure
14+
15+
- [explore](./explore/): Original Jupyter notebooks for interactive, exploratory analysis. Marked with `code_graph_analysis_pipeline_data_validation: ValidateAlwaysFalse` so they are not automatically executed by the pipeline.
16+
- [queries](./queries/): All Cypher queries for identifying and quantifying external dependencies. These are self-contained copies from [cypher/External_Dependencies/](../../cypher/External_Dependencies/).
17+
- [summary](./summary/): Markdown template and assembly script for the summary report.
18+
19+
## Prerequisites
20+
21+
This domain requires the following to be in place before running. These are provided by the central pipeline ([scripts/prepareAnalysis.sh](../../scripts/prepareAnalysis.sh)) and are **not** set up by this domain.
22+
23+
### Graph database
24+
25+
- Neo4j must be running and accessible at `bolt://localhost:7687`.
26+
- `NEO4J_INITIAL_PASSWORD` environment variable must be set.
27+
- Artifacts must already have been scanned and loaded by jQAssistant, creating `DEPENDS_ON` relationships between `Type` nodes.
28+
29+
### Node labels (Java)
30+
31+
The following labels must exist on `Type` nodes before external dependency analysis can run. They are created by Cypher queries in [cypher/Types/](../../cypher/Types/):
32+
33+
- `PrimitiveType` — primitive types like `int`, `boolean`
34+
- `Void` — void return type
35+
- `JavaType` — built-in Java standard library types (e.g. `java.lang.*`, `java.util.*`)
36+
- `ResolvedDuplicateType` — deduplicated types that appear in multiple jars
37+
38+
Without these labels, `Label_external_types_and_annotations.cypher` cannot correctly distinguish external types from internal and built-in ones.
39+
40+
### Relationship weight properties (Java)
41+
42+
The following properties must exist on `DEPENDS_ON` relationships between `Package` nodes. They are set by Cypher queries in [cypher/DependsOn_Relationship_Weights/](../../cypher/DependsOn_Relationship_Weights/):
43+
44+
- `weight` — sum of type-level dependency weights between two packages
45+
- `weightInterfaces` — subset of `weight` attributable to interface dependencies
46+
47+
### TypeScript enrichment
48+
49+
For TypeScript projects, the following must be completed by [cypher/Typescript_Enrichment/](../../cypher/Typescript_Enrichment/):
50+
51+
- Module properties set on `Module` nodes: `namespace`, `moduleName`, `isNodeModule`, `isExternalImport`
52+
- `IS_IMPLEMENTED_IN` relationships linking `ExternalModule` nodes to their resolved internal `Module` nodes
53+
- `DEPENDS_ON` relationships propagated to resolved modules
54+
- NPM packages linked to their corresponding `ExternalModule` nodes via `PROVIDED_BY_NPM_DEPENDENCY`
55+
56+
### General enrichment
57+
58+
- `name` and `extension` properties on `File` nodes — set by [cypher/General_Enrichment/](../../cypher/General_Enrichment/).
59+
60+
## What This Domain Produces
61+
62+
### CSV reports (`reports/external-dependencies/`)
63+
64+
One CSV file per Cypher query covering:
65+
66+
- **Java packages**: overall usage, spread, per-artifact, per-type, distribution, aggregated, Maven POM declared dependencies
67+
- **TypeScript modules and namespaces**: overall usage, spread, per-internal-module, aggregated
68+
- **Package management**: `package.json` dependency occurrence and combinations
69+
70+
### SVG charts (`reports/external-dependencies/`)
71+
72+
Python-generated charts from [externalDependencyCharts.py](./externalDependencyCharts.py):
73+
74+
- **Java**: pie charts for most-used and most-spread packages (by types and by packages, with drill-down into "others"), stacked bar charts for per-artifact breakdown, scatter plots for aggregated usage patterns
75+
- **TypeScript**: pie charts for modules and namespaces (usage and spread, with drill-down)
76+
77+
### Markdown summary (`reports/external-dependencies/external_dependencies_report.md`)
78+
79+
A structured report designed to be readable by both humans and AI agents. Includes key findings, tables, chart references, and architectural recommendations such as Hexagonal Architecture patterns and Anti-Corruption Layer candidates.

jupyter/ExternalDependenciesJava.ipynb renamed to domains/external-dependencies/explore/ExternalDependenciesJava.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@
17261726
}
17271727
],
17281728
"celltoolbar": "Tags",
1729-
"code_graph_analysis_pipeline_data_validation": "ValidateJavaExternalDependencies",
1729+
"code_graph_analysis_pipeline_data_validation": "ValidateAlwaysFalse",
17301730
"kernelspec": {
17311731
"display_name": "codegraph",
17321732
"language": "python",

jupyter/ExternalDependenciesTypescript.ipynb renamed to domains/external-dependencies/explore/ExternalDependenciesTypescript.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@
16291629
}
16301630
],
16311631
"celltoolbar": "Tags",
1632-
"code_graph_analysis_pipeline_data_validation": "ValidateTypescriptModuleDependencies",
1632+
"code_graph_analysis_pipeline_data_validation": "ValidateAlwaysFalse",
16331633
"kernelspec": {
16341634
"display_name": "codegraph",
16351635
"language": "python",

0 commit comments

Comments
 (0)