JCIA - Java Code Impact Analyzer
[]
[
]
[
]
JCIA 是一个 Python 工具,用于分析 Java 代码变更的影响范围,智能选择需要运行的测试用例,并提供回归分析能力。
特性
- 🔍 变更代码影响分析 - 自动分析 Git 提交,识别变更的文件和方法
- 📊 影响图构建 - 构建调用链图,计算受影响的类和方法
- 🌐 跨服务远程调用检测 - 识别 Dubbo/Feign/HTTP/MQ 远程调用并融合进影响图,评估跨服务变更风险(
--detect-remote-calls) - 🎯 智能测试选择 - 基于 STARTS 算法和影响范围选择测试用例
- 🤖 AI 测试生成 - 集成 LLM 服务,自动生成测试用例建议
- 📈 多格式报告 - 支持 HTML、JSON、Markdown 格式报告
- 🔄 回归分析 - 对比基线测试和回归测试结果,识别回归问题
快速开始
安装
# 克隆仓库
git clone https://github.com/boyingliu01/jcia.git
cd jcia
# 创建虚拟环境
python -m venv .venv
.venv\Scripts\Activate.ps1 # Windows PowerShell
# 安装依赖
pip install -e ".[dev]"
配置
创建配置文件 jcia.yaml(可选):
repository:
path: /path/to/your/java/project
analyzer:
max_depth: 10
include_test_files: false
report:
format: html
output_dir: ./reports
ai:
provider: volcengine
model: gpt-4
使用
# 分析变更影响
jcia analyze --repo-path /path/to/repo --from-commit abc123 --to-commit def456
# 分析变更影响并检测跨服务远程调用(Dubbo/Feign/HTTP/MQ)
jcia analyze --repo-path /path/to/repo --commit-range abc123..def456 --detect-remote-calls
# 生成测试用例
jcia test --repo-path /path/to/project --target-class com.example.Service
# 生成报告
jcia report --output-dir ./reports --format html
# 配置管理
jcia config --show
jcia config --set analyzer.max_depth=15
核心概念
变更分析
JCIA 使用 PyDriller 解析 Git 仓库,识别:
- 文件级变更(新增、修改、删除、重命名)
- 方法级变更(方法签名变更)
- 提交信息(作者、时间、消息)
影响图
影响图展示代码变更的传播路径:
- 直接影响 - 直接调用变更方法的代码
- 间接影响 - 通过调用链间接影响的代码
- 严重程度 - HIGH/MEDIUM/LOW
- 影响深度 - 变更传播的最大深度
测试选择
JCIA 支持多种测试选择策略:
- ALL - 运行所有测试
- STARTS - 使用 STARTS 算法选择
- IMPACT_BASED - 基于影响范围选择
- HYBRID - 混合策略
架构
JCIA 采用清洁架构(Clean Architecture):
Adapters Layer (Git, Maven, AI, Database)
↓
Infrastructure Layer (Repositories, Config, Logging)
↓
Use Cases Layer (Business Orchestration)
↓
Services Layer (Domain Logic)
↓
Entities Layer (Domain Models)
依赖规则
- 外部依赖(Git、Maven、AI)在适配器层
- 业务逻辑在核心层
- 核心层不依赖适配器层
- 通过接口(ABC)解耦
开发
设置开发环境
# 安装开发依赖
pip install -e ".[dev]"
# 配置 pre-commit hooks
make setup-hooks
运行测试
# 运行所有测试
make test
# 运行单元测试
pytest tests/unit -v
# 运行集成测试
pytest tests/integration -v
# 运行带覆盖率的测试
pytest tests/unit --cov=jcia --cov-report=html
代码质量
# Lint 检查
make lint
# 格式化代码
make format
# 类型检查
pyright jcia tests
# 安全扫描
make security
# 完整检查
make check
配置选项
CLI 选项
| 命令 | 选项 | 说明 |
|---|---|---|
analyze |
--repo-path |
Git 仓库路径 |
--from-commit |
起始提交哈希 | |
--to-commit |
结束提交哈希 | |
--commit-range |
提交范围(如 abc123..def456) | |
--max-depth |
最大追溯深度 | |
test |
--repo-path |
项目路径 |
--target-class |
目标类(可多次使用) | |
--coverage-file |
覆盖率报告文件 | |
--min-confidence |
最低置信度阈值 | |
report |
--output-dir |
报告输出目录(必填) |
--format |
报告格式(json/html/markdown/console,默认 json) | |
--include-details |
包含详细信息 | |
config |
--show |
显示当前配置项 |
--set |
设置配置项(如 analyzer.max_depth=15) |
环境变量
| 变量 | 说明 |
|---|---|
VOLCENGINE_ACCESS_KEY |
Volcengine 访问密钥 |
VOLCENGINE_SECRET_KEY |
Volcengine 密钥 |
VOLCENGINE_APP_ID |
Volcengine 应用 ID |
性能
- 单次提交分析:< 10 秒
- 影响图构建:< 5 秒
- 测试选择:< 3 秒
- 支持 1000+ 测试用例
- 选择性测试加速:≥ 50%
许可证
贡献
欢迎贡献!请查看 CONTRIBUTING.md 了解详细信息。
支持
- 🐛 Issues: GitHub Issues
- 📖 Docs: 项目文档
更新日志
查看 CHANGELOG.md 了解版本历史。
致谢
感谢所有贡献者和开源项目的支持:
Metadata
Release files for jcia 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jcia-0.2.0.tar.gz | 139.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jcia-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 313.6 kB
Release files / jcia-0.2.0.tar.gz
| Download URL | jcia-0.2.0.tar.gz |
|---|---|
| Size | 139.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fdb77ed18431e338730ec3a7a0e92b6a3c9225f7c0fe99db863106af15039f0
|
|
BLAKE2b-256 checksum How to use checksums |
8cedae51b037e7dc699b854b9dbeef4d4584077ff67790011487073334e4a5d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.
Transparency logRelease files / jcia-0.2.0-py3-none-any.whl
| Download URL | jcia-0.2.0-py3-none-any.whl |
|---|---|
| Size | 174.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ffbfa8603089f16835d97fe9a30d92c07b021e2d9df60d26e6498b41c09fdb95
|
|
BLAKE2b-256 checksum How to use checksums |
7af68ba90c1e4c00b50fc9162b7bddf6b8932d1fe9d2ce9ec758050b6bc898ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.
Transparency log