Skip to content

Latest commit

 

History

History
91 lines (64 loc) · 4.87 KB

README.en.md

File metadata and controls

91 lines (64 loc) · 4.87 KB

jcci

Description

Java code commit impact analysis, is a pure python library that analyzes the impact of two git submissions of Java projects on the project and generates tree chart data.

PYPI: jcci (It will be several versions behind github)

Achieve Effect

效果图

Software Architecture

The general principle is the same as Find Usage of Idea, locate the impact of the code through code changes, and continuously traverse the affected classes and methods until the top controller layer is found

The code is mainly written by python and mainly involves 2 libraries:

  • javalang java file syntax parsing library
  • unidiff git diff information parsing library

Obtain information such as import class extends implements declarators methods of each Java file through javalang syntax analysis

Parse git diff information through unidiff (diff file, added_line_num, removed_lin_num)

Then judge which classes and methods are affected according to the code lines added or deleted in the file, and continuously traverse the affected classes and methods until you find the top controller layer

By passing in the commit id of the project git address branch twice, the impact of code changes between the two commit ids can be analyzed, and the tree diagram data can be generated to display the affected links.

Installation

Require python >= 3.9 , sqlite3 >= 3.38

Method 1: pypi installation (will be several versions behind github)
$ pip install jcci
Method 2: Clone the project (recommended)
$ git clone https://github.com/baikaishuipp/jcci.git

Instructions

Method 1: pypi installation (will be several versions behind github)

Start a new python project, add a new python file, code example:

from jcci.analyze import JCCI

# Compare different commits on the same branch
commit_analyze = JCCI('[email protected]', 'username1')
commit_analyze.analyze_two_commit('master','commit_id1','commit_id2')

# To analyze the impact of methods in a class, use the analyze_class_method method. The last parameter is the line number(s) of the method(s) you want to analyze. If multiple methods are specified, separate their line numbers with commas. If left blank, it will analyze the impact of the entire class.
class_analyze = JCCI('[email protected]', 'username1')
class_analyze.analyze_class_method('master','commit_id1', 'package\src\main\java\ClassA.java', '20,81')

# Compare different branches
branch_analyze = JCCI('[email protected]', 'username1')
branch_analyze.analyze_two_branch('branch_new','branch_old')
Method 2: Clone the project (recommended)

After the project is cloned, create a new python file and introduce jcci in the src directory of the jcci project.

from path.to.jcci.src.jcci.analyze import JCCI

# Compare different commits on the same branch
commit_analyze = JCCI('[email protected]', 'username1')
commit_analyze.analyze_two_commit('master','commit_id1','commit_id2')

# To analyze the impact of methods in a class, use the analyze_class_method method. The last parameter is the line number(s) of the method(s) you want to analyze. If multiple methods are specified, separate their line numbers with commas. If left blank, it will analyze the impact of the entire class.
class_analyze = JCCI('[email protected]', 'username1')
class_analyze.analyze_class_method('master','commit_id1', 'package\src\main\java\ClassA.java', '20,81')

# Compare different branches
branch_analyze = JCCI('[email protected]', 'username1')
branch_analyze.analyze_two_branch('branch_new','branch_old')
Parameter Description:
  • project_git_url - project git address, the code uses the native git configuration to clone the code, ensure the native git permissions or splice the url through username, password/token to clone the code. Example: https://userName:[email protected]/xxx.git or https://[email protected]/xxx.git
  • username1 - Enter whatever you want. In order to avoid incorrect results caused by concurrent analysis of the same project, when user 1 analyzes project A, user B needs to wait, so this parameter is set.

At the same time, the project will be cloned in the directory and then analyzed to generate a file with the suffix format xxx.cci, which contains the tree diagram data generated by the analysis results, download jcci-result.html , upload analyze result file end with .cci, then can be displayed through the view.

If this tool is helpful to you, please click star in the upper right corner ⭐,and buy me a cup of coffee thanks~~~~

buy me coffee

Communication

Scan QR code via WeChat app, and comment:JCCI communication

communicate via Wechat