AI code review method, system and equipment based on browser extension
Through browser extensions, a local terminology library and review rule library are established, developer operation trajectories are captured in real time, review rule nodes are dynamically activated, the neural symbolic joint reasoning engine is called for static rule review, and the browser Canvas API is used for visual display. This solves the problems of limited deployment permissions and inconvenient interactions of existing tools, and improves the efficiency and accuracy of code review.
Patent Information
- Application Number
- CN202510920433.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-04
- Publication Date
- 2025-10-17
AI Technical Summary
Existing AI code review tools have limited deployment permissions on GitLab, lack flexible customization capabilities, and have inconvenient interaction methods, which affects the efficiency and quality of code review.
Through browser extensions, a local terminology library and review rule library are established to form a domain knowledge graph, the developer's operation trajectory is captured in real time, the review rule nodes are dynamically activated, the neural symbolic joint reasoning engine is called for static rule review, and the browser Canvas API is used for visual display, and computing resources are dynamically allocated to optimize system performance.
It enables the use of AI code review without administrator privileges, provides personalized code review services, improves review efficiency and accuracy, and optimizes user experience.
Smart Images

Figure CN120803458A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an AI code review method, system and device based on browser extension. BACKGROUND
[0002] In today's software development field, the rise of large language model technology has brought new changes to code development, and its application in the field of code development is increasingly widespread. Gitlab, as a mainstream open source code hosting platform, plays an important role in the software development process, and many development teams rely on it for code management, collaborative development and project advancement.
[0003] As the project size continues to expand and the complexity continues to increase, developers face many challenges when handling Merge Request (MR). Code review, merging and feedback, etc. become increasingly cumbersome, not only consuming a lot of time, but also due to the limitations of manual operation, it is easy to miss and make mistakes, thereby affecting code quality and project progress.
[0004] In order to solve these problems, many AI code review tools integrated with Gitlab have emerged in the market, which provide code review and feedback capabilities to some extent. However, the existing integration solutions still have significant problems.
[0005] Firstly, when the existing AI code review tools are integrated with Gitlab, they usually need to obtain Gitlab administrator permission to be deployed on the server of Gitlab. This requirement greatly limits the scope of use of the tools, and for many development teams, it is not easy to obtain administrator permission, which prevents a large number of teams with code review needs from conveniently using these tools, hindering the application of AI code review technology in a wider range of scenarios.
[0006] Secondly, the large model used by the integrated AI code review tool is usually fixed and cannot be customized according to the characteristics and needs of different projects. For example, different projects may have different requirements for code review language, specifications and scope, but existing tools cannot adapt to these differences, resulting in review results that may not fully meet the actual needs of the project, reducing the effectiveness and relevance of code review.
[0007] Finally, the existing tools lack convenient interaction methods in the code review process, and cannot provide a good user experience for developers. When using these tools, developers often need to spend additional time and effort to adapt to the tool's operation process, and when obtaining review results and providing feedback, the operation is not intuitive and efficient, affecting the efficiency and quality of code review. SUMMARY
[0008] The present application aims to provide an AI code review method, system and device based on browser extension, which can not only solve the problems of limited deployment authority and lack of flexible customization capability of existing tools, but also improve user experience by optimizing the interaction mode, and provide developers with more efficient and convenient code review solutions, so as to solve at least one of the above technical problems.
[0009] In a first aspect, the present application provides an AI code review method based on browser extension, which specifically comprises: A local terminology library and a review rule library are established through browser extension, project-specific terminology and coding specifications are persistently stored, and a domain knowledge graph is formed; When it is detected that a Gitlab MR page is loaded, the cursor trajectory and the window focus area of the developer are captured in real time, and an operation heat distribution map is generated; Based on the operation heat distribution map, the review rule nodes associated with the code blocks in the domain knowledge graph are dynamically activated, and a rule node priority sequence is obtained; According to the rule node priority sequence, the neural symbol joint reasoning engine is called to perform static rule review on the high-heat area, and the neural network model is called to perform semantic defect detection on the associated function chain, and the review result is obtained; The review result is converted into multi-layer superimposed rendering through browser Canvas API, and a visual analysis layer is formed; Through the browser resource manager, the computing resources are dynamically allocated, when it is detected that the system load exceeds the preset load threshold, the Canvas rendering of the non-focus area is suspended, and the background model memory is automatically released according to the tab active state.
[0010] In a second aspect, the present application provides an AI code review system based on browser extension, which specifically comprises: The first review module is used to establish a local terminology library and a review rule library through browser extension, persistently store project-specific terminology and coding specifications, and form a domain knowledge graph; The second review module is used to capture the cursor trajectory and the window focus area of the developer in real time when it is detected that a Gitlab MR page is loaded, and generate an operation heat distribution map; The third review module is used to dynamically activate the review rule nodes associated with the code blocks in the domain knowledge graph based on the operation heat distribution map, and obtain a rule node priority sequence; The fourth review module is used to call the neural symbol joint reasoning engine to perform static rule review on the high-heat area according to the rule node priority sequence, and call the neural network model to perform semantic defect detection on the associated function chain, and obtain the review result; The fifth review module is configured to convert the review result into multi-layer superimposed rendering through a browser Canvas API to form a visual analysis layer. The sixth review module is configured to dynamically allocate computing resources through a browser resource manager, suspend Canvas rendering of a non-focus area when detecting that system load exceeds a preset load threshold, and automatically release background model memory according to a tab page active state.
[0011] In a third aspect, the present application provides a computer device, comprising a memory and a processor, and a computer program stored in the memory, when the computer program is executed on the processor, the browser extension-based AI code review method according to any one of the above methods is implemented.
[0012] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, when the computer program is executed on a processor, the browser extension-based AI code review method according to any one of the above methods is implemented.
[0013] Compared with the prior art, the present application has at least one of the following technical effects: 1. The present application not only solves the problems of limited deployment permissions and lack of flexible customization capabilities of existing tools, but also optimizes the interaction mode to improve user experience and provide developers with a more efficient and convenient code review solution.
[0014] 2. The present application identifies high heat value areas according to the operation heat distribution map, dynamically activates the review rule node of the associated code block, and generates a rule node priority sequence, thereby realizing intelligent matching and dynamic adjustment of the review rules.
[0015] 3. Based on the rule node priority sequence, the present application selectively loads high-priority symbol rules for static rule review, and uses a neural network model to detect semantic defects of the associated function chain to generate a hierarchical review report, thereby improving the review efficiency and accuracy.
[0016] 4. The present application uses the browser Canvas API to display the review result in the form of multi-layer superimposed rendering to form a visual analysis layer, which is convenient for developers to intuitively understand the code review result.
[0017] 5. The present application calls the browser performance interface to obtain system load data in real time, identifies high-priority code blocks according to the operation heat distribution map and window position information, and dynamically allocates computing resources, thereby optimizing the system performance and ensuring the smoothness of the review process.
[0018] 6、The application records historical interaction data by listening to the interaction operation of the developer on the review suggestion, extracts a normalized state feature matrix, updates the suggestion weight value of the review suggestion using a Q-learning model, generates a review report with a one-key submission interface, and injects a Gitlab comment system through a browser extension agent, thereby realizing intelligent sorting and efficient submission of the review suggestion. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.
[0020] Figure 1 is a flow diagram of an AI code review method based on browser extension provided by an embodiment of the present application; Figure 2 is a structural diagram of an AI code review system based on browser extension provided by an embodiment of the present application; Figure 3 is a structural diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0021] In the following description, specific details such as specific system structures, techniques, etc. are presented in order to thoroughly understand the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits and methods are omitted to avoid unnecessary details that hinder the description of the present application.
[0022] It should be understood that when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of the described features, whole, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, whole, steps, operations, elements, components and / or sets thereof.
[0023] It should also be understood that the term "and / or" used in the specification and the appended claims of the present application means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0024] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0025] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0026] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0027] In the embodiments of the present application, the execution subject of the process includes a terminal device, which includes but is not limited to: a server, a computer, a smart phone, a tablet computer, and other devices capable of executing the method disclosed in the present application. Figure 1 A flowchart of an AI code review method based on browser extension disclosed in an embodiment of the present invention is shown, and is described in detail as follows: S101, establish a local terminology library and review rule library through browser extension, persistently store project-specific terminology and coding standards, and form a domain knowledge graph.
[0028] In this example, the browser extension is first set up. When a developer opens a GitLab project page for the first time, the browser extension automatically pops up an initial setup window. In this window, the developer enters basic information such as the project name and description so that the extension can identify the current project. The extension also prompts the developer whether to import an existing termbase and review rulebase (if any) or create one from scratch.
[0029] Developers can manually add project-specific terms in the extended term management interface provided. Browser extensions can analyze code files, document files (such as README, design documents, etc.) in the project, and automatically extract professional terms frequently appearing in them. To facilitate management and use, developers can classify the terms added to the term library. Browser extensions use the local storage function of the browser (such as localStorage or IndexedDB) to persistently store the term library locally. In this way, even if the browser is closed or the device is restarted, the information in the term library will not be lost. At the same time, to prevent data loss, the extension can also provide data backup and recovery functions, and developers can backup the term library data to local files or cloud storage.
[0030] Developers can define syntax rules according to the coding specifications of the project. For example, specify the indentation method in the code, naming specifications (such as naming rules for variable names, function names, etc.). When defining syntax rules, natural language can be used to describe the content of the rules, and the extension can provide some example code to help developers better understand the requirements of the rules. For the business logic of the project, developers can define logic rules and associate the defined review rules with specific code elements (such as functions, classes, modules, etc.) in the project. Different review rules may have different importance, and developers can set priorities for each review rule to facilitate review in order of priority during code review. Similar to the term library, the browser extension uses the local storage function of the browser to persistently store the review rule library locally. At the same time, provide backup and recovery functions to ensure the safety and maintainability of rule data.
[0031] The browser extension associates information in the local term library and review rule library to form a domain knowledge graph. For example, associate terms with related review rules, and associate code elements with applicable review rules. Through this association, the extension can quickly obtain term and rule information related to the code during code review. As the project continues to develop and change, project-specific terms and coding specifications may change. The browser extension provides knowledge updating and maintenance functions, and developers can modify, add, and delete operations to the term library and review rule library at any time. The extension will automatically update the domain knowledge graph to ensure that it is consistent with the actual situation of the project.
[0032] In this embodiment, the local term library and review rule library established based on the browser extension can persistently store project-specific terms and coding specifications and form a domain knowledge graph. In subsequent code review processes, the browser extension can provide knowledge support based on the domain knowledge graph to conduct more accurate and targeted reviews of the code, improving the efficiency and quality of code review, while reducing the workload and error rate of manual review.
[0033] S102, when detecting the Gitlab MR page loading, real-time capture developer cursor trajectory and window focus area, generate operation heat distribution map.
[0034] In this embodiment, the browser extension uses the extension API provided by the browser (such as chrome.webNavigation or similar page navigation listening API) to listen to the loading event of the Gitlab MR (Merge Request) page. When the developer opens the Gitlab MR page, the extension can timely perceive the completion of the page loading. Once the MR page loading is detected, the extension will immediately inject a custom script (through the content script) into the page context, which is responsible for subsequent operation capture and data processing work.
[0035] The injected script will be initialized after the page is loaded. It will create a temporary data structure, such as an object array, to store cursor trajectory and window focus area data, to record the timestamp, position information, etc. of each cursor movement and window focus change. At the same time, the script will set some initial parameters, such as the resolution of the heat map (used to determine the accuracy of each small area in the heat map), the time interval of data collection (used to control the frequency of capture operations), etc.
[0036] The injected script captures the developer's cursor trajectory by listening to the mouse move event (such as the mousemove event) of the page. Every time the developer's mouse moves on the page, the event handling function will be triggered. In the event handling function, the script will get the current cursor position information in the page, usually through the clientX and clientY attributes of the event object to get the cursor coordinates relative to the browser window, and then combine the page scroll position (get through window.scrollX and window.scrollY) to calculate the absolute position of the cursor in the page document. After capturing the cursor position information each time, the script will record the information (including timestamp, absolute coordinates of the cursor in the page) to the temporary data structure created earlier. In order to avoid too much data, the script can set a data storage limit, when the data volume reaches the limit, delete the earliest recorded data according to the first-in first-out principle, to ensure the real-time and effectiveness of the data.
[0037] The script captures the developer's focus area by listening to the focus change events (such as focus and blur events) of the page. When the developer switches focus to an element in the page (such as a code input box, comment area, etc.), the focus event is triggered; when the focus leaves the element, the blur event is triggered. In the focus event handling function, the script records the element information of the current focus, including the type of the element (such as <input> 、 <textarea>The element's position and size in the page (obtained via the element's getBoundingClientRect() method) and the timestamp of the focus gain.< / textarea>
[0038] The script maintains a record of the current focus area, and updates it every time a focus change event occurs. If the new focus area overlaps with the previous focus area, it can be merged into a larger focus area; if there is no overlap, the new focus area is added to the record.
[0039] At certain time intervals (for example, every minute) or when the developer actively triggers (such as clicking a "generate heat map" button), the script aggregates and statistics the captured cursor trajectory and window focus area data. For cursor trajectory data, the script divides the page into multiple small areas (according to the previously set heat map resolution), and counts the number of times the cursor stays in each small area and the total time of staying. For the window focus area data, the script maps it to the corresponding small area according to the position and size of the focus area, and increases the focus weight of the small area.
[0040] The script uses the Canvas API of the browser to draw the operation heat distribution map. First, create a Canvas element (if there is none in the page), and set its size to match the content area of the page. Then, according to the aggregated and statistical data, set different color values for each small area. The color value can be determined according to the number of times the cursor stays, the time of staying or the focus weight, etc., for example, the more times the cursor stays, the longer the time of staying or the greater the focus weight of the small area, the deeper the color (such as the deeper red), and vice versa, the lighter the color (such as the lighter blue). Finally, use the drawing methods (such as fillStyle and fillRect) of Canvas to draw each small area according to the corresponding color value, forming a complete operation heat distribution map. The heat distribution map can intuitively show the developer's focus in the code review process, providing valuable reference for subsequent code review work, helping to improve the efficiency and quality of code review.
[0041] S103, based on the operation heat distribution map, dynamically activate the review rule node associated with the code block in the domain knowledge graph, and obtain the priority sequence of the rule node.
[0042] In this embodiment, each code block is uniquely identified in the Gitlab MR page. A unique identifier can be assigned to each function, class, module, etc. code element by parsing the syntax structure of the code file. For example, for a function, the function name can be used in combination with its file path and line number to generate an identifier; for a class, the class name can be used in combination with the file path to identify.
[0043] When generating the operation heat distribution map, each small area is associated with the corresponding code block identifier. When the developer operates on the page, the small area where the operation is located is determined according to the cursor trajectory and window focus area data, and the corresponding code block identifier is obtained.
[0044] In the domain knowledge graph, an association relationship between each review rule node and the code block is established. For example, for a review rule node for a specific function naming specification, it is associated with all function code blocks that may involve the naming specification. This association relationship can be realized by adding attributes or relationship edges in the knowledge graph, clearly indicating which code blocks each review rule node is applicable to.
[0045] When the code block identifier corresponding to a small area in the operation heat distribution map is obtained, all review rule nodes associated with the code block are found by querying the domain knowledge graph.
[0046] According to the operation heat distribution map, the heat value of each code block is calculated. The heat value can consider factors such as the number of cursor stays, stay time, and the weight of the window focus area. For example, for a small area, the more times the cursor stays, the longer the stay time, or the more times the area is in the window focus area, the higher the heat value of the corresponding code block.
[0047] The heat value of the code block is mapped to the review rule node associated with it as an important evaluation indicator of the rule node priority. The higher the heat value of the code block, the higher the priority of the review rule node associated with it.
[0048] In the domain knowledge graph, an importance indicator is predefined for each review rule node. The importance indicator can be set according to the influence of the rule on code quality, security, performance, etc. For example, rules related to code security vulnerability detection have high importance, while some rules that only affect code readability have relatively low importance.
[0049] This importance indicator serves as another evaluation indicator of the rule node priority, and together with the heat indicator, it affects the final priority of the rule node.
[0050] Set project characteristic indicators for each review rule node considering the specific requirements and characteristics of the project. Project characteristic indicators can be set based on project documents, requirement specifications, etc., and are associated with review rule nodes in the domain knowledge graph.
[0051] Assign weights to the heat index, rule importance index, and project characteristic index. The weights can be adjusted according to the actual situation of the project and the focus of the review. For example, if the project pays more attention to the focus of the developers, the weight of the heat index can be set higher; if the project has strict requirements on code quality and security, the weight of the rule importance index can be increased accordingly. Weight allocation can be set in the configuration file of the browser extension, or a user interface can be provided for developers to customize according to project requirements.
[0052] For each review rule node associated with a code block, calculate the priority score based on its corresponding heat index value, rule importance index value, and project characteristic index value, and the pre-assigned weights. For example, a weighted average method can be used for calculation, i.e. rule node priority score = heat index value x heat index weight + rule importance index value x rule importance index weight + project characteristic index value x project characteristic index weight.
[0053] Sort all associated review rule nodes according to the priority score to obtain the rule node priority sequence. The higher the priority score of a rule node, the higher its position in the sequence, meaning it will be activated and executed first in the subsequent code review process.
[0054] In this embodiment, based on the operation heat distribution map, the review rule nodes associated with the code block in the domain knowledge graph can be dynamically activated, and a reasonable rule node priority sequence can be obtained. This makes the code review more accurate for the code parts that developers pay attention to, improves the efficiency and quality of the review, and ensures that the review rules can be flexibly adjusted according to the actual requirements of the project and the operation behavior of the developers.
[0055] S104, according to the rule node priority sequence, call the neural symbol joint reasoning engine to perform static rule review on the high heat area, and simultaneously call the neural network model to detect semantic defects on the associated function chain, to obtain the review result.
[0056] In this embodiment, a heat threshold is set based on the previously generated operation heat distribution map. Regions with heat values higher than the threshold are identified as high-heat regions. Based on the location information of the high-heat regions in the operation heat distribution map, combined with the code block identifiers, the corresponding code blocks of these high-heat regions are determined. The browser extension obtains the complete code content of the code blocks corresponding to the high-heat regions through interaction with the Gitlab MR page. The target code can be located by parsing the DOM structure of the page and extracting the text content of the element containing the target code.
[0057] According to the rule node priority sequence, the review rule nodes associated with the high-heat regions are filtered out from the domain knowledge graph. The priority sequence is arranged in descending order, and the rule nodes with high priority are processed first.
[0058] The review rules corresponding to the filtered rule nodes are configured for the neural-symbol joint reasoning engine. These rules can be obtained from the domain knowledge graph and converted into a format that the neural-symbol joint reasoning engine can understand. For example, the rules include code indentation specifications, variable naming rules, function call logic rules, etc. At the same time, the extracted high-heat region code is passed as input to the neural-symbol joint reasoning engine. The engine will parse the code and perform static rule review according to the configured rules. During the review process, the engine will check whether the code complies with various rules, such as whether it follows a specific coding style, whether there are logical errors, etc.
[0059] After completing the static rule review, the neural-symbol joint reasoning engine generates a review result. The review result includes information such as the location of the code that does not comply with the rules, the specific rule content that is violated, and the recommended modification method. The browser extension records these review results for subsequent integration and display.
[0060] The high-heat region code is subjected to semantic analysis to identify the function call relationships involved, and an associated function chain is constructed. The calling order and dependency relationship between functions can be determined by analyzing the function call statements in the code.
[0061] The browser extension takes each function code in the associated function chain as input and calls a pre-trained neural network model for semantic defect detection. The neural network model has been trained on a large number of code samples and can understand the semantic information of the code to identify potential semantic defects, such as function functionality not matching expectations, parameter passing errors, etc.
[0062] When calling the neural network model, the extension will preprocess the function code according to the input requirements of the model, such as removing comments and unifying code format, to ensure that the model can accurately understand the code semantics.
[0063] After the neural network model completes semantic defect detection, it outputs the detection results. The detection results include the detected semantic defect location, defect type, and possible repair suggestions, and other information. The browser extension records these semantic defect detection results and distinguishes them from static rule review results.
[0064] The browser extension integrates static rule review results and semantic defect detection results. According to the order of code blocks and function chains, different types of review results are associated to form a complete review result set. For example, for a function in a high-heat area, both code format problems found in static rule review and logical errors found in semantic defect detection are integrated together to facilitate developers to view.
[0065] In this embodiment, according to the rule node priority sequence, the high-heat area is called to the neural symbol joint reasoning engine to perform static rule review, and the associated function chain is called to the neural network model to perform semantic defect detection, which can comprehensively and deeply review the code and find various problems in the code. At the same time, after integrating and processing the review results, the developer is presented with clear and accurate review feedback, which helps to improve the efficiency and quality of code review and ensures the quality of the code and the smooth progress of the project.
[0066] S105, the review results are converted into multi-layer superimposed rendering through the browser Canvas API to form a visual analysis layer.
[0067] In this embodiment, after the browser extension completes code review, it collects various types of review results, such as code format errors and logical errors in static rule review, and semantic mismatching in semantic defect detection. These review results are sorted, and key information is extracted, including problem type, problem location (code file path, line number, etc.), problem description, and suggested repair method.
[0068] According to the nature and severity of the review results, they are classified. For example, the problem type is divided into three categories: serious error, warning, and suggestion; according to the severity from high to low, the serious error may affect the normal operation of the code, the warning may have potential risks, and the suggestion is a prompt for code optimization. At the same time, according to the problem location, the review results are associated with the code blocks in the Gitlab MR page to accurately mark the problem location in the visual analysis layer.
[0069] In the Gitlab MR page, a Canvas element is dynamically created by the browser extension and inserted into the appropriate location of the page, such as below or on the side of the code editing area. The size of the Canvas is set so that it can cover the area where the review results need to be displayed.
[0070] With the multi-layer overlay feature of Canvas, different layers are planned for displaying different types of review results. For example, a basic layer is set to display the original content of the code, an error layer is used to highlight serious errors, a warning layer is used to display warning information, and a suggestion layer is used to display optimization suggestions.
[0071] Each layer has independent drawing and rendering capabilities, and can be operated and updated separately as needed to ensure that different types of information can be clearly and orderly displayed.
[0072] The current displayed code content can be obtained from the Gitlab MR page by parsing the page's DOM structure, extracting <pre>or <code>The text in the label is the code content.
[0073] On the base layer, use the text drawing function of Canvas to draw the code content on the Canvas according to the original format. Keep the indentation, line breaks, and other formats of the code unchanged to ensure that the developer can clearly view the code structure. Set appropriate font, font size, and color to make the code readable on the Canvas. For example, choose a monospaced font, set an appropriate font size, and use black or dark gray for the code body.
[0074] For the review results of the serious error type, draw on the error layer. According to the problem location, determine the corresponding position coordinates in the code. Use a prominent color (such as red) and style (such as a highlighted background, underlined, etc.) to mark the error location. For example, draw a red highlighted area on the background of the error code line, and add a red exclamation mark icon at the end of the line, while displaying the error description and brief tips for fixing the problem next to it.
[0075] For the review results of the warning type, draw on the warning layer. Similarly, determine the coordinates according to the problem location. Use a more prominent color such as yellow, but not as strong as red, to mark it. For example, draw a yellow highlighted area on the background of the warning code line, and add a yellow triangle icon at the end of the line, with the warning information and brief fixing ideas displayed next to it.
[0076] For the review results of the suggestion type, draw on the suggestion layer. Determine the coordinates according to the problem location. Use a softer color such as green to mark it. For example, draw a green circular icon next to the suggestion code line, and display the suggestion content and related instructions next to the icon.
[0077] Stack the various layers in the planned order, with the base layer at the bottom, the serious error layer, the warning layer, and the suggestion layer stacked upwards in turn. In this way, the developer can see the code content and different types of review results at the same time when viewing, and the different types of results can be clearly distinguished.
[0078] In this embodiment, the review results are converted into multiple layers of superimposed rendering using the browser Canvas API to form a visual analysis layer, which can display the code review results in an intuitive and clear manner, helping developers quickly locate and understand the problems in the code.
[0079] S106, dynamically allocate computing resources through the browser resource manager, when the system load exceeds the preset load threshold, pause the Canvas rendering of non-focus areas, and automatically release the background model memory according to the tab activity state.
[0080] In this embodiment, key resource indicators for measuring system load are determined, such as CPU usage, memory occupancy, and GPU usage if graphics processing tasks are involved. These indicators can comprehensively reflect the resource consumption of the system and provide a basis for subsequent load judgment.
[0081] The browser extension uses the API provided by the browser to obtain the values of the above resource indicators in real time. According to the hardware configuration of the system and the expected performance, a reasonable load threshold is set.
[0082] The browser extension determines the focus area of the current developer by listening to the focus event and mouse movement event of the browser. For example, when the developer operates a certain code block in the Gitlab MR page, the area where the block is located is the focus area. The focus area can be determined by recording the mouse position and the interaction state of the page elements.
[0083] According to the location and range of the focus area, the other areas in the page except the focus area are determined as non-focus areas. These non-focus areas may contain some visual display of code review results that are not directly related to the current developer's operation.
[0084] When the system load is detected to exceed the preset load threshold, the browser extension sends instructions to the Canvas rendering module to suspend the rendering task of the non-focus area. A flag can be set to control the rendering process, and when the flag is in the suspended state, the rendering operation of the non-focus area will be skipped. At the same time, the rendering state of the non-focus area is recorded to restore the rendering when the system load decreases. For example, record the part of the non-focus area that has been rendered and the content that needs to be continued to render.
[0085] The browser extension uses the tab management API of the browser to obtain the state information of all currently opened tabs, including whether the tab is in an active state (i.e. the tab currently being viewed by the user), the loading progress of the tab, and the last interaction time, etc. According to the obtained tab state information, the activity level of each tab is determined. For example, the tab in the active state is determined as high activity state; the tab with the last interaction time within a certain time range (such as within 5 minutes) is determined as medium activity state; the tab that has not been interacted for a long time and is not in the active state is determined as low activity state.
[0086] The browser extension evaluates the memory occupied by the background running neural symbol joint reasoning engine and neural network model. The memory usage information related to the model can be obtained through the memory management API provided by the browser, including the memory size occupied by the model instance and the memory size occupied by the model cache, etc.
[0087] According to the active state of the tab page, the background model memory is automatically released. For the tab page with low activity, the background model memory associated with it is preferentially released. For example, when the system load is too high, first check the activity of all tab pages, find the tab page with low activity, and then release the background model memory used by the code review task corresponding to the tab page.
[0088] For the tab page with medium activity, partial release of the model memory can be considered, such as releasing some infrequently used model cache data. For the tab page with high activity, the associated background model memory is kept as much as possible to ensure the normal progress of the code review task.
[0089] When releasing the memory, record the released memory information, including the size of the released memory and the released model instance, so that the model can be reloaded when needed.
[0090] After taking the above resource optimization measures, the system load is continuously monitored in real time. When the system load decreases below the preset load threshold, it is determined that the system load has returned to normal. For the non-focus area whose rendering is suspended, the browser extension sends a resume instruction to the Canvas rendering module, and according to the previously recorded rendering state, the rendering task of the non-focus area is continued. The rendering process of the non-focus area can be restarted by updating the flag bit to the resume state. For the background model whose memory is released, the model is reloaded in a timely manner according to the system load and the needs of the code review task. For example, when the system load is low and the developer switches to the tab page whose model memory has been released, the background model required by the code review task corresponding to the tab page is reloaded.
[0091] In this embodiment, based on the browser resource manager, the computing resources are dynamically allocated, when the system load exceeds the preset load threshold, the Canvas rendering of the non-focus area is suspended, and the background model memory is automatically released according to the active state of the tab page, which can effectively reduce the system load and avoid the situation that the browser is stuck or crashes due to excessive resource consumption. At the same time, after the system load returns to normal, the rendering and model reloading can be resumed in a timely manner to ensure the continuity and stability of the code review work, improve the developer's use experience and code review efficiency.
[0092] In some embodiments, in the step S101, the local terminology library and the review rule library are established by the browser extension, the project-specific terminology and coding specifications are persistently stored, and the domain knowledge graph is formed, which specifically includes: Based on the browser file listening interface, capture the project document change event, extract the domain-specific terminology through the named entity recognition model, and establish the terminology-file mapping index; Based on the term-file mapping index, the coding specification files are parsed by the rule template matcher, while loading external custom rule plugins, generating a rule priority list. According to the rule priority list, the terms are associated with the rules in the form of triples, and the domain knowledge graph is constructed through a lightweight graph database.
[0093] In this embodiment, the browser extension uses the file listening interface provided by the browser to monitor the document files in the project directory in real time. When the project document changes, such as creation, modification, deletion, etc., the file listening interface can capture these events in time and pass the relevant information (such as file path, change type, etc.) to the browser extension.
[0094] The browser extension has a built-in or external service called named entity recognition model. When the project document change event is captured, the changed file is located according to the file path, and the file content is read. The file content is input into the named entity recognition model, which can identify the domain-specific terms in the text. For each domain-specific term identified, record the file path where it appears, and establish a term-file mapping index. This index can be stored in the form of key-value pairs, where the key is the term and the value is the list of file paths containing the term.
[0095] The browser extension has a built-in rule template matcher, which defines a series of rule templates for common coding specifications. When the project document change event involves coding specification files (such as code style guidelines, naming specifications, etc.), the contents of the coding specification files are read.
[0096] The rule template matcher matches the contents of the coding specification files with the predefined rule templates to parse the specific coding rules. For example, for code indentation specifications, the rule template may define the character type (such as space or tab) and the number of indentation, and the matcher can extract these specific requirements from the coding specification file.
[0097] Considering that different projects may have unique coding specification needs, the browser extension supports loading external custom rule plugins. Developers can write custom rule plugins according to the specific requirements of the project and upload them to the browser extension. When parsing the coding specification files, the browser extension loads these external custom rule plugins and integrates the custom rules with the rules parsed from the coding specification files.
[0098] Each rule is assigned a priority based on its source (e.g., built-in rules, coding standard file parsing rules, custom rule plugin rules) and its importance. For example, built-in base rules might have a lower priority, while project-customized critical rules might have a higher priority. All rules are arranged in a rule priority list in order of priority from high to low. This list provides the basis for subsequent association of terms with rules.
[0099] Based on the rule priority list, terms are associated with rules in the form of triples. The form of the triple is (term, rule, association strength). The association strength can be set according to factors such as the frequency of the rule appearing in the relevant files, the importance of the rule, etc. For example, if a term appears in multiple files related to a particular rule, the association strength of the term with the rule may be higher.
[0100] The browser extension uses a lightweight graph database to store and build the domain knowledge graph. The lightweight graph database has efficient graph data storage and query capabilities, and is suitable for running in a browser environment. The associated term and rule triple data is imported into the lightweight graph database to build the domain knowledge graph. In the knowledge graph, terms and rules are nodes, and the association between them is an edge.
[0101] As the project progresses, project documents and coding standards may change. The browser extension continuously listens for file change events, and when relevant file changes are detected, the above steps are repeated to update the term-file mapping index, rule priority list, and update the domain knowledge graph accordingly. For example, if a new coding standard about data storage is added, the rule template matcher will parse the new rule and add it to the rule priority list. Then, the browser extension will re-associate terms with rules and update the knowledge graph to ensure that the knowledge graph always reflects the latest domain knowledge and coding standards of the project.
[0102] In some embodiments, in the step S102 described above, the real-time capturing of the developer cursor trajectory and the window focus area, and the generation of the operation heat distribution map specifically include: By injecting page scripts, the cursor movement and window scrolling events are monitored in real time, and the visible code area, cursor coordinate position, and corresponding dwell time are recorded; Based on the cursor coordinate position and corresponding dwell time, the cursor movement speed is determined, the attention weight value of different behavior patterns is calculated according to the cursor movement speed, and the cursor event data is classified and aggregated; According to the attention weight value, the heat value of each line of code is calculated in combination with the time accumulation effect, and a decay factor is applied to the heat value outside the visible code area in combination with the window focus area; The heat value is mapped to a gradient color band, and the heat distribution map is rendered synchronously on the side of the code line through the browser Canvas API.
[0103] In this embodiment, the browser extension realizes the monitoring of the cursor movement and window scrolling events by injecting a page script into the target webpage. After the webpage is loaded, the browser extension automatically inserts the pre-written page script into the DOM structure of the webpage, enabling it to interact with the webpage.
[0104] The injected page script adds event listeners for the cursor movement event (mousemove) and the window scrolling event (scroll). When the cursor moves on the webpage, the mousemove event is triggered, and the script records the current cursor coordinate position (relative to the window or the entire document) and the corresponding dwell time of the coordinate position. The dwell time can be calculated by recording the timestamps of the event triggers, for example, when the cursor moves to a certain position, record the current timestamp, and when the cursor leaves that position, record the timestamp again, the difference between the two is the dwell time. When the window is scrolled, the scroll event is triggered, and the script records the current scrolling position of the window and determines the visible code region according to the scrolling position. The visible code region can be determined by comparing the boundaries of the code elements with the boundaries of the window, for example, by obtaining the offsetTop, offsetHeight, and other attributes of all code elements, as well as the scrollTop and window.innerHeight of the window, to determine which code elements are within the visible range of the window.
[0105] According to the recorded cursor coordinate positions and corresponding dwell times, the moving speed of the cursor between different positions is calculated. For example, for two adjacent cursor position records, the distance between them (which can use the Euclidean distance formula) and the time interval are calculated to obtain the moving speed of the cursor between the two positions.
[0106] According to the cursor moving speed, the attention weight value of different behavior patterns is calculated. Generally speaking, when the cursor moves slowly, the developer may be carefully reading or editing the code, and the attention weight value is higher; when the cursor moves quickly, the developer may be just quickly browsing the code, and the attention weight value is lower. Some speed thresholds and corresponding attention weight value ranges can be pre-set, for example, when the cursor moving speed is less than a certain threshold, the attention weight value is set to 0.8-1.0; when the speed is within the threshold range, the attention weight value is set to 0.5-0.8; when the speed is greater than another threshold, the attention weight value is set to 0.2-0.5.
[0107] According to the calculated attention weight values, the cursor event data is classified and aggregated. Cursor event data with similar attention weight values is classified into a category, for example, cursor event data with attention weight values in the range of 0.8-1.0 is classified into the "high attention" category, in the range of 0.5-0.8 is classified into the "medium attention" category, and in the range of 0.2-0.5 is classified into the "low attention" category. For each category of data, the total residence time of the cursor on different code lines and other information are counted for subsequent calculation of heat values.
[0108] According to the attention weight values, the heat values of each line of code are calculated in combination with the time cumulative effect. For each line of code, the attention weight values of all its related cursor event data are multiplied by the corresponding residence time, and then all the results are added to obtain the initial heat value of the line of code. For example, if a line of code has two cursor event record points, the first record point has an attention weight value of 0.9 and a residence time of 2 seconds, and the second record point has an attention weight value of 0.7 and a residence time of 3 seconds, then the initial heat value of the line of code is 0.9*2+0.7*3=1.8+2.1=3.9.
[0109] In combination with the window focus area, a decay factor is applied to the heat values outside the visible code area. Since the developer mainly focuses on the visible code area, the heat values of the code lines outside the visible code area should be decayed. The decay factor can be determined according to the distance of the code line from the visible code area, the farther the distance, the smaller the decay factor. For example, a decay function can be set, when the code line is outside the visible code area, the decay factor is calculated according to the line number difference between the code line and the visible code area, such as decay factor = 1 / (1+distance*0.5), then the initial heat value is multiplied by the decay factor to obtain the final heat value of each line of code.
[0110] The calculated heat value of each line of code is mapped to a gradient color band. A color gradient range is defined in advance, for example, from light blue (low heat value) to deep red (high heat value). According to the size of the heat value, the corresponding color in the color gradient range is selected. For example, the heat value range can be divided into several intervals, each interval corresponds to a color value, and then the corresponding color of each line of code is determined according to the interval in which the heat value of the line of code is located.
[0111] The operation heat distribution map is rendered synchronously on the side of the code line through the Canvas API of the browser. A Canvas element is created beside the code area of the webpage, with the same height as the code area and the width can be set as needed. For each line of code, a rectangular bar with the same height as the line of code is drawn on the Canvas according to its corresponding color value, and the color of the rectangular bar is the corresponding color of the line of code. In this way, the developer can intuitively see the operation heat distribution on the code line.
[0112] In some embodiments, in step S103 described above, based on the operation heat distribution map, the review rule nodes associated with the code block in the domain knowledge graph are dynamically activated, and a rule node priority sequence is obtained, specifically including: Identify the high heat value area in the operation heat distribution map that exceeds the preset heat threshold, and extract the file path and line number range of the corresponding code block; Based on the file path and line number range, query the associated review rule nodes in the domain knowledge graph to obtain an initial node set; Based on the initial node set, assign a basic weight according to the heat value intensity, and combine the context features of the code block to superimpose a correction factor to generate a rule node priority sequence.
[0113] In this embodiment, after generating the operation heat distribution map, a heat threshold needs to be set in advance. This threshold can be determined according to the actual situation and historical data of the project. For example, by analyzing the operation heat distribution maps of multiple projects, the code attention degree corresponding to different heat value intervals is counted, and a heat value that can clearly distinguish high attention and low attention code regions is selected as the preset threshold. It can also be manually adjusted according to the experience and needs of the development team.
[0114] The browser extension or related analysis tool scans the operation heat distribution map and compares the heat value of each line of code with the preset heat threshold. When the heat value of a line of code exceeds the threshold, it is determined that the region where the line of code is located is a high heat value region. In order to more accurately identify the region, a minimum continuous line number threshold can be set. Only when the number of lines that continuously exceed the heat threshold reaches the threshold, it is considered as an effective high heat value region.
[0115] For the identified high heat value region, the file path and line number range of the corresponding code block are extracted. The file path can be determined by the code file information obtained by the browser extension when recording the cursor trajectory and the window focus area. The line number range is determined according to the starting line and ending line of the high heat value region. For example, if the high heat value region starts from line 10 and ends at line 20, the line number range is 10-20.
[0116] Based on the extracted file path and line number range, the browser extension initiates a query request to the domain knowledge graph. In the knowledge graph, by traversing the nodes and edges related to the file path and line number range, all associated review rule nodes are found, and an initial node set is obtained. For example, if the file path is "project / src / utils.js" and the line number range is 10-20, the knowledge graph will find review rule nodes associated with the file and the code block in the line number range, such as "variable naming specification check" and "code comment integrity check".
[0117] A basic weight is assigned to each rule node in the initial node set according to the heat value intensity. The heat value intensity can be measured by the average heat value or the highest heat value of the high heat value region. Generally speaking, the higher the heat value intensity, the more frequently the developer operates on the code block, and the more important the associated review rule node may be, and therefore the greater the basic weight assigned. For example, a correspondence between the heat value intensity and the basic weight can be set, such as when the heat value intensity is between 0-5, the basic weight is 1; when it is between 5-10, the basic weight is 2; and so on.
[0118] The context features of the code block are analyzed, including the complexity of the code, the importance of the function module to which it belongs, and the degree of association with other codes. The complexity of the code can be evaluated by factors such as the number of lines, nesting level, and algorithm complexity used; the importance of the function module to which it belongs can be determined according to the business requirements and architecture design of the project; and the degree of association with other codes can be measured by calling relationship, data transmission relationship, etc.
[0119] A correction factor is added to each rule node according to the context features. For example, if the complexity of a certain code block is high, the correction factor of the review rule node associated with it (such as "code readability check" and "performance optimization check") can be appropriately increased to improve its priority; if the function module to which a certain code block belongs is the core module of the project, the correction factor of the rule node associated with it can also be increased.
[0120] The basic weight and the correction factor are combined to obtain the final priority value of each rule node. The combined calculation can use the weighted summation method, for example, set the weight of the basic weight to 0.6 and the weight of the correction factor to 0.4, multiply the basic weight by 0.6 and add the correction factor by 0.4 to obtain the final priority value.
[0121] The rule nodes in the initial node set are sorted in descending order of the final priority value to generate a rule node priority sequence. For example, the priority sequence can be "[variable naming specification check (priority value 3.5), code comment integrity check (priority value 3.0), performance optimization check (priority value 2.8)]".
[0122] In some embodiments, in step S104, the static rule review on the high heat region is performed by calling the neural-symbol joint reasoning engine according to the rule node priority sequence, and the semantic defect detection on the associated function chain is performed by calling the neural network model, to obtain the review result, specifically including: Based on the rule node priority sequence, high-priority symbol rules are selectively loaded, symbol rule review is performed on the code abstract syntax tree, and symbol rule review results are obtained; The correlation function call chain is extracted, the non-deterministic semantic defect is identified through the neural network model, and the defect detection result is obtained; The mapping relationship between the symbol rule review result and the defect detection result is established, and the hierarchical review report is generated according to the defect type and the confidence; Based on the user adoption behavior in the hierarchical review report, the weight parameter of the rule node priority sequence is updated.
[0123] In this embodiment, a symbol rule library is pre-constructed, which stores various symbol rules related to code review. These rules can cover syntax specifications, coding styles, security vulnerabilities, etc. For example, for variable naming rules, a symbol rule can be defined as "variable names should be descriptive and cannot use single characters or meaningless abbreviations".
[0124] According to the rule node priority sequence, high-priority symbol rules are selectively loaded. The browser extension or review tool will check whether the symbol rule corresponding to each rule node exists in the rule library in the order of the priority sequence, and load the existing rules into the memory. For example, if the priority of the "variable naming specification check" rule node in the priority sequence is the highest, the symbol rules related to variable naming are loaded first.
[0125] The existing code parsing tool (such as a parser based on different programming languages) is used to parse the target code and construct an abstract syntax tree (AST) of the code. The abstract syntax tree is a tree structure that can represent the syntax structure and semantic information of the code. The loaded symbol rule review is performed on the constructed abstract syntax tree. The review tool will traverse each node of the abstract syntax tree and check the properties of the node, the relationship between child nodes, etc. according to the symbol rule. For example, when performing variable naming rule review, it checks whether the variable name of each variable declaration node meets the rule requirements. If it is found that the rule is not met, the corresponding error information is recorded, including error location, error type, etc., and finally the symbol rule review result is obtained.
[0126] Through the analysis of the abstract syntax tree, the function call chain in the code is extracted. The review tool will traverse the abstract syntax tree, identify the function call nodes, and track the function call relationship to construct a complete function call chain.
[0127] A neural network model for semantic defect detection is pre-trained. This model can be trained based on a large number of code samples and corresponding defect labels, and can identify non-deterministic semantic defects in the code, such as logic errors, potential null pointer exceptions, etc. The review tool loads the trained neural network model, which is deployed in memory or communicates with the model on a remote server through an API interface. The extracted function call chain and related code context information are input into the neural network model for semantic defect detection. The model analyzes and processes the input information, identifies possible semantic defects, and outputs the defect detection results. For example, the model may detect potential null pointer reference risks in a function call chain and record the location and type of the defect.
[0128] A mapping relationship between the results of the symbol rule review and the defect detection is established. Since the symbol rule review and the semantic defect detection are directed at different aspects of the code, there may be some correlation between them. For example, a variable name that does not conform to the standard may affect the logical correctness of the code, resulting in semantic defects. The review tool analyzes the review results and associates relevant symbol rule review errors and semantic defects to establish a mapping relationship.
[0129] The review results are classified according to the defect type and confidence. Different types of defects have different degrees of impact on code quality, for example, security vulnerability defects are usually more serious than coding style defects. At the same time, the defect detection results output by the neural network model contain confidence information, indicating the reliability of the model's judgment on the defect. The review tool classifies the review results into different levels according to the defect type and confidence, such as high risk, medium risk, low risk, etc. Then, a classified review report is generated, which contains detailed information about each defect, such as defect location, defect type, confidence, and level.
[0130] After the review report is displayed to the developer, the developer's adoption behavior of the review results is recorded. For example, the developer can choose to accept a defect repair suggestion, ignore a defect, or mark a defect as a false positive. The review tool collects the developer's operation information through interface interaction and records it.
[0131] According to the adoption behavior of the developer, the weight parameter of the rule node priority sequence is updated. If the developer often accepts the review results related to a certain rule node, it means that the review rule corresponding to the rule node has high value in actual application, and therefore its weight parameter can be appropriately increased. Conversely, if the developer often ignores or marks the review results related to a certain rule node as false positives, it means that the rule node may not be suitable for the current project, and therefore its weight parameter can be appropriately decreased. The update of the weight parameter can be in the form of incremental update, and the weight parameter is fine-tuned each time according to the adoption behavior of the developer, so as to gradually optimize the rule node priority sequence and make it more in line with the actual needs of the project.
[0132] In this embodiment, by establishing the review result mapping relationship and generating the hierarchical review report, clear and intuitive review information is provided for the developer. In addition, the weight parameter of the rule node priority sequence is updated based on the user adoption behavior, which realizes dynamic optimization and continuous improvement of the review rule, improves the quality and efficiency of code review, and helps to ensure the quality and stability of the software project.
[0133] In some embodiments, in the step S105, the review results are converted into multi-layer superimposed rendering through the browser Canvas API, specifically including: Parsing the review results, and storing the line-level defect data, architecture conflict data and resource monitoring data in a classified manner; Calling the browser Canvas API, establishing a position index table according to the line-level defect data, generating a gradient color scale according to the complexity value, and drawing a proportional color band in the gap between code lines; Calling the browser Canvas API, detecting the position change of the file tree node according to the architecture conflict data, drawing a warning mark at the corresponding node position, and creating a conflict detail pop-up window; Calling the browser Canvas API, reserving a drawing area at the edge of the code line window according to the resource monitoring data, and drawing a real-time resource occupation stacking curve.
[0134] In this embodiment, after the browser extension or the review tool obtains the review results, the results are first parsed. The review results can come from different review modules, such as static code analysis tools, architecture checking tools and resource monitoring tools, etc. The parsing process includes identifying key information in the results, such as defect type, location, severity, etc. For example, for line-level defect data, the information such as the code file where the defect is located, the line number, the defect description, etc. needs to be extracted; for architecture conflict data, the file tree nodes involved and the specific content of the conflict need to be determined; for resource monitoring data, the resource type (such as CPU, memory), the occupation situation and the timestamp, etc. need to be obtained.
[0135] The parsed review results are stored in a classified manner according to data types. A local storage mechanism provided by the browser, such as IndexedDB or localStorage, can be used. Row-level defect data is stored in a dedicated data table, which contains fields such as file path, line number, defect type, and defect description. Architecture conflict data is stored in another data table, which records file tree node paths involved in conflicts, conflict types, and conflict details. Resource monitoring data is stored in a third data table, which contains fields such as resource type, occupancy value, and timestamp. Classified storage facilitates subsequent targeted processing and rendering of different types of data.
[0136] A canvas (Canvas) element is created by calling the browser Canvas API, and its drawing context (2D context) is obtained. According to the file path and line number information in the row-level defect data, a position index table is established. The position index table records the position coordinates of each code line on the canvas, for example, by calculating the start and end positions of the code line to determine its rectangular area on the canvas. In this way, during subsequent rendering, the code line that needs to be drawn defect markers can be quickly located according to the position index table.
[0137] Each defect is assigned a complexity value based on its severity or other related indicators (such as the frequency of the defect). The higher the complexity value, the more serious or more attention the defect needs. A gradient color scale is generated based on the complexity value, for example, the complexity value is divided into several intervals, and each interval corresponds to a color. Low complexity values correspond to light colors, and high complexity values correspond to dark colors. The gradient color scale can be implemented through a predefined color array or a color mapping function.
[0138] Draw proportional color bands in the gaps between code lines. According to the position index table, determine the gap position between each line of code, and then use the drawing method (such as fillRect) of the Canvas API to draw proportional color bands corresponding to the defects related to the line of code. The width of the color band can be adjusted according to the size of the gap, and the color of the color band is selected from the gradient color scale according to the complexity value of the defect. For example, if there are multiple defects in a line of code, an average complexity value can be calculated based on the complexity values of these defects, and then the color of the color band is determined according to the average complexity value.
[0139] Draw the file tree structure of the code file by calling the browser Canvas API. The file tree structure can be drawn in a recursive manner, and each node represents a file or folder. During the drawing process, record the position coordinates of each file tree node on the canvas. According to the file tree node path in the architecture conflict data, detect the change of node position. For example, if a file is moved to a different folder before and after the architecture conflict, the position in the file tree will also change.
[0140] After detecting the node position change, draw an alert marker at the corresponding node position. The alert marker can use simple graphics such as circles, triangles, etc., and fill with eye-catching colors (such as red) to attract the attention of developers. For example, use the arc method of the Canvas API to draw a circular alert marker, set its center coordinates to the node position coordinates, radius to a fixed value, and color to red.
[0141] When the developer hovers the mouse over the alert marker, create a conflict details pop-up window. The pop-up window can be drawn by the Canvas API to draw a rectangular area, and display the details of the conflict in it, such as conflict type, involved file path, specific content of the conflict, etc. The text information can be drawn in the pop-up window using the text drawing method (such as fillText) of the Canvas API. The position of the pop-up window can be adjusted according to the position of the mouse to ensure that it does not block other important information.
[0142] Reserve a drawing area at the edge of the code line window for drawing resource occupation stack curves. You can reserve a certain space on the right or below the code line window as a drawing area by adjusting the size or layout of the canvas. The width and height of the drawing area can be set according to actual needs to ensure that the resource occupation situation can be clearly displayed.
[0143] Call the browser Canvas API to draw real-time resource occupation stack curves in the drawing area according to the resource monitoring data. Resource monitoring data is usually collected in time series, with a resource occupation value at each time point. Stack the occupation values of different resource types, for example, draw CPU occupation values and memory occupation values on different layers, and then distinguish them by setting different colors or transparencies. Use the drawing methods of the Canvas API (such as beginPath, lineTo, stroke) to draw curves, determine the position of each data point in the drawing area according to the timestamp, and then connect the data points in sequence to form a curve. To achieve real-time updating, you can set a timer to periodically retrieve the latest resource monitoring data from local storage and redraw the curve.
[0144] Superimpose and render the visualization results of line-level defect data, architecture conflict data, and resource monitoring data in multiple layers. This can be achieved by setting different layers (using the save and restore methods of Canvas) to ensure that different types of data can be drawn independently while being displayed on the same canvas. For example, draw the proportional color band of line-level defects on the bottom layer, draw the alert markers and pop-up windows of architecture conflicts on the middle layer, and draw the stack curves of resource monitoring on the top layer.
[0145] To visualize the results, add interactive features to improve user experience. For example, when a developer clicks on a certain defect marker, a more detailed defect information window can pop up; when the developer drags the mouse, the canvas can be zoomed in or out or panned to view the review results of different areas. Interactive features can be achieved by listening to the events of the Canvas element (such as click, mousedown, mousemove, etc.), and performing corresponding operations according to the event type.
[0146] In some embodiments, in the step S106 described above, the computing resources are dynamically allocated by the browser resource manager, when it is detected that the system load exceeds the preset load threshold, the Canvas rendering of the non-focus area is suspended, and the background model memory is automatically released according to the tab activity state, specifically including: Call the browser performance interface to obtain CPU, memory and video memory data in real time, set the light load threshold and the heavy load threshold; Based on the operation heat distribution map and the window position information, identify high-priority code blocks, and generate a resource allocation weight mapping table; When the light load threshold is exceeded, suspend the Canvas rendering of the non-focus area and reduce the background model frequency, and when the heavy load threshold is exceeded, release the background model memory of the inactive tab.
[0147] In this embodiment, the browser extension or related tool uses the performance interface (such as Performance API) provided by the browser to obtain the CPU, memory and video memory data of the system in real time. Performance API can provide detailed information about the performance of the browser, including CPU usage, memory usage, etc. For video memory data, it can be obtained indirectly, such as monitoring the memory usage related to graphics rendering, or using the browser's support for WebGL and other graphics APIs to obtain video memory-related indicators.
[0148] According to the actual application scenario and system performance, set the light load threshold and the heavy load threshold. The light load threshold is used to judge that the system load starts to rise, but has not yet reached the degree of seriously affecting the performance; the heavy load threshold indicates that the system load is too high, and emergency measures must be taken to release resources. For example, the CPU usage rate of 70% can be set as the light load threshold, and 90% as the heavy load threshold; for memory usage, when the total memory usage reaches 80%, it is set as the light load threshold, and when it reaches 95%, it is set as the heavy load threshold. The threshold setting of video memory can be determined according to the complexity of graphics rendering and the total amount of available video memory.
[0149] By monitoring the user's operation behavior in the browser, an operation heat distribution map is constructed. The browser's event listening mechanism can be used to record the user's mouse movement, click, scroll, and other operations on the code review interface, and the operation frequency and dwell time of each code block are counted. For example, if the user frequently clicks and stays for a long time on a certain code block, it means that this block may be the user's focus, and the corresponding position in the heat distribution map will have a higher heat value.
[0150] The position information of the browser window is obtained to determine the currently visible code block. The window position information can be obtained through the browser's DOM operation and the related properties of the window object, such as the size of the window obtained through window.innerHeight and window.innerWidth, and the position of the element in the window obtained through the getBoundingClientRect() method of the element.
[0151] In combination with the operation heat distribution map and the window position information, high-priority code blocks are identified. High-priority code blocks are usually blocks with high operation heat and currently visible in the window. For example, if a code block has a high heat value in the heat distribution map and is currently within the visible range of the window, then this block is identified as a high-priority code block.
[0152] According to the identified high-priority code blocks, a resource allocation weight mapping table is generated. The weight mapping table assigns a weight value to each code block, and the higher the weight value, the higher the priority of the block in resource allocation. High-priority code blocks are assigned higher weight values, and non-high-priority code blocks are assigned lower weight values. For example, the weight value of a high-priority code block can be set to 10, and the weight value of a non-high-priority code block can be set to 1. The weight mapping table can be stored in the local storage of the browser for subsequent dynamic resource allocation.
[0153] When the real-time system load data exceeds the light load threshold, the Canvas rendering of the non-focus area is suspended and the background model frequency is reduced.
[0154] According to the resource allocation weight mapping table, the current focus area (usually the Canvas rendering area corresponding to the code block being operated or viewed by the user) and the non-focus area are determined. The non-focus area refers to the Canvas rendering area corresponding to the code block with a lower weight value and a lower user attention. Through the Canvas API operation provided by the browser, the Canvas rendering of the non-focus area is suspended. For example, a flag can be set, and when the flag is in the suspended state, the Canvas of the non-focus area is no longer drawn.
[0155] For models running in the background (such as semantic analysis models for code review, defect detection models, etc.), reduce their running frequency. This can be achieved by adjusting the timer interval or task scheduling strategy of the model. For example, if the model originally performs an analysis task every second, when the system load exceeds the light load threshold, the execution interval is adjusted to every two seconds, thereby reducing the model's occupation of computing resources.
[0156] When the real-time system load data exceeds the heavy load threshold, release the background model memory of the inactive tab page.
[0157] The browser can determine which tabs are inactive by their active state. For example, if a tab has not been operated by the user for a period of time or is running in the background, it can be considered inactive. The active state of a tab can be tracked by listening to the blur and focus events of the tab.
[0158] For background models running in inactive tabs, release the memory they occupy. This can be achieved by calling the memory management interface provided by the browser or directly destroying the model object. For example, set the model object in the inactive tab page to null, and let the browser's garbage collection mechanism automatically reclaim the memory it occupies. At the same time, the released model information can be recorded in the local storage to reinitialize the model when the tab page becomes active again.
[0159] In some embodiments, in steps S101-S106 above, the method further comprises: Listen to the developer's adoption operation, ignore operation and marking operation of the review suggestion, record the interaction event with timestamp and associate the review context to form historical interaction data; Based on the historical interaction data, extract the adoption frequency, response speed, association strength and authority weight to generate a normalized state feature matrix; Based on the normalized state feature matrix, use the Q-learning model to update the suggestion weight value of each review suggestion in combination with the preset reward rule, and when a preset number of behavior samples are accumulated, perform batch strategy optimization; Sort the review suggestions according to the updated suggestion weight values to generate a review report with a one-key submission interface, and inject the Gitlab comment system through the browser extension proxy.
[0160] In this embodiment, a browser extension is developed that can listen to three main operations of the developer on the review suggestions in the code review interface: adoption operation, ignore operation and marking operation. For example, when the developer clicks the "Adopt" button, the extension can capture this event; when the developer chooses to ignore a suggestion, the extension can also detect it; the marking operation may be that the developer marks the suggestion as "to be processed later" and the like, and the extension can also identify such operations.
[0161] At the same time of listening to the interaction event, the timestamp of the event occurrence is recorded. The timestamp is used to accurately record the time of the developer's operation, so as to analyze the response speed of the developer later. At the same time, each interaction event is associated with the corresponding review context. The review context includes but is not limited to the code file where the review suggestion is located, the code line number, the suggestion content, the severity of the suggestion and the like. By associating the interaction event with the review context, the operation behavior of the developer in different review scenarios can be more comprehensively understood.
[0162] The recorded timestamped interaction event and its associated review context are stored in the local storage of the browser to form historical interaction data. The local storage can use IndexedDB or localStorage technology to ensure safe storage and fast access of data.
[0163] Based on the historical interaction data, four key features are extracted: adoption frequency, response speed, association strength and authority weight.
[0164] Adoption frequency is used to count the number of times each review suggestion is adopted by the developer, reflecting the importance and practicality of the suggestion.
[0165] Response speed is used to calculate the average time interval from when the developer sees the review suggestion to when the developer takes action (adoption, ignore or marking), reflecting the developer's attention to the suggestion and processing efficiency.
[0166] Association strength is used to analyze the degree of association between the review suggestion and the code context. For example, if the suggestion has a high degree of association with the modification history of the current code and the relevant module, the association strength is high. The association strength can be determined by analyzing the dependency relationship of the code, comment information and the like.
[0167] According to the professional level, historical adoption rate and other factors of the developer or reviewer who proposes the review suggestion, an authority weight is given to each suggestion. For example, the suggestion of a senior developer may have a higher authority weight.
[0168] Since the four extracted features have different dimensions and value ranges, they need to be normalized to facilitate subsequent model processing. Normalization can map feature values to a specific interval, such as [0, 1]. For example, for the adoption frequency, first find the maximum adoption frequency in all suggestions, then divide the adoption frequency of each suggestion by the maximum adoption frequency to get the normalized value.
[0169] Combine the normalized four feature values to generate a normalized state feature vector for each review suggestion. Combine the feature vectors of all review suggestions into a matrix, i.e. the normalized state feature matrix. This matrix contains information about each review suggestion in four feature dimensions, providing input data for the Q-learning model.
[0170] Define a set of pre-set reward rules to guide the learning of the Q-learning model. Reward rules can be designed according to actual business needs, for example, when a developer adopts a suggestion, give the suggestion a positive reward; when a developer ignores a suggestion, give a negative reward; marking operations can give different rewards or penalties according to the type of marking. The size of the reward value can be dynamically adjusted according to the importance of the suggestion and the operation behavior of the developer.
[0171] Use the Q-learning model, use the normalized state feature matrix as the state input, the operation of the review suggestion (adoption, ignore, mark) as the action, and the pre-set reward rule as the reward feedback. Q-learning model learns the Q value of different actions in each state by constantly interacting with the environment (i.e. the interaction process between developers and review suggestions).
[0172] When a preset number of behavior samples are accumulated, perform batch strategy optimization. The preset number can be set according to actual conditions, for example, collect 100 interaction behavior samples and perform strategy optimization once. In the strategy optimization process, according to the Q value learned by the Q-learning model, update the suggestion weight value of each review suggestion. The suggestion weight value reflects the importance and priority of the suggestion, the higher the weight value, the more likely the suggestion will be displayed to the developer first.
[0173] Sort the review suggestions according to the updated suggestion weight values. Suggestions with high weight values are placed in front, and suggestions with low weight values are placed in back, forming an ordered review suggestion list.
[0174] Based on the sorted review suggestion list, a review report with a one-click submission interface is generated. The review report can include detailed information of the review suggestions, suggested code locations, suggested solutions, etc. The one-click submission interface allows developers to directly submit the review report to the Gitlab comment system without manually copying and pasting the content, improving the review efficiency.
[0175] Using the proxy function of the browser extension, the generated review report is injected into the Gitlab comment system through the one-click submission interface. The extension can simulate the developer's operation on the Gitlab interface, fill in the content of the review report in the comment box, and click the submit button to realize the automatic submission of the review report.
[0176] In this embodiment, the developer's interactive operation on the review suggestion can be effectively monitored, the historical interaction data can be recorded and analyzed, the weight value of the review suggestion can be optimized using the Q-learning model, and a review report that better meets the developer's needs can be generated and injected into the Gitlab comment system. This helps to improve the efficiency and effectiveness of code review, allowing developers to quickly handle important review suggestions and reduce unnecessary repetitive work, improving the overall quality of software development.
[0177] Reference Figure 2 An embodiment of the present application provides an AI code review system 2 based on a browser extension, which specifically comprises: A first review module 201 is used to establish a local terminology library and a review rule library through a browser extension, to persistently store project-specific terminology and coding specifications, and to form a domain knowledge graph. A second review module 202 is used to capture the developer's cursor trajectory and window focus area in real time when detecting the loading of the Gitlab MR page, and to generate an operation heat distribution map. A third review module 203 is used to dynamically activate the review rule nodes associated with the code blocks in the domain knowledge graph based on the operation heat distribution map, and to obtain the rule node priority sequence. A fourth review module 204 is used to perform static rule review on the high-heat area by calling the neural-symbol joint reasoning engine according to the rule node priority sequence, and to simultaneously perform semantic defect detection on the associated function chain by calling the neural network model, to obtain the review result. A fifth review module 205 is used to convert the review result into multi-layer superimposed rendering through the browser Canvas API, to form a visual analysis layer. A sixth review module 206 is used to dynamically allocate computing resources through the browser resource manager, to suspend the Canvas rendering of the non-focus area when detecting that the system load exceeds the preset load threshold, and to automatically release the background model memory according to the tab active state.
[0178] It can be understood that the contents in the browser extension-based AI code review method embodiment as shown in the above Figure 1 The contents in the browser extension-based AI code review method embodiment as shown in the above Figure 1 The browser extension-based AI code review system embodiment specifically implements the same functions as the browser extension-based AI code review method embodiment as shown in the above Figure 1 The browser extension-based AI code review system embodiment achieves the same beneficial effects as the browser extension-based AI code review method embodiment as shown in the above
[0179] It should be noted that the information interaction and execution process between the above systems, since based on the same concept as the method embodiments, the specific functions and the technical effects brought about can be specifically referred to the method embodiments part, and will not be repeated here.
[0180] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the system is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit or module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The above integrated unit can be realized in the form of hardware or software. In addition, the specific names of each functional unit or module are only for easy distinction, and do not limit the protection scope of the present application. The specific working process of the units and modules in the above system can refer to the corresponding process in the above method embodiments, which will not be repeated here.
[0181] With reference to Figure 3 The embodiment of the present application also provides a computer device 3, comprising a memory 302 and a processor 301 and a computer program 303 stored in the memory 302, when the computer program 303 is executed on the processor 301, the browser extension-based AI code review method as described in any of the above methods is implemented.
[0182] The computer device 3 can be a desktop computer, a notebook computer, a palm computer, and a cloud server, etc. The computer device 3 can include, but is not limited to, a processor 301, a memory 302. Those skilled in the art can understand that Figure 3 The computer device 3 is merely an example and does not limit the computer device 3, which can include more or fewer components than shown, or have components in different configurations and / or have different components, such as input / output devices, network access devices, and the like.
[0183] The processor 301 can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or the like. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0184] The memory 302 can be an internal storage unit of the computer device 3, such as a hard disk or a memory of the computer device 3 in some embodiments. The memory 302 can also be an external storage device of the computer device 3, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, or the like, in other embodiments. Further, the memory 302 can include both an internal storage unit and an external storage device of the computer device 3. The memory 302 is used to store an operating system, application programs, a boot loader, data, and other programs, such as program codes of the computer program, and the like. The memory 302 can also be used to temporarily store data that has been output or is to be output.
[0185] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program. When the computer program is run by a processor, the browser extension-based AI code review method is implemented.
[0186] In this embodiment, the integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the computer program for instructing the relevant hardware to complete all or part of the processes in the above-described embodiment methods can be stored in a computer readable storage medium. The computer program can be executed by a processor to implement the steps of the above-mentioned various method embodiments. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer readable medium at least includes any entity or device capable of carrying the computer program code to the photographing device / terminal equipment, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, according to legislation and patent practice, the computer readable medium can not be an electrical carrier signal and a telecommunication signal.
[0187] In the above embodiments, the description of each embodiment has its own focus, and the parts not described or recorded in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0188] Those skilled in the art can appreciate that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are implemented in hardware or software depends on the specific application and design constraints of the technical solutions. The skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0189] In the embodiments disclosed in the present application, it should be understood that the disclosed apparatus / terminal equipment and methods can be implemented in other ways. For example, the apparatus / terminal equipment embodiments described above are only schematic, for example, the division of the modules or units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed each other can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.
[0190] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may also be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.< / code> < / pre>
Claims
1. An AI code review method based on browser extension, characterized in that: The method specifically includes: Establish a local terminology library and review rule library through browser extensions to persistently store project-specific terminology and coding standards, forming a domain knowledge graph; When the GitLab MR page is detected loading, the developer's cursor trajectory and window focus area are captured in real time to generate an operation heat distribution map; Based on the operation heat distribution map, dynamically activate the review rule nodes of the associated code blocks in the domain knowledge graph and obtain the priority sequence of the rule nodes; Based on the priority sequence of rule nodes, the neural symbolic joint reasoning engine is called to perform static rule review on high-heat areas, and the neural network model is called to perform semantic defect detection on the associated function chain to obtain the review results; The review results are converted into multi-layer overlay rendering through the browser Canvas API to form a visual analysis layer; Computing resources are dynamically allocated through the browser resource manager. When the system load is detected to exceed the preset load threshold, Canvas rendering of non-focus areas is paused, and background model memory is automatically released based on the active status of the tab.
2. The method according to claim 1, characterized in that The above mentioned method of establishing a local terminology library and review rule library through browser extension, persistently storing project-specific terminology and coding standards, and forming a domain knowledge graph specifically includes: Based on the browser file monitoring interface, project document change events are captured, domain-specific terms are extracted through the named entity recognition model, and a term-file mapping index is established; Based on the term-file mapping index, the coding specification file is parsed through the rule template matcher, and external custom rule plug-ins are loaded to generate a rule priority list; According to the rule priority list, terms and rules are associated in the form of triples, and a domain knowledge graph is constructed through a lightweight graph database.
3. The method according to claim 1, characterized in that The real-time capture of the developer's cursor trajectory and window focus area to generate an operation heat distribution map specifically includes: By injecting page scripts to monitor cursor movement and window scrolling events in real time, the visible code area, cursor coordinate position and corresponding dwell time are recorded; Determine the cursor movement speed based on the cursor coordinate position and the corresponding dwell time, calculate the attention weight value of different behavior patterns according to the cursor movement speed, and classify and aggregate the cursor event data; The heat value of each line of code is calculated based on the attention weight value and the time accumulation effect, and an attenuation factor is applied to the heat value outside the visible code area based on the window focus area; Map the heat value to a gradient color band, and use the browser Canvas API to render the heat distribution map synchronously on the code line side.
4. The method according to claim 1, wherein The method of dynamically activating the review rule nodes of the associated code blocks in the domain knowledge graph based on the operation heat distribution map and obtaining the rule node priority sequence specifically includes: Identify high-heat value areas exceeding the preset heat threshold in the operation heat distribution map and extract the file path and line number range of the corresponding code block; Based on the file path and line number range, query the associated review rule nodes in the domain knowledge graph to obtain the initial node set; Based on the initial node set, basic weights are assigned according to the intensity of the thermal value, and the correction factor is superimposed in combination with the contextual features of the code block to generate a rule node priority sequence.
5. The method according to claim 1, wherein According to the rule node priority sequence, the neural symbolic joint reasoning engine is called to perform static rule review on the high-heat area, and the neural network model is called to perform semantic defect detection on the associated function chain to obtain the review results, which specifically include: Based on the priority sequence of rule nodes, high-priority symbolic rules are selectively loaded, and symbolic rule review is performed on the code abstract syntax tree to obtain the symbolic rule review results; Extract the associated function call chain, identify non-deterministic semantic defects through the neural network model, and obtain defect detection results; Establish a mapping relationship between symbol rule review results and defect detection results, and generate a graded review report based on defect type and confidence level; Based on the user adoption behavior in the hierarchical review report, the weight parameters of the rule node priority sequence are updated.
6. The method according to claim 1, characterized in that The review results are converted into multi-layer overlay rendering through the browser Canvas API, specifically including: Analyze review results and categorize and store row-level defect data, architecture conflict data, and resource monitoring data; Call the browser Canvas API, build a location index table based on line-level defect data, generate a gradient color scale based on the complexity value, and draw a proportional color band between code lines; Call the browser Canvas API to detect changes in file tree node positions based on architecture conflict data, draw warning marks at corresponding node positions, and create a floating window with conflict details. Call the browser Canvas API, reserve a drawing area at the edge of the code line window based on resource monitoring data, and draw a real-time resource usage stacking curve.
7. The method according to claim 1, characterized in that The browser resource manager dynamically allocates computing resources, pausing Canvas rendering in non-focus areas when it detects that the system load exceeds a preset load threshold, and automatically releasing background model memory based on the active status of the tab, specifically including: Call the browser performance interface to obtain CPU, memory, and video memory data in real time, and set light load thresholds and heavy load thresholds; Based on the operation heat distribution map and window position information, it identifies high-priority code blocks and generates a resource allocation weight mapping table; When the light load threshold is exceeded, the canvas rendering of the non-focus area is paused and the background model frequency is reduced. When the heavy load threshold is exceeded, the background model memory of the inactive tab is released.
8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: Monitor developers' actions of adopting, ignoring, and marking review suggestions, record interaction events with timestamps, and associate them with review context to form historical interaction data; Based on historical interaction data, adoption frequency, response speed, association strength, and authority weight are extracted to generate a normalized state feature matrix. Based on the normalized state feature matrix, the Q-learning model is used to update the weight of each review suggestion in combination with the preset reward rules. When a preset number of behavior samples are accumulated, the strategy optimization is performed in batches. Sort the review suggestions according to the updated suggestion weight values, generate a review report with a one-click submission interface, and inject it into the GitLab review system through the browser extension proxy.
9. An AI code review system based on browser extension, characterized in that: The system specifically includes: The first review module is used to establish a local terminology library and review rule library through browser extensions, persistently store project-specific terminology and coding standards, and form a domain knowledge graph; The second review module is used to capture the developer's cursor trajectory and window focus area in real time when the GitLab MR page is detected to be loaded, and generate an operation heat distribution map; The third review module is used to dynamically activate the review rule nodes of the associated code blocks in the domain knowledge graph based on the operation heat distribution map and obtain the priority sequence of the rule nodes; The fourth review module is used to call the neural symbolic joint reasoning engine to perform static rule review on high-heat areas according to the rule node priority sequence, and simultaneously call the neural network model to perform semantic defect detection on the associated function chain to obtain the review results; The fifth review module is used to convert the review results into multi-layer overlay rendering through the browser Canvas API to form a visual analysis layer; The sixth review module is used to dynamically allocate computing resources through the browser resource manager. When it is detected that the system load exceeds the preset load threshold, the Canvas rendering of the non-focus area is suspended and the background model memory is automatically released according to the active status of the tab.
10. A computer device, characterized in that: include: A memory, a processor, and a computer program stored in the memory, which, when executed on the processor, implements the browser extension-based AI code review method as described in any one of claims 1 to 8.
Citation Information
Cited By
Generative visual code-oriented security audit and resource scheduling method and system
CN121615151A
Security auditing and resource scheduling method and system for generative visualization code
CN121615151B