Software outsourcing-oriented heterogeneous code warehouse intelligent coupling degree detection system and method
Through semantic coupling analysis, quantum-inspired optimization, and digital twin simulation technology, the problems of inaccurate coupling pattern recognition and low optimization efficiency in heterogeneous code repositories have been solved, efficient and accurate coupling detection and optimization have been achieved, and the quality and efficiency of software development have been improved.
Patent Information
- Application Number
- CN202510964892.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-14
- Publication Date
- 2025-10-17
AI Technical Summary
The existing technology for coupling degree detection in heterogeneous code repositories has the following problems: there is a lack of a unified semantic analysis framework for multi-language codes, inaccurate coupling pattern recognition, low optimization algorithm efficiency, and the inability to handle complex coupling structures. Dynamic coupling degree detection lacks effective simulation tools, making it difficult to simulate the real operating environment.
Semantic coupling analysis is combined with quantum-inspired optimization algorithms and digital twin simulation technology. Multi-language codes are parsed through a distributed crawler module, and information is extracted using Fine-tune's CodeLlama model. A dependency graph is constructed and modularized to identify coupling anti-patterns. The quantum annealing algorithm is used to optimize the coupling structure, and repair suggestions are generated in combination with GPT-4. A digital twin of the code repository is constructed for dynamic coupling detection, and cross-language interface testing tools are used to perform interface compatibility and call chain coupling testing.
It achieves efficient parsing and information extraction of multi-language codes, accurately identifies coupling patterns, improves optimization efficiency, provides coupling degree assessment in a real operating environment, ensures the stability and maintainability of heterogeneous code repositories, and improves the quality and efficiency of software development.
Smart Images

Figure CN120803510A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software engineering, more particularly, to a software outsourcing-oriented intelligent coupling degree detection system and method for heterogeneous code repositories. BACKGROUND
[0002] In the field of software outsourcing, coupling degree detection of heterogeneous code repositories is a key link to ensure software quality, improve development efficiency and reduce maintenance cost. With the increasing size and complexity of software projects, multiple programming languages, frameworks and technology stacks are involved in code repositories, forming a complex heterogeneous environment. This heterogeneity not only increases the difficulty of code management, but also leads to an increase in the complexity of coupling degree detection. Coupling degree refers to the degree of dependence between code modules. High coupling degree can reduce the maintainability, scalability and testability of code, and increase the cost of software development and maintenance.
[0003] Traditional coupling degree detection methods mainly rely on static code analysis tools. These tools can only detect explicit dependency relationships at the code level, but cannot identify implicit coupling at the semantic level. In addition, traditional methods require separate analysis for each language when dealing with multi-language heterogeneous code repositories, lack a unified analysis framework, resulting in low detection efficiency and inconsistent results. Static analysis methods cannot capture the dynamic behavior of code at runtime and cannot fully assess the actual impact of coupling degree. In recent years, with the development of artificial intelligence and quantum computing technologies, new ideas have been provided to solve the coupling degree detection problem of heterogeneous code repositories. Semantic analysis technology can identify deeper coupling patterns through semantic understanding of code. Quantum computing technology can efficiently optimize coupling structures using its parallel computing capabilities. In addition, the emergence of digital twinning technology provides a new means for dynamic coupling degree detection. By constructing a digital twin of the code repository, the actual running scenario of the code can be simulated in a virtual environment, thereby more accurately assessing the coupling degree. However, despite the development of these technologies, existing technologies still have many shortcomings in coupling degree detection of heterogeneous code repositories, which seriously restricts the optimization and management of heterogeneous code repositories in software outsourcing projects.
[0004] Therefore, in the coupling degree detection of heterogeneous code repositories, the existing technology has the following problems: lack of unified semantic analysis framework for multi-language code, inaccurate coupling pattern recognition; low efficiency of optimization algorithms, unable to handle complex coupling structures; lack of effective simulation tools for dynamic coupling degree detection, difficult to simulate real running environment. SUMMARY
[0005] In order to overcome the problems of inaccurate coupling pattern recognition, inability to handle complex coupling structures and difficulty in simulating real running environment in existing technology, the present application discloses a software outsourcing-oriented intelligent coupling degree detection system and method for heterogeneous code repositories, which can effectively solve the above technical problems.
[0006] To solve the above technical problems, the technical solutions of the present application are as follows: A software outsourcing-oriented intelligent coupling degree detection method for heterogeneous code repositories, comprising the following steps: In response to a detection instruction initiated by a developer, drive intelligent detection to access a heterogeneous code repository to be detected, and obtain code file information, dependency relationship information, and development log information of the heterogeneous code repository to be detected; Perform coupling mode recognition on the code file information using semantic coupling analysis, obtain a recognition result, determine a coupling anti-pattern position based on the recognition result, and perform preliminary optimization on the coupling anti-pattern position based on a quantum heuristic coupling optimization algorithm; After preliminary optimization, perform dynamic coupling degree detection on the optimized code repository using digital twin simulation to obtain a first detection result, perform interface compatibility testing and call chain coupling testing on the heterogeneous code repository using a cross-language interface testing tool to obtain a second detection result, and enable the developer to perform in-depth optimization on the heterogeneous code repository based on the first detection result and the second detection result; wherein the cross-language interface testing tool maps interface information of different programming languages to a unified testing framework through a preset adaptation protocol, and the preset adaptation protocol is constructed based on a domain-specific language.
[0007] Preferably, the code file information, dependency relationship information, and development log information of the heterogeneous code repository to be detected are obtained as follows: Parse multi-language code files using a Fine-tune CodeLlama model through a distributed crawler module to traverse the version control protocol of the heterogeneous code repository to be detected, and extract code file information; Construct a dependency graph between code modules using an abstract syntax tree analysis tool to obtain dependency relationship information; Perform sentiment analysis and keyword extraction on commit information and issue records in the development log using natural language processing to obtain development log information.
[0008] Preferably, the coupling mode recognition on the code file information using semantic coupling analysis to obtain a recognition result, and determining a coupling anti-pattern position based on the recognition result are as follows: After receiving the code file information, modularize the code file information to obtain a plurality of code module units; Input the plurality of code module units into a large language model equipped with a LoRA adapter to detect a plurality of preset coupling anti-patterns and obtain a recognition result; Determine the position of the coupling anti-pattern with the highest priority based on the confidence level of each coupling anti-pattern in the recognition result.
[0009] Preferably, the quantum heuristic coupling optimization algorithm preliminarily optimizes the coupling anti-pattern positions, specifically: The code module corresponding to the coupling anti-pattern position is abstracted as a quantum bit system, and a coupling degree energy function is constructed: ; Wherein, is the coupling weight, is the quantum state representation of the code module; The global minimum value of the energy function is found by a quantum annealing algorithm, and the optimal solution corresponding to the code reconstruction path is obtained; Call GPT-4 to generate a coupling repair suggestion for the code reconstruction path, and automatically adjust the coupling anti-pattern position based on the repair suggestion.
[0010] Preferably, the optimized code repository is dynamically coupled by digital twin simulation to obtain a first detection result, specifically: Based on the static structure and runtime data of the code repository, a digital twin is constructed to simulate a multi-user concurrent access scenario; Through the probe node in the twin, the real-time call frequency, memory sharing rate and abnormal interaction times of the code module are collected; According to the preset coupling degree calculation formula, the dynamic coupling degree value is calculated, and it is judged whether the dynamic coupling degree value is lower than the preset threshold value to obtain the first detection result; wherein the preset coupling degree calculation formula is: coupling degree = , and .
[0011] Preferably, the interface compatibility test and call chain coupling test of the heterogeneous code repository are performed by using a cross-language interface test tool to obtain a second detection result, specifically: The cross-language interface test tool generates automated test cases for multi-language interfaces, and performs type matching detection on the input and output parameters of interfaces in different programming languages to determine whether the interface compatibility meets the preset standard to obtain a compatibility test result; The call chain tracking tool records the call path between code modules, analyzes the circular dependency and over-dependency nodes in the path, and calculates the call chain coupling coefficient; Compare the call chain coupling coefficient with the reference coefficient to determine whether it meets the preset coupling health condition to obtain a call chain coupling test result; The second detection result is obtained according to the compatibility test result and the call chain coupling test result.
[0012] Preferably, the calling chain coupling test of the heterogeneous code repository by the cross-language interface test tool to obtain the second detection result further comprises: Perform community discovery on the calling chain network by using a complex network analysis algorithm, and calculate the community cohesion and the inter-community coupling degree; Determine whether the community cohesion is higher than a preset cohesion threshold and the inter-community coupling degree is lower than a preset cross-community threshold, and obtain a modular coupling test result according to the determination result.
[0013] Preferably, a heterogeneous code repository intelligent coupling degree detection system for software outsourcing comprises: An information acquisition module is configured to, in response to a detection instruction initiated by any developer, drive an intelligent detection module to access a heterogeneous code repository to be detected, and acquire code file information, dependency relationship information, and development log information of the heterogeneous code repository to be detected; A semantic coupling analysis module is configured to call a semantic coupling analysis module based on a large language model to perform coupling mode recognition on the code file information, obtain a recognition result, and determine a coupling anti-pattern position according to the recognition result; A quantum optimization module is configured to perform preliminary optimization on the coupling anti-pattern position based on a quantum heuristic coupling optimization algorithm; A coupling degree detection module is configured to, after the preliminary optimization, perform dynamic coupling degree detection on the optimized code repository by using a digital twin simulation module to obtain a first detection result, perform interface compatibility test and calling chain coupling test on the heterogeneous code repository by using a cross-language interface test tool to obtain a second detection result, and enable the developer to perform deep optimization on the heterogeneous code repository according to the first detection result and the second detection result; wherein the cross-language interface test tool maps interface information of different programming languages to a unified test framework through a preset adaptation protocol.
[0014] Preferably, the information acquisition module comprises a code parsing unit, a dependency analysis unit, and a log processing unit, wherein: The code parsing unit is configured to traverse a version control protocol of the heterogeneous code repository to be detected by using a distributed crawler module, parse multilingual code files by using a Fine-tune CodeLlama model, and extract code file information; The dependency analysis unit is configured to construct a dependency graph between code modules by using an abstract syntax tree analysis tool, and acquire dependency relationship information; The log processing unit is configured to perform sentiment analysis and keyword extraction on commit information and issue records in the development log by using a natural language processing module, and obtain development log information.
[0015] Preferably, the semantic coupling analysis module further comprises a module segmentation unit and a pattern recognition unit, wherein: The module segmentation unit is configured to receive the code file information and perform modular segmentation on the code file information to obtain a plurality of code module units; The pattern recognition unit is configured to input the plurality of code module units into a large language model equipped with a LoRA adapter, detect a plurality of preset coupling anti-patterns, obtain a recognition result, and determine a coupling anti-pattern position according to the recognition result.
[0016] Compared with the prior art, the present application has the following advantages: the present application solves the problems of lack of unified semantic analysis framework for multi-language code, low efficiency of optimization algorithm, and lack of effective simulation tools for dynamic coupling degree detection in existing heterogeneous code repository coupling degree detection, and realizes efficient parsing and information extraction of multi-language code files by combining a distributed crawler module with a Fine-tune CodeLlama model, providing accurate code file information for analysis; at the same time, an abstract syntax tree analysis tool is used to construct a dependency graph, and natural language processing is used to extract key information from development logs, further enriching the data basis required for detection; secondly, in the semantic coupling analysis module, a large language model equipped with a LoRA adapter is used to segment and recognize coupling patterns of code modules, which not only accurately identifies a plurality of preset coupling anti-patterns, but also determines the position of the coupling anti-pattern with the highest priority through confidence sorting, thereby solving the problem of inaccurate multi-language code coupling pattern recognition; thirdly, based on the quantum heuristic coupling optimization algorithm, the code module corresponding to the coupling anti-pattern position is abstracted as a quantum bit system, the global optimal solution is found through a quantum annealing algorithm, and the optimization efficiency is improved by combining the repair suggestions generated by GPT-4 for automatic code adjustment, which can efficiently handle complex coupling structures; finally, the digital twin simulation technology is used to construct the digital twin of the code repository, simulate the multi-user concurrent access scenario, and collect key data in real time through the probe node to calculate the dynamic coupling degree value, thereby providing accurate evaluation of the coupling degree in the real running environment for developers, effectively making up for the shortcomings of the dynamic coupling degree detection tools in the prior art; in addition, the cross-language interface test tool maps the interface information of different programming languages to a unified test framework through a preset adaptation protocol, realizes comprehensive testing of interface compatibility and call chain coupling, and further ensures the stability and maintainability of the heterogeneous code repository. In summary, the present application provides efficient and accurate technical support for the management of heterogeneous code repositories in software outsourcing projects through a systematic detection and optimization process, improving the quality and efficiency of software development. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to make the technical solutions of the embodiments of the present application or the prior art clearer, the accompanying drawings needed in the description of the embodiments or the prior art will be briefly introduced. Obviously, the accompanying drawings in the following description are only exemplary and for those skilled in the field, other drawings can be obtained without creative work based on the provided drawings.
[0018] Figure 1 For the method steps of the present application; Figure 2 For the system structure diagram of the present application. DETAILED DESCRIPTION
[0019] The accompanying drawings are only used for exemplary description and cannot be understood as a limitation of the present patent; In order to better illustrate the embodiments, some components in the drawings may be omitted, enlarged or reduced, and do not represent the actual product size; For those skilled in the art, it is understandable that some well-known structures in the drawings and their descriptions may be omitted.
[0020] The technical solutions of the present application will be further described below in combination with the drawings and embodiments.
[0021] Embodiment 1 A heterogeneous code repository intelligent coupling degree detection method for software outsourcing, comprising the following steps: In response to the detection instruction initiated by the developer, the intelligent detection accesses the heterogeneous code repository to be detected, and obtains the code file information, dependency relationship information and development log information of the heterogeneous code repository to be detected; The code file information is coupled mode-identified by using semantic coupling analysis to obtain an identification result, the coupling anti-pattern position is determined according to the identification result, and the coupling anti-pattern position is preliminarily optimized based on a quantum heuristic coupling optimization algorithm; After preliminary optimization, dynamic coupling degree detection is performed on the optimized code repository by using digital twin simulation to obtain a first detection result, and interface compatibility testing and call chain coupling testing are performed on the heterogeneous code repository by using a cross-language interface testing tool to obtain a second detection result, so that the developer can perform deep optimization on the heterogeneous code repository according to the first detection result and the second detection result; wherein the cross-language interface testing tool maps the interface information of different programming languages to a unified testing framework through a preset adaptation protocol, and the preset adaptation protocol is constructed based on a domain-specific language.
[0022] The code file information, dependency relationship information and development log information of the heterogeneous code repository to be detected are obtained, specifically: The distributed crawler module traverses the version control protocol of the heterogeneous code repository to be detected, and the Fine-tuned CodeLlama model is used to parse multi-language code files and extract code file information. An abstract syntax tree analysis tool is used to construct a dependency graph between code modules and obtain dependency relationship information. The commit information and issue records in the development log are subjected to sentiment analysis and keyword extraction through natural language processing to obtain development log information.
[0023] The code file information is subjected to coupling mode recognition using semantic coupling analysis to obtain a recognition result, and the coupling anti-pattern position is determined according to the recognition result, specifically as follows: After receiving the code file information, the code file information is subjected to modular segmentation to obtain a plurality of code module units. The plurality of code module units are input into a large language model equipped with a LoRA adapter to detect a plurality of preset coupling anti-patterns and obtain a recognition result. According to the confidence level of each coupling anti-pattern in the recognition result, the coupling anti-pattern position with the highest priority is determined.
[0024] The coupling anti-pattern position is subjected to preliminary optimization based on a quantum heuristic coupling optimization algorithm, specifically as follows: The coupling anti-pattern position is abstracted as a quantum bit system, and a coupling degree energy function is constructed: ; wherein, is the coupling weight, is the quantum state representation of the code module; The global minimum value of the energy function is found through a quantum annealing algorithm to obtain an optimal solution corresponding to a code restructuring path. GPT-4 is called to generate a coupling repair suggestion based on the code restructuring path, and the coupling anti-pattern position is subjected to automatic code adjustment based on the repair suggestion.
[0025] The optimized code repository is subjected to dynamic coupling degree detection based on digital twin simulation to obtain a first detection result, specifically as follows: A digital twin is constructed based on the static structure and runtime data of the code repository to simulate a multi-user concurrent access scenario. The real-time call frequency, memory sharing rate, and abnormal interaction times of the code modules are collected through probe nodes in the digital twin. The dynamic coupling degree value is calculated according to a preset coupling degree calculation formula, and it is determined whether the dynamic coupling degree value is lower than a preset threshold to obtain a first detection result; wherein the preset coupling degree calculation formula is: coupling degree = , and .
[0026] The interface compatibility test and the call chain coupling test on the heterogeneous code repository by the cross-language interface test tool are specifically: The cross-language interface test tool generates an automated test case for the multi-language interface, performs type matching detection on the input and output parameters of the interfaces in different programming languages, judges whether the interface compatibility meets the preset standard, and obtains a compatibility test result; The call chain tracking tool records the call paths between code modules, analyzes the circular dependencies and excessive dependency nodes in the paths, and calculates the call chain coupling coefficient; The call chain coupling coefficient is compared with a reference coefficient to determine whether it meets a preset coupling health condition, and a call chain coupling test result is obtained; The second detection result is obtained according to the compatibility test result and the call chain coupling test result.
[0027] The call chain coupling test on the heterogeneous code repository by the cross-language interface test tool further includes: The complex network analysis algorithm is used to perform community discovery on the call chain network, calculate the community cohesion and the inter-community coupling degree; It is judged whether the community cohesion is higher than a preset cohesion threshold and the inter-community coupling degree is lower than a preset cross-community threshold, and a modular coupling test result is obtained according to the judgment result.
[0028] Please refer to Figure 1 In specific implementation, the developer initiates a detection instruction through a special detection tool interface. The tool can be a plug-in integrated in the development environment or a standalone software system.
[0029] After receiving the instruction, the detection tool connects to the heterogeneous code repository to be detected through a network. The code repository can be hosted on a local server or a cloud platform, and supports common version control systems such as Git, SVN, etc.
[0030] Start the distributed crawler module and traverse the directory structure of the code repository according to the version control protocol of the code repository, such as the HTTP / HTTPS protocol of Git.
[0031] Use the Fine-tune CodeLlama model to parse multi-language code files. The CodeLlama model is a large language model that has been fine-tuned for code understanding and analysis. It can recognize the syntax and semantics of multiple programming languages, such as Java, Python, C++, etc.
[0032] Extract code file information, including file name, code line number, function definition, class definition, etc., which will be stored in the intermediate database for coupling degree analysis.
[0033] Analyze the code file using an Abstract Syntax Tree (AST) analysis tool, which can parse the syntax structure of the code and generate a dependency graph between code modules.
[0034] The dependency graph represents the dependency relationship between code modules in the form of nodes and edges, where nodes represent code modules such as classes, functions, and modules, and edges represent the calling relationship or data dependency between modules.
[0035] By analyzing the dependency graph, we obtain dependency relationship information, including direct and indirect dependencies between modules, which is also stored in the intermediate database.
[0036] Process commit information and issue records in the development log through a Natural Language Processing (NLP) module.
[0037] Use sentiment analysis algorithms to analyze commit information to determine the emotional tendencies of developers when submitting code, such as positive, negative, or neutral, which helps understand the background of code modifications and potential problems.
[0038] Extract keywords related to code coupling degree from issue records, such as "coupling", "dependency", "conflict", etc., which will be used as reference for subsequent coupling degree analysis.
[0039] After receiving the code file information, modularize the code files, the purpose of which is to divide the code into multiple relatively independent code module units for more detailed coupling degree analysis.
[0040] Use predefined segmentation rules to divide the code files into multiple module units based on their structure and function, such as dividing a large Java project into multiple classes, interfaces, and packages.
[0041] Input the segmented code module units into a large language model equipped with a LoRA adapter, which is a lightweight adapter used to enhance the performance of the large language model on specific tasks.
[0042] The large language model learns the semantic information of the code and detects multiple preset coupling anti-patterns, which are forms of coupling in the code that do not conform to good design principles, such as circular dependencies and excessive coupling.
[0043] Based on the detection results, obtain the recognition results of the coupling anti-patterns, which include the type, location, and confidence of the coupling anti-patterns.
[0044] According to the confidence of each coupling anti-pattern in the identification result, the position of the coupling anti-pattern with the highest priority is determined.
[0045] The confidence is the reliability evaluation of the detection result by the model. The higher the confidence, the more reliable the detection result. The position of the coupling anti-pattern with the highest priority will be the focus of subsequent optimization.
[0046] The code module corresponding to the position of the coupling anti-pattern is abstracted as a quantum bit system. Quantum bits are the basic units of quantum computing, with superposition and entanglement states.
[0047] A coupling degree energy function is constructed to describe the coupling relationship between code modules. The form of the energy function is: ; Where, is the coupling weight, is the quantum state representation of the code module.
[0048] A quantum annealing algorithm is used to find the global minimum of the energy function. Quantum annealing is an optimization algorithm based on quantum tunneling effects, which can quickly find the optimal solution in complex problem spaces.
[0049] Through the quantum annealing algorithm, the optimal solution corresponding to the code refactoring path is obtained. The refactoring path refers to the specific steps for optimizing and adjusting the code, such as module splitting, dependency relationship adjustment, etc.
[0050] GPT-4 is called to generate a descriptive analysis of the code refactoring path, generating coupling repair suggestions. GPT-4 is a language generation model that can generate detailed repair suggestions based on the input refactoring path.
[0051] Based on the generated repair suggestions, automatic code adjustment is made to the coupling anti-pattern position. The adjustment process can be completed through the automation tools of the code editor, such as using the plugins of Eclipse or Visual Studio Code.
[0052] Based on the static structure and runtime data of the code repository, a digital twin is constructed. The digital twin is a virtual code repository model that can simulate the behavior of the code repository in actual operation.
[0053] Simulate a multi-user concurrent access scenario, and collect real-time call frequency, memory sharing rate, and abnormal interaction times of code modules through probe nodes in the twin.
[0054] According to the preset coupling degree calculation formula, the dynamic coupling degree value is calculated. The coupling degree calculation formula is: Coupling degree = a x call frequency + β x memory sharing rate + γ x abnormal interaction times Wherein, α + β + γ = 1, α, β and γ are preset weight coefficients for balancing the influence of different factors on the coupling degree.
[0055] Determine whether the dynamic coupling degree value is lower than the preset threshold value to obtain a first detection result. If the coupling degree value is lower than the threshold value, it indicates that the coupling degree of the code repository is low, and the optimization effect is good.
[0056] An automated test case for a multi-language interface is generated using a cross-language interface test tool. The test case includes type matching detection of interface input and output parameters for different programming languages.
[0057] Determine whether the interface compatibility meets the preset standard to obtain a compatibility test result. If the interface compatibility meets the standard, it indicates that the interface design in the code repository is reasonable and can support multi-language interaction.
[0058] Use a call chain tracking tool to record the call path between code modules and analyze the circular dependency and excessive dependency nodes in the path.
[0059] Calculate the call chain coupling coefficient, compare the call chain coupling coefficient with the reference coefficient, and determine whether it meets the preset coupling health condition to obtain a call chain coupling test result.
[0060] Obtain a second detection result according to the compatibility test result and the call chain coupling test result.
[0061] Use a complex network analysis algorithm to perform community discovery on the call chain network. The community discovery algorithm can identify the modular structure in the call chain network and divide the network into multiple communities.
[0062] Calculate the community cohesion and inter-community coupling degree. The community cohesion represents the tightness between modules within the community, and the inter-community coupling degree represents the coupling degree between different communities.
[0063] Determine whether the community cohesion is higher than the preset cohesion threshold and the inter-community coupling degree is lower than the preset cross-community threshold. Obtain a modular coupling test result according to the determination result. If the community cohesion is high and the inter-community coupling degree is low, it indicates that the modular design of the code repository is good and the coupling degree is low.
[0064] Through the above method, the developer can comprehensively detect and optimize the coupling degree of the heterogeneous code repository. This method combines semantic analysis, quantum optimization, digital twin simulation and cross-language interface testing and other technical means, which can effectively identify and solve the coupling problems in the code repository and improve the quality and maintainability of the software system.
[0065] Embodiment 2 The application discloses a software outsourcing-oriented intelligent coupling degree detection system for a heterogeneous code repository, and relates to the technical field of software outsourcing. An information acquisition module is configured to, in response to a detection instruction initiated by any developer, drive an intelligent detection module to access a heterogeneous code repository to be detected, and acquire code file information, dependency relationship information and development log information of the heterogeneous code repository to be detected. A semantic coupling analysis module is configured to call a semantic coupling analysis module based on a large language model to perform coupling mode recognition on the code file information, obtain a recognition result, and determine a coupling anti-pattern position according to the recognition result. A quantum optimization module is configured to perform preliminary optimization on the coupling anti-pattern position based on a quantum heuristic coupling optimization algorithm. A coupling degree detection module is configured to, after the preliminary optimization, perform dynamic coupling degree detection on the optimized code repository by using a digital twin simulation module, obtain a first detection result, perform interface compatibility testing and calling chain coupling testing on the heterogeneous code repository by using a cross-language interface testing tool, obtain a second detection result, and enable the developer to perform deep optimization on the heterogeneous code repository according to the first detection result and the second detection result. The cross-language interface testing tool maps interface information of different programming languages to a unified testing framework through a preset adaptation protocol.
[0066] The information acquisition module comprises a code parsing unit, a dependency analysis unit and a log processing unit. The code parsing unit is configured to traverse a version control protocol of a heterogeneous code repository to be detected by using a distributed crawler module, parse multilingual code files by using a Fine-tune CodeLlama model, and extract code file information. The dependency analysis unit is configured to construct a dependency graph between code modules by using an abstract syntax tree analysis tool, and acquire dependency relationship information. The log processing unit is configured to perform sentiment analysis and keyword extraction on commit information and issue records in development logs by using a natural language processing module, and obtain development log information.
[0067] The semantic coupling analysis module further comprises a module segmentation unit and a mode recognition unit. The module segmentation unit is configured to, after receiving the code file information, perform modular segmentation on the code file information, and obtain a plurality of code module units. The mode recognition unit is configured to input the plurality of code module units into a large language model equipped with a LoRA adapter, detect a plurality of preset coupling anti-patterns, obtain a recognition result, and determine a coupling anti-pattern position according to the recognition result.
[0068] Please refer to Figure 2The information acquisition module is used to acquire necessary information from the heterogeneous code repository to be detected, and the module includes the following units: The code parsing unit traverses the version control protocols of the heterogeneous code repository to be detected, such as Git, SVN, etc., through a distributed crawler module, and uses a Fine-tune CodeLlama model to parse multi-language code files and extract code file information.
[0069] Use a distributed crawler module, such as Scrapy or a custom crawler, to connect to the version control system of the code repository and obtain information such as the path, filename, and code content of the code file.
[0070] Input the obtained code file content into the Fine-tune CodeLlama model, which has been specially fine-tuned and can parse the code structure of multiple programming languages such as Java, Python, and C++, and extract key code information such as function names, class names, and variable names.
[0071] Store the parsed code information in a structured data format such as JSON or XML.
[0072] The dependency analysis unit constructs a dependency graph between code modules through an Abstract Syntax Tree (AST) analysis tool to obtain dependency relationship information.
[0073] Use an AST analysis tool such as Esprima, js2py, etc. to analyze the code file and generate an Abstract Syntax Tree for each code file.
[0074] Traverse the Abstract Syntax Tree to extract the dependency relationships between code modules, such as function calls, class inheritance, and module imports.
[0075] Store the dependency relationships in the form of a graph, with nodes representing code modules and edges representing the dependency relationships between modules.
[0076] The generated dependency graph can be used for coupling analysis.
[0077] The log processing unit performs sentiment analysis and keyword extraction on commit information and issue records in development logs through a natural language processing module to obtain development log information.
[0078] Use natural language processing tools such as NLTK, spaCy, etc. to preprocess commit information and issue records in development logs, including word segmentation and stop word removal.
[0079] Apply sentiment analysis algorithms such as BERT-based sentiment analysis models to perform sentiment analysis on commit information and issue records to determine the emotional tendencies of developers, such as positive, negative, and neutral.
[0080] Extract key information such as problem description, solution, etc. from the log using keyword extraction algorithms like TF-IDF, TextRank, etc.
[0081] Integrate sentiment analysis results and keyword extraction results into development log information and store them in a structured data format.
[0082] The semantic coupling analysis module identifies coupling patterns in code file information based on large language models and determines the location of coupling anti-patterns. This module includes the following units: The module segmentation unit modularizes the code file information to obtain multiple code module units.
[0083] Input the code file information obtained from the information acquisition module into the module segmentation unit.
[0084] Use code segmentation algorithms such as code structure-based segmentation algorithms to divide the code file into multiple logical modules, such as functions, classes, modules, etc.
[0085] Store the segmented code module units as independent code snippets for pattern recognition.
[0086] The pattern recognition unit inputs the code module units into a large language model equipped with a LoRA adapter to detect multiple preset coupling anti-patterns and obtain recognition results to determine the location of coupling anti-patterns.
[0087] Input the code module units into a large language model equipped with a LoRA adapter, such as OpenAI's GPT or its variants, which is used to improve the model's ability to recognize specific coupling patterns.
[0088] Preset multiple coupling anti-patterns such as over-coupling, circular dependency, tight coupling, etc. The model learns the characteristics of these patterns and analyzes the input code module units.
[0089] The model outputs recognition results, including whether there is a coupling anti-pattern and the specific location of the coupling anti-pattern, such as file name, line number, etc.
[0090] Store the recognition results in a structured data format for use by subsequent modules.
[0091] The quantum optimization module uses quantum heuristic coupling optimization algorithms to preliminarily optimize the coupling anti-pattern location and reduce the coupling degree.
[0092] Input the coupling anti-pattern location obtained from the semantic coupling analysis module into the quantum optimization module.
[0093] The quantum heuristic algorithm, such as quantum genetic algorithm, quantum simulated annealing algorithm, etc. is used to optimize the coupling anti-pattern. The quantum algorithm simulates the evolution of quantum state to find the optimal code structure adjustment scheme. During the optimization process, factors such as maintainability, scalability and performance of the code are considered. The optimized code structure adjustment suggestion is stored in a structured data format for subsequent module use.
[0094] The optimized code repository is dynamically coupled and interface compatibility tested by the coupling degree detection module.
[0095] The optimized code repository is dynamically coupled and interface compatibility tested by the coupling degree detection module.
[0096] The optimized code repository is simulated by using digital twin simulation module, such as Simulink or custom simulation tool.
[0097] During the simulation process, the interaction between code modules is dynamically monitored, and coupling degree indicators such as inter-module call frequency and data sharing degree are calculated.
[0098] The first detection result is generated according to the coupling degree index, including coupling degree score, coupling module list, etc.
[0099] The first detection result is stored in a structured data format.
[0100] The interface compatibility test and call chain coupling test of the heterogeneous code repository are performed by using cross-language interface test tool, and the second detection result is obtained. Cross-language interface test tools such as Postman, SoapUI, etc. are used to map interface information of different programming languages to a unified test framework through a preset adaptation protocol.
[0101] The interface compatibility test of the heterogeneous code repository is performed, and the input and output of the interface are checked to see if they meet the expected requirements and whether there are compatibility problems.
[0102] The coupling test of the call chain is performed, and the complexity and coupling of the call chain are analyzed.
[0103] The second detection result is generated according to the test result, including interface compatibility score, call chain coupling score, etc.
[0104] The second detection result is stored in a structured data format.
[0105] The system integrates the first detection result and the second detection result and outputs them to the developer. The developer can optimize the heterogeneous code repository based on these results.
[0106] The output content includes: The first detection result: dynamic coupling degree score, coupling module list, etc.
[0107] The second detection result: interface compatibility score, call chain coupling score, etc.
[0108] Optimization suggestions: code optimization suggestions generated according to the detection results, including structure adjustment suggestions, interface improvement suggestions, etc.
[0109] The embodiment faces each module of the intelligent coupling degree detection system of the heterogeneous code repository of software outsourcing and the specific implementation method thereof, basic information of the code repository is acquired through the information acquisition module, the semantic coupling analysis module identifies the coupling anti-pattern, the quantum optimization module performs preliminary optimization, the coupling degree detection module performs dynamic detection and interface testing, and finally detailed detection results and optimization suggestions are provided for the developers. The whole system comprehensively considers the characteristics of the heterogeneous code repository, can effectively detect and optimize the code coupling degree, and improves the quality and maintainability of the software.
[0110] The same or similar reference signs correspond to the same or similar components; The terms describing the positional relationship in the drawings are only used for illustrative description, and cannot be understood as a limitation on the patent; Obviously, the above embodiments of the present application are only examples for clearly illustrating the present application, and are not a limitation on the embodiments of the present application. For ordinary skilled in the art, on the basis of the above description, other different forms of changes or variations can be made, here, all the embodiments do not need to be exhausted, and it is impossible to exhaust all the embodiments. Any modification, equivalent replacement and improvement made within the spirit and principle of the present application should be included in the protection scope of the claims of the present application.
Claims
1. A method for intelligent coupling degree detection of heterogeneous code repositories for software outsourcing, characterized by: The following steps are involved: In response to a detection instruction initiated by a developer, drive intelligent detection to access the heterogeneous code repository to be detected, and obtain code file information, dependency information, and development log information of the heterogeneous code repository to be detected; Performing coupling pattern recognition on the code file information using semantic coupling analysis to obtain recognition results, determining coupling anti-pattern locations based on the recognition results, and preliminarily optimizing the coupling anti-pattern locations based on a quantum-inspired coupling optimization algorithm; After the preliminary optimization is completed, the optimized code repository is dynamically coupled using digital twin simulation to obtain a first detection result, and the heterogeneous code repository is subjected to interface compatibility testing and call chain coupling testing using a cross-language interface testing tool to obtain a second detection result, so that the developer can deeply optimize the heterogeneous code repository based on the first and second detection results; wherein, the cross-language interface testing tool maps the interface information of different programming languages to a unified testing framework through a preset adaptation protocol, and the preset adaptation protocol is constructed based on a domain-specific language.
2. The detection method according to claim 1, wherein The obtaining of code file information, dependency information, and development log information of the heterogeneous code repository to be detected is specifically as follows: The distributed crawler module traverses the version control protocol of the heterogeneous code repository to be detected, and uses Fine-tune's CodeLlama model to parse multi-language code files and extract code file information; Use the abstract syntax tree analysis tool to build a dependency graph between code modules and obtain dependency information; Through natural language processing, sentiment analysis and keyword extraction are performed on the commit information and issue records in the development log to obtain the development log information.
3. The detection method according to claim 1, wherein The coupling pattern recognition is performed on the code file information by using semantic coupling analysis to obtain a recognition result, and the coupling anti-pattern location is determined according to the recognition result as follows: After receiving the code file information, modularly segmenting the code file information to obtain a plurality of code module units; Inputting the plurality of code module units into a large language model equipped with a LoRA adapter, detecting a plurality of preset coupling anti-patterns, and obtaining recognition results; According to the confidence ranking of each coupling anti-pattern in the identification result, the coupling anti-pattern position with the highest priority is determined.
4. The detection method according to claim 1, wherein The preliminary optimization of the coupling anti-mode position based on the quantum heuristic coupling optimization algorithm is specifically as follows: The code module corresponding to the coupling anti-mode position is abstracted into a quantum bit system, and the coupling energy function is constructed: ; in, is the coupling weight, is the quantum state representation of the code module; The global minimum of the energy function is found through the quantum annealing algorithm, and the code reconstruction path corresponding to the optimal solution is obtained; GPT-4 is called to generatively analyze the code refactoring path to generate coupling repair suggestions, and automatic code adjustments are performed on the coupling anti-pattern locations based on the repair suggestions.
5. The detection method according to claim 1, wherein The dynamic coupling degree test of the optimized code repository using digital twin simulation is performed, and the first test result obtained is specifically: Build a digital twin based on the static structure and runtime data of the code repository to simulate multi-user concurrent access scenarios; The real-time call frequency, memory sharing rate, and number of abnormal interactions of the code module are collected through the probe nodes in the twin; The dynamic coupling value is calculated according to the preset coupling calculation formula, and it is determined whether the dynamic coupling value is lower than the preset threshold value to obtain the first detection result; wherein, the preset coupling calculation formula is: coupling = ,and .
6. The detection method according to claim 1, characterized in that The cross-language interface testing tool is used to perform interface compatibility testing and call chain coupling testing on the heterogeneous code repository, and the second test result obtained is specifically: Generate automated test cases for multi-language interfaces through cross-language interface testing tools, perform type matching tests on interface input and output parameters in different programming languages, determine whether the interface compatibility meets the preset standards, and obtain compatibility test results; Use call chain tracing tools to record the call paths between code modules, analyze the circular dependencies and over-dependency nodes in the paths, and calculate the call chain coupling coefficient; Comparing the call chain coupling coefficient with a reference coefficient to determine whether it meets a preset coupling health condition, and obtaining a call chain coupling test result; A second detection result is obtained according to the compatibility test result and the call chain coupling test result.
7. The detection method according to claim 6, characterized in that The performing of a call chain coupling test on the heterogeneous code repository using a cross-language interface testing tool to obtain a second test result further includes: Use complex network analysis algorithms to discover communities in call chain networks and calculate community cohesion and inter-community coupling. It is determined whether the community cohesion is higher than a preset cohesion threshold and whether the inter-community coupling is lower than a preset cross-community threshold, and a modular coupling test result is obtained according to the determination result.
8. An intelligent coupling degree detection system for heterogeneous code repositories for software outsourcing, implemented by the detection method according to any one of claims 1 to 7, characterized in that: include: An information acquisition module is configured to respond to a detection instruction initiated by any developer and drive the intelligent detection module to access the heterogeneous code repository to be detected, and obtain code file information, dependency information, and development log information of the heterogeneous code repository to be detected; a semantic coupling analysis module, configured to call a semantic coupling analysis module based on a large language model to perform coupling pattern recognition on the code file information, obtain recognition results, and determine a coupling anti-pattern location based on the recognition results; A quantum optimization module, configured to perform preliminary optimization on the coupling anti-mode position based on a quantum-inspired coupling optimization algorithm; The coupling degree detection module is used to perform dynamic coupling degree detection on the optimized code repository using the digital twin simulation module after the preliminary optimization is completed to obtain a first detection result, and to perform interface compatibility testing and call chain coupling testing on the heterogeneous code repository using a cross-language interface testing tool to obtain a second detection result, so that the developer can deeply optimize the heterogeneous code repository based on the first and second detection results; wherein, the cross-language interface testing tool maps the interface information of different programming languages to a unified testing framework through a preset adaptation protocol.
9. The detection system according to claim 8, characterized in that: The information acquisition module includes a code parsing unit, a dependency analysis unit, and a log processing unit, wherein: The code parsing unit is used to traverse the version control protocol of the heterogeneous code repository to be detected through a distributed crawler module, parse multi-language code files using Fine-tune's CodeLlama model, and extract code file information; The dependency analysis unit is used to construct a dependency graph between code modules through an abstract syntax tree analysis tool to obtain dependency relationship information; The log processing unit is used to perform sentiment analysis and keyword extraction on the commit information and issue records in the development log through the natural language processing module to obtain development log information.
10. The detection system according to claim 8, characterized in that: The semantic coupling analysis module further includes a module segmentation unit and a pattern recognition unit, wherein: The module segmentation unit is configured to, after receiving the code file information, perform modular segmentation on the code file information to obtain a plurality of code module units; The pattern recognition unit is used to input the multiple code module units into a large language model equipped with a LoRA adapter, detect multiple preset coupling anti-patterns, obtain recognition results, and determine the coupling anti-pattern location according to the recognition results.
Citation Information
Cited By
Business-oriented post quantum cryptography migration risk determination method and device, equipment and medium
CN122119888A