Git Product home page Git Product logo

jcci's Introduction

jcci

介绍

Java代码提交影响分析,是一个纯python库,分析Java项目的两次git提交差异对项目的影响,并生成树形图数据。

PYPI: jcci (会落后github几个版本)

软件架构

大致原理同Idea的Find Usage一致,通过代码改动定位代码影响,并不断遍历受影响的类和方法直至找到最上层的controller层

代码主要由python编写,主要涉及2个库:

  • javalang java文件语法解析库
  • unidiff git diff信息解析库

通过javalang语法解析获取每个Java文件的import class extends implements declarators methods 等信息

通过unidiff 解析git diff信息(diff file, added_line_num, removed_lin_num)

然后根据文件增删的代码行去判断影响了哪些类和方法,不断遍历受影响的类和方法直至找到最上层的controller层

通过传入项目git地址 分支 两次的commit id,即可分析出两次commit id之间代码改动所带来的影响,并生成树图数据方便展示影响链路。

安装教程

方式1:pypi安装(会落后github几个版本)
$ pip install jcci
方式2:克隆项目(推荐此种方式)
$ git clone https://github.com/baikaishuipp/jcci.git

使用说明

方式1:pypi安装(会落后github几个版本)

新建python项目,新建python文件,代码如下:

from jcci import jcci

# 同一分支不同commit比较
jcci.analyze('[email protected]','master','commit_id1','commit_id2', 'username1')

方式2:克隆项目(推荐此种方式)

项目克隆下来后,新建python文件,引入jcci项目src目录下的jcci

from path.to.jcci.src.jcci import jcci

# 同一分支不同commit比较
jcci.analyze('[email protected]','master','commit_id1','commit_id2', 'username1')

参数说明:
  • project_git_url - 项目git地址,代码使用本机git配置clone代码,确保本机git权限或通过用户名密码/token的方式拼接url来clone代码。示例:https://userName:[email protected]/xxx.githttps://[email protected]/xxx.git
  • username1 - 随便输入,为了避免并发分析同一项目导致结果错误,用户1分析项目A时,用户B需要等待,所以设置了该参数

运行时,会将项目克隆到目录中,然后进行分析,生成后缀格式为commit_id1...commit_id2.cci的文件,其中包含分析结果生成的树形图数据,下载jcci-result.html ,选择分析结果的.cci文件,即可可通过视图显示。

CCI result

result

CCI result tree view

treeView

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

开源不易,如本工具对您有帮助,请点一下右上角 star ⭐ , 谢谢~~~

沟通交流

扫码加微信,备注:JCCI微信群交流

微信交流群

jcci's People

Contributors

baikaishuipp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.