Software quality detection method and device and electronic equipment
By traversing the software component code and calculating the degree of abstraction and stability, the problem of single software quality detection dimension in the prior art is solved, and the accuracy of the detection results is improved.
Patent Information
- Application Number
- CN202411525258.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-18
AI Technical Summary
The existing software quality detection methods have a single detection dimension, resulting in inaccurate software quality detection results.
By obtaining the code file of the target software, traverse the component code of each component in sequence, determine the degree of abstraction based on class features, determine the degree of stability based on dependency features, and calculate the component's quality score based on these two dimensions to finally determine the software quality.
The accuracy of software quality detection results is improved, and the software quality is comprehensively judged through the two dimensions of abstraction and stability.
Smart Images

Figure CN119473851A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer software detection, and in particular to a software quality detection method, device and electronic equipment. Background Art
[0002] As the complexity of software engineering increases, software quality will deteriorate. The current method of testing software quality is usually to determine the software quality by testing the stability of the components in the software. This method has a relatively single testing dimension and the software quality test results are not accurate enough. Summary of the invention
[0003] In view of this, the present application provides a software quality detection method, device and electronic device to improve the accuracy of software quality detection results.
[0004] The technical solutions provided by this application are as follows:
[0005] According to an embodiment of the first aspect of the present application, a software quality detection method is provided, the method comprising:
[0006] Acquire a code file of the target software, wherein the code file includes component codes of a plurality of components;
[0007] Traversing the component code of each component in turn, determining the abstraction level of the component based on the class characteristics of the component code, and determining the stability level of the component based on the dependency characteristics of the component code; wherein the class characteristics represent the structural complexity of the component, and the dependency characteristics represent the dependency relationship between the component and other components;
[0008] Determine the quality score of the component according to its abstraction level and stability level;
[0009] The software quality of the target software is determined based on the quality score of each component.
[0010] Optionally, the class characteristics of the component code include the total number of classes in the component and the number of abstract classes in the component, and determining the abstraction level of the component based on the class characteristics of the component code includes:
[0011] Divide the number of the abstract classes by the total number of the classes to obtain the abstraction level of the component; wherein the component code includes multiple classes, the multiple classes include abstract classes and concrete classes, the classes are used to define the relevant data and functions of the component, and the abstract classes are used to define the general interface and basic functions of the component.
[0012] Optionally, the dependency characteristics of the component code include the number of components that the component depends on and the number of components that the component depends on. Determining the stability of the component based on the dependency characteristics of the component code includes:
[0013] The number of components that the component depends on and the number of components that the component depends on are summed to obtain the target sum; wherein the components that the component depends on refer to other components that provide the required services for the component so that the component can be executed; the components that the component depends on refer to other components that can only be executed by relying on the services provided by the component;
[0014] The number of components that the component depends on is divided by the target sum to obtain the stability of the component.
[0015] Optionally, determining the quality score of the component according to the abstraction level and stability level of the component includes:
[0016] Determine a coordinate point corresponding to the component in the established target coordinate system based on the abstraction level and stability level of the component, wherein the abscissa of the coordinate point is the abstraction level of the component, and the ordinate of the coordinate point is the stability level of the component, or the abscissa of the coordinate point is the stability level of the component, and the ordinate of the coordinate point is the abstraction level of the component;
[0017] A target standard line is generated in the target coordinate system based on a value range of the degree of abstraction and the degree of stability; a quality score of the component is determined based on a distance between a coordinate point of the component in the target coordinate system and the target standard line; wherein the distance is inversely proportional to the quality score.
[0018] Optionally, the value range based on the abstraction level and the stability level generates a target standard line in the target coordinate system, including:
[0019] Determine a first target point and a second target point in the target coordinate system according to the value ranges of the abstraction degree and the stability degree; wherein the first target point refers to a coordinate point corresponding to the minimum value of the abstraction degree and the maximum value of the stability degree, and the second target point refers to a coordinate point corresponding to the maximum value of the abstraction degree and the minimum value of the stability degree;
[0020] The straight line where the first target point and the second target point are located is determined as the target standard line.
[0021] Optionally, determining the software quality of the target software based on the quality score of each component includes:
[0022] The average value of the quality scores of all components is determined as the quality score of the target software; if the quality score of the target software is less than a first score value, the software quality of the target software is determined to be degraded software; if the quality score of the target software is not less than the first score value, the software quality of the target software is determined to be qualified software;
[0023] Alternatively, for each component, if the quality score of the component is less than the second score value, the quality result of the component is determined to be a degraded component; if the number of degraded components among the components included in the target software is greater than a preset number, the software quality of the target software is determined to be degraded software; if the number of degraded components among the components included in the target software is not greater than a preset number, the software quality of the target software is determined to be qualified software.
[0024] Optionally, the method further includes:
[0025] When the code file of the target software is modified, the modified code file is packaged by a continuous integration CI process, and an operation of obtaining the modified code file of the target software is performed at the same time;
[0026] After determining the software quality of the target software based on the quality score of each component, the method further includes:
[0027] If it is detected that the software quality of the target software is degraded software and the current CI process packaging has not yet ended, the step of CI process packaging is stopped to debug the target software;
[0028] If it is detected that the quality result of the target software is qualified software and the current CI process packaging has not yet ended, the CI process packaging step is continued to generate an executable file of the target software.
[0029] According to an embodiment of the second aspect of the present application, a software quality detection device is provided, the device comprising:
[0030] An acquisition unit, configured to acquire a code file of a target software, wherein the code file includes component codes of a plurality of components;
[0031] A traversal unit, used to traverse the component code of each component in turn, determine the abstraction level of the component based on the class characteristics of the component code, and determine the stability level of the component based on the dependency characteristics of the component code; wherein the class characteristics represent the structural complexity of the component, and the dependency characteristics represent the dependency relationship between the component and other components;
[0032] A determination unit, used for determining a quality score of the component according to the abstraction level and stability level of the component;
[0033] The detection unit is used to determine the software quality of the target software based on the quality score of each component.
[0034] Optionally, the class characteristics of the component code include the total number of classes in the component and the number of abstract classes in the component, and the traversal unit is specifically used for:
[0035] Dividing the number of the abstract classes by the total number of the classes to obtain the abstraction level of the component; wherein the component code includes multiple classes, the multiple classes include abstract classes and concrete classes, the classes are used to define the relevant data and functions of the component, and the abstract classes are used to define the general interface and basic functions of the component;
[0036] And / or, the dependency characteristics of the component code include the number of components that the component depends on and the number of components that the component depends on, and the traversal unit is specifically used to:
[0037] The number of components that the component depends on and the number of components that the component depends on are summed to obtain the target sum; wherein the components that the component depends on refer to other components that provide the required services for the component so that the component can be executed; the components that the component depends on refer to other components that can only be executed by relying on the services provided by the component;
[0038] Divide the number of components that the component depends on by the target sum to obtain the stability of the component;
[0039] And / or, the determining unit is specifically configured to:
[0040] Determine a coordinate point corresponding to the component in the established target coordinate system based on the abstraction level and stability level of the component, wherein the abscissa of the coordinate point is the abstraction level of the component, and the ordinate of the coordinate point is the stability level of the component, or the abscissa of the coordinate point is the stability level of the component, and the ordinate of the coordinate point is the abstraction level of the component;
[0041] Generate a target standard line in the target coordinate system based on the value range of the abstraction degree and the stability degree; determine the quality score of the component based on the distance between the coordinate point of the component in the target coordinate system and the target standard line; wherein the distance is inversely proportional to the quality score;
[0042] And / or, the determining unit is specifically configured to:
[0043] Determine a first target point and a second target point in the target coordinate system according to the value ranges of the abstraction degree and the stability degree; wherein the first target point refers to a coordinate point corresponding to the minimum value of the abstraction degree and the maximum value of the stability degree, and the second target point refers to a coordinate point corresponding to the maximum value of the abstraction degree and the minimum value of the stability degree;
[0044] Determine the straight line where the first target point and the second target point are located as the target standard line;
[0045] And / or, the detection unit is specifically used for:
[0046] The average value of the quality scores of all components is determined as the quality score of the target software; if the quality score of the target software is less than a first score value, the software quality of the target software is determined to be degraded software; if the quality score of the target software is not less than the first score value, the software quality of the target software is determined to be qualified software;
[0047] Alternatively, for each component, if the quality score of the component is less than the second score value, the quality result of the component is determined to be a degraded component; if the number of degraded components in the components included in the target software is greater than a preset number, the software quality of the target software is determined to be degraded software; if the number of degraded components in the components included in the target software is not greater than a preset number, the software quality of the target software is determined to be qualified software;
[0048] And / or, the acquisition unit is further used for:
[0049] When the code file of the target software is modified, the modified code file is packaged by a continuous integration CI process, and an operation of obtaining the modified code file of the target software is performed at the same time;
[0050] After determining the software quality of the target software based on the quality score of each component, the detection unit is further used for:
[0051] If it is detected that the software quality of the target software is degraded software and the current CI process packaging has not yet ended, the step of CI process packaging is stopped to debug the target software;
[0052] If it is detected that the quality result of the target software is qualified software and the current CI process packaging has not yet ended, the CI process packaging step is continued to generate an executable file of the target software.
[0053] According to an embodiment of the third aspect of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the program.
[0054] It can be seen from the above technical scheme that the present application targets the component code of each component included in the target software that needs to be quality tested, determines the abstraction level of the component through the class characteristics of the component code, and determines the stability level of the component through the dependency characteristics of the component code, further determines the quality score of the component according to the abstraction level and the stability level, determines the software quality of the target software according to the quality score of each component, and comprehensively judges the software quality of the target software through the two dimensions of abstraction level and stability level, thereby improving the accuracy of the software quality test results. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0056] Figure 1 A flowchart of a software quality detection method provided in an embodiment of the present application;
[0057] Figure 2 A schematic diagram of the relationship between classes and abstract classes provided in the embodiments of the present application;
[0058] Figure 3A A schematic diagram of dependencies between components provided in an embodiment of the present application;
[0059] Figure 3B Another schematic diagram of dependencies between components provided in an embodiment of the present application;
[0060] Figure 4 A schematic diagram of a target coordinate system provided in an embodiment of the present application;
[0061] Figure 5 A schematic diagram of a software quality detection device provided in an embodiment of the present application;
[0062] Figure 6 A flowchart of a software quality detection method based on a software quality detection device provided in an embodiment of the present application;
[0063] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0064] Figure 8 A structural diagram of a software quality detection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.
[0066] Please refer to Figure 1 , Figure 1 A flowchart of a software quality detection method provided in an embodiment of the present application.
[0067] like Figure 1 As shown, the method may include the following steps:
[0068] Step 101, obtaining a code file of the target software, the code file including component codes of multiple components.
[0069] In this embodiment, the target software is the software that needs to be tested for software quality. Software is a complete system, including code, resources, configuration, and documents that implement specific functions, while a component is a subset of the software. A component can be a functional module in the software that can be developed, tested, and maintained independently. A software can be composed of one or more components.
[0070] In addition, the software can implement its specific functions through the code file of the software. For the multiple components included in the software, each component also has its corresponding component code, which is used to implement the sub-functions of the component, that is, the component code corresponding to each component is part of the code file of the software.
[0071] As an embodiment, if the target software is open source software, the code file of the target software can be directly obtained by accessing the code library of the target software; if the target software is non-open source software, the code file of the target software can be obtained by viewing the software documentation, etc. This application does not limit the specific method of obtaining the code file of the target software.
[0072] Since the target software includes at least one component, in this embodiment, each component in the target software can be quality tested, and the software quality of the target software can be further determined based on the quality test results of each component included in the target software. Therefore, after the code file of the target software is obtained, the component code corresponding to each component included in the target software can be obtained from the code file of the target software.
[0073] As an embodiment, after obtaining the code file of the target software, the component code corresponding to each component can be determined through the directory structure of the target software, the configuration file of the build tool, etc., and this application does not limit this.
[0074] At this point, the description of step 101 ends, and step 102 is executed next.
[0075] Step 102, traverse the component code of each component in turn, determine the abstraction level of the component based on the class characteristics of the component code, and determine the stability level of the component based on the dependency characteristics of the component code.
[0076] After obtaining the component code of each component included in the target software, the component code of each component may be traversed in sequence, and for the component code of each component, the class characteristics and dependency characteristics of the component code may be determined.
[0077] In this embodiment, the class feature of the component code represents the structural complexity of the component and is used to characterize the abstraction level of the component; the dependency feature of the component code represents the dependency relationship between the component and other components and is used to characterize the stability of the component.
[0078] The following first briefly introduces the class characteristics of component code and the method of determining the degree of component abstraction through class characteristics.
[0079] In this embodiment, the class characteristics of the component code may include the total number of classes in the component and the number of abstract classes in the component. The specific method for determining the abstraction level of the component based on the class characteristics of the component code may include:
[0080] Divide the number of abstract classes by the total number of classes to obtain the abstraction level of the component; wherein the component code includes multiple classes, the multiple classes include abstract classes and concrete classes, the classes are used to define the relevant data and functions of the component, and the abstract classes are used to define the general interface and basic functions of the component.
[0081] In this embodiment, for each component included in the target software, the abstraction level of the component can be used as a dimension for evaluating the quality of the component. The abstraction level of the component can be determined by the class characteristics of the component, that is, the total number of classes included in the component and the number of abstract classes in the component, wherein the total number of classes included in the component and the number of abstract classes in the component can be determined by the component code corresponding to the component.
[0082] In this embodiment, a component may be composed of multiple classes, and the internal logic of the component may be implemented through these classes. The classes are used to define the relevant data and functions of the component.
[0083] Below through Figure 2 Briefly describe the relationship between classes and abstract classes.
[0084] Please refer to Figure 2 , Figure 2 A schematic diagram of the relationship between classes and abstract classes provided in an embodiment of the present application.
[0085] like Figure 2 As shown, in each component, classes can be divided into abstract classes and concrete classes, wherein the abstract class can be used to define the general interface and basic functions of the component, and the concrete class can be used to implement abstract methods, extend functions, and provide specific data, etc. This application does not impose any restrictions on this.
[0086] In actual applications, components may contain mixed classes according to design requirements, that is, both abstract classes and concrete classes, to achieve a more flexible architecture and reusability; similarly, the classes included in the component can all be abstract classes or all be concrete classes, and this application does not impose any restrictions on this.
[0087] This concludes Figure 2 Introduction to the relationship between classes and abstract classes.
[0088] As an embodiment, a static code analysis tool such as SonarQube, JArchitect or PyLint may be used to scan the component code corresponding to the component, thereby obtaining class statistics to determine the total number of classes included in the component and the number of abstract classes in the component.
[0089] As an embodiment, a specific script may be used to traverse the component code corresponding to the component to find class definitions and abstract class definitions, thereby determining the total number of classes included in the component and the number of abstract classes in the component. This application does not impose any restrictions on this.
[0090] After determining the total number of classes included in the component and the number of abstract classes in the component, the abstraction level of the component may be determined based on the total number of classes included in the component and the number of abstract classes in the component.
[0091] Specifically, the number of abstract classes can be divided by the total number of classes to obtain the abstraction level of the component.
[0092] In this embodiment, the number of abstract classes in the component (denoted as X) can be divided by the total number of classes included in the component (denoted as Y), and the value X / Y obtained by dividing the two is determined as the abstraction level of the component (denoted as s), that is:
[0093]
[0094] Since the minimum number X of abstract classes in a component is 0 (i.e., the component does not include any abstract classes) and the maximum number is the same as the total number Y of classes included in the component (i.e., all classes included in the component are abstract classes), the value range of the abstraction degree s is [0,1]. The greater the abstraction degree, the higher the abstraction degree and the higher the degree of encapsulation of the component; the smaller the abstraction degree, the lower the abstraction degree and the lower the degree of encapsulation of the component.
[0095] The following is a brief introduction to the dependency characteristics of component code and the method of determining the stability of components through dependency characteristics.
[0096] In this embodiment, the dependency characteristics of the component code include the number of components that the component depends on and the number of components that the component depends on. The specific method for determining the stability of the component based on the dependency characteristics of the component code may include:
[0097] The number of components that the component depends on and the number of components that the component depends on are summed to obtain the target sum; wherein the components that the component depends on refer to other components that provide the required services for the component to enable the component to execute; the components that the component depends on refer to other components that can only be executed by relying on the services provided by the component;
[0098] Divide the number of components that the component depends on by the target sum to get the stability of the component.
[0099] In this embodiment, for each component included in the target software, the stability of the component can also be used as another dimension to evaluate the quality of the component. The stability of the component can be determined by the dependency characteristics of the component, that is, the number of components that the component depends on and the number of components that the component is dependent on.
[0100] In this embodiment, the number of components that a component depends on refers to the total number of other components required by the component during its implementation, that is, the number of other components that provide the required services for the component to enable the component to execute; the number of components that the component depends on refers to the total number of other components that require the participation of the target component during the implementation process, that is, the number of other components that can only be executed by relying on the services provided by the component.
[0101] Below through Figure 3A as well as Figure 3B Provide a brief description of the dependencies between components.
[0102] Please refer to Figure 3A , Figure 3A A diagram of dependencies between components.
[0103] like Figure 3A As shown, component A depends on component B, component C and component D during the implementation process. If one or more of component B, component C and component D cannot run normally, component A cannot run normally. It can be seen that the number of components that component A depends on is 3, namely component B, component C and component D.
[0104] Please refer to Figure 3B , Figure 3B Another diagram of dependencies between components.
[0105] like Figure 3B As shown, component F, component G, and component H all depend on component E during the implementation process. If component E cannot run normally, then component F, component G, and component H cannot run normally. It can be seen that the number of components that component E depends on is 3, namely component F, component G, and component H.
[0106] This concludes the description of dependencies between components.
[0107] In this embodiment, the number of components that a component depends on and the number of components that are depended on can be obtained by viewing the configuration file of the component or using a dependency management tool, and this application does not limit this.
[0108] For each component, after determining the number of components that the component depends on and the number of components that are depended on, the stability of the component can be determined based on the number of components that the component depends on and the number of components that are depended on.
[0109] Specifically, the number of components that the component depends on and the number of components that the component is dependent on may be summed to obtain a target sum; and the number of components that the component depends on may be divided by the target sum to obtain the stability of the component.
[0110] In this embodiment, the number of components that the component depends on can be recorded as P, and the number of components that the component is dependent on can be recorded as Q. Then the stability of the component (referred to as r) can be determined by the following formula:
[0111]
[0112] Since the minimum number of components P that the component depends on is 0 (that is, the component does not depend on any component), and the minimum number of components Q that the component depends on is also 0 (that is, the component is not dependent on any component), and P and Q are not 0 at the same time, the value range of the stability r is [0,1]. The larger the value of the stability, the more unstable the component is; the smaller the value of the stability, the more stable the component is.
[0113] It should be noted that there is actually no fixed time sequence for determining the degree of abstraction and the degree of stability in step 102. When the method is actually executed, the degree of abstraction of the component can be determined first, and then the degree of stability of the component; the degree of stability of the component can be determined first, and then the degree of abstraction of the component; or both steps can be performed simultaneously, and this application does not limit this.
[0114] At this point, the description of step 102 ends, and step 103 is executed next.
[0115] Step 103: Determine the quality score of the component according to the abstraction level and stability level of the component.
[0116] In this embodiment, for each component, after the abstraction level and stability level of the component are determined, the quality score of the component may be further determined according to the abstraction level and stability level of the component.
[0117] As an embodiment, a specific method for determining the quality score of a component according to the abstraction level and stability level of the component may include:
[0118] Determine a coordinate point corresponding to the component in the established target coordinate system based on the abstraction level and stability level of the component, wherein the abscissa of the coordinate point is the abstraction level of the component, and the ordinate of the coordinate point is the stability level of the component, or the abscissa of the coordinate point is the stability level of the component, and the ordinate of the coordinate point is the abstraction level of the component;
[0119] A target standard line is generated in the target coordinate system based on the value range of the abstraction level and the stability level; a quality score of the component is determined based on the distance between the coordinate point of the component in the target coordinate system and the target standard line; wherein the distance is inversely proportional to the quality score.
[0120] In this embodiment, the target coordinate system can be established by taking the component's abstraction level as the horizontal coordinate and the component's stability level as the vertical coordinate; or the component's stability level can be taken as the horizontal coordinate and the component's abstraction level as the vertical coordinate, and this application does not impose any restrictions on this.
[0121] The following example uses the abstraction level s as the horizontal coordinate (x-axis) and the stability level r as the vertical coordinate (y-axis) to establish a target coordinate system.
[0122] It is easy to understand that according to the degree of abstraction and stability of each component, the corresponding coordinate point of the component can be found in the target coordinate system. For example, if the degree of abstraction of component A is 0.4 and the degree of stability is 0.6, then the target coordinate point in the corresponding coordinate system is (0.4, 0.6).
[0123] Since the value range of abstraction level and stability level is [0,1], the possible range of coordinate points in the target coordinate system is the square enclosed by the points (0,0), (0,1), (1,0), and (1,1) as vertices.
[0124] Furthermore, a target standard line may be generated in the target coordinate system based on the value ranges of the abstraction level and the stability level; and a quality score of the component may be determined based on the distance between the coordinate point of the component in the target coordinate system and the target standard line.
[0125] As an embodiment, a specific method for generating a target standard line in a target coordinate system based on the value range of the abstraction level and the stability level may include:
[0126] Determine a first target point and a second target point in the target coordinate system according to the value range of the abstraction degree and the stability degree; wherein the first target point refers to a coordinate point corresponding to the minimum value of the abstraction degree and the maximum value of the stability degree, and the second target point refers to a coordinate point corresponding to the maximum value of the abstraction degree and the minimum value of the stability degree;
[0127] The straight line where the first target point and the second target point are located is determined as the target standard line.
[0128] In this embodiment, according to the value range [0,1] of the abstraction level and the stability level, the coordinate point (0,1) corresponding to the minimum abstraction level and the maximum stability level can be determined as the first target point, and the coordinate point (1,0) corresponding to the maximum abstraction level and the minimum stability level can be determined as the second target point, and the straight line where the first target point and the second target point are located (that is, the straight line with the analytical expression y=-x+1) is used as the target standard line.
[0129] For each component, a quality score of the component may be determined based on a distance between a coordinate point of the component in the target coordinate system and a target standard line, wherein the distance is inversely proportional to the quality score.
[0130] As an example, the distance between the origin (0,0) and the target standard line can be used as a reference, and the distance is recorded as a reference distance l (0,0) It is easy to understand that the distance between the origin and the target standard line is the farthest distance between the coordinate point corresponding to each component in the target coordinate system and the target standard line. The distance between the coordinate point corresponding to the component and the target standard line is denoted as l (x,y) , then the quality score t of the component (in percentage) can be:
[0131]
[0132] In this embodiment, the distance between the coordinate point corresponding to the component and the target standard line is l (x,y) The smaller it is, the higher the quality score of the component is. The distance l between the coordinate point corresponding to the component and the target standard line (x,y) The larger it is, the lower the quality score of the component.
[0133] Combine the following Figure 4 A brief introduction to the calculation of component quality scores is given.
[0134] Please refer to Figure 4 , Figure 4 A schematic diagram of the target coordinate system provided in an embodiment of the present application.
[0135] like Figure 4 As shown, the target coordinate system takes the abstraction level s as the x-axis and the stability level as the y-axis, where the straight line between the point (0,1) and the point (1,0) (the analytical expression is y=-x+1) is the target standard line.
[0136] In this embodiment, point M (0.2, 0.5) and point (0.9, 0.7) are coordinate points corresponding to two different components (referred to as component 1 and component 2). It is easy to understand that the abstraction level s of component 1 is 0.2 and the stability level r is 0.5; the abstraction level s of component 2 is 0.9 and the stability level r is 0.7.
[0137] In this embodiment, the distance d1 (i.e., l ) from point M to the target standard line can be calculated based on the coordinates of point M (0.2, 0.5) and the analytical expression y=-x+1 of the target standard line. (0.2,0.5) ) is about 0.21, and the distance between the origin (0,0) and the target standard line is 0.71 (i.e. l (0,0) ), so the quality score of the component corresponding to point M is [1-(0.21 / 0.71)]*100=70.
[0138] Similarly, the quality score of the component corresponding to point N can be calculated as 40 in the same way.
[0139] This concludes Figure 4 And the description of step 103, step 104 is performed below.
[0140] Step 104 : determining the software quality of the target software based on the quality score of each component.
[0141] In this embodiment, after determining the quality score of each component, the software quality of the target software can be determined according to the quality score of each component.
[0142] As an embodiment, the method for determining the target software quality result may include:
[0143] The average of the quality scores of all components is determined as the quality score of the target software;
[0144] If the quality score of the target software is less than the first score value, determining that the software quality of the target software is degraded software;
[0145] If the quality score of the target software is not less than the first score value, the software quality of the target software is determined to be qualified software.
[0146] In this embodiment, the average value of the quality scores of all components may be used as the quality score of the target software. If the quality score of the target software is less than a preset first score value, the target software is determined to be degraded software, that is, software with unqualified quality.
[0147] For example, the above Figure 4 Taking the illustrated embodiment as an example, the average quality score of component 1 and component 2 is (70+40) / 2=55 points. Assuming that the preset first score is 60 points, it indicates that the target software is degraded software.
[0148] As an embodiment, the method for determining the target software quality result may further include:
[0149] For each component, if the quality score of the component is less than a second score value, determining the quality result of the component as a degraded component;
[0150] If the number of degraded components in the components included in the target software is greater than a preset number, determining that the software quality of the target software is degraded software;
[0151] If the number of degraded components among the components included in the target software is not greater than a preset number, the software quality of the target software is determined to be qualified software.
[0152] In this embodiment, the quality result of each component may also be determined first according to the quality score of each component and a preset second score value.
[0153] For example, still using the above Figure 4 Taking the illustrated embodiment as an example, the quality score of component 1 is 70 points, and the quality score of component 2 is 40 points. Assuming that the preset second score value is 50 points, component 1 is a normal component, and component 2 is a degraded component.
[0154] Furthermore, the software quality of the target software may be determined according to a preset maximum number of degraded components.
[0155] For example, if the preset maximum number of degraded components is 1, and there is only one degraded component, component 2, in the target software, it means that the number of degraded components in the components included in the target software is not greater than the preset number, and the software quality of the target component is determined to be qualified software.
[0156] This concludes the description of step 104.
[0157] In this embodiment, the method proposed in this embodiment may further include:
[0158] When the code file of the target software is modified, the modified code file is packaged by the continuous integration CI process, and at the same time, an operation of obtaining the modified code file of the target software is performed;
[0159] After determining the software quality of the target software based on the quality score of each component, the method further includes:
[0160] If it is detected that the software quality of the target software is degraded software and the current CI process packaging has not yet ended, the CI process packaging step is stopped to debug the target software;
[0161] If it is detected that the quality result of the target software is qualified software and the current CI process packaging has not yet ended, the CI process packaging step will continue to generate an executable file of the target software.
[0162] In this embodiment, it is easy to understand that the timing of performing software quality detection on the target software can be when the code file of the target software is modified. If the code file of the target software changes, it indicates that the software quality of the target software may have deteriorated, and the software quality of the target software needs to be detected after the code file of the target software is modified.
[0163] Exemplarily, the code file of the target software is modified, which may include functional expansion, functional adjustment or code reconstruction of the software, and the present application does not limit this.
[0164] As an embodiment, it is determined that the target software needs to be quality tested, and the code file of the target software can be obtained at this time, and the code file refers to the modified code file of the target software. At the same time, the modified code file can be packaged by the continuous integration CI process to obtain the executable file of the target software and update the target software.
[0165] After determining the software quality of the target software based on the quality score of each component, if the software quality of the target software is determined to be degraded software, it indicates that running the target software according to the current code may cause exceptions. At this time, if the CI process packaging step has not yet ended, the CI process packaging step can be stopped, and the target software can be further debugged to avoid the target software running abnormally and causing its functions to fail to be realized; if the software quality of the target software is determined to be qualified software, it indicates that running the software according to the current code will not cause exceptions under normal circumstances, and the CI process packaging step can be continued to generate an executable file of the target software.
[0166] The above method is to simultaneously perform quality inspection on the target software during the CI process packaging process, and can directly terminate the CI process packaging when it is detected that the software quality of the target software is degraded software, so as to further debug the target software.
[0167] As an embodiment, when the code file of the target software is modified, the modified code file can also be obtained before the modified code file is packaged by the continuous integration CI process, and when it is detected that the software quality of the target software is degraded software, the execution of the CI process packaging is prohibited; when it is detected that the software quality of the target software is qualified software, the steps of executing the CI process packaging are started.
[0168] In this embodiment, the quality score of each component, the quality score of the target software, and the quality result of the target software can also be sent to a corresponding display device to display the above information to the user through the display device, and this application does not limit this.
[0169] This concludes Figure 1Description of the software quality detection method flowchart.
[0170] The present application targets the component code of each component included in the target software that needs to be quality tested, determines the abstraction level of the component through the class characteristics of the component code, and determines the stability level of the component through the dependency characteristics of the component code, further determines the quality score of the component according to the abstraction level and the stability level, determines the software quality of the target software according to the quality score of each component, comprehensively judges the software quality of the target software through the two dimensions of abstraction level and stability level, and improves the accuracy of the software quality test results.
[0171] The following describes a software quality detection device proposed in an embodiment of the present application through a specific embodiment.
[0172] Please refer to Figure 5 , Figure 5 A schematic diagram of a software quality detection device proposed in an embodiment of the present application.
[0173] like Figure 5 As shown, in this embodiment, the software quality detection device may include: an analysis device and a quality result UI module.
[0174] Specifically, the analysis device may include:
[0175] A component stability and abstraction calculation module, used to traverse the component code of each component in turn, determine the abstraction level of the component based on the class characteristics of the component code, and determine the stability level of the component based on the dependency characteristics of the component code;
[0176] A chart drawing module, for establishing a target coordinate system according to the abstraction degree and stability degree of the components, determining the coordinate point corresponding to each component in the target coordinate system based on the abstraction degree and stability degree of each component, and generating a target standard line in the target coordinate system based on the value range of the abstraction degree and stability degree;
[0177] A data analysis module, used to determine the quality score of the component based on the distance between the coordinate point of the component in the target coordinate system and the target standard line, and determine the software quality of the target software based on the quality score of each component;
[0178] The packaging and compilation termination module is used to stop the CI process packaging step if it is detected that the software quality of the target software is degraded software and the current CI process packaging has not yet ended, so as to debug the target software.
[0179] The quality result UI module can be used to send the quality score of each component, the quality score of the target software, and the quality result of the target software to the corresponding display device, so as to display the above information to the user through the display device.
[0180] This concludes Figure 5 Description of the schematic diagram of the software quality detection device.
[0181] Below through Figure 6 Based on Figure 5 The software quality detection method of the software quality detection device is introduced.
[0182] Please refer to Figure 6 , Figure 6 A flowchart of a software quality detection method based on a software quality detection device provided in an embodiment of the present application.
[0183] like Figure 6 As shown, the method may include the following steps:
[0184] Step 601, engineering integration device.
[0185] In this embodiment, the target software that needs to be tested for software quality can be integrated in advance. Figure 5 The software quality detection device shown.
[0186] Step 602: The user modifies the code.
[0187] In this embodiment, the user modifies the code file of the target software.
[0188] Step 603: The user submits the code.
[0189] In this embodiment, the user submits the code modification to the target software in step 602 to generate a modified code file.
[0190] Step 604, the device automatically detects.
[0191] In this embodiment, after the user submits the code and a modified code file is generated, the software quality of the target software can be tested by the deployed software quality testing device.
[0192] Step 605: software quality analysis.
[0193] In this embodiment, the deployed software quality detection device is based on Figure 1 The method in the invention determines the abstraction degree of each component included in the target software that needs to be quality tested through the class characteristics of the component code, and determines the stability degree of the component through the dependency characteristics of the component code, and further determines the quality score of the component according to the abstraction degree and the stability degree, and determines the software quality of the target software according to the quality score of each component.
[0194] Step 606, result feedback.
[0195] In this embodiment, the software quality of the target software is fed back to the user through the quality result UI module in the software quality detection device, so that the user can perform subsequent operations.
[0196] This concludes Figure 6 Description of the flow chart in .
[0197] Please refer to Figure 7 , Figure 7 It is a schematic structural diagram of an electronic device proposed in an embodiment of the present application. At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and of course may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a terminal interaction device at the logical level. Of course, in addition to the software implementation method, this application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0198] Please refer to Figure 8 , Figure 8 : is a structural diagram of a software quality detection device proposed in the embodiment of the present application. Figure 8 As shown, the software quality detection device may include an acquisition unit 801, a traversal unit 802, a determination unit 803 and a detection unit 804. Specifically, the device includes:
[0199] An acquisition unit 801 is used to acquire a code file of a target software, where the code file includes component codes of multiple components;
[0200] A traversal unit 802 is used to traverse the component code of each component in turn, determine the abstraction level of the component based on the class characteristics of the component code, and determine the stability level of the component based on the dependency characteristics of the component code; wherein the class characteristics represent the structural complexity of the component, and the dependency characteristics represent the dependency relationship between the component and other components;
[0201] A determination unit 803, configured to determine a quality score of the component according to the abstraction level and stability level of the component;
[0202] The detection unit 804 is used to determine the software quality of the target software based on the quality score of each component.
[0203] Optionally, the class characteristics of the component code include the total number of classes in the component and the number of abstract classes in the component. The traversal unit 802 is specifically used for:
[0204] Divide the number of abstract classes by the total number of classes to get the abstraction level of the component; wherein the component code includes multiple classes, and the multiple classes include abstract classes and concrete classes. The classes are used to define the relevant data and functions of the component, and the abstract classes are used to define the general interface and basic functions of the component;
[0205] And / or, the dependency characteristics of the component code include the number of components that the component depends on and the number of components that the component depends on, and the traversal unit 802 is specifically used for:
[0206] The number of components that the component depends on and the number of components that the component depends on are summed to obtain the target sum; wherein the components that the component depends on refer to other components that provide the required services for the component to enable the component to execute; the components that the component depends on refer to other components that can only be executed by relying on the services provided by the component;
[0207] Divide the number of components that the component depends on by the target sum to get the stability of the component;
[0208] And / or, the determining unit 803 is specifically configured to:
[0209] Determine a coordinate point corresponding to the component in the established target coordinate system based on the abstraction level and stability level of the component, wherein the abscissa of the coordinate point is the abstraction level of the component, and the ordinate of the coordinate point is the stability level of the component, or the abscissa of the coordinate point is the stability level of the component, and the ordinate of the coordinate point is the abstraction level of the component;
[0210] Generate a target standard line in the target coordinate system based on the value range of the abstraction degree and the stability degree; determine the quality score of the component based on the distance between the coordinate point of the component in the target coordinate system and the target standard line; wherein the distance is inversely proportional to the quality score;
[0211] And / or, the determining unit 803 is specifically configured to:
[0212] Determine a first target point and a second target point in the target coordinate system according to the value range of the abstraction degree and the stability degree; wherein the first target point refers to a coordinate point corresponding to the minimum value of the abstraction degree and the maximum value of the stability degree, and the second target point refers to a coordinate point corresponding to the maximum value of the abstraction degree and the minimum value of the stability degree;
[0213] The straight line where the first target point and the second target point are located is determined as the target standard line;
[0214] And / or, the detection unit 804 is specifically used for:
[0215] The average value of the quality scores of all components is determined as the quality score of the target software; if the quality score of the target software is less than the first score value, the software quality of the target software is determined to be degraded software; if the quality score of the target software is not less than the first score value, the software quality of the target software is determined to be qualified software;
[0216] Alternatively, for each component, if the quality score of the component is less than the second score value, the quality result of the component is determined to be a degraded component; if the number of degraded components in the components included in the target software is greater than a preset number, the software quality of the target software is determined to be degraded software; if the number of degraded components in the components included in the target software is not greater than a preset number, the software quality of the target software is determined to be qualified software;
[0217] And / or, the acquiring unit 801 is further configured to:
[0218] When the code file of the target software is modified, the modified code file is packaged by the continuous integration CI process, and at the same time, an operation of obtaining the modified code file of the target software is performed;
[0219] After determining the software quality of the target software based on the quality score of each component, the detection unit is further used to:
[0220] If it is detected that the software quality of the target software is degraded software and the current CI process packaging has not yet ended, the CI process packaging step is stopped to debug the target software;
[0221] If it is detected that the quality result of the target software is qualified software and the current CI process packaging has not yet ended, the CI process packaging step will continue to generate an executable file of the target software.
[0222] So far, completed Figure 8 Description of the software quality detection device in .
[0223] Correspondingly, in this embodiment, the embodiment of the present application also provides a computer-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed, the method disclosed in the above example of the present application can be implemented.
[0224] Exemplarily, the computer-readable storage medium may be any electronic, magnetic, optical or other physical storage device that may contain or store information, such as executable instructions, data, etc. For example, the computer-readable storage medium may be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof.
[0225] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the scope of protection of the present application.
Claims
1. A software quality detection method, characterized in that: The method includes: Acquire a code file of the target software, wherein the code file includes component codes of a plurality of components; Traversing the component code of each component in turn, determining the abstraction level of the component based on the class characteristics of the component code, and determining the stability level of the component based on the dependency characteristics of the component code; wherein the class characteristics represent the structural complexity of the component, and the dependency characteristics represent the dependency relationship between the component and other components; Determine the quality score of the component according to its abstraction level and stability level; The software quality of the target software is determined based on the quality score of each component.
2. The method according to claim 1, characterized in that The class characteristics of the component code include the total number of classes in the component and the number of abstract classes in the component. The abstraction level of the component is determined based on the class characteristics of the component code, including: Divide the number of the abstract classes by the total number of the classes to obtain the abstraction level of the component; wherein the component code includes multiple classes, the multiple classes include abstract classes and concrete classes, the classes are used to define the relevant data and functions of the component, and the abstract classes are used to define the general interface and basic functions of the component.
3. The method according to claim 1, characterized in that The dependency characteristics of the component code include the number of components that the component depends on and the number of components that the component is dependent on. The stability of the component is determined based on the dependency characteristics of the component code, including: The number of components that the component depends on and the number of components that the component depends on are summed to obtain the target sum; wherein the components that the component depends on refer to other components that provide the required services for the component so that the component can be executed; the components that the component depends on refer to other components that can only be executed by relying on the services provided by the component; The number of components that the component depends on is divided by the target sum to obtain the stability of the component.
4. The method according to claim 1, characterized in that: Determining the quality score of the component according to the abstraction level and stability level of the component includes: Determine a coordinate point corresponding to the component in the established target coordinate system based on the abstraction level and stability level of the component, wherein the abscissa of the coordinate point is the abstraction level of the component, and the ordinate of the coordinate point is the stability level of the component, or the abscissa of the coordinate point is the stability level of the component, and the ordinate of the coordinate point is the abstraction level of the component; A target standard line is generated in the target coordinate system based on a value range of the degree of abstraction and the degree of stability; a quality score of the component is determined based on a distance between a coordinate point of the component in the target coordinate system and the target standard line; wherein the distance is inversely proportional to the quality score.
5. The method according to claim 4, characterized in that The value range based on the abstraction level and the stability level generates a target standard line in the target coordinate system, including: Determine a first target point and a second target point in the target coordinate system according to the value ranges of the abstraction degree and the stability degree; wherein the first target point refers to a coordinate point corresponding to the minimum value of the abstraction degree and the maximum value of the stability degree, and the second target point refers to a coordinate point corresponding to the maximum value of the abstraction degree and the minimum value of the stability degree; The straight line where the first target point and the second target point are located is determined as the target standard line.
6. The method according to claim 1, characterized in that The determining the software quality of the target software based on the quality score of each component includes: The average value of the quality scores of all components is determined as the quality score of the target software; if the quality score of the target software is less than a first score value, the software quality of the target software is determined to be degraded software; if the quality score of the target software is not less than the first score value, the software quality of the target software is determined to be qualified software; Alternatively, for each component, if the quality score of the component is less than the second score value, the quality result of the component is determined to be a degraded component; if the number of degraded components among the components included in the target software is greater than a preset number, the software quality of the target software is determined to be degraded software; if the number of degraded components among the components included in the target software is not greater than a preset number, the software quality of the target software is determined to be qualified software.
7. The method according to claim 1, characterized in that The method further includes: When the code file of the target software is modified, the modified code file is packaged by a continuous integration CI process, and an operation of obtaining the modified code file of the target software is performed at the same time; After determining the software quality of the target software based on the quality score of each component, the method further includes: If it is detected that the software quality of the target software is degraded software and the current CI process packaging has not yet ended, the step of CI process packaging is stopped to debug the target software; If it is detected that the quality result of the target software is qualified software and the current CI process packaging has not yet ended, the CI process packaging step is continued to generate an executable file of the target software.
8. A software quality detection device, characterized in that: The device includes: An acquisition unit, configured to acquire a code file of a target software, wherein the code file includes component codes of a plurality of components; A traversal unit, used to traverse the component code of each component in turn, determine the abstraction level of the component based on the class characteristics of the component code, and determine the stability level of the component based on the dependency characteristics of the component code; wherein the class characteristics represent the structural complexity of the component, and the dependency characteristics represent the dependency relationship between the component and other components; A determination unit, used for determining a quality score of the component according to the abstraction level and stability level of the component; The detection unit is used to determine the software quality of the target software based on the quality score of each component.
9. The device according to claim 8, characterized in that The class characteristics of the component code include the total number of classes in the component and the number of abstract classes in the component. The traversal unit is specifically used for: Dividing the number of the abstract classes by the total number of the classes to obtain the abstraction level of the component; wherein the component code includes multiple classes, the multiple classes include abstract classes and concrete classes, the classes are used to define the relevant data and functions of the component, and the abstract classes are used to define the general interface and basic functions of the component; And / or, the dependency characteristics of the component code include the number of components that the component depends on and the number of components that the component depends on, and the traversal unit is specifically used to: The number of components that the component depends on and the number of components that the component depends on are summed to obtain the target sum; wherein the components that the component depends on refer to other components that provide the required services for the component so that the component can be executed; the components that the component depends on refer to other components that can only be executed by relying on the services provided by the component; Divide the number of components that the component depends on by the target sum to obtain the stability of the component; And / or, the determining unit is specifically configured to: Determine a coordinate point corresponding to the component in the established target coordinate system based on the abstraction level and stability level of the component, wherein the abscissa of the coordinate point is the abstraction level of the component, and the ordinate of the coordinate point is the stability level of the component, or the abscissa of the coordinate point is the stability level of the component, and the ordinate of the coordinate point is the abstraction level of the component; Generate a target standard line in the target coordinate system based on the value range of the abstraction degree and the stability degree; determine the quality score of the component based on the distance between the coordinate point of the component in the target coordinate system and the target standard line; wherein the distance is inversely proportional to the quality score; And / or, the determining unit is specifically configured to: Determine a first target point and a second target point in the target coordinate system according to the value ranges of the abstraction degree and the stability degree; wherein the first target point refers to a coordinate point corresponding to the minimum value of the abstraction degree and the maximum value of the stability degree, and the second target point refers to a coordinate point corresponding to the maximum value of the abstraction degree and the minimum value of the stability degree; Determine the straight line where the first target point and the second target point are located as the target standard line; And / or, the detection unit is specifically used for: The average value of the quality scores of all components is determined as the quality score of the target software; if the quality score of the target software is less than a first score value, the software quality of the target software is determined to be degraded software; if the quality score of the target software is not less than the first score value, the software quality of the target software is determined to be qualified software; Alternatively, for each component, if the quality score of the component is less than the second score value, the quality result of the component is determined to be a degraded component; if the number of degraded components in the components included in the target software is greater than a preset number, the software quality of the target software is determined to be degraded software; if the number of degraded components in the components included in the target software is not greater than a preset number, the software quality of the target software is determined to be qualified software; And / or, the acquisition unit is further used for: When the code file of the target software is modified, the modified code file is packaged by a continuous integration CI process, and an operation of obtaining the modified code file of the target software is performed at the same time; After determining the software quality of the target software based on the quality score of each component, the detection unit is further used for: If it is detected that the software quality of the target software is degraded software and the current CI process packaging has not yet ended, the step of CI process packaging is stopped to debug the target software; If it is detected that the quality result of the target software is qualified software and the current CI process packaging has not yet ended, the CI process packaging step is continued to generate an executable file of the target software.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.