JohT/code-graph-analysis-pipeline
GitHub: JohT/code-graph-analysis-pipeline
基于Neo4j和jQAssistant构建的自动化代码图谱分析流水线,通过图算法和机器学习揭示代码结构、依赖关系和架构异常。
Stars: 30 | Forks: 1
# Code Graph 分析流水线
本仓库提供了一个基于 [jQAssistant](https://jqassistant.github.io/jqassistant/current) 和 [Neo4j](https://neo4j.com) 构建的自动化代码图谱分析流水线。它支持 Java 和实验性的 TypeScript 分析,能够捕捉代码库的结构及其演变。
你是否曾想过哪些库最重要、模块之间如何构建、哪些部分贡献者较少、哪些文件会一起变更,或者结构异常出现在哪里?
本项目通过基于图谱的分析、可视化以及机器学习帮助揭示此类模式——提供数百种专家级报告以深入洞察代码。
好奇吗?在 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 探索示例,并通过 [GETTING_STARTED.md](./GETTING_STARTED.md) 开始使用 :rocket:
## :sparkles: 特性
- 将静态代码结构作为图谱进行分析
- 支持 Java 代码分析
- 支持 Typescript 代码分析(实验性)
- 完全自动化的 [Java 流水线](./.github/workflows/internal-java-code-analysis.yml),从工具安装到报告生成
- 完全自动化的 [Typescript 流水线](./.github/workflows/internal-typescript-code-analysis.yml),从工具安装到报告生成
- 完全自动化的 [本地运行](./GETTING_STARTED.md)
- 可轻松集成到您的 [持续集成流水线](./INTEGRATION.md) 中
- 超过 200 个 CSV 报告,涵盖依赖、指标、循环、注解、算法等
- 用于依赖、指标、可见性等方面的 Jupyter notebook 报告
- 基于无监督机器学习和可解释 AI 的异常检测
- 图谱结构可视化
- 自动生成参考文档
- 使用 [shell scripts](./scripts/SCRIPTS.md) 实现独立于运行时和库的自动化
- 已在 MacOS (zsh)、Linux (bash) 和 Windows (Git Bash) 上测试
- 详尽的 [Cypher 查询](./cypher/CYPHER.md) 列表
- [AxonFramework](https://github.com/AxonFramework/AxonFramework) 分析示例
- [react-router](https://github.com/remix-run/react-router) 分析示例
### :newspaper: 新闻
- 2025 年 11 月:移除了自 2.x 版本起已弃用的 "graph-visualization" node 包
- 2025 年 11 月:用于异常和原型的 Treemap 图表
- 2025 年 10 月:异常原型的图谱可视化
- 2025 年 10 月:带有 markdown 摘要的异常原型
- 2025 年 8 月:针对 git 历史中共同变更文件的关联规则挖掘
- 2025 年 8 月:基于无监督机器学习和可解释 AI 的异常检测
- 2025 年 5 月:迁移至 [Neo4j 2025.x](https://neo4j.com/docs/upgrade-migration-guide/current/version-2025/upgrade) 和 Java 21。
### :notebook: Jupyter Notebook 和 Python 报告
以下是来自 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 的 [Jupyter Notebooks](https://jupyter.org) 报告概览。完整列表请参阅 [Jupyter Notebook 报告参考](#page_with_curl-jupyter-notebook-report-reference)。
- [External Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/external-dependencies-java/ExternalDependenciesJava.md) 包含有关外部库使用的详细信息 ([Notebook](./jupyter/ExternalDependenciesJava.ipynb))。
- [Git History](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/git-history-general/GitHistoryGeneral.md) 包含有关被分析代码的 git 历史信息 ([Notebook](./jupyter/GitHistoryGeneral.ipynb))。
- [Internal Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/internal-dependencies-java/InternalDependenciesJava.md) 基于 [Analyze java package metrics in a graph database](https://joht.github.io/johtizen/data/2023/04/21/java-package-metrics-analysis.html),还包括循环依赖 ([Notebook](./jupyter/InternalDependenciesJava.ipynb))。
- [Method Metrics](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/method-metrics-java/MethodMetricsJava.md) 展示了代码中方法的有效代码行数和圈复杂度分布 ([Notebook](./jupyter/MethodMetricsJava.ipynb))。
- [Node Embeddings](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/node-embeddings-java/NodeEmbeddingsJava.md) 展示了如何生成节点嵌入并进一步降低其维度,以便在 2D 图表中可视化它们 ([Notebook](./jupyter/NodeEmbeddingsJava.ipynb))。
- [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) 基于 [OO Design Quality Metrics by Robert Martin](https://api.semanticscholar.org/CorpusID:18246616) ([Notebook](./jupyter/ObjectOrientedDesignMetricsJava.ipynb))。
- [Overview](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/overview-java/OverviewJava.md) 包含整体统计数据以及有关方法及其复杂性的详细信息。([Notebook](./jupyter/OverviewJava.ipynb))。
- [Visibility Metrics](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/visibility-metrics-java/VisibilityMetricsJava.md) ([Notebook](./jupyter/VisibilityMetricsJava.ipynb))。
- [Wordcloud](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/wordcloud/Wordcloud.md) 包含包和类名称的可视化表示 ([Notebook](./jupyter/Wordcloud.ipynb))。
- [Java Archetypes Treemap](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/anomaly-detection/JavaTreemap2ArchetypesOverviewPerDirectory.svg) ([Python Script](./domains/anomaly-detection/treemapVisualizations.py))
### :blue_book: Graph Data Science 报告
本项目包含多个使用 Neo4j 的 [Graph Data Science Library](https://neo4j.com/product/graph-data-science) 的报告。这些报告是 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 仓库的一部分。有关报告的完整列表,请查看 [CSV Cypher Query 报告参考](#page_with_curl-csv-cypher-query-report-reference)。
以下是利用 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 中 Neo4j 的 [Graph Data Science Library](https://neo4j.com/product/graph-data-science) 的一些报告。完整列表请参阅 [CSV Cypher Query 报告参考](#page_with_curl-csv-cypher-query-report-reference)。
- [Centrality with Page Rank](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/centrality-csv/Package_Centrality_Page_Rank.csv) ([Source Script](./scripts/reports/CentralityCsv.sh))
- [Community Detection with Leiden](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/community-csv/Package_communityLeidenId_Community__Metrics.csv) ([Source Script](./scripts/reports/CommunityCsv.sh))
- [Node Embeddings with HashGNN](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/node-embeddings-csv/Package_Embeddings_HashGNN.csv) ([Source Script](./scripts/reports/NodeEmbeddingsCsv.sh))
- [Path Finding with all pairs shortest path](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/path-finding-csv/Package_all_pairs_shortest_paths_distribution_per_project.csv) ([Source Script](./scripts/reports/PathFindingCsv.sh))
- [Similarity with Jaccard](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/similarity-csv/Package_Similarity.csv) ([Source Script](./scripts/reports/SimilarityCsv.sh))
- [Topology Sort](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/topology-csv/Package_Topological_Sort.csv) ([Source Script](./scripts/reports/TopologicalSortCsv.sh))
### :art: 图谱可视化
以下是一些利用 [GraphViz](https://graphviz.org) 从 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 生成的全自动图谱可视化:
- [Java Artifact Build Levels](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/internal-dependencies-visualization/JavaArtifactBuildLevels.svg) ([Query](./cypher/Internal_Dependencies/Java_Artifact_build_levels_for_graphviz.cypher), [Source Script](./scripts/visualization/visualizeQueryResults.sh))
- [Java Artifact Longest Path Contributors](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/path-finding-visualization/JavaArtifactLongestPaths.svg) ([Query](./cypher/Path_Finding/Path_Finding_6_Longest_paths_contributors_for_graphviz.cypher), [Source Script](./scripts/visualization/visualizeQueryResults.sh))
- [Java Package Top #1 Authority Archetype and contributing packages](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/anomaly-detection/Java_Package/GraphVisualizations/TopAuthority1.svg) ([Query](./domains/anomaly-detection/labels/AnomalyDetectionArchetypeAuthority.cypher), [Source Script](./domains/anomaly-detection/graphs/anomalyDetectionGraphs.sh))
## :book: 博客文章
- [Analyze java dependencies with jQAssistant](https://joht.github.io/johtizen/data/2021/02/21/java-jar-dependency-analysis.html)
- [Analyze java package metrics in a graph database (Part 2)](https://joht.github.io/johtizen/data/2023/04/21/java-package-metrics-analysis.html)
## :mega: 演讲
- [Unleashing the Power of Graphs in Java Code Structure Analysis](https://github.com/JohT/code-graph-analysis-examples/blob/main/talks/2023-12-14-Engineering_Kiosk_Alps_Meetup-Code_Structure_Graph_Analysis.pdf) - Engineering Kiosk Alps Meetup, 2023 年 12 月
- [How anomalous is your code?](https://github.com/JohT/code-graph-analysis-examples/blob/main/talks/2026-02-25_AI_Meetup_Austria_How_Anomalous_Is_Your_Code.pdf) - AI Meetup Austria, 2026 年 2 月
## :hammer_and_wrench: 前置条件
运行 [scripts/checkCompatibility.sh](./scripts/checkCompatibility.sh) 以检查是否已安装所有必需的依赖项并在您的环境中可用。
- 自 [Neo4j 2025.01](https://neo4j.com/docs/operations-manual/current/installation/requirements/#deployment-requirements-java) 起 [需要 Java 21](https://neo4j.com/docs/operations-manual/current/installation/requirements/#deployment-requirements-java)。另请参阅 [Changes from Neo4j 5 to 2025.x](https://neo4j.com/docs/upgrade-migration-guide/current/version-2025/upgrade)。
- [Neo4j 5 需要 Java 17](https://neo4j.com/docs/operations-manual/current/installation/requirements/#deployment-requirements-java)。
- 在 Windows 上,建议使用 [git for windows](https://github.com/git-guides/install-git#install-git-on-windows) 提供的 git bash。
- 需要安装 [jq](https://github.com/jqlang/jq),即“轻量级且灵活的命令行 JSON 处理器”。最新版本:https://github.com/jqlang/jq/releases/latest。使用 `jq --version` 检查。
- 将环境变量 `NEO4J_INITIAL_PASSWORD` 设置为您选择的密码。例如:
export NEO4J_INITIAL_PASSWORD=neo4j_password_of_my_choice
要运行 Jupyter notebook,请在打开 notebook 的文件夹中创建一个 `.env` 文件,其中包含例如:`NEO4J_INITIAL_PASSWORD=neo4j_password_of_my_choice`
### Python 和 Jupyter Notebooks 的额外前置条件
- Jupyter Notebook 和 Python 报告需要 Python。
- 需要使用 [Conda](https://docs.conda.io) 或 Python 的内置模块 [venv](https://docs.python.org/3/library/venv.html) 作为环境管理器。
- 对于 Conda,例如可以使用 [Miniconda](https://docs.conda.io/projects/miniconda/en/latest) 或 [Anaconda](https://www.anaconda.com/download)(推荐 Windows 使用)。
- 要使用 venv,无需额外安装。为此,需要将环境变量 `USE_VIRTUAL_PYTHON_ENVIRONMENT_VENV` 设置为 `'true'`。
- 如果 Jupyter Notebook PDF 报告生成需要,Chromium 将自动下载。
### Windows 的额外前置条件
- 如果您使用的是 Anaconda3,请将此行添加到您的 `~/.bashrc` 文件中:`/c/ProgramData/Anaconda3/etc/profile.d/conda.sh`。尝试为其他 conda 包管理器或版本查找类似的脚本。
- 以管理员身份打开的 git bash 中运行 `conda init`。在普通模式下运行通常会导致错误消息。
### 分析 Typescript 的额外前置条件
- 请按照此处的说明创建包含 Typescript 项目静态代码信息的 json 文件:
https://github.com/jqassistant-plugin/jqassistant-typescript-plugin
这可能就像在您的 Typescript 项目中运行以下命令一样简单:
npx --yes @jqassistant/ts-lce
- 克隆的仓库或源项目需要复制到分析工作区内名为 `source` 的目录中,以便 [resetAndScan.sh](./scripts/resetAndScan.sh) 和可选的 [importGit.sh](./scripts/importGit.sh) 在扫描期间也能将其选中。
## :rocket: 开始使用
请参阅 [GETTING_STARTED.md](./GETTING_STARTED.md) 了解如何在本地机器上开始使用。
## :rocket: 集成
请参阅 [INTEGRATION.md](./INTEGRATION.md) 了解如何将代码分析集成到您的持续集成流水线中。
目前 (2025 年),仅支持 GitHub Actions。
## :building_construction: 流水线和工具
[Code Structure Analysis Pipeline](./.github/workflows/internal-java-code-analysis.yml) 利用 [GitHub Actions](https://docs.github.com/de/actions) 自动化整个分析过程:
- 使用 [GitHub Actions](https://docs.github.com/de/actions) Linux Runner
- [Checkout GIT Repository](https://github.com/actions/checkout)
- [Setup Java](https://github.com/actions/setup-java)
- [Setup Python with Conda](https://github.com/conda-incubator/setup-miniconda) 包管理器 [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge)
- [Setup Python with venv](https://docs.python.org/3/library/venv.html)
- 下载包含要分析代码的工件和可选源代码 [scripts/downloader](./scripts/downloader)
- 设置 [Neo4j](https://neo4j.com) Graph Database ([analysis.sh](./scripts/analysis/analyze.sh))
- 设置 [jQAssistant](https://jqassistant.github.io/jqassistant/current) 用于 Java 和 [Typescript](https://github.com/jqassistant-plugin/jqassistant-typescript-plugin) 分析 ([analysis.sh](./scripts/analysis/analyze.sh))
- 启动 [Neo4j](https://neo4j.com) Graph Database ([analysis.sh](./scripts/analysis/analyze.sh))
- 使用命令行 JSON 解析器 [jq](https://jqlang.github.io/jq) 生成 CSV 报告 [scripts/reports](./scripts/reports)
- 使用 [Neo4j Graph Data Science](https://neo4j.com/product/graph-data-science) 进行社区检测、中心性、相似性、节点嵌入和拓扑排序 ([analysis.sh](./scripts/analysis/analyze.sh))
- 使用 [conda-environment.yml](./conda-environment.yml) 中指定的这些库生成 [Jupyter Notebook](https://jupyter.org) 报告:
- [Python](https://www.python.org)
- [jupyter](https://jupyter.org)
- [matplotlib](https://matplotlib.org)
- [nbconvert](https://nbconvert.readthedocs.io)
- [numpy](https://numpy.org)
- [pandas](https://pandas.pydata.org)
- [pip](https://pip.pypa.io/en/stable)
- [plotly](https://plotly.com/python)
- [monotonic](https://github.com/atdt/monotonic)
- [Neo4j Python Driver](https://neo4j.com/docs/api/python-driver)
- [openTSNE](https://github.com/pavlin-policar/openTSNE)
- [wordcloud](https://github.com/amueller/word_cloud)
- [umap](https://umap-learn.readthedocs.io)
- [scikit-learn](https://scikit-learn.org)
- [optuna](https://optuna.org)
- [SHAP](https://github.com/shap/shap)
- [HPCC-Systems (High Performance Computing Cluster) Web-Assembly (JavaScript)](https://github.com/hpcc-systems/hpcc-js-wasm) 包含用于可视化图结构的 GraphViz 包装器。
- [GraphViz](https://gitlab.com/graphviz/graphviz) 用于 CLI Graph Visualization
- [Check links in markdown documentation (GitHub workflow)](./.github/workflows/internal-check-links-in-documentation.yml) 使用 [markdown-link-check](https://github.com/tcort/markdown-link-check)。
**特别感谢** 📣 所有这些优秀库的创建者和贡献者 👍。没有他们,像这样的项目是不可能实现的。如果列表中缺少或有误请随时 [创建 issue](https://github.com/JohT/code-graph-analysis-pipeline/issues/new/choose)。
## :runner: 命令参考
[COMMANDS.md](./COMMANDS.md) 包含有关命令以及如何进行手动设置的更多详细信息。
## :page_with_curl: CSV Cypher Query 报告参考
[CSV_REPORTS.md](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/CSV_REPORTS.md) 列出了 [results](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results) 目录中的所有 CSV Cypher 查询结果报告。它可以按照 [Generate CSV Report Reference](./COMMANDS.md#generate-csv-cypher-query-report-reference) 中的描述生成。
## :page_with_curl: Jupyter Notebook 报告参考
[JUPYTER_REPORTS.md](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/JUPYTER_REPORTS.md) 列出了 [results](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results) 目录中的所有 Jupyter Notebook 报告。它可以按照 [Generate Jupyter Notebook Report Reference](./COMMANDS.md#generate-jupyter-notebook-report-reference) 中的描述生成。
## :camera: 图像参考
[IMAGES.md](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/IMAGES.md) 列出了 [results](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results) 目录中的所有 PNG 图像。它可以按照 [Generate Image Reference](./COMMANDS.md#generate-image-reference) 中的描述生成。
## :gear: 脚本参考
[SCRIPTS.md](./scripts/SCRIPTS.md) 列出了本仓库的所有 shell 脚本,包括其第一行注释作为描述。它可以按照 [Generate Script Reference](./COMMANDS.md#generate-script-reference) 中的描述生成。
## :mag: Cypher Query 参考
[CYPHER.md](./cypher/CYPHER.md) 列出了本仓库的所有 Cypher 查询,包括其第一行注释作为描述。它可以按照 [Generate Cypher Reference](./COMMANDS.md#generate-cypher-reference) 中的描述生成。
## :globe_with_meridians: 环境变量参考
[ENVIRONMENT_VARIABLES.md](./scripts/ENVIRONMENT_VARIABLES.md) 包含脚本支持的所有环境变量,包括默认值和描述。它可以按照 [Generate Environment Variable Reference](./COMMANDS.md#generate-environment-variable-reference) 中的描述生成。
## :closed_book: 变更日志
[CHANGELOG.md](./CHANGELOG.md) 包含本仓库的所有变更。
## :thinking: 问答
- 如何在本地运行分析?
👉 检查 [前置条件](#hammer_and_wrench-prerequisites)。
👉 参阅 [命令参考](./COMMANDS.md) 中的 [Start an analysis](./COMMANDS.md#start-an-analysis)。
👉 要从头开始,请参阅 [GETTING_STARTED.md](./GETTING_STARTED.md)。
- 如何手动探索 Graph?
👉 分析后 [start Neo4j](./COMMANDS.md#start-neo4j-graph-database) 并打开 Neo4j Web UI (`http://localhost:7474/browser`)。
- 如何向流水线添加 CSV 报告?
👉 将您的新 cypher 查询放入 [cypher](./cypher) 目录或合适的(新)子目录中。
👉 在 [scripts/reports](./scripts/reports/) 目录中创建一个新的 CSV 报告脚本。以 [OverviewCsv.sh](./scripts/reports/OverviewCsv.sh) 作为参考。
👉 该脚本将因其目录及其以 "Csv.sh" 结尾的名称而被自动包含。
- 如何向流水线添加 Jupyter Notebook 报告?
👉 将您的新 notebook 放入 [jupyter](./jupyter) 目录。
👉 该文件随后将被 [executeJupyterNotebookReport.sh](./scripts/executeJupyterNotebookReport.sh) 自动选中。
- 如何自动分析不同的代码库?
👉 在 [scripts/downloader](./scripts/downloader/) 目录中创建一个新的下载脚本。以 [downloadAxonFramework.sh](./scripts/downloader/downloadAxonFramework.sh) 作为 Java 项目的参考,以 [downloadReactRouter.sh](./scripts/downloader/downloadReactRouter.sh) 作为 Typescript 项目的参考。
👉 下载后,运行 [analyze.sh](./scripts/analysis/analyze.sh)。您也可以在 [pipeline](./.github/workflows/internal-java-code-analysis.yml) 中找到这些步骤作为参考。
- 如何触发所有工件的完整重新扫描?
👉 删除 `artifacts` 目录中的 `artifactsChangeDetectionHash.txt` 文件。
👉 删除 `source` 目录中的 `typescriptFileChangeDetectionHashFile.txt` 文件,以额外重新扫描 Typescript 项目。
- 如何为 Jupyter Notebooks 启用 PDF 生成(依赖 chromium,耗时更多)?
👉 将环境变量 `ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION` 设置为除空字符串以外的任何内容。示例:
export ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION="true"
👉 或者,在您的命令前加上 `ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION="true"`,如:
ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION=true ./../../scripts/analysis/analyze.sh
- 如何禁用 git log 数据导入?
👉 将环境变量 `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT` 设置为 `none`。示例:
export IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="none"
👉 或者,在您的命令前加上 `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="none"`:
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="none" ./../../scripts/analysis/analyze.sh
👉 一个中间选项是仅使用 `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="aggregated"` 导入按月汇总的更改:
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="aggregated" ./../../scripts/analysis/analyze.sh
- 为什么有些 Jupyter Notebook 报告被跳过?
👉 可以设置自定义 Jupyter Notebook 元数据属性 `code_graph_analysis_pipeline_data_validation`,以从 [cypher/Validation](./cypher/Validation) 中选择一个查询,该查询将在 notebook 之前执行。如果查询至少产生一个结果,则验证成功,notebook 将运行。如果查询没有结果,notebook 将被跳过。
有关更多详细信息,请参阅 [Data Availability Validation](./COMMANDS.md#data-availability-validation)。
- 如何在扫描大型 Typescript 项目时增加 heap memory?
👉 使用环境变量 TYPESCRIPT_SCAN_HEAP_MEMORY(以兆字节为单位)(默认值 = 4096):
TYPESCRIPT_SCAN_HEAP_MEMORY=16384 ./../../scripts/analysis/analyze.sh
- 如何在扫描 Typescript 项目时遇到错误继续执行,而不是取消整个分析?
👉 使用 profile `Neo4j-latest-continue-on-scan-errors`(默认值 = `Neo4j-latest`):
./../../scripts/analysis/analyze.sh --profile Neo4j-latest-continue-on-scan-errors
- 如何减少内存 (RAM) 消耗?
👉 使用 profile `Neo4j-latest-low-memory`(默认值 = `Neo4j-latest`):
./../../scripts/analysis/analyze.sh --profile Neo4j-latest-low-memory
- 如何增加内存 (RAM) 消耗?
👉 使用 profile `Neo4j-latest-high-memory`(默认值 = `Neo4j-latest`):
./../../scripts/analysis/analyze.sh --profile Neo4j-latest-high-memory
## 🕸 Web 参考
- [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples)
- [Bite-Sized Neo4j for Data Scientists](https://neo4j.com/video/bite-sized-neo4j-for-data-scientists)
- [The Story behind Russian Twitter Trolls](https://neo4j.com/blog/story-behind-russian-twitter-trolls)
- [Graphs for Data Science and Machine Learning](https://de.slideshare.net/neo4j/graphs-for-data-science-and-machine-learning)
- [Modularity](https://www.cs.cmu.edu/~ckingsf/bioinfo-lectures/modularity.pdf)
- [Graph Data Science Centrality Algorithms](https://neo4j.com/docs/graph-data-science/2.5/algorithms/centrality)
- [Graph Data Science Community Detection Algorithms](https://neo4j.com/docs/graph-data-science/2.5/algorithms/community)
- [Graph Data Science Community Similarity Algorithms](https://neo4j.com/docs/graph-data-science/2.5/algorithms/similarity)
- [Graph Data Science Community Topological Sort Algorithm](https://neo4j.com/docs/graph-data-science/2.5/algorithms/dag/topological-sort)
- [Node embeddings for Beginners](https://towardsdatascience.com/node-embeddings-for-beginners-554ab1625d98)
本仓库提供了一个基于 [jQAssistant](https://jqassistant.github.io/jqassistant/current) 和 [Neo4j](https://neo4j.com) 构建的自动化代码图谱分析流水线。它支持 Java 和实验性的 TypeScript 分析,能够捕捉代码库的结构及其演变。
你是否曾想过哪些库最重要、模块之间如何构建、哪些部分贡献者较少、哪些文件会一起变更,或者结构异常出现在哪里?
本项目通过基于图谱的分析、可视化以及机器学习帮助揭示此类模式——提供数百种专家级报告以深入洞察代码。
好奇吗?在 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 探索示例,并通过 [GETTING_STARTED.md](./GETTING_STARTED.md) 开始使用 :rocket:
## :sparkles: 特性
- 将静态代码结构作为图谱进行分析
- 支持 Java 代码分析
- 支持 Typescript 代码分析(实验性)
- 完全自动化的 [Java 流水线](./.github/workflows/internal-java-code-analysis.yml),从工具安装到报告生成
- 完全自动化的 [Typescript 流水线](./.github/workflows/internal-typescript-code-analysis.yml),从工具安装到报告生成
- 完全自动化的 [本地运行](./GETTING_STARTED.md)
- 可轻松集成到您的 [持续集成流水线](./INTEGRATION.md) 中
- 超过 200 个 CSV 报告,涵盖依赖、指标、循环、注解、算法等
- 用于依赖、指标、可见性等方面的 Jupyter notebook 报告
- 基于无监督机器学习和可解释 AI 的异常检测
- 图谱结构可视化
- 自动生成参考文档
- 使用 [shell scripts](./scripts/SCRIPTS.md) 实现独立于运行时和库的自动化
- 已在 MacOS (zsh)、Linux (bash) 和 Windows (Git Bash) 上测试
- 详尽的 [Cypher 查询](./cypher/CYPHER.md) 列表
- [AxonFramework](https://github.com/AxonFramework/AxonFramework) 分析示例
- [react-router](https://github.com/remix-run/react-router) 分析示例
### :newspaper: 新闻
- 2025 年 11 月:移除了自 2.x 版本起已弃用的 "graph-visualization" node 包
- 2025 年 11 月:用于异常和原型的 Treemap 图表
- 2025 年 10 月:异常原型的图谱可视化
- 2025 年 10 月:带有 markdown 摘要的异常原型
- 2025 年 8 月:针对 git 历史中共同变更文件的关联规则挖掘
- 2025 年 8 月:基于无监督机器学习和可解释 AI 的异常检测
- 2025 年 5 月:迁移至 [Neo4j 2025.x](https://neo4j.com/docs/upgrade-migration-guide/current/version-2025/upgrade) 和 Java 21。
### :notebook: Jupyter Notebook 和 Python 报告
以下是来自 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 的 [Jupyter Notebooks](https://jupyter.org) 报告概览。完整列表请参阅 [Jupyter Notebook 报告参考](#page_with_curl-jupyter-notebook-report-reference)。
- [External Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/external-dependencies-java/ExternalDependenciesJava.md) 包含有关外部库使用的详细信息 ([Notebook](./jupyter/ExternalDependenciesJava.ipynb))。
- [Git History](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/git-history-general/GitHistoryGeneral.md) 包含有关被分析代码的 git 历史信息 ([Notebook](./jupyter/GitHistoryGeneral.ipynb))。
- [Internal Dependencies](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/internal-dependencies-java/InternalDependenciesJava.md) 基于 [Analyze java package metrics in a graph database](https://joht.github.io/johtizen/data/2023/04/21/java-package-metrics-analysis.html),还包括循环依赖 ([Notebook](./jupyter/InternalDependenciesJava.ipynb))。
- [Method Metrics](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/method-metrics-java/MethodMetricsJava.md) 展示了代码中方法的有效代码行数和圈复杂度分布 ([Notebook](./jupyter/MethodMetricsJava.ipynb))。
- [Node Embeddings](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/node-embeddings-java/NodeEmbeddingsJava.md) 展示了如何生成节点嵌入并进一步降低其维度,以便在 2D 图表中可视化它们 ([Notebook](./jupyter/NodeEmbeddingsJava.ipynb))。
- [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) 基于 [OO Design Quality Metrics by Robert Martin](https://api.semanticscholar.org/CorpusID:18246616) ([Notebook](./jupyter/ObjectOrientedDesignMetricsJava.ipynb))。
- [Overview](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/overview-java/OverviewJava.md) 包含整体统计数据以及有关方法及其复杂性的详细信息。([Notebook](./jupyter/OverviewJava.ipynb))。
- [Visibility Metrics](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/visibility-metrics-java/VisibilityMetricsJava.md) ([Notebook](./jupyter/VisibilityMetricsJava.ipynb))。
- [Wordcloud](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/wordcloud/Wordcloud.md) 包含包和类名称的可视化表示 ([Notebook](./jupyter/Wordcloud.ipynb))。
- [Java Archetypes Treemap](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/anomaly-detection/JavaTreemap2ArchetypesOverviewPerDirectory.svg) ([Python Script](./domains/anomaly-detection/treemapVisualizations.py))
### :blue_book: Graph Data Science 报告
本项目包含多个使用 Neo4j 的 [Graph Data Science Library](https://neo4j.com/product/graph-data-science) 的报告。这些报告是 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 仓库的一部分。有关报告的完整列表,请查看 [CSV Cypher Query 报告参考](#page_with_curl-csv-cypher-query-report-reference)。
以下是利用 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 中 Neo4j 的 [Graph Data Science Library](https://neo4j.com/product/graph-data-science) 的一些报告。完整列表请参阅 [CSV Cypher Query 报告参考](#page_with_curl-csv-cypher-query-report-reference)。
- [Centrality with Page Rank](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/centrality-csv/Package_Centrality_Page_Rank.csv) ([Source Script](./scripts/reports/CentralityCsv.sh))
- [Community Detection with Leiden](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/community-csv/Package_communityLeidenId_Community__Metrics.csv) ([Source Script](./scripts/reports/CommunityCsv.sh))
- [Node Embeddings with HashGNN](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/node-embeddings-csv/Package_Embeddings_HashGNN.csv) ([Source Script](./scripts/reports/NodeEmbeddingsCsv.sh))
- [Path Finding with all pairs shortest path](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/path-finding-csv/Package_all_pairs_shortest_paths_distribution_per_project.csv) ([Source Script](./scripts/reports/PathFindingCsv.sh))
- [Similarity with Jaccard](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/similarity-csv/Package_Similarity.csv) ([Source Script](./scripts/reports/SimilarityCsv.sh))
- [Topology Sort](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/topology-csv/Package_Topological_Sort.csv) ([Source Script](./scripts/reports/TopologicalSortCsv.sh))
### :art: 图谱可视化
以下是一些利用 [GraphViz](https://graphviz.org) 从 [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples) 生成的全自动图谱可视化:
- [Java Artifact Build Levels](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/internal-dependencies-visualization/JavaArtifactBuildLevels.svg) ([Query](./cypher/Internal_Dependencies/Java_Artifact_build_levels_for_graphviz.cypher), [Source Script](./scripts/visualization/visualizeQueryResults.sh))
- [Java Artifact Longest Path Contributors](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/path-finding-visualization/JavaArtifactLongestPaths.svg) ([Query](./cypher/Path_Finding/Path_Finding_6_Longest_paths_contributors_for_graphviz.cypher), [Source Script](./scripts/visualization/visualizeQueryResults.sh))
- [Java Package Top #1 Authority Archetype and contributing packages](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/AxonFramework/latest/anomaly-detection/Java_Package/GraphVisualizations/TopAuthority1.svg) ([Query](./domains/anomaly-detection/labels/AnomalyDetectionArchetypeAuthority.cypher), [Source Script](./domains/anomaly-detection/graphs/anomalyDetectionGraphs.sh))
## :book: 博客文章
- [Analyze java dependencies with jQAssistant](https://joht.github.io/johtizen/data/2021/02/21/java-jar-dependency-analysis.html)
- [Analyze java package metrics in a graph database (Part 2)](https://joht.github.io/johtizen/data/2023/04/21/java-package-metrics-analysis.html)
## :mega: 演讲
- [Unleashing the Power of Graphs in Java Code Structure Analysis](https://github.com/JohT/code-graph-analysis-examples/blob/main/talks/2023-12-14-Engineering_Kiosk_Alps_Meetup-Code_Structure_Graph_Analysis.pdf) - Engineering Kiosk Alps Meetup, 2023 年 12 月
- [How anomalous is your code?](https://github.com/JohT/code-graph-analysis-examples/blob/main/talks/2026-02-25_AI_Meetup_Austria_How_Anomalous_Is_Your_Code.pdf) - AI Meetup Austria, 2026 年 2 月
## :hammer_and_wrench: 前置条件
运行 [scripts/checkCompatibility.sh](./scripts/checkCompatibility.sh) 以检查是否已安装所有必需的依赖项并在您的环境中可用。
- 自 [Neo4j 2025.01](https://neo4j.com/docs/operations-manual/current/installation/requirements/#deployment-requirements-java) 起 [需要 Java 21](https://neo4j.com/docs/operations-manual/current/installation/requirements/#deployment-requirements-java)。另请参阅 [Changes from Neo4j 5 to 2025.x](https://neo4j.com/docs/upgrade-migration-guide/current/version-2025/upgrade)。
- [Neo4j 5 需要 Java 17](https://neo4j.com/docs/operations-manual/current/installation/requirements/#deployment-requirements-java)。
- 在 Windows 上,建议使用 [git for windows](https://github.com/git-guides/install-git#install-git-on-windows) 提供的 git bash。
- 需要安装 [jq](https://github.com/jqlang/jq),即“轻量级且灵活的命令行 JSON 处理器”。最新版本:https://github.com/jqlang/jq/releases/latest。使用 `jq --version` 检查。
- 将环境变量 `NEO4J_INITIAL_PASSWORD` 设置为您选择的密码。例如:
export NEO4J_INITIAL_PASSWORD=neo4j_password_of_my_choice
要运行 Jupyter notebook,请在打开 notebook 的文件夹中创建一个 `.env` 文件,其中包含例如:`NEO4J_INITIAL_PASSWORD=neo4j_password_of_my_choice`
### Python 和 Jupyter Notebooks 的额外前置条件
- Jupyter Notebook 和 Python 报告需要 Python。
- 需要使用 [Conda](https://docs.conda.io) 或 Python 的内置模块 [venv](https://docs.python.org/3/library/venv.html) 作为环境管理器。
- 对于 Conda,例如可以使用 [Miniconda](https://docs.conda.io/projects/miniconda/en/latest) 或 [Anaconda](https://www.anaconda.com/download)(推荐 Windows 使用)。
- 要使用 venv,无需额外安装。为此,需要将环境变量 `USE_VIRTUAL_PYTHON_ENVIRONMENT_VENV` 设置为 `'true'`。
- 如果 Jupyter Notebook PDF 报告生成需要,Chromium 将自动下载。
### Windows 的额外前置条件
- 如果您使用的是 Anaconda3,请将此行添加到您的 `~/.bashrc` 文件中:`/c/ProgramData/Anaconda3/etc/profile.d/conda.sh`。尝试为其他 conda 包管理器或版本查找类似的脚本。
- 以管理员身份打开的 git bash 中运行 `conda init`。在普通模式下运行通常会导致错误消息。
### 分析 Typescript 的额外前置条件
- 请按照此处的说明创建包含 Typescript 项目静态代码信息的 json 文件:
https://github.com/jqassistant-plugin/jqassistant-typescript-plugin
这可能就像在您的 Typescript 项目中运行以下命令一样简单:
npx --yes @jqassistant/ts-lce
- 克隆的仓库或源项目需要复制到分析工作区内名为 `source` 的目录中,以便 [resetAndScan.sh](./scripts/resetAndScan.sh) 和可选的 [importGit.sh](./scripts/importGit.sh) 在扫描期间也能将其选中。
## :rocket: 开始使用
请参阅 [GETTING_STARTED.md](./GETTING_STARTED.md) 了解如何在本地机器上开始使用。
## :rocket: 集成
请参阅 [INTEGRATION.md](./INTEGRATION.md) 了解如何将代码分析集成到您的持续集成流水线中。
目前 (2025 年),仅支持 GitHub Actions。
## :building_construction: 流水线和工具
[Code Structure Analysis Pipeline](./.github/workflows/internal-java-code-analysis.yml) 利用 [GitHub Actions](https://docs.github.com/de/actions) 自动化整个分析过程:
- 使用 [GitHub Actions](https://docs.github.com/de/actions) Linux Runner
- [Checkout GIT Repository](https://github.com/actions/checkout)
- [Setup Java](https://github.com/actions/setup-java)
- [Setup Python with Conda](https://github.com/conda-incubator/setup-miniconda) 包管理器 [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge)
- [Setup Python with venv](https://docs.python.org/3/library/venv.html)
- 下载包含要分析代码的工件和可选源代码 [scripts/downloader](./scripts/downloader)
- 设置 [Neo4j](https://neo4j.com) Graph Database ([analysis.sh](./scripts/analysis/analyze.sh))
- 设置 [jQAssistant](https://jqassistant.github.io/jqassistant/current) 用于 Java 和 [Typescript](https://github.com/jqassistant-plugin/jqassistant-typescript-plugin) 分析 ([analysis.sh](./scripts/analysis/analyze.sh))
- 启动 [Neo4j](https://neo4j.com) Graph Database ([analysis.sh](./scripts/analysis/analyze.sh))
- 使用命令行 JSON 解析器 [jq](https://jqlang.github.io/jq) 生成 CSV 报告 [scripts/reports](./scripts/reports)
- 使用 [Neo4j Graph Data Science](https://neo4j.com/product/graph-data-science) 进行社区检测、中心性、相似性、节点嵌入和拓扑排序 ([analysis.sh](./scripts/analysis/analyze.sh))
- 使用 [conda-environment.yml](./conda-environment.yml) 中指定的这些库生成 [Jupyter Notebook](https://jupyter.org) 报告:
- [Python](https://www.python.org)
- [jupyter](https://jupyter.org)
- [matplotlib](https://matplotlib.org)
- [nbconvert](https://nbconvert.readthedocs.io)
- [numpy](https://numpy.org)
- [pandas](https://pandas.pydata.org)
- [pip](https://pip.pypa.io/en/stable)
- [plotly](https://plotly.com/python)
- [monotonic](https://github.com/atdt/monotonic)
- [Neo4j Python Driver](https://neo4j.com/docs/api/python-driver)
- [openTSNE](https://github.com/pavlin-policar/openTSNE)
- [wordcloud](https://github.com/amueller/word_cloud)
- [umap](https://umap-learn.readthedocs.io)
- [scikit-learn](https://scikit-learn.org)
- [optuna](https://optuna.org)
- [SHAP](https://github.com/shap/shap)
- [HPCC-Systems (High Performance Computing Cluster) Web-Assembly (JavaScript)](https://github.com/hpcc-systems/hpcc-js-wasm) 包含用于可视化图结构的 GraphViz 包装器。
- [GraphViz](https://gitlab.com/graphviz/graphviz) 用于 CLI Graph Visualization
- [Check links in markdown documentation (GitHub workflow)](./.github/workflows/internal-check-links-in-documentation.yml) 使用 [markdown-link-check](https://github.com/tcort/markdown-link-check)。
**特别感谢** 📣 所有这些优秀库的创建者和贡献者 👍。没有他们,像这样的项目是不可能实现的。如果列表中缺少或有误请随时 [创建 issue](https://github.com/JohT/code-graph-analysis-pipeline/issues/new/choose)。
## :runner: 命令参考
[COMMANDS.md](./COMMANDS.md) 包含有关命令以及如何进行手动设置的更多详细信息。
## :page_with_curl: CSV Cypher Query 报告参考
[CSV_REPORTS.md](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/CSV_REPORTS.md) 列出了 [results](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results) 目录中的所有 CSV Cypher 查询结果报告。它可以按照 [Generate CSV Report Reference](./COMMANDS.md#generate-csv-cypher-query-report-reference) 中的描述生成。
## :page_with_curl: Jupyter Notebook 报告参考
[JUPYTER_REPORTS.md](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/JUPYTER_REPORTS.md) 列出了 [results](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results) 目录中的所有 Jupyter Notebook 报告。它可以按照 [Generate Jupyter Notebook Report Reference](./COMMANDS.md#generate-jupyter-notebook-report-reference) 中的描述生成。
## :camera: 图像参考
[IMAGES.md](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results/IMAGES.md) 列出了 [results](https://github.com/JohT/code-graph-analysis-examples/blob/main/analysis-results) 目录中的所有 PNG 图像。它可以按照 [Generate Image Reference](./COMMANDS.md#generate-image-reference) 中的描述生成。
## :gear: 脚本参考
[SCRIPTS.md](./scripts/SCRIPTS.md) 列出了本仓库的所有 shell 脚本,包括其第一行注释作为描述。它可以按照 [Generate Script Reference](./COMMANDS.md#generate-script-reference) 中的描述生成。
## :mag: Cypher Query 参考
[CYPHER.md](./cypher/CYPHER.md) 列出了本仓库的所有 Cypher 查询,包括其第一行注释作为描述。它可以按照 [Generate Cypher Reference](./COMMANDS.md#generate-cypher-reference) 中的描述生成。
## :globe_with_meridians: 环境变量参考
[ENVIRONMENT_VARIABLES.md](./scripts/ENVIRONMENT_VARIABLES.md) 包含脚本支持的所有环境变量,包括默认值和描述。它可以按照 [Generate Environment Variable Reference](./COMMANDS.md#generate-environment-variable-reference) 中的描述生成。
## :closed_book: 变更日志
[CHANGELOG.md](./CHANGELOG.md) 包含本仓库的所有变更。
## :thinking: 问答
- 如何在本地运行分析?
👉 检查 [前置条件](#hammer_and_wrench-prerequisites)。
👉 参阅 [命令参考](./COMMANDS.md) 中的 [Start an analysis](./COMMANDS.md#start-an-analysis)。
👉 要从头开始,请参阅 [GETTING_STARTED.md](./GETTING_STARTED.md)。
- 如何手动探索 Graph?
👉 分析后 [start Neo4j](./COMMANDS.md#start-neo4j-graph-database) 并打开 Neo4j Web UI (`http://localhost:7474/browser`)。
- 如何向流水线添加 CSV 报告?
👉 将您的新 cypher 查询放入 [cypher](./cypher) 目录或合适的(新)子目录中。
👉 在 [scripts/reports](./scripts/reports/) 目录中创建一个新的 CSV 报告脚本。以 [OverviewCsv.sh](./scripts/reports/OverviewCsv.sh) 作为参考。
👉 该脚本将因其目录及其以 "Csv.sh" 结尾的名称而被自动包含。
- 如何向流水线添加 Jupyter Notebook 报告?
👉 将您的新 notebook 放入 [jupyter](./jupyter) 目录。
👉 该文件随后将被 [executeJupyterNotebookReport.sh](./scripts/executeJupyterNotebookReport.sh) 自动选中。
- 如何自动分析不同的代码库?
👉 在 [scripts/downloader](./scripts/downloader/) 目录中创建一个新的下载脚本。以 [downloadAxonFramework.sh](./scripts/downloader/downloadAxonFramework.sh) 作为 Java 项目的参考,以 [downloadReactRouter.sh](./scripts/downloader/downloadReactRouter.sh) 作为 Typescript 项目的参考。
👉 下载后,运行 [analyze.sh](./scripts/analysis/analyze.sh)。您也可以在 [pipeline](./.github/workflows/internal-java-code-analysis.yml) 中找到这些步骤作为参考。
- 如何触发所有工件的完整重新扫描?
👉 删除 `artifacts` 目录中的 `artifactsChangeDetectionHash.txt` 文件。
👉 删除 `source` 目录中的 `typescriptFileChangeDetectionHashFile.txt` 文件,以额外重新扫描 Typescript 项目。
- 如何为 Jupyter Notebooks 启用 PDF 生成(依赖 chromium,耗时更多)?
👉 将环境变量 `ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION` 设置为除空字符串以外的任何内容。示例:
export ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION="true"
👉 或者,在您的命令前加上 `ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION="true"`,如:
ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION=true ./../../scripts/analysis/analyze.sh
- 如何禁用 git log 数据导入?
👉 将环境变量 `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT` 设置为 `none`。示例:
export IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="none"
👉 或者,在您的命令前加上 `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="none"`:
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="none" ./../../scripts/analysis/analyze.sh
👉 一个中间选项是仅使用 `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="aggregated"` 导入按月汇总的更改:
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT="aggregated" ./../../scripts/analysis/analyze.sh
- 为什么有些 Jupyter Notebook 报告被跳过?
👉 可以设置自定义 Jupyter Notebook 元数据属性 `code_graph_analysis_pipeline_data_validation`,以从 [cypher/Validation](./cypher/Validation) 中选择一个查询,该查询将在 notebook 之前执行。如果查询至少产生一个结果,则验证成功,notebook 将运行。如果查询没有结果,notebook 将被跳过。
有关更多详细信息,请参阅 [Data Availability Validation](./COMMANDS.md#data-availability-validation)。
- 如何在扫描大型 Typescript 项目时增加 heap memory?
👉 使用环境变量 TYPESCRIPT_SCAN_HEAP_MEMORY(以兆字节为单位)(默认值 = 4096):
TYPESCRIPT_SCAN_HEAP_MEMORY=16384 ./../../scripts/analysis/analyze.sh
- 如何在扫描 Typescript 项目时遇到错误继续执行,而不是取消整个分析?
👉 使用 profile `Neo4j-latest-continue-on-scan-errors`(默认值 = `Neo4j-latest`):
./../../scripts/analysis/analyze.sh --profile Neo4j-latest-continue-on-scan-errors
- 如何减少内存 (RAM) 消耗?
👉 使用 profile `Neo4j-latest-low-memory`(默认值 = `Neo4j-latest`):
./../../scripts/analysis/analyze.sh --profile Neo4j-latest-low-memory
- 如何增加内存 (RAM) 消耗?
👉 使用 profile `Neo4j-latest-high-memory`(默认值 = `Neo4j-latest`):
./../../scripts/analysis/analyze.sh --profile Neo4j-latest-high-memory
## 🕸 Web 参考
- [code-graph-analysis-examples](https://github.com/JohT/code-graph-analysis-examples)
- [Bite-Sized Neo4j for Data Scientists](https://neo4j.com/video/bite-sized-neo4j-for-data-scientists)
- [The Story behind Russian Twitter Trolls](https://neo4j.com/blog/story-behind-russian-twitter-trolls)
- [Graphs for Data Science and Machine Learning](https://de.slideshare.net/neo4j/graphs-for-data-science-and-machine-learning)
- [Modularity](https://www.cs.cmu.edu/~ckingsf/bioinfo-lectures/modularity.pdf)
- [Graph Data Science Centrality Algorithms](https://neo4j.com/docs/graph-data-science/2.5/algorithms/centrality)
- [Graph Data Science Community Detection Algorithms](https://neo4j.com/docs/graph-data-science/2.5/algorithms/community)
- [Graph Data Science Community Similarity Algorithms](https://neo4j.com/docs/graph-data-science/2.5/algorithms/similarity)
- [Graph Data Science Community Topological Sort Algorithm](https://neo4j.com/docs/graph-data-science/2.5/algorithms/dag/topological-sort)
- [Node embeddings for Beginners](https://towardsdatascience.com/node-embeddings-for-beginners-554ab1625d98)标签:Apex, Cutter, DevSecOps, jQAssistant, JS文件枚举, Neo4j, TypeScript, WebSocket, 上游代理, 代码可视化, 代码图谱, 依赖分析, 可解释AI, 安全专业人员, 安全插件, 开源框架, 异常检测, 技术债务, 持续集成, 机器学习, 自动化流水线, 软件度量, 软件架构分析, 逆向工具, 错误基检测, 静态代码分析