Source code analysis device, source code analysis method, and source code analysis program

The source code analysis device and method address the challenge of balancing maintainability and readability by using maintainability indices and execution paths to optimize refactoring, enhancing code quality and reducing manual adjustments.

JP7799580B2Active Publication Date: 2026-01-15HITACHI VANTARA LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2022132550
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Filing Date
2022-08-23
Publication Date
2026-01-15
Estimated Expiration
2042-08-23

AI Technical Summary

Technical Problem

Existing source code analysis methods, such as those described in Patent Document 1, fail to evaluate maintainability and developer readability needs effectively, leading to potential decreases in maintainability or readability when refactoring source code, requiring repetitive and time-consuming adjustments to meet both criteria.

Method used

A source code analysis device and method that calculates maintainability indices and execution paths to identify candidate elements for division, considering both maintainability and developer readability needs, using source code metrics and dynamic information to generate lists for optimal refactoring.

Benefits of technology

The solution allows for effective refactoring by identifying optimal division points that improve maintainability while respecting developer readability, reducing manual effort and ensuring high-quality code readability and maintainability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007799580000001
    Figure 0007799580000001
  • Figure 0007799580000002
    Figure 0007799580000002
  • Figure 0007799580000003
    Figure 0007799580000003
Patent Text Reader

Abstract

To present a section of a program element to be subdivided, as a section to be improved, while satisfying legibility needs from a developer.SOLUTION: A source code analysis apparatus calculates source code metrics from a source code, calculates a maintainability index from the source code metrics, generates a subdivision candidate element list of a program on the basis of the maintainability index and a maintainability index threshold, generates a dynamic information list from the source code, the program, and a test case for the program, generates a basic path list from the dynamic information list and a duplicate threshold, and generates a subdivision path list from the subdivision candidate element list and the basic path list.SELECTED DRAWING: Figure 2
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to a source code analysis device, a source code analysis method, and a source code analysis program. [Background technology]

[0002] In recent years, software has become increasingly complex due to repeated functional expansions and changes over many years of software derivative development. As software becomes more complex, the readability of source code decreases. To resolve this situation, refactoring is used. Refactoring means changing the internal structure of software without changing its behavior. By appropriately refactoring program components such as methods, classes, and files (hereafter referred to as program elements) that are difficult to maintain, it becomes easier to reduce software complexity.

[0003] One refactoring technique is elementalization. This is a technique in which complex processing written in functions or methods is broken down into smaller units of processing, which are then separated into other independent functions or methods. Elementalization allows complex, long, and difficult-to-read source code to be broken down into simple, short, and highly readable source code. This reduces the amount of work required to create unit test cases, modify or change source code, or perform maintenance, and improves the maintainability of the software.

[0004] Patent Document 1 describes a method for presenting the parts of each module that should be divided based on source code and module division rule data. This makes it possible to identify the parts that should be divided from complex source code. [Prior art documents] [Patent documents]

[0005] [Patent Document 1] Japanese Patent Application Laid-Open No. 2007-219586 Summary of the Invention [Problem to be solved by the invention]

[0006] The technique of Patent Document 1 determines whether a program corresponds to a location that should be divided based on source code and module division rule data, and if so, presents the location of the source code.

[0007] However, the presented division points are not evaluated for maintainability of the source code using features of program elements obtained by program analysis of the source code (hereinafter referred to as source code metrics), etc. Therefore, it is thought that the method of Patent Document 1 may result in a decrease in maintainability of the source code when division is performed.

[0008] Furthermore, in order to maintain the readability of source code for developers at development sites, there is a need to avoid splitting existing processing within a certain program element into other elements (hereinafter referred to as developer readability needs). For example, there may be a case where a development practice uses conditional branch statements in source code, but the actual processing is sequential, and the developer wants to describe that part within a single function and understand it as a single function. To meet such developer readability needs, it is necessary to leave the parts that developers do not want split and split the other program elements into elements. In order to split elements while meeting developer readability needs, the method of Patent Document 1 requires multiple changes to module splitting rule data and repeated source code analysis until the developers at development sites are satisfied. Such repetitive work is cumbersome and requires a lot of man-hours.

[0009] Furthermore, while improving source code maintainability and developer readability are both important for development, they often have a trade-off relationship. If program elements are divided too much in order to improve source code maintainability, it may not be possible to meet developer readability needs. On the other hand, if you try to meet all developer readability needs, program elements may not be divided appropriately, which may result in a decrease in source code maintainability.

[0010] Therefore, in this disclosure, it is considered that developer readability needs lie in the parts of a cohesive process that are frequently executed in actual programs, and developer readability needs are met by leaving the parts that are frequently executed in the program as parts that are not split into elements, while at the same time evaluating the maintainability of the source code using source code metrics to present the parts of the program elements that should be split into elements to improve the maintainability of the source code.

[0011] In this case, the unit of the program element may be any unit as long as it is a portion of source code having a certain length, such as a part of a function, a class, a module, or a structure. [Means for solving the problem]

[0012] A source code analysis device according to one aspect included in the present disclosure is a source code analysis device that analyzes source code corresponding to a program, and includes: a source code metrics calculation unit that calculates source code metrics for each program element included in the program from the source code to be analyzed; a maintainability index calculation unit that calculates a maintainability index for each of the program elements from the source code metrics; a division candidate element generation unit that generates a division candidate element list recording program elements that are candidates for division based on the maintainability index and a maintainability index threshold; and a division candidate element generation unit that generates a division candidate element list recording program elements that are candidates for division based on the source code, the program, and test cases for the program, and a division candidate element generation unit that generates a division candidate element list recording program elements that are candidates for division based on the test cases. The program includes a program processing tracking unit that generates a dynamic information list that records execution paths, which are portions of the source code corresponding to the processing that is executed when the program is executed based on the dynamic information list; a basic path generation unit that generates, from the dynamic information list and an overlap threshold, a basic path list that records portions of the source code in each of the program elements included in the splitting candidate element list, where the proportion of test cases that include said portions in the execution paths shown in the dynamic information list is equal to or greater than the overlap threshold; and a split path generation unit that generates, from the splitting candidate element list and the basic path list, a split path list that records portions of each of the program elements included in the splitting candidate element list that are not included in the basic path list.

[0013] A source code analysis method according to one aspect included in the present disclosure is a method for analyzing source code corresponding to a program, executed by an apparatus having a processor and a storage device, the method comprising: calculating source code metrics for each program element included in the program from the source code to be analyzed; calculating a maintainability index for each of the program elements from the source code metrics; generating a division candidate element list recording program elements that are candidates for division based on the maintainability index and a maintainability index threshold; and generating a division candidate element list for each program element included in the division candidate element list from the source code, the program, and test cases for the program. a dynamic information list that records execution paths that are portions of the source code corresponding to the processing that is executed when the program is executed based on the above; a basic path list that records, from the dynamic information list and an overlap threshold, portions of the source code for each of the program elements included in the splitting candidate element list, for which the proportion of test cases that include said portions in the execution paths shown in the dynamic information list is equal to or greater than the overlap threshold; and a split path list that records portions of each of the program elements included in the splitting candidate element list that are not included in the basic path list, from the splitting candidate element list and the basic path list.

[0014] A source code analysis program according to one aspect of the present disclosure is a source code analysis program for analyzing source code corresponding to a program, the program being installed in an apparatus having a processor and a storage device, and includes the following steps: calculate source code metrics for each program element included in the program from the source code to be analyzed; calculate a maintainability index for each of the program elements from the source code metrics; generate a division candidate element list recording program elements that are candidates for division based on the maintainability index and a maintainability index threshold; and, based on the source code, the program, and test cases for the program, perform a division on each of the program elements included in the division candidate element list based on the test cases. a dynamic information list that records execution paths that are portions of the source code corresponding to processes that are executed when the program is executed using the dynamic information list; a basic path list that records, from the dynamic information list and an overlap threshold, portions of the source code for each of the program elements included in the splitting candidate element list, for which the proportion of test cases that include said portions in the execution paths shown in the dynamic information list is equal to or greater than the overlap threshold; and a split path list that records, from the splitting candidate element list and the basic path list, portions of each of the program elements included in the splitting candidate element list that are not included in the basic path list. [Effects of the Invention]

[0015] According to one aspect of the present disclosure, for program elements to be divided into elements, it is possible to present the parts where element division should be performed as parts to be improved while meeting the developer's readability needs. [Brief explanation of the drawings]

[0016] [Figure 1] FIG. 1 is a conceptual diagram illustrating an example of a hardware configuration of a source code analyzing device. [Figure 2] 1 is a conceptual diagram showing functions provided in a source code analyzing device and data stored in the source code analyzing device; [Figure 3] FIG. 10 is a diagram illustrating an example of source code to be analyzed. [Figure 4] FIG. 10 is a diagram illustrating an example of source code metrics. [Figure 5] FIG. 10 is a diagram illustrating an example of a maintainability index. [Figure 6] FIG. 10 is a diagram illustrating an example of a division candidate element list. [Figure 7] FIG. 10 is a diagram illustrating an example of a dynamic information list. [Figure 8] FIG. 10 is a diagram illustrating an example of a basic path list. [Figure 9] FIG. 10 is a diagram illustrating an example of a divided path list. [Figure 10] 10 is a flowchart illustrating an example of processing by a source code metrics calculation unit. [Figure 11] 10 is a flowchart illustrating an example of processing by a maintainability index calculation unit. [Figure 12] 10 is a flowchart illustrating an example of processing by a division candidate element generation unit. [Figure 13] 10 is a flowchart illustrating an example of processing by a program processing tracing unit. [Figure 14] 10 is a flowchart illustrating an example of processing by a basic path generation unit. [Figure 15] 10 is a flowchart illustrating an example of processing by a divided path generating unit. [Figure 16] FIG. 10 is a conceptual diagram illustrating functions provided in a source code analyzing device and data stored in the source code analyzing device according to a second embodiment. [Figure 17] FIG. 10 is a diagram illustrating an example of a basic path maintainability index. [Figure 18] FIG. 11 is a diagram illustrating an example of a divided path list according to the second embodiment. [Figure 19] 10 is a flowchart illustrating an example of the operation of a basic path maintainability index calculation unit. [Figure 20] 10 is a flowchart illustrating an example of the operation of a divided path generating unit. [Figure 21] FIG. 11 is a conceptual diagram illustrating functions provided in a source code analyzing device and data stored in the source code analyzing device according to a third embodiment. [Figure 22] 10 is a flowchart illustrating an example of the operation of a basic path generation unit. [Figure 23] FIG. 10 is a conceptual diagram illustrating functions provided in a source code analyzing device and data stored in the source code analyzing device according to a fourth embodiment. [Figure 24] 10 is a flowchart illustrating an example of the operation of a division portion mapping unit. [Figure 25] FIG. 10 is a diagram illustrating an example of source code in which division locations are indicated. [Figure 26] 1 is a conceptual diagram illustrating an example of screen transitions of a source code analyzing device. [Figure 27] FIG. 10 is a conceptual diagram illustrating an example of an analysis target selection screen. [Figure 28] FIG. 10 is a conceptual diagram illustrating an analysis result list screen. [Figure 29] FIG. 10 is a conceptual diagram illustrating a division portion display screen. DETAILED DESCRIPTION OF THE INVENTION

[0017] Hereinafter, embodiments of the present disclosure will be described with reference to the drawings. Note that the embodiments described below do not limit the invention according to the claims. Furthermore, not all of the elements and combinations thereof described in the embodiments are necessarily essential to the solution of the invention. [Example]

[0018] FIG. 1 is a conceptual diagram showing an example of the hardware configuration of a source code analyzing device.

[0019] The source code analysis device 100 is an information processing device used for developing and maintaining software systems, etc. The source code analysis device 100 may be realized virtually, such as a cloud server provided by a cloud system.

[0020] 1, a source code analysis device 100 includes a processor 101, a main memory device 102, an auxiliary memory device 103, an input device 104, an output device 105, and a communication device 106. These are connected to each other so as to be able to communicate with each other via communication means such as a bus (not shown).

[0021] The processor 101 is configured by, for example, a CPU (Central Processing Unit), an MPU (Micro Processing Unit), a GPU (Graphics Processing Unit), an FPGA (Field-Programmable Gate Array), etc. The processor 101 reads and executes various programs, such as a source code analysis program, stored in the main storage device 102 or the auxiliary storage device 103, thereby realizing various functions of the source code analysis device 100.

[0022] The main memory device 102 is a device that stores programs and data, and is, for example, a random access memory (RAM), a read only memory (ROM), or a non-volatile semiconductor memory (Non-Volatile RAM (NVRAM)).

[0023] The auxiliary storage device 103 is, for example, a reading and writing device for recording media such as a Hard Disc Drive (HDD), a Solid State Drive (SSD), a storage system, an Integrated Circuit (IC) card, a Secure Digital (SD) memory card, or an optical recording medium (Compact Disc (CD), Digital Versatile Disc (DVD), etc.), or a storage area of ​​a cloud server.

[0024] The input device 104 is a device that accepts information input by a user, and is, for example, a keyboard, a mouse, a touch panel, a card reader, or a voice input device.

[0025] The output device 105 is a device that provides the user with various information such as processing progress and processing results, etc. The output device 105 is, for example, a screen display device (such as a Liquid Crystal Display (LCD) or a Head Mounted Display (HMD)), an audio output device, or a printing device.

[0026] Furthermore, the source code analyzing device 100 may input and output information to and from other devices via the communication device 106 .

[0027] The communication device 106 is a wired or wireless communication interface that realizes communication with other devices via a communication line such as a local area network (LAN) or the Internet. The communication device 106 is, for example, a network interface card (NIC), a wireless communication module, a universal serial interface (USB) module, or a serial communication module.

[0028] FIG. 2 is a conceptual diagram showing the functional configuration of the source code analyzing device.

[0029] The source code analysis device 100 includes a source code metrics calculation unit 201 , a maintainability index calculation unit 202 , a division candidate element generation unit 203 , a program processing tracing unit 204 , a basic path generation unit 205 , and a division path generation unit 206 .

[0030] Each of these units is realized, for example, by the processor 101 reading and executing a program stored in the main storage device 102 or the auxiliary storage device 103. Furthermore, each of these units may be realized, for example, by hardware (such as an Application Specific Integrated Circuit (ASIC)) included in the source code analysis device 100.

[0031] The source code analysis device 100 further includes an information storage unit 207. The information storage unit 207 stores information. The information storage unit 207 is configured from at least one of the main storage unit 102 and the auxiliary storage unit 103. The information storage unit 207 stores source code metrics 213. The information storage unit 207 also records information referenced or generated as appropriate by the source code metrics calculation unit 201, the maintainability index calculation unit 202, the division candidate element generation unit 203, the program processing tracking unit 204, the basic path generation unit 205, and the division path generation unit 206. The information storage unit 207 may manage the information stored in at least one of the main storage unit 102 and the auxiliary storage unit 103 in the form of, for example, a file system or a database management system (DBMS).

[0032] The maintainability index threshold 211, the source code to be analyzed 208, the program to be analyzed 209, the test cases 210, and the duplication threshold 212 are input information for the source code analysis device 100. These pieces of input information may be stored in advance in the main storage device 102 or the auxiliary storage device 103. In addition, the source code analysis device 100 may acquire input data stored in an external device via the communication device 106.

[0033] (Source code analysis process) The source code metrics calculation unit 201 acquires the analysis target source code 208 and calculates the source code metrics 213. As described above, the source code metrics are feature quantities of program elements obtained by program analysis of the source code.

[0034] The maintainability index calculation unit 202 acquires the source code metrics 213 and calculates the maintainability index 214. A specific example of the maintainability index will be described later with reference to FIGS.

[0035] The division candidate element generation unit 203 acquires the maintainability index 214 and the maintainability index threshold 211, and generates a division candidate element list 215 for the program. The division candidate element list 215 will be described later with reference to Figs. 6 and 12, etc.

[0036] The program processing tracing unit 204 acquires the analysis target source code 208, the analysis target program 209, and test cases 210 for the analysis target program 209, and generates a dynamic information list 216. The dynamic information list 216 will be described later with reference to Figs. 7 and 13, etc.

[0037] The basic path generation unit 205 acquires the dynamic information list 216 and the overlap threshold 212, and generates a basic path list 217. The basic path list 217 will be described later with reference to Figs. 8 and 14, etc.

[0038] The division path generation unit 206 acquires the division candidate element list 215 and the basic path list 217, and generates a division path list 218. The division path list will be described later with reference to Figs. 9 and 15, etc.

[0039] The source code analysis device 100 generates a list of program elements to be divided according to a maintainability index 214 and a dynamic information list 216 based on a source code to be analyzed 208, a program to be analyzed 209, test cases 210, a maintainability index threshold 211, and an overlap threshold 212.

[0040] The analysis target source code 208 is input information that records the source code to be analyzed by the source code analysis device 100 .

[0041] FIG. 3 is a diagram showing an example of source code to be analyzed. The source code to be analyzed 208 is composed of a set 301 of source code portions for each program element of the program to be analyzed. Here, the unit of a program element can be any unit of source code of a certain length, such as a part of a function, a class, a module, or a structure. A source code portion means at least a portion of the source code corresponding to a program element. A source code portion may also be the entire source code corresponding to a program element. In the example of FIG. 3, funcA and funcB are program elements. funcA is program element A, and funcB is program element B. Program element A includes processing A, processing B, processing C, processing D, and processing E. Program element B includes processing F, processing G, processing H, processing I, and processing J.

[0042] The analysis target program 209 is an executable program generated by building the analysis target source code 208. The source code analysis device 100 analyzes the analysis target source code 208 corresponding to the analysis target program 209.

[0043] The test cases 210 are information recording various test cases for the analysis target program 209 .

[0044] The maintainability index threshold 211 means a threshold of the maintainability index 214 used when the division candidate element generation unit 203 determines whether each program element has low maintainability, i.e., whether each program element should be divided. For example, the maintainability index threshold 211 is set to 20. However, the value of the maintainability index threshold 211 may be a value other than 20.

[0045] The overlap threshold 212 is a recorded percentage threshold used by the basic path generation unit 205 when determining whether each element of source code included in the dynamic information list 216 appears frequently in the entire dynamic information list 216. For example, 0.7 (70%) is set as the overlap threshold 212. However, the value of the overlap threshold 212 may be a value other than 0.7.

[0046] FIG. 4 is a diagram showing an example of source code metrics. The source code metrics 213 are obtained by inputting the analysis target source code 208 and calculating various metric values ​​calculated by the source code metrics calculation unit 201, and recording them as a source code metrics record 400. The source code metrics record 400 is composed of a program element name 401 that records the program element of the program that is the calculation target of the source code metrics record, and source code metrics 402 that records the metric values ​​of various source code metrics 213 for that program element name. Note that the number of metric values ​​is not limited to one. FIG. 4 shows an example in which the source code metrics record 400 includes at least two metric values, Metric 1 and Metric 2. The source code metrics 402 may be calculated using a calculation method known to those skilled in the art.

[0047] 5 is a diagram showing an example of a maintainability index. The maintainability index 214 is obtained by inputting the source code metrics 213 and calculating the maintainability index by the maintainability index calculation unit 202, and recording the calculated maintainability index as a maintainability index record 500. The maintainability index record 500 is composed of a program element name 501 that records the program element of the program that is the target of calculation of the maintainability index record, and a maintainability index 502 that records the maintainability index 214 of the program element. A calculation method known to those skilled in the art may be used to calculate the maintainability index 502. For example, a calculation method may be used in which a larger value of the maintainability index 502 indicates higher maintainability of the program element.

[0048] Fig. 6 is a diagram showing an example of a division candidate element list. Dividing candidate element list 215 records, as division candidate element records 600, program elements that division candidate element generation unit 203 has determined to correspond to program elements that should be divided, using maintainability index 214 as input. Dividing candidate element record 600 is made up of program element names 601 that correspond to program elements that should be divided. In the example of Fig. 6, program element A and program element B are the division candidate elements.

[0049] The division candidate element list 215 corresponds to the analysis result obtained by the source code analysis device 100 statically analyzing the analysis target source code 208 using a maintainability index based on source code metrics.

[0050] Next, the dynamic analysis of the source code to be analyzed will be described.

[0051] 7 is a diagram showing an example of a dynamic information list. The dynamic information list 216 records, as dynamic information records 700, execution paths generated by the program processing tracing unit 204 using the analysis target source code 208, the analysis target program 209, and the test case 210 as inputs.

[0052] A dynamic information record 700 is composed of a program element name 701, which is the name of a program element of the program that is the calculation target of the dynamic information record, a test case name 702, which is the name of a test case 210 used during program execution of the analysis target program 209, and an execution path 703, which records the execution path corresponding to the program element and the test case. In the example of FIG. 7, in test case AI, processes A, C, D, and E in program element A are executed. In test case A-II, processes A, C, and D in program element A are executed. In test case BI, process G in program element B is executed. The execution path will be described later with reference to FIG. 13.

[0053] Fig. 8 is a diagram showing an example of a basic path list. The basic path list 217 records the basic paths generated by the basic path generation unit 20 as basic path records 800. The basic path record 800 is made up of a program element name 801 that records the program element of the program that is the calculation target of the basic path record, and a basic path 802 that records the basic path of the program element. In the example of Fig. 8, the basic path of program element A includes processes A, C, and D. Furthermore, the basic path of program element B includes process G.

[0054] 9 is a diagram showing an example of a split path list. Split path list 218 records split paths generated by split path generation unit 206 as split path records 900. Split path record 900 is made up of program element names 901 determined to be split, and split paths 902 recording the split paths of those program elements. In the example of FIG. 9, the split path of program element A includes processes B and E that were not included in the basic path shown in FIG. 8. Furthermore, the split path of program element B includes processes F, H, and I that were not included in the basic path shown in FIG. 8.

[0055] (Processing content of each processing block) FIG. 10 is a flowchart illustrating an example of processing by the source code metrics calculation unit.

[0056] The source code metrics calculation unit 201 reads the source code 208 to be analyzed (1001).

[0057] The source code metrics calculation unit 201 executes the process of step 1003 for each program element E included in the acquired source code to be analyzed 208 (steps 1002 to 1004).

[0058] In step 1003 , the source code metrics calculation unit 201 calculates the source code metrics 213 .

[0059] The source code metrics calculation unit 201 calculates source code metrics such as those used in the maintainability index calculation unit 202. Examples of the source code metrics that are calculated include the halted volume in the maintainability index (MI), cyclomatic complexity, and the number of lines of source code excluding comment lines.

[0060] FIG. 11 is a flowchart illustrating an example of processing by the maintainability index calculation unit.

[0061] The maintainability index calculation unit 202 executes the processes of steps 1102 and 1103 for each program element E (steps 1101 to 1104).

[0062] The maintainability index calculation unit 202 reads (1102) the source code metrics 213. The maintainability index calculation unit 202 uses the read source code metrics 213 to calculate the maintainability index 214 (1103).

[0063] A maintainability index is a metric that indicates the ease of software maintenance. An example of a maintainability index is the Maintainability Index (MI) shown in the following formula (1).

[0064] Maintainability index=max(0, (171 - 5.2*ln(HV) - 0.23*C - 16.2*ln(L))*100 / 171) …(1)

[0065] Here, HV stands for Halsted Volume, C stands for Cyclomatic Complexity, L stands for the number of lines of source code excluding comment lines, and ln stands for the natural logarithm.

[0066] The maintainability index 214 is not limited to the maintainability index described above, but may be any index related to the maintainability of a program.

[0067] FIG. 12 is a flowchart illustrating an example of processing by the division candidate element generating unit.

[0068] The division candidate element generation unit 203 reads (1201) the maintainability index threshold 211. The read maintainability index threshold is denoted as A.

[0069] The division candidate element generation unit 203 executes the processing of steps 1203-1205 for each program element E (steps 1202-1206).

[0070] The division candidate element generation unit 203 reads (1203) the maintainability index 214. The read maintainability index is represented as H.

[0071] The division candidate element generation unit 203 determines whether the maintainability index H is less than the maintainability index threshold A (1204). If the maintainability index H is less than the maintainability index threshold A (step 1204: YES), the process proceeds to step 1205. If the maintainability index H is not less than the maintainability index threshold A (step 1204: NO), step 1205 is skipped.

[0072] In step 1205 , the division candidate element generation unit 203 adds the program element to the division candidate element list 215 .

[0073] The above shows an example of processing when a maintainability index is used in which the larger the value, the higher the maintainability of the program element. When a maintainability index is used in which the smaller the value, the higher the maintainability of the program element, if the maintainability index 214 is greater than the maintainability index threshold value 211 in step 1204, the processing proceeds to step 1205.

[0074] FIG. 13 is a flowchart illustrating an example of processing by the program processing tracing unit.

[0075] The program processing tracing unit 204 reads the analysis target source code 208 (1301). The program processing tracing unit 204 reads the analysis target program 209 (1302). The program processing tracing unit 204 reads the test case 210 corresponding to the analysis target program 209 (1303).

[0076] The program processing tracking unit 204 executes the processing of steps 1305-1308 for each program element E included in the analysis target program 209 (steps 1304-1309). Here, an example is shown in which the processing of steps 1305-1308 is executed for all program elements E included in the analysis target program 209. However, as another example, the processing of steps 1305-1308 may be executed for all program elements E included in the division candidate element list 215.

[0077] The program processing tracing unit 204 executes the processing of steps 1306-1307 for each test case T included in the test case 210 (steps 1305-1308).

[0078] The program processing tracing unit 204 executes the analysis target program 209 based on the test case T (1306).

[0079] The program processing tracing unit 204 extracts (1307) from the source code 208 a set of source code portions corresponding to the executed processing for the program element E. The set of source code portions executed for the test case is referred to as an execution path. This execution path will be included in the dynamic information record 700 of the dynamic information list 216 described with reference to FIG. 7.

[0080] The order of reading the analysis target source code 208 (step 1301), the analysis target program 209 (step 1302), and the test case 210 (step 1303) does not matter.

[0081] FIG. 14 is a flowchart illustrating an example of processing by the basic path generation unit.

[0082] The basic path generation unit 205 reads (1401) the overlap threshold 212. The read overlap threshold is denoted as B.

[0083] The basic path generation module 205 executes the processing of steps 1403-1409 for each program element E (1402-1410).

[0084] The basic path generation unit 205 reads the dynamic information list 216 (1403).

[0085] The basic path generation unit 205 executes the processes of steps 1405-1407 (1404-1408) for each portion S of source code included in the program element E. Note that the portion S of source code included in the program element E is referred to as a source code fragment.

[0086] The basic path generation unit 205 calculates the ratio R of test cases whose execution paths indicated in the dynamic information list include the source code fragment S in the program element E (1405).

[0087] The basic path generation unit 205 determines whether the ratio R is equal to or greater than the overlap threshold B (1406). If the ratio R is equal to or greater than the overlap threshold B (step 1406: YES), the process proceeds to step 1407. If the ratio R is not equal to or greater than the overlap threshold B (step 1406: NO), step 1407 is skipped.

[0088] In step 1407, the basic path generation unit 205 adds the source code fragment S to the basic path (1407). Note that the set of source code fragments S formed by performing the processing of step 1407 on one program element is referred to as a basic path.

[0089] In step 1409 , the basic path generation unit 205 adds the basic path to the basic path list 217 .

[0090] The loop process of steps 1404-1408 will now be described in more detail.

[0091] 2 and 7, dynamic information list 216 includes a set consisting of parts of source code 208 executed by program processing tracing unit 204 for test case 210. This corresponds to the execution path in Fig. 7. Basic path generation unit 205 adds to the basic path parts of source code 208 whose proportion of inclusion in the set consisting of parts of source code 208 executed by program processing tracing unit 204 for test case 210 is equal to or greater than overlap threshold 212 (steps 1405-1407), thereby generating basic path list 217 from dynamic information list 216 and overlap threshold 212.

[0092] As mentioned above, it is assumed that developers have readability needs that prevent them from splitting typical processes within a certain program element into other elements in order to maintain the readability of the source code for the developers in the development field. If a source code fragment whose proportion inclusion in the execution path is equal to or exceeds the overlap threshold is added to the basic path, the typical processes with high execution frequency become the basic path and are not subject to splitting (step 1505, described below with reference to Figure 15). This has the advantage that typical processes with high execution frequency that developers would want to read together as a single source code are not split against the developer's intention.

[0093] FIG. 15 is a flowchart showing an example of processing by the divided path generating unit.

[0094] The division path generation unit 206 reads the division candidate element list 215 (1501).

[0095] The divided path generation unit 206 executes the processing of steps 1503 to 1507 for each program element E (1502 to 1508).

[0096] The division path generation unit 206 determines (1503) whether or not program element E is included in the division candidate element list 215. If program element E is included in the division candidate element list 215 (step 1503: YES), the process proceeds to step 1504. If program element E is not included in the division candidate element list 215 (step 1503: NO), steps 1504-1507 are skipped.

[0097] In step 1504 , the path division generation unit 206 reads the basic path list 217 .

[0098] The divided path generation unit 206 extracts (1505) source code portions (source code fragments) from the program element E that are not included in the basic path list 217. Note that a set of source code fragments that are not basic paths and that are extracted by executing step 1505 for one program element is referred to as a divided path.

[0099] The divided path generation unit 206 determines whether the divided path is empty (1506). If the divided path is not empty (step 1506: YES), the process proceeds to step 1507. If the divided path is empty (step 1506: NO), step 1507 is skipped.

[0100] The path division generation unit 206 adds the path division to the path division list (1507).

[0101] As described above, the program elements to be divided can be found and listed by using the maintainability index 214 obtained by statically analyzing the source code to be analyzed and the dynamic information list 216 including the execution paths obtained by executing the program to be analyzed corresponding to the source code to be analyzed based on the test cases. [Example]

[0102] This embodiment shows a case in which the basic path generation unit 205 shown in embodiment 1 calculates the maintainability index of the basic path remaining after dividing a program element, and in the divided path record in the divided path list, in addition to the program element name and divided path corresponding to the divided path, the pre-divided maintainability index of the program element and the basic path maintainability index of the program element are also recorded.

[0103] In addition to the case of the first embodiment, the information storage unit 207 stores a basic path maintainability index 1602 in at least one of the main storage device 102 and the auxiliary storage device 103. In addition to the case of the first embodiment, the information storage unit 207 also stores information other than the above information that is appropriately referenced or generated by the basic path maintainability index calculation unit 1601. The information storage unit 207 manages the information stored in at least one of the main storage device 102 and the auxiliary storage device 103 in the same way as in the first embodiment.

[0104] FIG. 16 is a conceptual diagram illustrating functions provided in a source code analyzing device and data stored in the source code analyzing device according to the second embodiment.

[0105] In addition to the configuration of the first embodiment, the source code analyzing device 100 further includes a basic path maintainability index calculation unit 1601. The basic path maintainability index calculation unit 1601 calculates a basic path maintainability index 1602 from the basic path list 217. Furthermore, the split path generation unit 206 acquires the maintainability index 214 and the basic path maintainability index 1602 in addition to the split candidate element list 215 and the basic path list 217.

[0106] 17 is a diagram showing an example of a basic path maintainability index. The basic path maintainability index 1602 is a metric value calculated by the basic path maintainability index calculation unit 1601 using the basic path list 217 as input, and recorded as a basic path maintainability index record 1700. The basic path maintainability index record 1700 is made up of a program element name 1701 that records the program element of the program that is the calculation target of the basic path maintainability index record, and a basic path maintainability index 1702 that records the maintainability index of the basic path of the program element.

[0107] 18 is a diagram showing an example of a split path list in the second embodiment. The split path list 218 in the second embodiment records the split paths generated by the split path generation unit 206 as split path records 1800. The split path record 1800 is made up of the element name of a program element 1801 determined to be split, a split path 1802 recording the split path of the program element, a pre-split maintainability index 1803 recording the maintainability index of the program element, and a post-split maintainability index 1804 recording the maintainability index of the basic path of the program element. In addition to the list of program elements 1801 to be split, the source code analysis device 100 generates a list of the pre-element split maintainability index 1803 and the post-element split maintainability index 1804.

[0108] FIG. 19 is a flowchart showing an example of the operation of the basic path maintainability index calculation unit.

[0109] The basic path maintainability index calculation unit 1601 reads the basic path list 217 (1901).

[0110] The basic path maintainability index calculation unit 1601 executes the processing of steps 1903-1904 for each program element E (1902-1905).

[0111] The basic path maintainability index calculation unit 1601 calculates (1903) the source code metrics of the basic path in the program element E. The source code metrics may be calculated using the same method as that used by the source code metrics calculation unit 201.

[0112] The basic path maintainability index calculation unit 1601 calculates the maintainability index of the basic path based on the source code metrics of the basic path (1904). The maintainability index calculation method may be the same as that used by the maintainability index calculation unit 202.

[0113] FIG. 20 is a flowchart showing an example of the operation of the divided path generating unit.

[0114] The flowchart shown in FIG. 20 is basically the same as the flowchart shown in FIG. 15, and therefore detailed description of the same processes will be omitted.

[0115] The flowchart shown in FIG. 20 includes steps 2001 and 2002 added to the flowchart shown in FIG.

[0116] 20. Also, step 1507 in the flowchart shown in FIG. 15 is changed to step 2003 in the flowchart shown in FIG.

[0117] In step 2001, the path division generation unit 206 reads the maintainability index 214. In step 2002, the path division generation unit 206 reads the basic path maintainability index 1602. In step 2003, the path division generation unit 206 adds the path divisions, the maintainability index 214, and the basic path maintainability index 1602 to the path division list.

[0118] In this way, by presenting the maintainability indicators before and after element splitting along with the split path, it is possible to present the effect of the element splitting presented in this embodiment on improving the maintainability of the source code being analyzed. [Example]

[0119] This embodiment shows a case where the basic path generation unit 205 shown in the first and second embodiments uses a maintainability index target value as an input in addition to the input shown in the first embodiment, and the threshold setter changes the overlap threshold to change the generated basic path.

[0120] FIG. 21 is a conceptual diagram illustrating functions provided in a source code analyzing device and data stored in the source code analyzing device according to the third embodiment.

[0121] In addition to the cases of the first and second embodiments, the source code analyzing device 100 receives an input of a maintainability index target value 2101. Furthermore, the basic path generating unit 205 receives an input of the maintainability index target value 2101 in addition to the dynamic information list 216 and the overlap threshold value 212.

[0122] The maintainability index target value 2101 is a record of the target value of the maintainability index 214 used by the threshold setter when determining whether the basic path of each program element is appropriate in the basic path generation unit 205. For example, 40 is set as the maintainability index target value 2101. However, a value other than 40 may also be used.

[0123] Fig. 22 is a flowchart showing an example of the operation of the basic path generation unit 100. In the flowchart shown in Fig. 22, detailed explanations of the same processes as those in the flowchart shown in Fig. 14 will be omitted.

[0124] In the third embodiment, steps 2201, 2203, 2204, 2205, 2206, and 2207 are added. Steps 2202 and 2208 represent the loop processing from steps 1403 to 2207. Step 2209 is the same processing as step 1409 in the flowchart shown in Fig. 14, and therefore a detailed description thereof will be omitted.

[0125] In step 2201, the basic path generation unit 205 reads the maintainability index target value 2101. The read maintainability index target value is represented as M.

[0126] In step 2203, the basic path generation unit 205 calculates the source code metrics of the basic path.

[0127] In step 2204, the basic path generation unit 205 calculates the maintainability index of the basic path. If the basic path maintainability index calculation unit 1601 is provided, the basic path maintainability index calculation unit 1601 may calculate the maintainability index of the basic path as explained based on the second embodiment. If the basic path maintainability index calculation unit 1601 is not provided, the basic path generation unit 205 may calculate the maintainability index of the basic path in the same manner. The calculated maintainability index of the basic path is denoted as K.

[0128] In step 2205, the basic path generation unit 205 determines whether the maintainability index K of the basic path is less than the maintainability index target value M. If the maintainability index K of the basic path is less than the maintainability index target value M (step 2205: YES), the process proceeds to step 2206. If the maintainability index K of the basic path is not less than the maintainability index target value M (step 2205: NO), the process proceeds to step 2209.

[0129] Step 2206 is a judgment made by a human. A user such as a threshold setter judges whether the generated basic path is appropriate. If the user judges that the generated basic path is appropriate (step 2206: YES), the process exits the loop of steps 2202-2208 and proceeds to step 2209. If the user judges that the generated basic path is inappropriate (step 2206: NO), the process proceeds to step 2207.

[0130] In step 2207, the user changes the overlap threshold B. Then, the process returns to step 1403, where the basic path list is regenerated based on the new overlap threshold B (2202, 2208). In this case, by increasing the value of the overlap threshold B, the basic paths are narrowed down and the maintainability index K of the basic paths is increased.

[0131] In step 2209, the basic path generation unit 205 adds the basic path to the basic path list 217, and ends the generation of the basic path for the program element (step 2208).

[0132] As described above, in the third embodiment, when generating a basic path, it is determined whether the maintainability index of the basic path is less than the maintainability index target value 2101. In addition, the basic path list is regenerated based on the overlap threshold whose value has been changed. This allows the user to flexibly determine whether the generated basic path satisfies the developer's readability needs, while also presenting the locations where program elements should be divided into elements to improve source code maintainability. [Example]

[0133] In the fourth embodiment, after the divided path list shown in the second or third embodiment is generated, source code in which the divided locations are further indicated is generated.

[0134] FIG. 23 is a conceptual diagram illustrating functions provided in a source code analyzing device and data stored in the source code analyzing device according to the fourth embodiment.

[0135] The source code analyzing device 100 according to the fourth embodiment further includes a division portion mapping unit 2301 in addition to the components of the second or third embodiment.

[0136] A division portion mapping unit 2301 acquires the analysis target source code 208 and the division path list 218, and generates source code 2302 in which the division portions are shown so as to be distinguishable from other portions.

[0137] FIG. 24 is a flowchart showing an example of the operation of the division portion mapping unit.

[0138] The division location mapping unit 2301 reads the analysis target source code 208 (2401). The division location mapping unit 2301 reads the division path list 218 (2402). Note that the order of steps 2401 and 2402 does not matter.

[0139] The division portion mapping unit 2301 executes the processing of steps 2404 to 2406 for each program element E (steps 2403 to 2407).

[0140] The division portion mapping unit 2301 determines whether or not program element E is included in the divided paths (2404). If program element E is included in the divided paths (step 2404: YES), the process proceeds to step 2405. If program element E is not included in the divided paths (step 2404: NO), the process proceeds to step 2406.

[0141] In step 2405, the division portion mapping unit 2301 maps the divided paths to the source code to be analyzed, and generates source code 2302 in which the division portions are indicated. There are no particular limitations on how the division portions are indicated.

[0142] In step 2406, the division portion mapping unit 2301 extracts the unmapped portions in the source code to be analyzed as the divided source code (2406).

[0143] As described above, the source code analyzing device 100 indicates the divided portions of the source code after generating the divided path list, thereby assisting the source code corrector in correcting the source code. [Example]

[0144] In the fifth embodiment, in the source code in which the division points in the fourth embodiment are indicated, the division points are particularly indicated in units of program lines or tokens.

[0145] FIG. 25 is a diagram showing an example of source code in which division points are indicated.

[0146] Source code 2500 showing the division points is composed of source code 2501 of the program element, one or more division target points 2502 in source code 2501 of the program element, source code 2503 of the program element after division, maintainability index 2504 of the program element, and maintainability index 2505 of the source code of the program element after division.

[0147] As described above, by indicating the division locations in units of program lines or tokens, the source code analysis device 100 can clearly indicate the changes in the source code before and after division in units of lines or tokens, which makes it easier for users such as those who modify the source code to understand the results of the element division. [Example]

[0148] The sixth embodiment shows an example of a screen display by the source code analyzing device in the fifth embodiment.

[0149] 26 is a conceptual diagram illustrating an example of screen transitions in the source code analysis device. The screen is displayed on the output device 105 of the source code analysis device 100. However, the screen may also be displayed on a display device communicably connected to the source code analysis device 100. For example, the screen may also be displayed on a display device provided in a client terminal communicably connected to the source code analysis device 100. The following describes an example in which the screen is displayed on the output device 105.

[0150] The screen configuration of the source code analysis device 100 consists of an analysis target selection screen 2601, an analysis result list screen 2602, and a division location display screen 2603. It is possible to transition between the analysis target selection screen 2601 and the analysis result list screen 2602 in both directions. It is possible to transition between the analysis result list screen 2602 and the division location display screen 2603 in both directions. It is possible to transition from the division location display screen 2603 to the analysis target selection screen 2601.

[0151] 27 is a conceptual diagram illustrating an example of the analysis target selection screen. The analysis target selection screen 2601 has an analysis target selection tab 2701 and an analysis start button 2702.

[0152] The analysis target selection tab 2701 has an analysis target source code selection section 2703 for selecting the analysis target source code 208, an analysis target program selection section 2704 for selecting the analysis target program 209, a test case selection section 2705 for selecting the test case 210, a maintainability index threshold selection section 2706 for selecting the maintainability index threshold 211, and an overlap threshold selection section 2707 for selecting the overlap threshold 212.

[0153] The user of the source code analysis device 100 selects each data using the analysis target source code selection unit 2703, the analysis target program selection unit 2704, the test case selection unit 2705, the maintainability index threshold selection unit 2706, and the overlap threshold selection unit 2707, and presses the analysis start button 2702 to start the analysis.

[0154] When the user presses the analysis start button 2702, the source code metrics calculation unit 201, maintainability index calculation unit 202, division candidate element generation unit 203, program processing tracing unit 204, basic path generation unit 205, if provided, basic path maintainability index calculation unit 1601, division path generation unit 206, and if provided, division point mapping unit 2301, all within the source code analysis device 100, perform the processes described above.Then, the screen transitions to the analysis result list screen 2602.

[0155] 28 is a conceptual diagram illustrating an example of the analysis result list screen. The analysis result list screen 2602 has an analysis result list tab 2801 and a button 2802 for returning to analysis target selection.

[0156] The analysis result list tab 2801 has a division path list display section 2803. The division path list display section 2803 displays the contents related to the division path list 218. In this example, the division path list display section 2803 displays the names of the program elements to be divided in the division path record 1800, the values ​​of the pre-division maintainability index, and the values ​​of the post-division maintainability index.

[0157] When the user of the source code analyzing device 100 presses the name of a program element that has been determined to be divided in each division path record 1800 in the division path list display section 2803, the division point mapping section 2301 performs the above-mentioned process. Then, the screen transitions to the division point display screen 2603.

[0158] When the user presses a button 2802 for returning to the analysis target selection screen, the screen transitions to the analysis target selection screen 2601 .

[0159] 29 is a conceptual diagram illustrating an example of the division part display screen. The division part display screen 2603 has a division part display tab 2901, a button 2902 for returning to the analysis object selection, and a button 2903 for returning to the analysis result list.

[0160] The division location display tab 2901 has a source code display section 2904. The source code display section 2904 displays the source code 2500 in which the division locations are displayed so as to be distinguishable from other parts. The source code display section 2904 displays the maintainability indexes before and after the program division, along with the source code 2500 in which the division locations are displayed so as to be distinguishable from other parts. By viewing the division location display screen 2603, the user of the source code analysis device 100 can know the division locations of the source code and the maintainability indexes before and after the division.

[0161] When the user presses a button 2902 to return to analysis target selection, the screen transitions to the analysis target selection screen 2601. When the user presses a button 2903 to return to analysis result list, the screen transitions to the analysis result list screen 2602.

[0162] The above-described embodiments of the present invention are merely illustrative examples of the present invention, and are not intended to limit the scope of the present invention to these embodiments alone. Those skilled in the art can implement the present invention in various other forms without departing from the scope of the present invention.

[0163] As described above, the source code analysis device 100 that analyzes source code 208 corresponding to a program 209 includes a source code metrics calculation unit 201 that calculates source code metrics 213 from the source code 208 to be analyzed. The source code analysis device 100 includes a maintainability index calculation unit 202 that calculates a maintainability index 214 from the source code metrics 213. The source code analysis device 100 includes a division candidate element generation unit 203 that generates a division candidate element list 215 for the program based on the maintainability index 214 and a maintainability index threshold 211. The source code analysis device 100 includes a program processing tracing unit 204 that generates a dynamic information list 216 from the source code 208, the program 209, and test cases 210 for the program 209. The source code analysis device 100 includes a basic path generation unit 205 that generates a basic path list 217 from the dynamic information list 216 and the overlap threshold 212. The source code analysis device 100 includes a split path generation unit 206 that generates a split path list 218 from a split candidate element list 215 and a basic path list 217. The source code analysis device 100 generates a list of program elements to be split according to a maintainability index 214 and a dynamic information list 216, based on source code 208, a program 209, test cases 210, a maintainability index threshold 211, and an overlap threshold 212. This makes it possible to present areas where element splitting should be performed as improvement areas for program elements to be split, while meeting the developer's readability needs. As a result, typical frequently executed processes that a developer would want to read together as a single source code are not split against the developer's intention.

[0164] The source code analysis device 100 further includes a basic path maintainability index calculation unit 1601 that generates a basic path maintainability index 1602 from the basic path list 217, and generates a list of program elements to be divided 1801 as well as a list of maintainability indexes before element division 1803 and maintainability indexes after element division 1804. This makes it possible to present the effect of how much the maintainability of the source code to be analyzed is improved by element division.

[0165] The basic path generation unit 205 determines whether the maintainability index of the basic path is less than the maintainability index target value, and regenerates the basic path list based on the changed overlap threshold value. This allows the user to flexibly determine whether the generated basic path satisfies the developer's readability needs, while presenting locations where program elements should be divided to improve source code maintainability.

[0166] The source code analyzing device 100 further includes a division location mapping unit 2301 that generates source code 2302 indicating the division locations from the source code 208 and the division path list 218. This makes it possible to support the source code modification work by the person modifying the source code.

[0167] The division location mapping unit 2301 generates source code 2302 in which the division locations are indicated in units of program lines or tokens. By indicating the division locations in units of program lines or tokens, the source code analysis device 100 can clearly indicate the changes in the source code before and after division in units of lines or tokens. This makes it possible to present the division locations to a user, such as a source code corrector, in a manner that makes it easy to understand the results of element division.

[0168] The source code analyzing device 100 displays the source code 2500 showing the division locations, thereby allowing the user to know the division locations of the source code.

[0169] The source code analysis device 100 displays the maintainability indices before and after dividing the program together with the source code 2500 showing the division locations, allowing the user to know the division locations of the source code and the maintainability indices before and after the division. [Explanation of symbols]

[0170] 1...processing device, 100...source code analysis device, 101...processor, 102...main memory device, 103...auxiliary memory device, 104...input device, 105...output device, 106...communication device, 201...source code metrics calculation unit, 202...maintainability index calculation unit, 203...division candidate element generation unit, 204...program processing tracking unit, 205...basic path generation unit, 206...division path generation unit, 207...information storage unit, 208...analysis target source code, 209...analysis target program, 210...test case, 211...maintainability index threshold, 212...overlap threshold, 213...source code metrics, 214...maintainability index, 215...division candidate element list, 216 ...Dynamic information list, 217...Basic path list, 218...Split path list, 1601...Basic path maintainability index calculation section, 1602...Basic path maintainability index, 2301...Split location mapping section, 2601...Analysis target selection screen, 2602...Analysis result list screen, 2603...Split location display screen, 2701...Analysis target selection tab, 2702...Analysis start button, 2703...Analysis target source code selection section, 2704...Analysis target program selection section, 2705...Test case selection section, 2706...Maintainability index threshold selection section, 2707...Overlap threshold selection section, 2801...Analysis result list tab, 2802, 2902, 2903...Buttons, 2803...Split path list display section 2901...Division point display tab, 2904...Source code display section

Claims

1. A source code analysis device that analyzes source code corresponding to a program, a source code metrics calculation unit that calculates source code metrics of each program element included in the program from the source code to be analyzed; a maintainability index calculation unit that calculates a maintainability index for each of the program elements from the source code metrics; a division candidate element generating unit that generates a division candidate element list that records program elements that are candidates for division based on the maintainability index and a maintainability index threshold; a program processing tracing unit that generates, for each program element included in the division candidate element list, a dynamic information list that records an execution path that is a portion of the source code corresponding to a process that is executed when the program is executed based on the test case, from the source code, the program, and a test case for the program; and a basic path generation unit that generates, from the dynamic information list and an overlap threshold, a basic path list that records portions of the source code in each of the program elements included in the splitting candidate element list, where the proportion of test cases that include the portions in the execution paths shown in the dynamic information list is equal to or greater than the overlap threshold; a division path generating unit that generates a division path list from the division candidate element list and the basic path list, the division path list recording parts of each of the program elements included in the division candidate element list that are not included in the basic path list, Source code analyzer.

2. a basic path maintainability index calculation unit that generates, from the basic path list, a basic path maintainability index that is a maintainability index for a basic path of a program element included in the division candidate element list, The source code analysis device according to claim 1 .

3. the basic path generation unit increases the overlap threshold and regenerates the basic path list if the basic path maintainability index is less than a maintainability index target value; The source code analysis device according to claim 2 .

4. a division point mapping unit that generates, from the source code and the division path list, source code in which parts included in the division path list are shown so as to be distinguishable from other parts, The source code analysis device according to claim 1 .

5. the division portion mapping unit generates source code in which the portions included in the division path list are indicated in units of program lines or tokens. The source code analysis device according to claim 4.

6. displaying the source code in which the parts included in the split path list are distinguishable from other parts; 6. The source code analysis device according to claim 4 or 5.

7. displaying maintainability indicators before and after dividing the program together with source code in which the parts included in the divided path list are shown so as to be distinguishable from other parts; The source code analysis device according to claim 6.

8. A method for analyzing source code corresponding to a program, executed by a device having a processor and a storage device, comprising: Calculating source code metrics for each program element included in the program from the source code to be analyzed; calculating a maintainability index for each of the program elements from the source code metrics; generating a division candidate element list that records program elements that are candidates for division based on the maintainability index and a maintainability index threshold; generating a dynamic information list for each program element included in the division candidate element list from the source code, the program, and test cases for the program, the dynamic information list recording an execution path that is a portion of the source code corresponding to a process that is executed when the program is executed based on the test cases; From the dynamic information list and the overlap threshold, generate a basic path list that records, among the portions of the source code in each of the program elements included in the splitting candidate element list, portions of the test cases in which the proportion of test cases that include the portions in the execution paths shown in the dynamic information list is equal to or greater than the overlap threshold; A source code analysis method that generates a split path list from the split candidate element list and the basic path list, the split path list recording parts of each program element included in the split candidate element list that are not included in the basic path list.

9. A source code analysis program that analyzes source code corresponding to a program, An apparatus having a processor and a storage device, Calculating source code metrics for each program element included in the program from the source code to be analyzed; calculating a maintainability index for each of the program elements from the source code metrics; generating a division candidate element list that records program elements that are candidates for division based on the maintainability index and a maintainability index threshold; generating a dynamic information list for each program element included in the division candidate element list from the source code, the program, and test cases for the program, the dynamic information list recording an execution path that is a portion of the source code corresponding to a process that is executed when the program is executed based on the test cases; From the dynamic information list and the overlap threshold, generate a basic path list that records, among the portions of the source code in each of the program elements included in the splitting candidate element list, portions of the test cases in which the proportion of test cases that include the portions in the execution paths shown in the dynamic information list is equal to or greater than the overlap threshold; A source code analysis program for executing the following: generating a split path list from the split candidate element list and the basic path list, the split path list recording the parts of each program element included in the split candidate element list that are not included in the basic path list.

Citation Information

Patent Citations

  • Estimating device

    JP2005092532A

  • Source code analysis device

    JP2007219586A

  • Execution path detecting device, information processor, execution path detecting method, program and recording medium

    JP2008250867A

  • Source code analysis method and source code analysis device

    JP2019219848A

  • Hybrid dependency analysis using dynamic and static analyses

    US20140181835A1