Information processing device, information processing method, program, and information processing system

The information processing device efficiently detects copy and paste in source code and similar blocks across projects by encoding sub-blocks with hash functions, addressing inefficiencies in existing refactoring methods and reducing computational and manual costs.

JP7739297B2Active Publication Date: 2025-09-16FIXSTARS CORPORATION
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
JP2022542883
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2021-02-24
Filing Date
2021-08-12
Publication Date
2025-09-16
Estimated Expiration
2041-08-12

AI Technical Summary

Technical Problem

Existing refactoring methods for source code, particularly those involving copy and paste detection, are costly and inefficient, especially for large projects, and manually identifying similar code blocks for modification is difficult.

Method used

An information processing device and method that divides source code into units, encodes sub-blocks using hash functions, and detects duplicates or clone pairs based on predetermined percentages, enabling efficient detection of copy and paste and similar code blocks across projects.

Benefits of technology

Facilitates rapid detection of copy and paste occurrences and clone pairs with computational complexity of O(n), suitable for both server and client environments, improving security and reducing manual effort and costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007739297000001
    Figure 0007739297000001
  • Figure 0007739297000002
    Figure 0007739297000002
  • Figure 0007739297000003
    Figure 0007739297000003
Patent Text Reader

Abstract

[Problem] To extract code blocks that correspond between projects. [Solution] An information processing device that comprises at least one processing circuit. The processing circuit: divides a target into a plurality of units for each prescribed identifier; makes a group of a first prescribed number of units from each unit into a sub-block, for each of the plurality of units; codifies the sub-block using a prescribed conversion; uses the code as a key; and, if duplication of the key is detected, detects that another sub-block exists that has the same content as the sub-block corresponding to the code.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present disclosure relates to an information processing device, an information processing method, a program, and an information processing system. [Background technology]

[0002] Refactoring of source code is now widely practiced in various projects. Currently, refactoring is often carried out by the user extracting areas that can be modified and modifying those areas. However, this type of refactoring method has the drawback of being costly. To address this situation, some methods are being used to automatically extract areas in source code that have been written using copy and paste, which are areas that can be modified. However, this type of search requires O(n 2 ) requires a lot of processing and time, making automatic extraction impractical for large projects.

[0003] Furthermore, when source code uses common logic, there may be similar code blocks in different locations. While such blocks can be targets for refactoring, refactoring is often difficult. In such cases, there may be several similar code blocks in the source code. When adding or modifying a function, it may be desirable to make the same modifications to similar code blocks. However, manually extracting such target code blocks is often difficult or costly. [Prior art documents] [Non-patent literature]

[0004] [Non-Patent Document 1] PMD, https: / / pmd.github.io / pmd-6.26.0 / pmd_release_notes.html, [Internet], accessed August 13, 2020 Summary of the Invention [Problem to be solved by the invention]

[0005] Therefore, the present disclosure provides an information processing device, an information processing method, a program, and an information processing system that quickly extract portions created by copy and paste.

[0006] The present disclosure also provides an information processing device, an information processing method, a program, and an information processing system that extract corresponding code blocks within a single project or between different projects. [Means for solving the problem]

[0007] According to one embodiment, an information processing device comprises one or more processing circuits. The processing circuitry Dividing the object into a plurality of units for each predetermined identifier, For each of the plurality of units, a set of a first predetermined number of the units is defined as a sub-block; encoding said sub-blocks according to a predetermined transformation; When the code is used as a key and duplication of the key is detected, it is detected that there is another subblock with the same content as the subblock corresponding to the code.

[0008] According to one embodiment, an information processing device comprises one or more processing circuits. The processing circuitry Detecting a second code block that is a clone pair and has content identical to the first code block by a predetermined percentage or more in the first source code; extracting a third code block corresponding to the first code block from a second source code that has been edited earlier than the first source code; If the first code block has been modified, a dictionary based on the modification is created for the third code block; Based on the dictionary, it is detected whether there is a possibility that the second code block has not been corrected. [Brief explanation of the drawings]

[0009] [Figure 1] FIG. 1 is a block diagram schematically illustrating an information processing apparatus according to an embodiment. [Figure 2] 10 is a flowchart showing the operation of an information processing device according to an embodiment. [Figure 3] FIG. 10 is a diagram showing an example of analysis target data according to an embodiment. [Figure 4] 10 is a flowchart showing the operation of an information processing device according to an embodiment. [Figure 5] FIG. 10 is a diagram showing an example of a token type according to an embodiment. [Figure 6] FIG. 10 is a diagram showing an example of overlapping according to an embodiment. [Figure 7] FIG. 10 is a diagram showing an example of overlapping according to an embodiment. [Figure 8] A schematic diagram showing an example of an increase in clone pairs in a project. [Figure 9] FIG. 10 is a diagram showing an example of a comparison according to an embodiment. [Figure 10] FIG. 10 is a diagram schematically illustrating an example of detection according to an embodiment. DETAILED DESCRIPTION OF THE INVENTION

[0010] Embodiments of the present disclosure will be described with reference to the drawings. Note that the drawings and description only show exemplary configurations of the embodiments and do not limit the absence of other components. For example, various components for operating a computer are omitted. Furthermore, in the description of the embodiments, although there are expressions such as "greater than" (more than), it is not essential which of the boundary values ​​is included, and these should be appropriately interpreted as "less than" and "greater than." The same applies to the scope of the claims.

[0011] 1 is a diagram illustrating a configuration of an information processing system according to an embodiment. The information processing system 1 includes an information processing device 10 and a server 20.

[0012] The information processing device 10 includes a processing circuit 100, a memory 102, and an interface 104. The information processing device 10 is, for example, a computer (client) that can be controlled directly or indirectly by a user. This computer is connected to a server 20 via a network such as the Internet.

[0013] The processing circuit 100 executes various processes in the information processing device 10. The processing circuit 100 may be, for example, a CPU (Central Processing Unit) or a circuit that performs general-purpose processing. It may also be an accelerator such as a GPU (Graphics Processing Unit) or a circuit that executes calculations based on requests from the CPU. The processing circuit 100 may have the configuration exemplified above, or may be an analog circuit or a digital circuit that can realize the processes described below. Its configuration may be, for example, an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or the like.

[0014] The memory 102 stores data required to execute the operations of the information processing device 10 or data resulting from the operations. The memory 102 may include, for example, a dynamic random access memory (DRAM) or a magnetoresistive random access memory (MRAM), or may be partially configured with a read only memory (ROM).

[0015] For example, the operation of the processing circuit 100 may be such that software-based information processing is specifically realized using hardware resources (the processing circuit 100, the memory 102, etc.). In this case, the memory 102 may store information such as a program for executing the information processing, and the processing circuit 100 may read the program stored in the memory 102, thereby realizing the information processing by the processing circuit 100.

[0016] The interface 104 is an interface that connects the information processing device 10 to the outside. The interface 104 includes, for example, a network interface, and realizes communication with the server 20 via this network interface. Although not shown, the interface 104 is also connected to input devices such as a mouse and a keyboard, and output devices such as a display and a speaker. Requests from a user are accepted via these input devices, and the processed results are output to the user via the output devices.

[0017] The interface 104 may be, for example, a communication interface connected to a file server, and the information processing device 10 may acquire information to be analyzed from the file server and output the analysis results to the file server. The file server and the information processing device 10 may be provided within the same intranet or the like connected by a LAN (Local Area Network). In this case, the input of information to the information processing device 10 and the output of the analysis results may be accessed from a closed space within a company or the like, for example, so that the information cannot be leaked to the outside.

[0018] The server 20 provides a program required for operation in response to a request from the information processing device 10. The information processing device 10 executes information processing in the information processing device 10 using the program provided by the server 20. As another example, the information processing may be executed on the server side. In this case, the information processing device 10 may transmit data to be processed to the server 20, or may transmit the location where the data exists to the server 20, and the server 20 may automatically obtain the data to be processed from the information on the location.

[0019] (First embodiment) Next, a description will be given of the processing in the information processing system 1. First, a description will be given of the extraction of copy and paste in source code.

[0020] FIG. 2 is a flowchart showing the flow of processing by the information processing device 10 according to this embodiment.

[0021] First, the information processing device 10 obtains a necessary program from the server 20 (S100). More specifically, the processing circuit 100 obtains necessary information from the server 20 via the interface 104. The processing circuit 100 obtains a program necessary for analyzing the target from the server 20 using an application, for example, a web browser. The application is not limited to a web browser and may be a native application. The application downloads the program necessary for the analysis to a local environment and processes it, making it possible to process the analysis target in a local user environment. Completing the processing in a local environment prevents the contents of the source code from leaking to the outside.

[0022] Next, the processing circuit 100 acquires the data to be analyzed (S102). The processing circuit 100 may store the data to be analyzed in, for example, the memory 102, in which case this step can be omitted. The order of acquiring this information and acquiring the program in the previous step can be reversed as desired.

[0023] As another example, when information may be transmitted to the server 20, an ASP (Application Service Provider) or the like may be used. In this case, data to be analyzed is transmitted from the information processing device 10 to the server 20. As described above, if the data is stored on a cloud or the like, the server 20 may automatically acquire the analysis target, such as source code, by specifying the address. According to this example, the step of acquiring the program in S100 can be omitted. For example, when analyzing publicly available source code, this method may be adopted to reduce the computational costs on the client side. In this case, subsequent processing may be executed by, for example, a processing circuit of the server 20.

[0024] Next, the processing circuit 100 divides the target data into units using a predetermined identifier (S104). The predetermined identifier may be, for example, \n (a line feed code). When \n is used as the predetermined identifier, one line of the source code is recognized as a unit.

[0025] The predetermined identifier is not limited to this, and may be, for example, ";". If ";" is used as the predetermined identifier, for example, if the source code language is C or C++, a unit can be set for each instruction. Other characters may also be used. In this way, an object of any form, such as a control character or a character written in ASCII code, can be used as the predetermined identifier.

[0026] The predetermined identifier may also be set appropriately based on the language and other conditions. For example, some languages ​​allow for descriptions to span multiple lines. In such languages, "\n" is ignored, and it may not be appropriate to separate units by separating each "\n". For this reason, the unit can be appropriately determined by a statement in each programming language.

[0027] 3 is a diagram showing pseudocode as an example of data to be analyzed. As shown in this diagram, the analysis data may be, for example, source code written in a predetermined programming language. When the predetermined identifier is the above-mentioned \n, the processing circuit 100 divides the target data into units of instruction groups written on each line.

[0028] In Figure 3, if \n is a predetermined identifier, it is divided into units such as {, \tint a = 0;, \tint b = 1;, .... For example, a description like the one on line 7 is divided into units such as \tfunc01(p);\tfunc01(p);. Although spaces are used here as spaces, they may also be divided into control codes such as .

[0029] On the other hand, if ";" is the predetermined identifier as described above, then for example, a description like the one on line 7 will be split into func01(p) and \tfunc01(p). Depending on the language, \t may not be necessary for semantic analysis, so it may be deleted at the time of splitting, or it may be deleted when obtaining the token sequence described below. However, for languages ​​in which \t is meaningful (e.g., Python), these will not be deleted either. The same applies to blank lines; they may be appropriately deleted or left as they are when splitting.

[0030] Next, the processing circuit 100 acquires sub-blocks (S106). A sub-block is, for example, a set of units grouped together in a first predetermined number. In the example of FIG. 3, if the predetermined identifier is \n and the first predetermined number is 5, then {, int a = 0, ..., (blank line)) is acquired as the first sub-block. In this case, as described above, 5 lines are acquired as the sub-block. This first predetermined number can be determined appropriately and may be, for example, 20, or a smaller or larger number. A user may be able to specify the first predetermined number via an input interface.

[0031] Next, processing circuit 100 encodes this sub-block (S108). Figure 4 is a flowchart showing the process for encoding a sub-block.

[0032] First, the processing circuit 100 acquires a token sequence for a sub-block (S200). For example, in the example of the first sub-block in FIG. 3, the token sequence acquired is "int", "a", "=", "0", ";". By performing this for each unit included in the sub-block, the token sequence for the entire sub-block is acquired.

[0033] Next, the processing circuit 100 converts the token string acquired in S200 into token types (S202). In the above example, the token types are converted to "raw_identifier", "raw_identifier", "equal", "numeric_constant", and "semi". This conversion does not limit the form of the converted name, etc., as long as it can be converted uniquely for each type.

[0034] The obtained token type may be stored for each unit in the memory 102. By storing in this way, when obtaining the token type of a sub-block, it becomes possible to omit part of the process.

[0035] Next, the processing circuit 100 encodes the token type of the sub-block acquired in S202 (S204). This encoding may be performed by converting the token type using a predetermined function (predetermined conversion) and outputting the converted code as a code string. For example, the predetermined function is a hash function, and the encoded result is a hash value. For example, this hash value is treated as the code.

[0036] Note that the above steps S200 and S202 may be omitted. That is, the processing circuit 100 may convert the text data of the entire sub-block using a predetermined function to calculate the code.

[0037] As another example, a second predetermined number of units at the beginning of a sub-block, for example, the first two units, may be used as text data as is, and for the other units, a token sequence may be obtained and the token type converted to calculate a code. As another example, a second predetermined number of units at the end of a sub-block may be used as text data, and the other units may be converted into token types to calculate a code. Note that the second predetermined number is not limited to 2, and may be a smaller or larger number. As with the first predetermined number, it may be a number that can be specified by the user.

[0038] Figure 5 shows the token types obtained for the source code in Figure 3. The separator is written as a comma as an example, but is not limited to this. The separator may be an identifier such as another character, or there may be no separator at all.

[0039] When the first predetermined number is 5, in the case of FIG. 5, the first sub-block from the first left_curl unit to the blank unit is substituted into the predetermined function to obtain the code.

[0040] Returning to FIG. 2, the processing circuit 100 then uses this code as a key to detect whether it is a duplicate of a key already stored in memory 102 (S110). If the acquired key is already stored in memory 102, it is determined that a string of hash types, a string of text data, or a string of a combination of text data and hash types with the same content as the sub-block (e.g., the first sub-block) is already stored, and this is detected as a duplicate. If a duplicate key is not detected, the key is stored in memory 102.

[0041] This detection and storage may be performed using, for example, a database. In this case, the processing circuit 100 attempts to register the coded string in the database as a unique key. If the registration in the database is successful, it is determined that there are no duplicate sub-blocks in the portion analyzed up to this point. On the other hand, if the registration in the database is rejected due to a unique index error, it is determined that a duplicate sub-block has already been registered, and that a duplicate sub-block exists.

[0042] When an overlapping portion is detected, the processing circuit 100 may output the overlapping portion, or may store in the memory 102 the unit position of the overlapping portion (for example, information such as the number of lines, address, etc.).

[0043] When the processing circuit 100 determines that the processing has ended (S112: YES), it outputs, for example, information about the position information of the overlapping portion and ends the processing.

[0044] On the other hand, if it is determined that the processing is not complete (S112: NO), the sub-block is updated and the processing from S106 is repeated. In the example of FIG. 3, the sub-block is updated by setting the unit from int a = 0, which is the next unit after the beginning of the first sub-block, to SET_PARAM01('xxx', p, a, b); as the second sub-block. Then, the same processing is repeated for this second sub-block.

[0045] The end of processing is determined by, for example, setting sub-blocks for all units and determining whether the operation is complete. More specifically, in the example of Figure 3, the end of processing is determined by determining whether the processing up to the sub-block with all rows as the head (however, the sub-block that includes the last row at the end is the final sub-block) is complete.

[0046] In the above example, processing starts from the first unit in FIG. 3, but this is not limited to this. Conversely, processing may be performed in reverse order, with a first predetermined number of units from the end as sub-blocks. Processing may also start from an intermediate unit. These processes may be performed in ascending or descending order when the units are arranged in order.

[0047] Note that sub-block processing may be performed for each appropriate block. For example, in the example of FIG. 3, "{\n" to "}\n" may be considered as one block, and sub-blocks may be created so as not to extend beyond that block. In other words, the last sub-block may be the last sub-block in the line where the final unit is p = 0\n. By analyzing in this way, it is possible to extract whether or not copy and paste occurs for each block. The identifiers for the start and end of this block may also be predetermined, or may be set by the user. If they are predetermined, the identifiers for the start and end of the block may be automatically switched depending on the language.

[0048] 6 is a diagram showing how duplication occurs when the above process is performed. For example, if the parts enclosed in {} are the first block, the second block, and the third block, the first block is the first block, so the keys of each sub-block are stored in memory 102 as there are no duplications.

[0049] As for the second block, there are also no overlapping portions, so the keys of each sub-block are stored in memory 102 as being unique.

[0050] For the third block, the acquired token type is the same as that of the first block, so it is detected as a duplicated portion in each sub-block. Although the first block and the third block are different as raw text data, by acquiring the token string and converting it into a token type as in this embodiment, they are determined to be the same data string and can be detected as a duplicated portion where copy and paste may have been performed.

[0051] As described above, according to this embodiment, even when the content itself is different, it is possible to detect a portion having a similar configuration as a portion that may have been copied and pasted.

[0052] As another example, as described above, it is possible to omit S200 and S202 in FIG. 4, in which case a completely matching portion can be detected as a portion where copying and pasting has occurred.

[0053] In both cases, the amount of detection processing increases depending on the number of sub-blocks. That is, although the number of hash strings included in a unit may increase or decrease, in principle, copy and paste detection can be performed in a linear order with respect to the number of sub-blocks, that is, with n being the number of sub-blocks = the number of units, the amount of calculation required is O(n). As a result, this embodiment makes it possible to detect duplicates at high speed.

[0054] As mentioned above, this processing can be performed not only on the server side, but also in a client environment such as a web browser, without sending the data to be analyzed to the server side. Even in this case, the processing can be performed with a computational cost of O(n), so it can be easily processed even on clients that are generally not as suited to high-cost calculations as servers. In this way, processing can be performed without problems within the client without sending data externally from the client, which also leads to improved security.

[0055] (Variation) As mentioned above, the first second predetermined number of lines may be coded without converting them into token types. In such a case, for example, the first and third blocks are detected as overlapping up to the line SET_PARAM01(...), but the sub-block beginning with the line SET_PARAM01(...) is not detected as overlapping. The same is true for the sub-block beginning with the next line. Therefore, although there is overlap up to these lines, it is possible to determine that these lines are not overlapping.

[0056] In this way, by encoding the second predetermined number of units without converting them into token types, it becomes possible to output overlapping portions with finer granularity.

[0057] 7 is a diagram showing an example of output in which units of a second predetermined number are not converted into token types. In the diagram, diagonal lines slanting upward to the right indicate non-overlapping parts, and diagonal lines slanting upward to the left indicate overlapping parts. By not converting the second predetermined number of lines into token types for sub-blocks starting from each line, when non-overlapping parts are included in the middle, as in FIG. 7, it is possible to more clearly distinguish between overlapping parts and non-overlapping parts.

[0058] Furthermore, for a third predetermined number of units (2 as a non-limiting example), if there is a non-overlapping unit sandwiched between overlapping portions, that portion may be output as a possible copy-and-paste portion, as shown in the figure.

[0059] In this example, the first second predetermined number of units are used, but as described above, the last second predetermined number of units may also be used. As another example, the second predetermined number of units in the middle, not the first or last, may be used as raw data, and the other units may be converted into hash types and coded.

[0060] The above-described process is executed in a client-side application, and the application may output advertisements. Based on a request from the server 20, the processing circuit 100 may cause the application to output advertisements at least one of before, during, and after the analysis process.

[0061] The server 20 may store information about the advertisement and may store user responses to the advertisement. It is also possible to create a revenue model based on information that the advertisement was output or, for example, information that the user accessed the advertiser's website from the advertisement.

[0062] (Second embodiment) First, we will explain how to extract clone pairs from source code. A clone pair is a set of blocks in different blocks of source code that have the same description, or a set of blocks that have the same description but have been modified. If modifications have been made, the pair may be blocks that have a predetermined percentage or more of the same description. Here, the predetermined percentage may be, for example, 80%, but is not limited to this and may be a smaller value such as 60% or a larger value such as 95%. It may also be a value that changes depending on the project, file, etc. Furthermore, the source code from which the clone pairs are extracted may be source code that exists in the same file or may exist in different files.

[0063] In this embodiment, the process of extracting clone pairs is performed by performing the same process as the method shown in Fig. 2 in the first embodiment. For example, as in the above-described embodiment, it is possible to detect parts that have similar configurations even when the content itself is different as parts that may have been copied and pasted, and the information processing system 1 extracts these detected parts as clone pairs. Similarly, if there is a non-overlapping unit sandwiched between overlapping parts for the third predetermined number of units, the information processing system 1 can also output this part as a clone pair.

[0064] As described above, the information processing system 1 extracts clone pairs in the source code of a project. In a project, the source code is updated daily by one or more users. Accordingly, the number of clone pairs extracted as described above may increase or decrease.

[0065] Figure 8 is a schematic diagram of an example of an increase in clone pairs in a certain project A. For example, the project on January 1, 2021 and the clone pairs of the project on February 1, 2021 are shown. Hereinafter, the February 1, 2021 version will be referred to as the first source code, and the January 1, 2021 version will be referred to as the second source code. Note that information about the clone pairs extracted as described above may be recorded as project information.

[0066] As shown in the figure, the second source code has clone pairs α and β, and the first source code has clone pairs α, β, and γ. First, the information processing system 1 determines which clone pairs in the second source code correspond to which clone pairs in the first source code. As in the first embodiment, these processes and the following processes may be processed by either the information processing device 10 or the server 20, or may be processed cooperatively.

[0067] The information processing system 1 performs the association of clone pairs between the first source code and the second source code by a process similar to that of extracting clone pairs within a project. For example, the information processing system 1 performs the association by extracting blocks corresponding to the source code of the second source code using blocks and sub-blocks of the source code of the first source code.

[0068] This process is similar to the clone pair extraction process described above, in that, for example, sub-blocks in the first source code and sub-blocks in the second source code are coded, respectively. However, the difference is that the source code to be processed is not source code of the same version (revision), but spans the first source code and the second source code.

[0069] FIG. 9 shows a more detailed example. For example, the first source code and the second source code have the description shown in the figure. The numbers on the left side of the source code are numerical values ​​representing line numbers for explanation purposes and are not included in the source code. In the second source code, the portion described is a block recorded in the second source code as a clone pair.

[0070] The first line in this second source code has been deleted, and the third and sixth lines in the first source code have been added.

[0071] In such a case, for example, by converting each line into tokens and then calculating the hash value, it is possible to extract by performing the above process that lines 1 and 2 of the first source code correspond to lines 2 and 3 of the second source code, and that lines 4 and 5 of the first source code correspond to lines 4 and 5 of the second source code. Note that although the hash value is calculated after conversion into tokens in the above, the hash value may also be calculated without converting into tokens in order to detect an exact match. In either case, the calculated hash value may be registered in a database to detect duplicates, or hash values ​​may be compared using other methods.

[0072] Since there is no matching hash for lines 3 and 6 of the first source code in the second source code, the information processing system 1 determines that these lines are added lines. As described above, if the degree of match within a block is equal to or greater than a predetermined percentage, these blocks are determined to be edited versions of the same block.

[0073] This type of determination makes it possible to determine that a code block corresponds even if statements have been deleted or added in the source code, as long as other statements match sufficiently. If there are multiple candidates for a corresponding code block and there is no difference in the degree of match, the code block whose start line is closer in the old and new source codes may be adopted as the corresponding code block.

[0074] In this way, the information processing system 1 associates the combination of clone pairs in the new version with the combination of clone pairs in the old version. That is, by applying the comparison of blocks within the same project described in the above embodiment to source code of different versions of the project, the information processing system 1 associates the clone pairs in the new and old versions with each other.

[0075] As described above, this embodiment makes it possible to extract corresponding clone pairs in source code for the same project with different timestamps. By applying this clone pair extraction to the following process, even if the project progresses and the number of clone pairs increases as shown in the figure, it is possible to appropriately link the clone pairs of the old project with the clone pairs of the new project.

[0076] Furthermore, the detection method of this embodiment is not limited to detecting pairs between an old project and a new project; it can also detect duplicate or similar descriptions in other source code. By applying this embodiment to source code licensed under a license such as the GPL and the code of a target project, it is possible to check whether the source code of an ongoing project contains descriptions that cite other source code. Here, citation includes code that is similar and either a perfect match or a partial match. This can be detected by converting the descriptions into tokens.

[0077] As another example, it is possible to detect problems such as one's own code being included in another company's open source code.

[0078] In this way, it can also be used to investigate copyright infringement, such as when a particular open source code is included in proprietary software, when your code is included in someone else's code, or vice versa.

[0079] By performing such processing, the clone pairs in the new and old projects are associated with each other as shown in Fig. 8. Next, the information processing system 1 may determine whether or not there are any omitted corrections between the clone pairs.

[0080] Figure 10 shows clone pairs in the first source code and the second source code. As shown in this figure, a clone pair α-α' exists in each source code, and block α of the first source code and block α of the second source code are extracted as corresponding code blocks. Figure 10 also shows the processing steps.

[0081] First, the information processing system 1 detects corresponding code blocks between the first source code and the second source code (S300). The detection of the corresponding code blocks is performed by the above-described process.

[0082] Next, the information processing system 1 compares the corresponding source codes to determine whether or not there has been a correction, and if there has been a correction, extracts the corrected portion (S302). By comparing block α of the first source code with block α of the second source code, the information processing system 1 determines that the line "int d = 400;" has been corrected to "int d = 4;". The information processing system 1 calculates a hash value for the description for each line within the corresponding block, for example, and compares the hash values ​​in the same manner as above to extract lines with different descriptions.

[0083] Next, the information processing system 1 creates a change dictionary for corrections based on the text information of the different lines of this description (S304). The change dictionary is a dictionary that associates correction information, and for example, if "int d = 400;" is corrected to "int d = 4;", it may include information indicating that "400" has been changed to "4". However, this is not limited to this, and information on the corrected line ("int d = 400;" changed to "int d = 4;") may also be registered in the dictionary. Furthermore, the line number of the correction within the code block may be linked and registered in the dictionary.

[0084] Next, when the information processing system 1 detects a modification between corresponding blocks in the first source code and the second source code, it detects whether a similar modification has been made to the clone pair of the corresponding blocks in the first source code (S306). The information processing system 1 compares the code block α with the code block α' to determine whether the modification has been reflected. This determination is performed using a modification dictionary. For example, the information processing system 1 extracts information that matches the information before the modification in the modification dictionary.

[0085] Here, there is a line that matches the pre-correction information "int d = 400;", so the information processing system 1 extracts this information and detects lines (or sub-blocks) that have been corrected in the clone pair code block α but not in the code block α'. If the information in the change dictionary is linked to information about a position within the block, it may be possible to detect whether a similar correction has been made by the change dictionary around that position in the blocks that form the clone pair.

[0086] If there is a line (sub-block) that matches the information before correction in the change dictionary, the information processing system 1 determines that this part may be a missing correction (S308). The information processing system 1 appropriately stores this part as a missing correction candidate or appropriately outputs it to the user.

[0087] As described above, according to this embodiment, in projects of different versions, clone pairs corresponding to clone pairs in an old version are detected in a new version, and if there is a correction in one of the code blocks that make up the clone pair and information before the correction remains in the other code blocks, it is possible to detect the possibility that there is a missed correction in the source code in this location.

[0088] When improving source code, it is often the case that similar modifications should be made to clone pairs. The information processing system 1 according to this embodiment can reduce the possibility of missing modifications in places where such modifications should be made. This can reduce the occurrence of bugs and reduce the cost of visual checks by users.

[0089] The information processing system 1 may include or use, for example, a version control system. This version control system may be a general system such as Git, Mercurial, or Subversion, or may be system-specific. In this case, if the version control system records differences between source code fragments, the information processing system 1 may register the differences in a change dictionary within the code block based on the difference information.

[0090] Similarly, for code blocks of clone pairs, the difference information can be compared with dictionary information, and if, for example, there is a correction in code block α and there is a location registered in the dictionary, but there is no difference in the similar correction, it can be determined that there is a possibility that a correction has been missed.

[0091] The above-described process is executed in a client-side application, and the application may output advertisements. Based on a request from the server 20, the processing circuit 100 may cause the application to output advertisements at least one of before, during, and after the analysis process.

[0092] The server 20 may store information about the advertisement and may store user responses to the advertisement. It is also possible to create a revenue model based on information that the advertisement was output or, for example, information that the user accessed the advertiser's website from the advertisement.

[0093] The aspects of the present disclosure are not limited to the above-described embodiments and include various conceivable modifications, and the effects of the present disclosure are not limited to the above-described contents. The components in each embodiment may be appropriately combined and applied. In other words, various additions, modifications, and partial deletions are possible within the scope of the conceptual idea and intent of the present disclosure, which is derived from the content defined in the claims and their equivalents.

[0094] For example, in the above, the target of analysis was described as source code, but this is not limited to this and any text file will do. As some non-limiting examples, copy and paste in assignment reports, various manuals, and other documents can be similarly extracted. This can also be used for binary files, not just text files. In these cases, the above-mentioned predetermined identifiers, etc., can be set appropriately. [Explanation of symbols]

[0095] 10: Information processing device, 100: processing circuit, 102: Memory, 104: Interface, 20: Server

Claims

1. one or more processing circuits; The processing circuitry Dividing the object into a plurality of units for each predetermined identifier, For each of the plurality of units, a set of a first predetermined number of the units is defined as a sub-block; encoding said sub-blocks according to a predetermined transformation; using the code as a key, when detecting duplication of the key, detecting the presence of another sub-block with the same content as the sub-block corresponding to the code; Information processing device.

2. the predetermined conversion is a conversion using a hash function, The code is a hash value. The information processing device according to claim 1.

3. The processing circuitry The code is registered in a database to store the code as a unique key; a request to store the key in the database, and if a unique index error occurs in response to the storage request, detecting that there is another subblock with the same content as the subblock corresponding to the code; 3. The information processing device according to claim 1 or 2.

4. The processing circuitry further comprises: changing the sub-blocks for each unit in ascending or descending order; repeating the process for the modified sub-blocks; 4. The information processing device according to claim 1.

5. The target is text data.

5. The information processing device according to claim 1.

6. The text data is data describing source code. The information processing device according to claim 5.

7. The processing circuitry obtaining a token sequence for the object; determining the type of each element of the token sequence and converting it to the type; Calculating the code using the converted token sequence; 7. The information processing device according to claim 5 or claim 6.

8. The processing circuitry In the sub-block, a second predetermined number of the units at the beginning, end, or middle are coded without being tokenized. The information processing device according to claim 7.

9. The object is binary data.

5. The information processing device according to claim 1.

10. the processing circuit is provided in a client and performs processing without transmitting information to an external device; 10. The information processing device according to claim 1.

11. The processing circuitry In the first source code, which is one of the targets, a second code block is detected as a clone pair having content identical to the first code block by a predetermined percentage or more; extracting a third code block corresponding to the first code block from a second source code that is another target and was edited earlier than the first source code; If the first code block has been modified, a dictionary based on the modification is created for the third code block; detecting a possibility that the second code block may have been left uncorrected based on the dictionary; 11. The information processing device according to claim 1.

12. The processing circuitry Dividing the first code block into a plurality of the sub-blocks; locating, in the second source code, other sub-blocks corresponding to the plurality of sub-blocks of the first code block; extracting, as the third code block, a continuous set of the other sub-blocks that match the plurality of sub-blocks of the first code block at a predetermined rate or more; The information processing device according to claim 11.

13. one or more processing circuits, Dividing the object into a plurality of units for each predetermined identifier, For each of the plurality of units, a set of a first predetermined number of the units is defined as a sub-block; encoding said sub-blocks according to a predetermined transformation; using the code as a key, when detecting duplication of the key, detecting the presence of another sub-block with the same content as the sub-block corresponding to the code; Information processing methods.

14. The processing circuitry In the first source code, which is one of the targets, a second code block is detected as a clone pair having content identical to the first code block by a predetermined percentage or more; extracting a third code block corresponding to the first code block from a second source code that is another target and was edited earlier than the first source code; If the first code block has been modified, a dictionary based on the modification is created for the third code block; detecting a possibility that the second code block may have been left uncorrected based on the dictionary; 14. The information processing method according to claim 13.

15. one or more processing circuits, Dividing the object into a plurality of units for each predetermined identifier, For each of the plurality of units, a set of a first predetermined number of the units is defined as a sub-block; encoding said sub-blocks according to a predetermined transformation; using the code as a key, when detecting duplication of the key, detecting the presence of another sub-block with the same content as the sub-block corresponding to the code; A program that makes it happen.

16. The processing circuitry In the first source code, which is one of the targets, a second code block is detected as a clone pair having content identical to the first code block by a predetermined percentage or more; extracting a third code block corresponding to the first code block from a second source code that is another target and was edited earlier than the first source code; If the first code block has been modified, a dictionary based on the modification is created for the third code block; detecting a possibility that the second code block may have been left uncorrected based on the dictionary; 16. The program of claim 15.

17. A server; a client connected to the server via a network; An information processing system comprising: the client comprises one or more processing circuits; The processing circuit, in accordance with the program provided by the server, Dividing the object into a plurality of units for each predetermined identifier, For each of the plurality of units, a set of a first predetermined number of the units is defined as a sub-block; encoding said sub-blocks according to a predetermined transformation; using the code as a key, when detecting duplication of the key, detecting the presence of another sub-block with the same content as the sub-block corresponding to the code; The processing is performed without transmitting data to the server. Information processing system.

18. The processing circuitry In the first source code, which is one of the targets, a second code block is detected as a clone pair having content identical to the first code block by a predetermined percentage or more; extracting a third code block corresponding to the first code block from a second source code that is another target and was edited earlier than the first source code; If the first code block has been modified, a dictionary based on the modification is created for the third code block; detecting a possibility that the second code block may have been left uncorrected based on the dictionary; 18. The information processing system according to claim 17.

19. The client executes each process through an application.

19. An information processing system according to claim 17 or claim 18.

Citation Information

Patent Citations

  • Isomorphic pattern detection system

    JP2003029978A

  • Similar source code extraction program, similar source code extraction device and similar source code extraction method

    JP2006018693A

  • Information processing apparatus

    JP2016184323A

  • Source code evaluation device, source code evaluation method, and source code evaluation program

    WO2016189721A1