Low-code platform static code analysis method, device, equipment, medium and program product
By real-time parsing and analyzing the generated source code on a low-code platform, the problem of inaccurate static code analysis results in the existing technology is solved, and the development efficiency and analysis accuracy are improved.
Patent Information
- Application Number
- CN202411867105.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-03-28
AI Technical Summary
The static code analysis tools of existing low-code platforms cannot provide real-time feedback, resulting in low development efficiency, unable to adapt to the code characteristics generated by the code platform, and the analysis results are not accurate enough.
Provide a low-code platform static code analysis method, which obtains the generated source code in response to user editing operations, parses and converts it into an intermediate representation, uses static code analysis tools for analysis, and feedbacks the analysis results in real time.
Improve development efficiency, real-time feedback, improve the accuracy and automation of code analysis, and reduce development costs.
Smart Images

Figure CN119718889A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of software development, specifically to the field of code analysis technology, and more specifically to a low-code platform static code analysis method, device, equipment, medium and program product. Background Art
[0002] In the field related to low-code platforms, existing algorithms are not adapted to the characteristics of the code generated by the code platform, resulting in inaccurate code analysis results; existing static analysis tools are usually performed after the code is written, and cannot provide real-time feedback, affecting development efficiency.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] In view of the above problems, the present disclosure provides a low-code platform static code analysis method, apparatus, equipment, medium and program product to improve development efficiency.
[0005] According to a first aspect of the present disclosure, there is provided a low-code platform static code analysis method, comprising: in response to an editing operation of a user on the low-code platform, obtaining source code generated by the low-code platform;
[0006] Parsing the source code into an intermediate representation;
[0007] Analyze the intermediate representation code using static code analysis tools; and
[0008] Provide users with real-time feedback on code analysis results.
[0009] According to an embodiment of the present disclosure, converting the source code parsing into an intermediate representation includes:
[0010] Parsing the source code to determine the code type;
[0011] Performing a first conversion on the source code according to the code type to generate an abstract syntax tree; and
[0012] A second transformation is performed on the abstract syntax tree to generate an intermediate representation.
[0013] According to an embodiment of the present disclosure, performing a first conversion on the source code according to the code type to generate an abstract syntax tree includes:
[0014] Determining a technology stack type of the code according to the code type; and
[0015] A first conversion is performed on the source code according to the technology stack type to generate an abstract syntax tree.
[0016] According to an embodiment of the present disclosure, the code type includes front-end code and back-end code, and determining the technology stack type of the code according to the code type includes:
[0017] If it is determined that the source code is a front-end code, the technology stack type of the code is determined to be one or more of Hypertext Markup Language, Cascading Style Sheets and JavaScript scripting language;
[0018] If it is determined that the source code is backend code, the technology stack type of the code is determined to be one or more of Java and Python.
[0019] According to an embodiment of the present disclosure, performing a first conversion on the source code according to the technology stack type to generate an abstract syntax tree includes:
[0020] Determining a target parsing strategy based on the technology stack type; and
[0021] A first transformation is performed on the source code based on a target parsing strategy to generate an abstract syntax tree.
[0022] According to an embodiment of the present disclosure, the real-time feedback of code analysis results to the user includes:
[0023] Monitor the analysis reports generated by static code analysis tools; and
[0024] Error codes are highlighted based on the error and warning messages in the analysis report.
[0025] A second aspect of the present disclosure provides a low-code platform static code analysis device, including: a code acquisition module, for acquiring source code generated by the low-code platform in response to an editing operation of a user on the low-code platform;
[0026] A code parsing module, used to parse and convert the source code into an intermediate representation;
[0027] A code analysis module, used for analyzing the intermediate representation code using a static code analysis tool; and
[0028] The display module is used to provide real-time feedback of code analysis results to users.
[0029] According to an embodiment of the present disclosure, the code parsing module includes a code parsing submodule, a first conversion submodule and a second conversion submodule.
[0030] A code parsing submodule, used to parse the source code to determine the code type;
[0031] a first conversion submodule, configured to perform a first conversion on the source code according to the code type to generate an abstract syntax tree; and
[0032] The second conversion submodule is used to perform a second conversion on the abstract syntax tree to generate an intermediate representation.
[0033] According to an embodiment of the present disclosure, the first conversion submodule includes a technology stack type determination unit and a conversion unit.
[0034] a technology stack type determining unit, configured to determine a technology stack type of a code according to the code type; and
[0035] A conversion unit is used to perform a first conversion on the source code according to the technology stack type to generate an abstract syntax tree.
[0036] According to an embodiment of the present disclosure, the technology stack type determination unit includes a first determination subunit and a second determination subunit.
[0037] The first determination subunit is used to determine that the technology stack type of the code is one or more of Hypertext Markup Language, Cascading Style Sheets and JavaScript scripting language if the source code is determined to be a front-end code;
[0038] The second determining subunit is used to determine that the technology stack type of the code is one or more of Java language and Python language if the source code is determined to be backend code.
[0039] According to an embodiment of the present disclosure, the conversion unit includes a third determining subunit and a conversion subunit.
[0040] A third determining subunit is used to determine a target parsing strategy according to the technology stack type; and
[0041] The conversion subunit is used to perform a first conversion on the source code based on a target parsing strategy to generate an abstract syntax tree.
[0042] According to an embodiment of the present disclosure, the display module includes a monitoring submodule and a display submodule.
[0043] A monitoring submodule, used to monitor real-time changes in the analysis report generated by the static code analysis tool; and
[0044] The display submodule is used to highlight the error codes according to the error and warning information in the analysis report.
[0045] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.
[0046] The fourth aspect of the present disclosure further provides a computer-readable storage medium having a computer program or instructions stored thereon, which implements the steps of the above method when the above computer program or instructions are executed by a processor.
[0047] The fifth aspect of the present disclosure further provides a computer program product, including a computer program or instructions, which implement the steps of the above method when the above computer program or instructions are executed by a processor.
[0048] The low-code platform static code analysis method provided by the embodiment of the present disclosure can parse and convert the generated source code into an intermediate representation and use a static code analysis tool to analyze it while the developer is designing the application, providing timely feedback, improving development efficiency, increasing the degree of automation, and reducing development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0050] Figure 1 The application scenario diagram of the low-code platform static code analysis method, apparatus, device, medium and program product according to an embodiment of the present disclosure is schematically shown;
[0051] Figure 2 A flowchart of a low-code platform static code analysis method according to an embodiment of the present disclosure is schematically shown;
[0052] Figure 3 A flowchart of a low-code platform static code analysis method according to another embodiment of the present disclosure is schematically shown;
[0053] Figure 4 A flowchart of a low-code platform static code analysis method according to another embodiment of the present disclosure is schematically shown;
[0054] Figure 5 A flowchart of a low-code platform static code analysis method according to another embodiment of the present disclosure is schematically shown;
[0055] Figure 6 The structure block diagram of the low-code platform static code analysis device according to an embodiment of the present disclosure is schematically shown; and
[0056] Figure 7 A block diagram of an electronic device suitable for implementing a static code analysis method for a low-code platform according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0057] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0058] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0059] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0060] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0061] First, the terms that appear in the embodiments of the present disclosure are explained:
[0062] Low-Code Platform (LCP): A software development platform that allows developers to quickly build applications through a graphical interface and model-driven logic rather than the traditional hand-written code method.
[0063] Front-end Code: refers to the code that runs in the user interface, usually involving user interaction and interface display.
[0064] Back-end Code: refers to the code running on the server side, responsible for processing business logic, data storage, and server-side calculations.
[0065] Component Code: The code of each independent module that makes up the user interface.
[0066] Static Code Analysis (SCA): A code inspection method that does not run the code, used to detect potential errors in the code, irregular coding practices, etc.
[0067] Abstract Syntax Tree (AST): A structured representation of source code, used to represent the structure of the code.
[0068] Intermediate Representation (IR): An abstract representation of source code, usually used for optimization during compilation.
[0069] Based on the above technical problems, an embodiment of the present disclosure provides a static code analysis method for a low-code platform, the method comprising: in response to a user's editing operation on the low-code platform, obtaining source code generated by the low-code platform; parsing the source code into an intermediate representation; using a static code analysis tool to analyze the intermediate representation code; and providing real-time feedback of the code analysis results to the user.
[0070] Figure 1 The application scenario diagram of the low-code platform static code analysis method, apparatus, equipment, medium and program product according to an embodiment of the present disclosure is schematically shown.
[0071] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a large-scale server installation scenario. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0072] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0073] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0074] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0075] It should be noted that the low-code platform static code analysis method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the low-code platform static code analysis device provided in the embodiment of the present disclosure can generally be set in the server 105. The low-code platform static code analysis method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Correspondingly, the low-code platform static code analysis device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.
[0076] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements. Figure 1 The application scenarios shown are only examples of application scenarios and system architectures to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios. It should be noted that the low-code platform static code analysis method and device determined in the present disclosure can be used in the financial field, and can also be used in any field other than the financial field. The application field of the method and device for static code analysis of the low-code platform determined in the present disclosure is not limited.
[0077] The following will be based on Figure 1 The scene described by Figure 2~Figure 5 The low-code platform static code analysis method of the disclosed embodiment is described in detail.
[0078] Figure 2 A flowchart of a low-code platform static code analysis method according to an embodiment of the present disclosure is schematically shown.
[0079] like Figure 2 As shown, the low-code platform static code analysis method of this embodiment includes operations S210 to S240, and the transaction processing method can be executed by a server or other computing device.
[0080] In operation S210, in response to the user's editing operation on the low-code platform, source code generated by the low-code platform is obtained.
[0081] In operation S220, the source code is parsed and converted into an intermediate representation.
[0082] In one example, in a low-code platform, the code is usually generated through a graphical interface and lacks direct source code form. In order to perform static code analysis, these codes must first be converted into IR intermediate representations. For the specific process, see Figure 3 Operations S310 to S330 are shown.
[0083] In operation S230 , a static code analysis tool is used to analyze the code of the intermediate representation.
[0084] In operation S240 , the code analysis result is fed back to the user in real time.
[0085] According to an embodiment of the present disclosure, real-time changes of the analysis report generated by the static code analysis tool are monitored, and error codes are highlighted according to the error and warning information in the analysis report.
[0086] In one example, since the code structure generated by the low-code platform is different from the traditional handwritten code, the componentized nature of the low-code platform means that there are a large number of component dependencies in the code. Therefore, the static code analysis algorithm in the disclosed embodiment needs to be able to adapt to these differences and accurately identify and analyze these dependencies. In order to improve development efficiency, in the disclosed embodiment, the static code analysis tool is integrated into the low-code platform. As part of the low-code platform, developers can use it directly when designing pages. When developers write or modify code, the tool can analyze and provide feedback in a timely manner, display the code analysis results on the front-end interface, and provide users with specific positioning information and repair suggestions.
[0087] The low-code platform static code analysis method provided by the embodiment of the present disclosure can parse and convert the generated source code into an intermediate representation and use a static code analysis tool to analyze it while the developer is designing the application, providing timely feedback, improving development efficiency, increasing the degree of automation, and reducing development costs.
[0088] Figure 3 A flowchart of a low-code platform static code analysis method according to another embodiment of the present disclosure is schematically shown. Figure 4 A flowchart of a low-code platform static code analysis method according to another embodiment of the present disclosure is schematically shown. Figure 5 A flowchart of a low-code platform static code analysis method according to another embodiment of the present disclosure is schematically shown.
[0089] like Figure 3 As shown, the low-code platform static code analysis method of this embodiment includes operations S310 to S330, and the transaction processing method can be executed by a server or other computing devices.
[0090] In operation S310, the source code is parsed to determine a code type.
[0091] In one example, since both the front-end and back-end codes are important components of the application in the low-code platform, there are obvious differences in their functions, structures, and processing logic. In order to improve the efficiency of code analysis, the source code is first parsed to determine whether the code type is front-end code or back-end code. Specifically, for example, separation of responsibilities: the front-end code is mainly responsible for the display of the user interface (UI) and user interaction, while the back-end code is responsible for business logic processing, data storage, and server-side calculations. This separation makes the code structure clearer and easier to manage and maintain. For example, separation of technology stacks: the front-end and back-end codes may use different programming languages and technology stacks. For example, the front-end may use HyperText Markup Language HTML (HTML), Cascading Style Sheets CSS (CSS), and JavaScript, while the back-end may use Java, Python, or Node.js, etc.
[0092] In operation S320, a first conversion is performed on the source code according to the code type to generate an abstract syntax tree.
[0093] like Figure 4 As shown, operation S320 includes operation S321 to operation S322.
[0094] In operation S321, a technology stack type of the code is determined according to the code type.
[0095] According to an embodiment of the present disclosure, if the source code is determined to be a front-end code, the technology stack type of the code is determined to be one or more of Hypertext Markup Language, Cascading Style Sheets, and JavaScript scripting languages. If the source code is determined to be a back-end code, the technology stack type of the code is determined to be one or more of Java and Python languages.
[0096] In operation S322 , a first conversion is performed on the source code according to the technology stack type to generate an abstract syntax tree.
[0097] like Figure 5 As shown, operation S322 includes operation S410 and operation S420.
[0098] In operation S410, a target parsing strategy is determined according to the technology stack type.
[0099] In operation S420, a first transformation is performed on the source code based on a target parsing strategy to generate an abstract syntax tree.
[0100] In an example, whether it is front-end code or back-end code, the general steps for building an abstract syntax tree include: 1) Lexical analysis: decompose the source code into a series of lexical units, such as keywords, identifiers, operators, etc. 2) Syntax analysis: combine lexical units into grammatical units to build an abstract syntax tree. This step is usually completed using a top-down parser or a bottom-up parser. 3) Semantic analysis: perform semantic checks based on the abstract syntax tree, including type checking, scope resolution, etc. 4) Abstract syntax tree optimization: optimize the generated abstract syntax tree, such as removing unnecessary nodes, merging similar structures, etc., to facilitate subsequent analysis and processing. 5) Error handling: During the parsing process, if code that does not conform to the language specification is encountered, the tool will mark the error and provide error information. Through the above steps, the tool can convert the source code of the front-end and back-end into a structured abstract syntax tree representation, laying the foundation for subsequent static code analysis, code optimization, and conversion to IR.
[0101] In an example, the front-end code usually includes languages such as HTML, CSS, and JavaScript. Each language has its own specific grammatical rules and structure, so different parsing strategies need to be determined according to the type of technology stack. Specifically, HTML: Markup language parsing: HTML code will be parsed into a DOM (Document Object Model) tree, where each HTML tag corresponds to a node. Node attribute processing: Parse the attributes of the tag and store them as attributes of the node. CSS: Selector parsing: CSS selectors will be parsed and mapped to corresponding DOM elements. Style rule extraction: Extract CSS rules such as fonts, colors, layouts, etc. and associate them with selectors. JavaScript: Lexical analysis: Decompose JavaScript code into a series of lexical units, such as keywords, identifiers, literals, etc. Syntax analysis: According to the grammatical rules of JavaScript, lexical units are combined into grammatical structures such as expressions, statements, and functions. Scope parsing: Determine the scope of variables and functions, as well as the dependencies between them.
[0102] In an example, the backend code may also use multiple programming languages, such as Java, Python, C#, etc. The parsing process of each language has similarities, but also has its own specific characteristics. Java: Lexical analysis: Decompose Java source code into lexical units, such as class names, method names, variable names, etc. Syntax analysis: Construct the grammatical structure of classes, methods, variable declarations, etc. Type system: Analyze Java's type system, including class inheritance, interface implementation, etc. Python:
[0103] Dynamic type analysis: Python is a dynamically typed language that needs to determine the variable type at runtime, but the potential type of the variable can be marked in the abstract syntax tree. Indentation sensitivity: Process the indentation rules of Python code to ensure the correct division of code blocks. C#: Namespace and type analysis: Parse C# namespace and type definitions, including classes, structures, interfaces, etc. LINQ and asynchronous programming features: Process C#-specific language features, such as Lambda expressions, LINQ queries, and asynchronous methods.
[0104] In operation S330, a second transformation is performed on the abstract syntax tree to generate an intermediate representation.
[0105] In one example, in intermediate representation generation, the tool converts the abstract syntax tree into a form that is closer to machine code while removing some of the complexity associated with a specific programming language. The purpose of the intermediate representation is to provide a standardized view that makes subsequent optimizations and transformations more efficient. The steps for converting the abstract syntax trees of front-end code and back-end code to the intermediate representation are different because the runtime environments and optimization goals they serve are different. First, the general steps for converting the abstract syntax tree to the intermediate representation are introduced.
[0106] In one example, the conversion of the abstract syntax tree to the intermediate representation, whether it is the front-end or back-end code, usually includes the following general steps: 1) Node standardization: converting high-level language features in the abstract syntax tree into standardized nodes in the intermediate representation, such as assignment, arithmetic operations, control flow statements, etc. 2) Symbol table construction: building a symbol table to record the declaration and usage information of variables, functions, etc. 3) Control flow construction: building a control flow graph (CFG) to represent the execution path in the program. 4) Data flow construction: building a data flow graph to analyze the assignment and usage of variables. 5) Optimization: optimizing the intermediate representation according to the specific requirements of the program and the characteristics of the target platform. 6) Code generation: converting the intermediate representation into the code of the target platform, such as machine code, bytecode, or intermediate bytecode. Through these steps, the tool can convert the abstract syntax trees of the front-end and back-end codes into intermediate representations suitable for further analysis and optimization.
[0107] In an example, the front-end code mainly involves HTML, CSS and JavaScript, and the intermediate representation conversion steps are usually as follows: 1) HTML conversion: HTML itself is not directly converted into an intermediate representation because it is a markup language used to describe the page structure. However, HTML can be parsed into a DOM tree, which can be regarded as a specific intermediate representation for subsequent page rendering and event handling. 2) CSS conversion: CSS styles are usually not converted into an intermediate representation in the traditional sense, but can be converted into a style sheet representation that can be used to quickly find and apply styles. 3) JavaScript conversion: Scope and variable parsing: Convert the scope and variable declarations in the abstract syntax tree of JavaScript into a symbol table in the intermediate representation. Control flow analysis: Convert the control flow structure (such as if statements, loops, etc.) in the abstract syntax tree into a control flow graph (CFG). Data flow analysis: Analyze the assignment and use of variables and build a data flow graph. Optimization: Optimize the intermediate representation of JavaScript, such as dead code elimination, constant folding, function inlining, etc. Code generation: Convert the optimized intermediate representation into code that the browser can understand, such as generating efficient machine code through just-in-time compilation (JIT).
[0108] In one example, the backend code usually involves server-side logic processing, which may use languages such as Java, Python, and C#. The IR conversion steps are usually as follows: 1) Lexical and syntactic analysis: Convert the AST of the backend code into a standardized IR, such as three-address code. 2) For programming languages with a type system such as Java, type erasure may be required during the IR generation process to adapt to the runtime environment. 3) Control flow and data flow analysis: Build CFG and data flow graphs to provide information for subsequent optimization. 4) Intermediate representation optimization: Dead code elimination: Remove code parts that will not be executed in the IR. Loop optimization: Perform optimizations such as loop unrolling and loop fusion. Function inlining: Embed frequently called small functions directly into the call site to reduce function call overhead. 5) Code generation: Convert IR into target machine code or bytecode, such as Java's JVM bytecode.
[0109] Based on the above-mentioned low-code platform static code analysis method, the present disclosure also provides a low-code platform static code analysis device. Figure 6 The device is described in detail.
[0110] Figure 6 The structural block diagram of the low-code platform static code analysis device according to an embodiment of the present disclosure is schematically shown.
[0111] like Figure 6As shown, the low-code platform static code analysis device 600 of this embodiment includes a code acquisition module 610, a code parsing module 620, a code analysis module 630 and a display module 640.
[0112] The code acquisition module 610 is used to respond to the user's editing operation on the low-code platform and obtain the source code generated by the low-code platform. In one embodiment, the code acquisition module 610 can be used to perform the operation S210 described above, which will not be repeated here.
[0113] The code parsing module 620 is used to parse and convert the source code into an intermediate representation. In one embodiment, the code parsing module 620 can be used to perform the operation S220 described above, which will not be described in detail here.
[0114] The code analysis module 630 is used to analyze the code of the intermediate representation using a static code analysis tool. In one embodiment, the code analysis module 630 can be used to perform the operation S230 described above, which will not be described in detail here.
[0115] The presentation module 640 is used to analyze the intermediate representation code using a static code analysis tool. In one embodiment, the presentation module 640 can be used to perform the operation S240 described above, which will not be described in detail here.
[0116] According to an embodiment of the present disclosure, the code parsing module includes a code parsing submodule, a first conversion submodule and a second conversion submodule.
[0117] The code parsing submodule is used to parse the source code to determine the code type. In one embodiment, the code parsing submodule can be used to perform the operation S310 described above, which will not be described in detail here.
[0118] The first conversion submodule is used to perform a first conversion on the source code according to the code type to generate an abstract syntax tree. In one embodiment, the first conversion submodule can be used to perform the operation S320 described above, which will not be described in detail here.
[0119] The second conversion submodule is used to perform a second conversion on the abstract syntax tree to generate an intermediate representation. In one embodiment, the second conversion submodule can be used to perform the operation S330 described above, which will not be described in detail here.
[0120] According to an embodiment of the present disclosure, the first conversion submodule includes a technology stack type determination unit and a conversion unit.
[0121] The technology stack type determination unit is used to determine the technology stack type of the code according to the code type. In one embodiment, the technology stack type determination unit can be used to perform the operation S311 described above, which will not be described in detail here.
[0122] The conversion unit is used to perform a first conversion on the source code according to the technology stack type to generate an abstract syntax tree. In one embodiment, the conversion unit can be used to perform the operation S312 described above, which will not be described in detail here.
[0123] According to an embodiment of the present disclosure, the technology stack type determination unit includes a first determination subunit and a second determination subunit.
[0124] The first determination subunit is used to determine that the source code is a front-end code and determine that the technology stack type of the code is one or more of hypertext markup language, cascading style sheet and JavaScript scripting language. In one embodiment, the first determination subunit can be used to perform the operation S311 described above, which will not be repeated here.
[0125] The second determination subunit is used to determine that the technology stack type of the code is one or more of Java language and Python language if the source code is determined to be backend code. In one embodiment, the second determination subunit can be used to perform the operation S311 described above, which will not be repeated here.
[0126] According to an embodiment of the present disclosure, the conversion unit includes a third determining subunit and a conversion subunit.
[0127] The third determination subunit is used to determine the target parsing strategy according to the technology stack type; in one embodiment, the third determination subunit can be used to perform the operation S410 described above, which will not be repeated here.
[0128] The conversion subunit is used to perform a first conversion on the source code based on the target parsing strategy to generate an abstract syntax tree. In one embodiment, the conversion subunit can be used to perform the operation S420 described above, which will not be described in detail here.
[0129] According to an embodiment of the present disclosure, the display module includes a monitoring submodule and a display submodule.
[0130] The monitoring submodule is used to monitor the real-time changes of the analysis report generated by the static code analysis tool. In one embodiment, the monitoring submodule can be used to perform the operation S240 described above, which will not be described in detail here.
[0131] The display submodule is used to highlight the error code according to the error and warning information in the analysis report. In one embodiment, the display submodule can be used to perform the operation S240 described above, which will not be described in detail here.
[0132] According to an embodiment of the present disclosure, any multiple modules of the code acquisition module 610, the code parsing module 620, the code analysis module 630 and the display module 640 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the code acquisition module 610, the code parsing module 620, the code analysis module 630 and the display module 640 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in a suitable combination of any of them. Alternatively, at least one of the code acquisition module 610 , the code parsing module 620 , the code analysis module 630 and the presentation module 640 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.
[0133] Figure 7 A block diagram of an electronic device suitable for implementing a static code analysis method for a low-code platform according to an embodiment of the present disclosure is schematically shown.
[0134] like Figure 7 As shown, the electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 to a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0135] In RAM 903, various programs and data required for the operation of electronic device 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other via bus 904. Processor 901 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0136] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The electronic device 900 may further include one or more of the following components connected to the input / output (I / O) interface 905: an input portion 906 including a keyboard, a mouse, etc.; an output portion 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 908 including a hard disk, etc.; and a communication portion 909 including a network interface card such as a LAN card, a modem, etc. The communication portion 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the input / output (I / O) interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage portion 908 as needed.
[0137] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0138] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.
[0139] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program includes a program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the low-code platform static code analysis method provided by the embodiment of the present disclosure.
[0140] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 901. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0141] In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of a signal on a network medium, and downloaded and installed through the communication part 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0142] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0143] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0144] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0145] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0146] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A static code analysis method for a low-code platform, characterized in that: The method comprises: In response to the user's editing operation on the low-code platform, obtaining source code generated by the low-code platform; Parsing the source code into an intermediate representation; Analyze the intermediate representation code using static code analysis tools; and Provide users with real-time feedback on code analysis results.
2. The method according to claim 1, characterized in that The converting the source code parsing into an intermediate representation comprises: Parsing the source code to determine the code type; Performing a first conversion on the source code according to the code type to generate an abstract syntax tree; and A second transformation is performed on the abstract syntax tree to generate an intermediate representation.
3. The method according to claim 2, characterized in that The first converting the source code according to the code type to generate an abstract syntax tree includes: Determining a technology stack type of the code according to the code type; and A first conversion is performed on the source code according to the technology stack type to generate an abstract syntax tree.
4. The method according to claim 3, characterized in that The code type includes front-end code and back-end code, and the technology stack type of the code determined according to the code type includes: If it is determined that the source code is a front-end code, the technology stack type of the code is determined to be one or more of Hypertext Markup Language, Cascading Style Sheets and JavaScript scripting language; If it is determined that the source code is backend code, the technology stack type of the code is determined to be one or more of Java and Python.
5. The method according to claim 4, characterized in that The first converting the source code according to the technology stack type to generate an abstract syntax tree comprises: Determining a target parsing strategy based on the technology stack type; and A first transformation is performed on the source code based on a target parsing strategy to generate an abstract syntax tree.
6. The method according to claim 1, characterized in that The real-time feedback of the code analysis result to the user includes: Monitor real-time changes in analysis reports generated by static code analysis tools; and Error codes are highlighted based on the error and warning messages in the analysis report.
7. A low-code platform static code analysis device, characterized in that: The device comprises: A code acquisition module, used to obtain source code generated by the low-code platform in response to the user's editing operation on the low-code platform; A code parsing module, used to parse and convert the source code into an intermediate representation; A code analysis module, used for analyzing the intermediate representation code using a static code analysis tool; and The display module is used to provide real-time feedback of code analysis results to users.
8. An electronic device comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Compiling method, electronic equipment and storage medium
CN120491980A