JP5345020B2 - Clone code detection evaluation apparatus, clone code detection evaluation method and program - Google Patents

Clone code detection evaluation apparatus, clone code detection evaluation method and program Download PDF

Info

Publication number
JP5345020B2
JP5345020B2 JP2009196688A JP2009196688A JP5345020B2 JP 5345020 B2 JP5345020 B2 JP 5345020B2 JP 2009196688 A JP2009196688 A JP 2009196688A JP 2009196688 A JP2009196688 A JP 2009196688A JP 5345020 B2 JP5345020 B2 JP 5345020B2
Authority
JP
Japan
Prior art keywords
unit
clone
section information
detection
clone code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2009196688A
Other languages
Japanese (ja)
Other versions
JP2011048639A (en
Inventor
大亮 西川
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NS Solutions Corp
Original Assignee
NS Solutions Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NS Solutions Corp filed Critical NS Solutions Corp
Priority to JP2009196688A priority Critical patent/JP5345020B2/en
Publication of JP2011048639A publication Critical patent/JP2011048639A/en
Application granted granted Critical
Publication of JP5345020B2 publication Critical patent/JP5345020B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To efficiently and correctly evaluate and analyze clone codes by selecting clone codes to be evaluated, while preventing excessive detection. <P>SOLUTION: A detection table creation unit 102 registers in a detection table pieces of interval information for predetermined unit data in a file from which clone codes are to be detected, and registers in the detection table pieces of interval information for the predetermined unit data in a file to be compared with the file from which the clone codes are to be detected. If the pieces of interval information between the predetermined unit data in the detection table meet predetermined requirements, a simple clone coupling unit 103 couples together the corresponding pieces of interval information in the detection table for each file. A clone coupling unit 104 extracts the pieces of interval information in the detection table and registers them in a clone code table. A clone code analysis unit 208 evaluates the degree of effect on the quality of files based on the pieces of interval information registered in the clone code table. <P>COPYRIGHT: (C)2011,JPO&amp;INPIT

Description

本発明は、ファイル間のクローンコードの検出処理及びソースコード評価に適用される技術に関するものである。   The present invention relates to a technique applied to a process for detecting a clone code between files and source code evaluation.

近年、コンピュータシステムの開発において、大量のソースコードを多人数で記述することが行われている。コンピュータシステム開発のプロジェクトでは、プロジェクトを評価することも行われている。このような開発の場面では、あるメンバが作成したソースコードを他のメンバがコピー(クローン)して使うことが行われる場合もある。   In recent years, a large amount of source code has been described by a large number of people in the development of computer systems. In computer system development projects, projects are also evaluated. In such a development situation, the source code created by one member may be copied (clone) by another member and used.

なお、クローンコードは次のようにして発生することが考えられる。第1に、作業者が自分自身や他者のソースコードをコピー&ペーストを行ってクローンコードが発生する場合が挙げられる。第2に、アプリケーションフレームワーク等で同じようなコードが自動生成される場合が挙げられる。   The clone code can be generated as follows. First, there is a case where a clone code is generated when an operator copies and pastes the source code of himself or another person. Secondly, there is a case where similar code is automatically generated by an application framework or the like.

クローンコードは多くの場合、不具合や機能変更時の修正コストを増大させるため、クローンが多いことは望ましいことではなく、クローンを検出することはプロジェクトを評価する上で重要な指標である。   In many cases, the clone code increases the cost of correction at the time of malfunction or function change. Therefore, it is not desirable that there are many clones, and detection of clones is an important index for evaluating a project.

特開2003−29978号公報Japanese Patent Laid-Open No. 2003-29978

しかしながら、従来からクローンコードを検出する方法が存在するが、その検出処理の計算量が多く、クローンコードの検出に多くの時間がかかってしまい、実用的と言えるものではなかった。効率的にクローンコードを検出する技術が例えば特許文献1に開示されている。   However, there is a conventional method for detecting a clone code, but the calculation amount of the detection process is large, and it takes a lot of time to detect the clone code, which is not practical. For example, Patent Document 1 discloses a technique for efficiently detecting a clone code.

特許文献1には、テキストから同形パターンを検出する同形パターン検出システムが開示されている。特許文献1に開示される同形パターン検出システムでは、字句解析、規則による変形、パラメータ変換、同形検出、同形出力により対象のテキストの同形を検出する。しかしながら、特許文献1に開示される同形パターン検出システムは、計算量がO(N)〜O(NlogN)と高速であるが、抽出されたクローンコードが最長一致ではないので過検出が多くなるという問題があった。   Patent Document 1 discloses an isomorphic pattern detection system that detects isomorphic patterns from text. In the isomorphic pattern detection system disclosed in Patent Document 1, the isomorphism of the target text is detected by lexical analysis, rule transformation, parameter conversion, isomorphism detection, and isomorphism output. However, although the isomorphic pattern detection system disclosed in Patent Document 1 has a high calculation amount of O (N) to O (NlogN), the extracted clone code is not the longest match, so that overdetection increases. There was a problem.

一方、クローンコードは上述のようにフレームワークの生成によって生じるケース等、本来なら品質に影響は無く、評価する必要が無いものもある。このようにクローンコードには、ソースコードの品質向上に影響のある重要なものと、品質自体に影響を及ぼさない重要度合いの低いクローンコードがあり、この点を考慮せずに一緒くたにすると、評価対象は膨大になり、作業効率を下げることにつながる。   On the other hand, there are cases where the clone code originally has no influence on the quality and does not need to be evaluated, such as a case caused by the generation of the framework as described above. In this way, there are important clone codes that have an impact on the quality improvement of the source code and less important clone codes that do not affect the quality itself. The target becomes enormous, leading to a reduction in work efficiency.

そこで、本発明の目的は、過検出を防ぎ、評価すべきクローンコードを選別することで、クローンコードを効率的に正しく評価・分析することにある。   Therefore, an object of the present invention is to efficiently and correctly evaluate and analyze clone codes by preventing overdetection and selecting clone codes to be evaluated.

本発明のクローンコード検出評価装置は、クローンコード検出対象のファイルにおける第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を第1の検出テーブルに登録するとともに、前記クローンコード検出対象のファイルとの比較対象となるファイルにおける前記第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を前記第1の検出テーブルに登録する第1の検出テーブル生成手段と、前記第1の検出テーブルにおいて登録される前記クローンコード検出対象のファイルにおける第1の単位のデータの区間情報と前記比較対象となるファイルにおける前記第1の単位のデータの区間情報との間で所定の条件を満たす場合、前記第1の検出テーブルにおける前記第1の単位のデータの区間情報を前記ファイル毎に結合させる合手段と、前記結合手段により前記ファイル毎に結合された区間情報を前記第1の検出テーブルから抽出するとともに、前記結合手段により結合された区間情報に対応する前記第1の単位のデータを結合した第2の単位のデータであるクローンコードを抽出して、クローンコードテーブルに登録するクローンコードテーブル生成手段と、前記クローンコードテーブルにおいて登録されるクローンコードに基づいて、前記クローンコードの重要度合いを評価するクローンコード評価手段とを有することを特徴とする。
本発明のクローンコード検出評価方法は、クローンコード検出評価装置によるクローンコード検出評価方法であって、クローンコード検出対象のファイルにおける第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を検出テーブルに登録するとともに、前記クローンコード検出対象のファイルとの比較対象となるファイルにおける前記第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を前記検出テーブルに登録する検出テーブル生成ステップと、前記第1の検出テーブルにおいて登録される前記クローンコード検出対象のファイルにおける第1の単位のデータの区間情報と前記比較対象となるファイルにおける前記第1の単位のデータの区間情報との間で所定の条件を満たす場合、前記検出テーブルにおける前記第1の単位のデータの区間情報をファイル毎に結合させる結合ステップと、前記結合ステップにより前記ファイル毎に結合された区間情報を前記検出テーブルから抽出するとともに、前記検出ステップにより結合された区間情報に対応する前記第1の単位のデータを結合した第2の単位のデータであるクローンコードを抽出して、クローンコードテーブルに登録するクローンコードテーブル生成ステップと、前記クローンコードテーブルにおいて登録されるクローンコードに基づいて、前記クローンコードの重要度合いを評価するクローンコード評価ステップとを含むことを特徴とする。
本発明のプログラムは、クローンコード検出対象のファイルにおける第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を検出テーブルに登録するとともに、前記クローンコード検出対象のファイルとの比較対象となるファイルにおける前記第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を前記検出テーブルに登録する検出テーブル生成ステップと、前記第1の検出テーブルにおいて登録される前記クローンコード検出対象のファイルにおける第1の単位のデータの区間情報と前記比較対象となるファイルにおける前記第1の単位のデータの区間情報との間で所定の条件を満たす場合、前記検出テーブルにおける前記第1の単位のデータの区間情報をファイル毎に結合させる結合ステップと、前記結合ステップにより前記ファイル毎に結合された区間情報を前記検出テーブルから抽出するとともに、前記結合ステップにより結合された区間情報に対応する前記第1の単位のデータを結合した第2の単位のデータであるクローンコードを抽出して、クローンコードテーブルに登録するクローンコードテーブル生成ステップと、前記クローンコードテーブルにおいて登録されるクローンコードに基づいて、前記クローンコードの重要度合いを評価するクローンコード評価ステップとをコンピュータに実行させることを特徴とする。
Clones code detection evaluation apparatus of the present invention registers the segment information indicating the segment to the end position from the start position of each data of the first unit in clone code detection target file in the first detection table, the clone First detection table generation for registering section information indicating a section from a start position to an end position for each data of the first unit in a file to be compared with a code detection target file in the first detection table. And section information of the first unit data in the clone code detection target file registered in the first detection table and section information of the first unit data in the comparison target file. when a predetermined condition is satisfied between the front section information of data of the first unit in the first detection table A binding means for coupling to each file, extracts the section information that is coupled to each of the file from the first detection table by said coupling means, said second corresponding to combined section information by the coupling means 1 Based on the clone code table generating means for extracting the clone code which is the second unit data obtained by combining the unit data and registering it in the clone code table, and the clone code registered in the clone code table, And clone code evaluation means for evaluating the importance of the clone code.
The clone code detection / evaluation method of the present invention is a clone code detection / evaluation method by a clone code detection / evaluation apparatus, and shows a section from the start position to the end position for each data of the first unit in a clone code detection target file. registers the section information on the detection table, the clones code detection target file and the detection table section information indicating a section to the end position from the start position of each data of the first unit in the comparison subject to file A detection table generation step to be registered in the first detection table, section information of first unit data in the clone code detection target file registered in the first detection table, and the first unit in the file to be compared when a predetermined condition is satisfied with the section information of the data, the detected tape A coupling step of coupling the section information of the data of the first unit in the Le for each file, extracts the section information that is coupled to each of the files from the detection table by the coupling step, is coupled by said detecting step It was extracted clones encoding the data of the second unit that combines the data of the first unit corresponding to the section information, and clone encoding table generating step of registering the clones code table, registered in the clones code table And a clone code evaluation step for evaluating the importance of the clone code based on the clone code to be executed .
Program of the present invention, clones code detection target section information indicating a section to the end position from the start position of each data of the first unit and registers the detection table in the file, and the clone code detection target file A detection table generation step for registering section information indicating a section from a start position to an end position for each data of the first unit in the file to be compared in the detection table, and registration in the first detection table. When the predetermined condition is satisfied between the section information of the first unit data in the clone code detection target file and the section information of the first unit data in the comparison target file , a coupling step of coupling the section information of the data of the first unit for each file, The second unit data obtained by extracting the section information combined for each file by the combining step from the detection table and combining the data of the first unit corresponding to the section information combined by the combining step. A clone code table generating step for extracting the clone code and registering it in the clone code table; and a clone code evaluation step for evaluating the importance of the clone code based on the clone code registered in the clone code table ; Is executed by a computer.

本発明においては、過検出を防ぎ、評価すべきクローンコードを選別することで、クローンコードを効率的に正しく評価・分析できる。   In the present invention, clone code can be efficiently evaluated and analyzed efficiently by preventing overdetection and selecting clone codes to be evaluated.

本発明の第1の実施形態に係るクローンコード検出評価装置の機能的な構成を示すブロック図である。It is a block diagram which shows the functional structure of the clone code detection evaluation apparatus which concerns on the 1st Embodiment of this invention. 本発明の第2の実施形態に係るクローンコード検出評価装置のハードウェア構成を示す図である。It is a figure which shows the hardware constitutions of the clone code detection evaluation apparatus which concerns on the 2nd Embodiment of this invention. 本発明の第1の実施形態に係るクローンコード検出評価装置の動作の流れを示すフローチャートである。It is a flowchart which shows the flow of operation | movement of the clone code detection evaluation apparatus which concerns on the 1st Embodiment of this invention. 本発明の第1の実施形態に係るクローンコード検出評価装置の動作の流れを示すフローチャートである。It is a flowchart which shows the flow of operation | movement of the clone code detection evaluation apparatus which concerns on the 1st Embodiment of this invention. 本発明の第1の実施形態に係るクローンコード検出評価装置の動作の流れを示すフローチャートである。It is a flowchart which shows the flow of operation | movement of the clone code detection evaluation apparatus which concerns on the 1st Embodiment of this invention. リポジトリにおける各ファイルの各バージョンの格納状況とともにバージョンの更新状況を示す図である。It is a figure which shows the update condition of a version with the storage condition of each version of each file in a repository. ソースコードからトークン列への変換例と基底テーブルの構成例とを示す図である。It is a figure which shows the example of a conversion from a source code to a token sequence, and the structural example of a base table. 検出テーブル作成部による検出テーブルの作成処理を説明するための図である。It is a figure for demonstrating the creation process of the detection table by a detection table preparation part. クローン簡易結合処理を説明するための図である。It is a figure for demonstrating a clone simple joining process. クローン結合処理を説明するための図である。It is a figure for demonstrating a clone joint process. 包含クローン削除部の動作を説明するための図である。It is a figure for demonstrating operation | movement of an inclusion clone deletion part. 包含クローン削除部の動作を説明するための図である。It is a figure for demonstrating operation | movement of an inclusion clone deletion part. クローン簡易結合処理を説明するための図である。It is a figure for demonstrating a clone simple joining process. クローンテーブルの構成例を示す図である。It is a figure which shows the structural example of a clone table. 本発明の第2の実施形態に係るクローンコード検出評価装置の機能的な構成を示すブロック図である。It is a block diagram which shows the functional structure of the clone code detection evaluation apparatus which concerns on the 2nd Embodiment of this invention. 第1の実施形態で検出したクローンコード中において最大領域を占める繰り返し領域の属性を示す図である。It is a figure which shows the attribute of the repetition area which occupies the largest area in the clone code detected in 1st Embodiment. 重要度合いを示す評価マップを示す図である。It is a figure which shows the evaluation map which shows importance. 重要度「小」と判断されたクローンコードの例を示す図である。It is a figure which shows the example of the clone code determined as importance "small".

以下、本発明を適用した好適な実施形態を、添付図面を参照しながら詳細に説明する。   DESCRIPTION OF EXEMPLARY EMBODIMENTS Hereinafter, preferred embodiments to which the invention is applied will be described in detail with reference to the accompanying drawings.

図1は、本発明の第1の実施形態に係るクローンコード検出評価装置の機能的な構成を示すブロック図である。図1に示すように、本実施形態に係るクローンコード検出評価装置100は、基底テーブル作成部101、検出テーブル作成部102、クローン簡易結合部103、クローン結合部104及び包含クローン削除部105により構成される。   FIG. 1 is a block diagram showing a functional configuration of a clone code detection / evaluation apparatus according to the first embodiment of the present invention. As shown in FIG. 1, the clone code detection / evaluation apparatus 100 according to the present embodiment includes a base table creation unit 101, a detection table creation unit 102, a clone simple combination unit 103, a clone combination unit 104, and an included clone deletion unit 105. Is done.

基底テーブル作成部101は、最後にクローンコードの検出を行った時点における最新ファイルのソースコードをトークン列に変換し、n-gram化されたトークン列とそれらのトークン列の区間情報を基底テーブルに登録する。   The base table creation unit 101 converts the source code of the latest file at the time of the last clone code detection into a token string, and converts the token strings converted into n-grams and the interval information of those token strings into the base table. sign up.

検出テーブル作成部102は、クローンコードの検出対象となるファイルのソースコードをトークン列に変換し、n-gram化されたトークン列とそれらのトークン列の区間情報とを検出テーブルに登録する。そして、検出テーブル作成部102は、基底テーブルに登録される区間情報を後述する方法によって検出テーブルに登録する。   The detection table creation unit 102 converts the source code of the file that is the detection target of the clone code into a token string, and registers the token strings converted into n-grams and the section information of those token strings in the detection table. Then, the detection table creation unit 102 registers the section information registered in the base table in the detection table by a method described later.

クローン簡易結合部103は、検出テーブルのレコード同士の対応する区間情報を比較し、比較した区間情報が各ファイル間で同じオフセットを有するのであれば、区間情報の結合を行う。   The clone simple combining unit 103 compares the corresponding section information between the records in the detection table, and combines the section information if the compared section information has the same offset between the files.

クローン結合部104は、クローン簡易結合部103により生成された検出テーブルから、ファイル毎に区間情報を取得する。そして、クローン結合部104は、前段のトークン列の区間情報の終端と後段のトークン列の区間情報の始端とが重なる、又は、前段のトークン列の区間情報の終端と後段のトークン列の区間情報の始端とが接続される場合、それらの区間情報を結合した区間情報を新検出テーブルに登録する。   The clone combining unit 104 acquires section information for each file from the detection table generated by the clone simple combining unit 103. Then, the clone combining unit 104 overlaps the end of the section information of the preceding token string and the start of the section information of the subsequent token string, or the end information of the preceding token string and the section information of the subsequent token string Is connected to the new detection table, the section information obtained by combining the section information is registered in the new detection table.

包含クローン削除部105は、検出テーブルと新検出テーブルとを比較し、検出テーブルの区間情報が新検出テーブルの区間情報に完全に包含されている場合、即ち、検出テーブル内に過検出となっている区間情報が存在する場合、検出テーブルにおける過検出の区間情報が登録されているレコードを削除する。   The inclusion clone deletion unit 105 compares the detection table with the new detection table, and when the section information of the detection table is completely included in the section information of the new detection table, that is, the detection table is overdetected. If there is existing section information, the record in which the over-detected section information is registered in the detection table is deleted.

図2は、本実施形態に係るクローンコード検出評価装置100のハードウェア構成を示す図である。   FIG. 2 is a diagram illustrating a hardware configuration of the clone code detection / evaluation apparatus 100 according to the present embodiment.

CPU201は、システムバスに接続される各デバイスやコントローラを統括的に制御する。ROM203又はHD(ハードディスク)207には、CPU201の制御プログラムであるBIOS(Basic Input / Output System)やオペレーティングシステムプログラム、クローンコード検出評価装置100が実行する例えば図3−1乃至図3−3に示す処理のプログラム等が記憶されている。   The CPU 201 comprehensively controls each device and controller connected to the system bus. The ROM 203 or the HD (hard disk) 207 has a basic input / output system (BIOS) or an operating system program that is a control program of the CPU 201, and is executed by the clone code detection / evaluation apparatus 100, for example, as shown in FIGS. A processing program and the like are stored.

なお、図2の例では、HD207はクローンコード検出評価装置100の内部に配置された構成としているが、他の実施形態としてHD207に相当する構成がクローンコード検出評価装置100の外部に配置された構成としてもよい。また、本実施形態に係る例えば図3−1乃至図3−3に示す処理を行うためのプログラムは、フレキシブルディスク(FD)やCD−ROM等、コンピュータ読み取り可能な記録媒体に記録され、それらの記録媒体から供給される構成としてもよいし、インターネット等の通信媒体を介して供給される構成としてもよい。   In the example of FIG. 2, the HD 207 is configured to be disposed inside the clone code detection / evaluation apparatus 100. However, as another embodiment, a configuration corresponding to the HD 207 is disposed outside the clone code detection / evaluation apparatus 100. It is good also as a structure. In addition, for example, the program for performing the processing illustrated in FIGS. 3-1 to 3-3 according to the present embodiment is recorded on a computer-readable recording medium such as a flexible disk (FD) or a CD-ROM. It is good also as a structure supplied from a recording medium, and good also as a structure supplied via communication media, such as the internet.

RAM202は、CPU201の主メモリ、ワークエリア等として機能する。CPU201は、処理の実行に際して必要なプログラム等をRAM202にロードして、プログラムを実行することで各種動作を実現するものである。   The RAM 202 functions as a main memory, work area, and the like for the CPU 201. The CPU 201 implements various operations by loading a program necessary for execution of processing into the RAM 202 and executing the program.

HD207やFD206は、外部メモリとして機能する。CPU201は、処理の実行に際して必要なプログラム等をRAM202にロードして、プログラムを実行することで各種動作を実現するものである。   The HD 207 and the FD 206 function as an external memory. The CPU 201 implements various operations by loading a program necessary for execution of processing into the RAM 202 and executing the program.

ディスクコントローラ205は、HD207やFD206等の外部メモリへのアクセスを制御する。通信I/Fコントローラ204は、インターネットやLANと接続し、例えばTCP/IPによって外部との通信を制御するものである。   The disk controller 205 controls access to external memories such as the HD 207 and the FD 206. The communication I / F controller 204 is connected to the Internet or a LAN, and controls communication with the outside by, for example, TCP / IP.

ディスプレイコントローラ208は、ディスプレイ209における画像表示を制御する。   The display controller 208 controls image display on the display 209.

KBコントローラ210は、KB(キーボード)211からの操作入力を受け付け、CPU201に対して送信する。なお、図示していないが、KB211の他に、マウス等のポインティングデバイスもユーザの操作手段として本実施形態に係るクローンコード検出評価装置100に適用可能である。   The KB controller 210 receives an operation input from the KB (keyboard) 211 and transmits it to the CPU 201. Although not shown, in addition to the KB 211, a pointing device such as a mouse can also be applied to the clone code detection / evaluation apparatus 100 according to the present embodiment as a user operation means.

図1に示す基底テーブル作成部101、検出テーブル作成部102、クローン簡易結合部103、クローン結合部104及び包含クローン削除部105は、例えばHD207内に記憶され、必要に応じてRAM202にロードされるプログラム及びそれを実行するCPU201によって実現される構成である。   The base table creation unit 101, the detection table creation unit 102, the clone simple combination unit 103, the clone combination unit 104, and the included clone deletion unit 105 shown in FIG. 1 are stored in, for example, the HD 207 and loaded into the RAM 202 as necessary. The configuration is realized by a program and a CPU 201 that executes the program.

図3−1乃至図3−3は、本実施形態に係るクローンコード検出評価装置100の動作の流れを示すフローチャートである。以下、図3−1乃至図3−3に示すフローチャートを参照しながらクローンコード検出評価装置100の動作の流れについて説明するが、その説明の前に、図4を用いてリポジトリにおけるファイルの格納状況の一例について説明する。リポジトリには、クローンコード検出評価装置100によるクローンコードの検出対象となるファイルが格納されている。リポジトリは、クローンコード検出評価装置100内部におけるHDD等の記録媒体の一部記録領域に構成されてもよいし、クローンコード検出評価装置100と通信回線を介して接続されるDBサーバ等に構成されてもよい。なお、図4に示すリポジトリにおけるファイルの格納構成は飽くまでも一例であり、クローンコード検出評価装置100が処理の対象は図4に示すファイルのみではない。従って、以下の説明においては、説明の容易のため、図4に示すファイル以外も適宜使用してクローンコード検出評価装置100の動作を説明する。
するものとする。
FIGS. 3A to 3C are flowcharts showing the operation flow of the clone code detection / evaluation apparatus 100 according to the present embodiment. Hereinafter, the operation flow of the clone code detection / evaluation apparatus 100 will be described with reference to the flowcharts shown in FIGS. 3-1 to 3-3. Before the description, the file storage status in the repository will be described with reference to FIG. An example will be described. In the repository, a file that is a target of detection of a clone code by the clone code detection / evaluation apparatus 100 is stored. The repository may be configured in a partial recording area of a recording medium such as an HDD in the clone code detection / evaluation apparatus 100, or may be configured in a DB server or the like connected to the clone code detection / evaluation apparatus 100 via a communication line. May be. Note that the file storage configuration in the repository shown in FIG. 4 is merely an example, and the clone code detection / evaluation apparatus 100 is not limited to the file shown in FIG. Therefore, in the following description, the operation of the clone code detection / evaluation apparatus 100 will be described using the files other than those shown in FIG.
It shall be.

図4は、リポジトリにおける各ファイルの各バージョンの格納状況とともにバージョンの更新状況を示す図である。図4では、時間の経過を図面の上方から下方に表している。図4において、ファイル1(F1)は、バージョン1(V1)でリポジトリに登録され、それ以降の更新はない。ファイル2(F2)は、バージョン1(V1)でリポジトリに登録され、その後、バージョン2(V2)、バージョン3(V3)と2度更新されて登録されている。即ち、ファイル2については、バージョン1〜3のファイルが夫々登録されている。ファイル3(F3)は、バージョン1でリポジトリに登録され、その後、バージョン2、バージョン3、バージョン4と3度更新されて登録されている。即ち、ファイル3については、バージョン1〜4のファイルが夫々登録されている。401の破線は、最後にクローンコードの検出処理が行われた時点を表しており、402の破線は、現在時刻を表している。即ち、図4では、最後にクローンコードの検出が行われた時点でリポジトリに登録される最新ファイルは、ファイル1ではバージョン1、ファイル2ではバージョン2、ファイル3ではバージョン2であることを表している。また、図4では、最後のクローンコードの検出が行われた時点からファイル2がバージョン2からバージョン3に1度更新され、ファイル3がバージョン2からバージョン4まで2度更新されたことが示されている。   FIG. 4 is a diagram showing the update status of each version together with the storage status of each version of each file in the repository. In FIG. 4, the passage of time is shown from the top to the bottom of the drawing. In FIG. 4, file 1 (F1) is registered in the repository with version 1 (V1), and there is no subsequent update. File 2 (F2) is registered in the repository with version 1 (V1), and then updated and registered twice with version 2 (V2) and version 3 (V3). That is, as for the file 2, files of versions 1 to 3 are registered. The file 3 (F3) is registered in the repository with version 1, and then updated and registered with version 2, version 3, and version 4. That is, for the file 3, the files of versions 1 to 4 are registered. A broken line 401 represents the time when the clone code detection process was last performed, and a broken line 402 represents the current time. In other words, FIG. 4 shows that the latest file registered in the repository when clone code is detected last is version 1 for file 1, version 2 for file 2, and version 2 for file 3. Yes. FIG. 4 also shows that file 2 has been updated once from version 2 to version 3 and file 3 has been updated twice from version 2 to version 4 since the last clone code was detected. ing.

次に、クローンコード検出評価装置100の動作について説明する。図3−1において、基底テーブル作成部101は、最後にクローンコードの検出を行った時点における最新ファイルをリポジトリから読み出す(ステップS301)。即ち、基底テーブル作成部101は、ファイル1のバージョン1、ファイル2のバージョン2、ファイル3のバージョン2を読み出す。   Next, the operation of the clone code detection / evaluation apparatus 100 will be described. 3A, the base table creation unit 101 reads the latest file from the repository at the time when the clone code was last detected (step S301). That is, the base table creation unit 101 reads version 1 of file 1, version 2 of file 2, and version 2 of file 3.

続いて、基底テーブル作成部101は、リポジトリから取り出した各ファイル内に記述されるソースコードを構文解析し、voidであればVといったように、ソースコードをトークン列に変換する(ステップS302)。ここでの変換ルールはad hocを用いる。   Subsequently, the base table creation unit 101 parses the source code described in each file fetched from the repository, and converts the source code into a token string such as V if void (step S302). The conversion rule here uses ad hoc.

図5は、ソースコードからトークン列への変換例と基底テーブルの構成例とを示す図である。図5の501、502に示すように、void(ソースコード)はV(トークン)に、method1(ソースコード)は$(トークン)に、int(ソースコード)はI(トークン)に、arg(ソースコード)は%(トークン)に、long(ソースコード)はL(トークン)に、I(ソースコード)は%(トークン)に、10L(ソースコード)は&(トークン)に変換されている。   FIG. 5 is a diagram illustrating a conversion example from a source code to a token string and a configuration example of a base table. As shown in 501 and 502 of FIG. 5, void (source code) is V (token), method1 (source code) is $ (token), int (source code) is I (token), arg (source) Code () is converted to% (token), long (source code) is converted to L (token), I (source code) is converted to% (token), and 10L (source code) is converted to & (token).

続いて、基底テーブル作成部101は、トークン列をn-gram(n=1,2,3,・・・、図5では、n=10)化し、n-gram化されたトークン列とファイル内におけるトークン列の区間情報とを基底テーブルに登録する(ステップS303)。図5の503に示すように、基底テーブルにおいて、トークン列v$(I%)[L%=がファイル1の2行目の2列目(2,1)から3行目の4列目(3,4)まで((2,1)−(3,4))、トークン列v$(I%)[L%=がファイル2の10行目の1列目から10行目の9列目まで((10,1)−(10,9))、トークン列v$(I%)[L%=がファイル3の1行目の1列目から1行目の9列目まで((1,1)−(1,9))存在することが区間情報として登録されている。   Subsequently, the base table creation unit 101 converts the token string into an n-gram (n = 1, 2, 3,..., N = 10 in FIG. 5), and converts the token string into the n-gram and the file And the token sequence section information in step S303. As indicated by reference numeral 503 in FIG. 5, in the base table, the token string v $ (I%) [L% = is changed from the second column (2, 1) of the second row of the file 1 to the fourth column of the third row ( 3, 4) ((2,1)-(3,4)), token sequence v $ (I%) [L% = is the first column of the 10th row of the file 2 to the ninth column of the 10th row. ((10,1)-(10,9)), token sequence v $ (I%) [L% = is from the first column of the first row to the ninth column of the first row ((1 , 1)-(1, 9)) is registered as section information.

また、トークン列$(I%)[L%=&がファイル1の2行目の2列目から3行目の5列目まで((2,2)−(3,5))、トークン列$(I%)[L%=&がファイル3の1行目の2列目から1行目の10列目まで((1,2)−(1,10))存在することが区間情報として登録されている。   Also, the token string $ (I%) [L% = & is from the second column of the second row to the fifth column of the third row ((2, 2)-(3, 5)), Section information indicates that $ (I%) [L% = & exists from the second column of the first row to the tenth column of the first row ((1,2)-(1,10)). It is registered.

また、トークン列(I%)[L%=&;がファイル3の1行目の3列目から1行目の11列目まで((1,3)−(1,11))存在することが区間情報として登録されている。また、トークン列=$(%,%,%);がファイル1の12行目の1列目から12行目の12列目まで((12,1)−(12,12))存在することが区間情報として登録されている。   Further, the token string (I%) [L% = &; exists from the third column of the first row of the file 3 to the eleventh column of the first row ((1,3)-(1,11)). Is registered as section information. Further, the token string = $ (%,%,%); exists from the first column of the 12th row to the 12th column of the 12th row ((12,1)-(12,12)). Is registered as section information.

図6は、検出テーブル作成部102による検出テーブルの作成処理を説明するための図である。図6においては、ファイル3のバージョン3をクローンコードの検出対象とした場合に作成される検出テーブルの構成例を示している。   FIG. 6 is a diagram for explaining detection table creation processing by the detection table creation unit 102. FIG. 6 shows a configuration example of a detection table created when version 3 of the file 3 is a clone code detection target.

続いて、検出テーブル作成部102は、基底テーブルに検出対象のファイル3の旧バージョンが存在するか否かを判定する(ステップS304)。ファイル3の旧バージョンが存在する場合、検出テーブル作成部102は、図6の601に示すように、基底テーブルから検出対象のファイル3の旧バージョンの区間情報を削除する(ステップS305)。これは、バージョン違いの同一種類のファイルである場合、新バージョンのファイルは旧バージョンのファイルが部分的に更新されて共通部分が多いため、その共通部分をクローンコードとして検出するのは適切ではないからである。一方、ファイル3の旧バージョンが存在しない場合、処理はステップS305を実行せずにステップS306に移行する。   Subsequently, the detection table creation unit 102 determines whether or not an old version of the file 3 to be detected exists in the base table (step S304). When the old version of the file 3 exists, the detection table creation unit 102 deletes the section information of the old version of the detection target file 3 from the base table as indicated by 601 in FIG. 6 (step S305). If this is a file of the same type with a different version, it is not appropriate to detect the common part as a clone code because the new version file is partially updated from the old version file and there are many common parts. Because. On the other hand, if the old version of the file 3 does not exist, the process proceeds to step S306 without executing step S305.

続いて、検出テーブル作成部102は、ファイル3のバージョン3をリポジトリから読み出す(ステップS306)。そして、検出テーブル作成部102は、ファイル3のバージョン3内に記述されるソースコードを構文解析し、トークン列に変換する(ステップS307)。   Subsequently, the detection table creation unit 102 reads version 3 of the file 3 from the repository (step S306). Then, the detection table creation unit 102 parses the source code described in the version 3 of the file 3 and converts it into a token string (step S307).

続いて、検出テーブル作成部102は、トークン列をn-gram化し、n-gram化されたトークン列と該当するトークン列のファイル内における区間情報とを検出テーブルに登録する(ステップS308)。図6の602に示すように、クローン列v$(I%)[L%=がファイルF3のバージョンv3の2行目の5列目から2行目の13行目まで((2,5)−(2,13))、クローン列$(I%)[L%=&がファイルF3のバージョンv3の2行目の6行目から2行目の14行目まで((2,6)−(2,14))、クローン列(I%)[L%=&;がファイルF3のバージョンv3の2行目の7列目から2行目の15列目まで((2,7)−(2,15))存在することが区間情報として登録されている。   Subsequently, the detection table creation unit 102 converts the token string into an n-gram, and registers the token string converted into an n-gram and section information in the file of the corresponding token string in the detection table (step S308). As indicated by 602 in FIG. 6, the clone column v $ (I%) [L% = is from the fifth column of the second row of the version v3 of the file F3 to the thirteenth row of the second row ((2, 5) -(2,13)), clone string $ (I%) [L% = & is the second line of file F3 version v3 from the 6th line to the 14th line ((2,6)- (2,14)), the clone column (I%) [L% = &; is from the seventh row of the second row to the fifteenth column of the second row of version v3 of the file F3 ((2,7)-( 2, 15)) Existence is registered as section information.

続いて、検出テーブル作成部102は、検出テーブルに区間情報が登録されているトークン列と同じトークン列に区間情報が基底テーブルにおいて登録されている場合、基底テーブルにおける該当するトークン列の区間情報を検出テーブルに登録する(ステップS309)。   Subsequently, when the section information is registered in the base table in the same token string as the token string in which the section information is registered in the detection table, the detection table creation unit 102 displays the section information of the corresponding token string in the base table. Register in the detection table (step S309).

図6の603に示すように、検出テーブルにおいて、3つのトークン列v$(I%)[L%=、$(I%)[L%=&、(I%)[L%=&;の区間情報が登録されているが、基底テーブルでは、そのうちの2つのトークン列v$(I%)[L%=、$(I%)[L%=&の区間情報が登録された状態となっている。従って、検出テーブル作成部102は、基底テーブルにおける2つのトークン列v$(I%)[L%=、$(I%)[L%=&の区間情報を検出テーブルに登録する。   As indicated by reference numeral 603 in FIG. 6, in the detection table, three token sequences v $ (I%) [L% =, $ (I%) [L% = &, (I%) [L% = &; Section information is registered, but in the base table, section information of two token sequences v $ (I%) [L% =, $ (I%) [L% = & is registered. ing. Therefore, the detection table creation unit 102 registers the section information of the two token strings v $ (I%) [L% =, $ (I%) [L% = &] in the base table in the detection table.

続いて、図3−2において、検出テーブル作成部102は、ファイル間において区間情報が1つしか登録されていないトークン列のレコードが存在するか否かを判定する(ステップS310)。ファイル間において区間情報が1つしか登録されていない場合、検出テーブル作成部102は、該当するレコードを削除する(ステップS311)。これは、ファイル間において区間情報が1つしか登録されていないトークン列は、その時点でクローンコードではないことが明らかなためである。図6の例では、トークン列(I%)[L%=&;のレコードにはファイル3の区間情報しか登録されない。従って、トークン列(I%)[L%=&;のレコードが削除されることになる。以上により、図6の603に示す検出テーブルが作成される。一方、ファイル間において区間情報が1つしか登録されていないトークン列のレコードが存在しない場合、処理はステップS311を実行せずにステップS312に移行する。   Subsequently, in FIG. 3B, the detection table creation unit 102 determines whether or not there is a token string record in which only one section information is registered between files (step S310). When only one section information is registered between files, the detection table creation unit 102 deletes the corresponding record (step S311). This is because it is clear that a token string in which only one piece of section information is registered between files is not a clone code at that time. In the example of FIG. 6, only the section information of the file 3 is registered in the record of the token string (I%) [L% = &;. Therefore, the record of the token string (I%) [L% = &; is deleted. As described above, the detection table indicated by reference numeral 603 in FIG. 6 is created. On the other hand, if there is no token sequence record in which only one section information is registered between files, the process proceeds to step S312 without executing step S311.

続いて、クローン簡易結合部103は、検出テーブルの各レコードを区間情報の数毎に分類する(ステップS312)。図7の例においては、4つの区間情報を登録しているトークン列V$(I%)[L%=のレコードとトークン列(I%)[L%=&;のレコードとの分類と、3つの区間情報を登録しているトークン列$(I%)[L%=&のレコードとトークン列I%)[L%=&;%のレコードとの分類になる。   Subsequently, the clone simple combining unit 103 classifies each record of the detection table according to the number of section information (step S312). In the example of FIG. 7, the classification of the record of token sequence V $ (I%) [L% = and the record of token sequence (I%) [L% = &; The token sequence $ (I%) [L% = & record and the token sequence I%) [L% = &;% record in which three pieces of section information are registered are classified.

続いて、クローン簡易結合部103は、クローン簡易結合処理を行う(ステップS313)。即ち、クローン簡易結合部103は、分類毎に、レコード同士の対応する区間情報を比較し、比較した区間情報が各ファイル間で同じオフセットを有するのであれば、区間情報の結合を行う。   Subsequently, the clone simple combining unit 103 performs a clone simple combining process (step S313). That is, the simple clone combining unit 103 compares corresponding section information between records for each classification, and combines the section information if the compared section information has the same offset between files.

図7は、クローン簡易結合部103によるクローン簡易結合の処理を説明するための図である。ここでは、図7の701に示すように、検出テーブルにおいて4つのトークン列について区間情報が登録されている場合を例示している。即ち、検出テーブルにおいて、4つのファイル4〜7にトークン列V$(I%)[L%=の区間情報が登録され、4つのファイル4〜7にトークン列(I%)[L%=&;の区間情報が登録されている。また、3つのファイル4〜6にトークン列$(I%)[L%=&の区間情報が登録され、3つのファイル4〜6にトークン列I%)[L%=&;%の区間情報が登録されている。   FIG. 7 is a diagram for explaining the process of simple clone combining by the clone simple combining unit 103. Here, as shown by reference numeral 701 in FIG. 7, an example is shown in which section information is registered for four token strings in the detection table. That is, in the detection table, the section information of the token string V $ (I%) [L% = is registered in the four files 4 to 7, and the token string (I%) [L% = & is stored in the four files 4 to 7. ; Section information is registered. In addition, the section information of token sequence $ (I%) [L% = & is registered in the three files 4 to 6, and the token sequence I%) [L% = &;% section information is stored in the three files 4 to 6. Is registered.

図7の例では、トークン列V$(I%)[L%=の区間情報として、ファイル4、ファイル5、ファイル6、ファイル7について夫々、(2,1)−(3,3)、(3,2)−(4,4)、(4,5)−(5,7)、(6,2)−(7,4)が登録され、トークン列(I%)[L%=&;の区間情報として、(2,2)−(3,4)、(3,3)−(4,5)、(4,6)−(5,8)、(6,3)−(7,5)が登録されている。比較する区間情報は全て同じオフセット(横軸方向の1座標分)を有する。従って、この場合には区間情報の結合が行われる。即ち、検出テーブル作成部102は、比較したトークン列のうちの前段のトークン列の始端から後段のトークン列の終端までを結合した区間情報を生成する。このとき、クローン簡易結合部103は、分類毎に分けられたレコードのうちの1つのレコードのトークン列を結合後のトークン列に更新するとともに、当該レコードの各区間情報を結合後の区間情報に更新する。そして、クローン簡易結合部103は、当該分類に属する他のレコードを全て削除する。このようにクローン簡易結合処理の後は、図7の702に示す検出テーブルが生成される。   In the example of FIG. 7, as the section information of the token string V $ (I%) [L% =, (2, 1)-(3, 3), ( 3,2)-(4,4), (4,5)-(5,7), (6,2)-(7,4) are registered, and the token string (I%) [L% = &; (2, 2)-(3,4), (3, 3)-(4, 5), (4, 6)-(5, 8), (6, 3)-(7, 5) is registered. All section information to be compared has the same offset (one coordinate in the horizontal axis direction). Therefore, in this case, the section information is combined. In other words, the detection table creation unit 102 generates section information in which the beginning token end of the preceding token string to the end of the latter token string of the compared token strings are combined. At this time, the clone simple combining unit 103 updates the token string of one record among the records divided for each classification to the combined token string, and converts each section information of the record to the combined section information. Update. Then, the clone simple combination unit 103 deletes all other records belonging to the classification. As described above, after the clone simple combining process, a detection table indicated by 702 in FIG. 7 is generated.

ファイル毎に各区間情報を結合させた場合、結合後の区間情報に該当するトークン列は複数のファイル間に亘って同一のトークン列であると看做せる。従って、上述したクローン簡易結合処理は、レコード間において、複数のファイルに亘って或るトークン列の区間情報が同じ数だけ登録され、且つ同一分類のレコード間において、夫々のトークン列の区間情報が複数のファイルに亘って同じオフセットで登録されている場合に行われる。   When the section information is combined for each file, the token string corresponding to the combined section information can be regarded as the same token string across a plurality of files. Therefore, in the above-described clone simple combination process, the same number of section information of a certain token string is registered across a plurality of files between records, and the section information of each token string is recorded between records of the same classification. This is performed when a plurality of files are registered with the same offset.

続いて、クローン結合部104は、クローン結合処理を行う(ステップS314)。即ち、クローン結合部104は、クローン簡易結合部103により生成された検出テーブルから、ファイル毎に区間情報を取得する。そして、クローン結合部104は、前段のトークン列の区間情報の終端と後段のトークン列の区間情報の始端とが重なる、又は、前段のトークン列の区間情報の終端と後段のトークン列の区間情報の始端とが接続される場合、それらの区間情報を結合した区間情報を新検出テーブルに登録する。これにより、n-gram化されたトークン列を結合させた一連のトークン列に対応する区間情報が登録された新検出テーブルが作成される。   Subsequently, the clone combining unit 104 performs a clone combining process (step S314). That is, the clone combining unit 104 acquires section information for each file from the detection table generated by the clone simple combining unit 103. Then, the clone combining unit 104 overlaps the end of the section information of the preceding token string and the start of the section information of the subsequent token string, or the end information of the preceding token string and the section information of the subsequent token string Is connected to the new detection table, the section information obtained by combining the section information is registered in the new detection table. As a result, a new detection table is created in which section information corresponding to a series of token strings obtained by combining token strings converted into n-grams is created.

図8は、クローン結合部104によるクローン結合処理を説明するための図である。図8の801は、検出テーブルであり、図8の802は、検出テーブルに対してクローン結合処理を行うことにより生成される新検出テーブルである。検出テーブルは、トークン列$();(L%=N;のファイル9の区間情報が(10,3)−(11,5)であり、トークン列$();[L%=$(のファイル9の区間情報が(9,5)−(10,7)である。従って、前段のトークン列の区間情報((9,5)−(10,7))の終端と後段のトークン列の区間情報((10,3)−(11,5))の始端とが重なる。よって、それらの区間情報を結合した区間情報(9,5)−(11,5)が算出される。   FIG. 8 is a diagram for explaining clone joining processing by the clone joining unit 104. Reference numeral 801 in FIG. 8 is a detection table, and reference numeral 802 in FIG. 8 is a new detection table generated by performing clone combination processing on the detection table. In the detection table, the section information of the file 9 of the token sequence $ (); (L% = N; is (10, 3)-(11, 5), and the token sequence $ (); [L% = $ ( The section information of the file 9 is (9,5)-(10,7) Therefore, the end of the section information ((9,5)-(10,7)) of the preceding token string and the token information of the latter stage Section information ((10,3)-(11,5)) overlaps with the beginning of the section information, and section information (9,5)-(11,5) obtained by combining these section information is calculated.

また、トークン列$(%,%,%,%)のファイル9の区間情報が(11,5)−(12,7)であるため、トークン列$();(L%=N;のファイル9の区間情報((10,3)−(11,5))の終端と接続する。従って、それらの区間情報を結合した区間情報(10,3)−(12,7)が算出される。他のファイル10〜12についても同様に区間情報の結合が行われる。なお、ファイル13については、トークン列$();[L%=N;にのみ区間情報が登録されているため、区間情報の結合は行われない。   Further, since the section information of the file 9 of the token sequence $ (%,%,%,%) is (11, 5)-(12, 7), the file of the token sequence $ (); (L% = N; 9 is connected to the end of the section information ((10, 3)-(11, 5)), so section information (10, 3)-(12, 7) is calculated by combining the section information. The section information is similarly combined for the other files 10 to 12. Since section information is registered only in the token string $ (); [L% = N; Are not combined.

続いて、クローン結合部104は、クローン結合処理により結合された区間情報が存在したか否かを判定する(ステップS315)。クローン結合処理により結合された区間情報が存在する場合、クローン結合部104は、新検出テーブルにおいて、結合後のトークン列に結合後の区間情報を対応付けて登録する(ステップS316)。一方、クローン結合処理により結合された区間情報が存在しない場合、処理はステップS316を実行せずに図3−3のステップS317に移行する。   Subsequently, the clone combining unit 104 determines whether there is section information combined by the clone combining process (step S315). If there is section information combined by the clone combining process, the clone combining unit 104 registers the combined section information in association with the combined token string in the new detection table (step S316). On the other hand, when there is no section information joined by the clone joining process, the process proceeds to step S317 in FIG. 3-3 without executing step S316.

続いて、クローン結合部104は、新検出テーブルにおいてファイル間で1つの区間情報の登録しかないレコードが存在するか否かを判定する(ステップS317)。新検出テーブルにおいてファイル間で1つの区間情報の登録しかないレコードが存在する場合、クローン結合部104は、該当するレコードを削除する(ステップS318)。これは、ファイル間で1つの区間情報しか登録されていないトークン列はクローンではないためである。図8の例では、トークン列$();[L%=$();[L%=$(のレコードが削除されることになる。一方、新検出テーブルにおいてファイル間で1つの区間情報の登録しかないレコードが存在しない場合、処理はステップS318を実行せずにステップS319に移行する。上述したステップS314〜S318の処理によって、図8の801に示す検出テーブルから図8の802に示す新検出テーブルが生成される。   Subsequently, the clone combining unit 104 determines whether there is a record that has only one piece of section information registered between files in the new detection table (step S317). If there is a record that has only one section information registered between files in the new detection table, the clone combining unit 104 deletes the corresponding record (step S318). This is because a token string in which only one section information is registered between files is not a clone. In the example of FIG. 8, the record of token sequence $ (); [L% = $ (); [L% = $ (will be deleted. If there is no record that can only be registered, the process proceeds to step S319 without executing step S318, and the process in steps S314 to S318 described above is performed to detect the new table 802 in FIG. A detection table is generated.

図9及び図10は、包含クローン削除部105の動作を説明するための図である。包含クローン削除部105は、検出テーブルに登録されるファイルをグループに分離するとともに、新検出テーブルに登録されるファイルをグループに分離する(ステップS319)。このグループ分けは、同一のトークン列で区間情報が登録されているファイルを同じグループにする。このようにグループ分けするのは、後述するクローンの過検出処理をファイル毎に行うより、より高くクローンの可能性を有するグループ毎に過検出処理を行った方が処理量を軽減させることができるためである。図9の901は、検出テーブルのグループ分けの状況を示し、図9の902は、新検出テーブルのグループ分けの状況を示している。検出テーブル及び新検出テーブルはともに、ファイル9とファイル10のグループA、ファイル11とファイル12のグループBに分けられる。   9 and 10 are diagrams for explaining the operation of the inclusion clone deletion unit 105. FIG. The included clone deletion unit 105 separates the files registered in the detection table into groups, and separates the files registered in the new detection table into groups (step S319). In this grouping, files in which section information is registered with the same token string are grouped into the same group. Grouping in this way can reduce the amount of processing by performing overdetection processing for each group having a higher possibility of clones than performing clone overdetection processing described later for each file. Because. 901 in FIG. 9 indicates the status of grouping in the detection table, and 902 in FIG. 9 indicates the status of grouping in the new detection table. Both the detection table and the new detection table are divided into group A of file 9 and file 10 and group B of file 11 and file 12.

続いて、包含クローン削除部105は、検出テーブルと新検出テーブルとの間でグループ毎に区間情報を比較し、結合テーブルの区間情報が新結合テーブルの区間情報に完全に包含されているか否かを判定する(ステップS320)。即ち、ステップS320では、検出テーブル内に過検出となっている区間情報が存在するか否かを判定している。例えば、新検出テーブル内にトークン列ABABAが登録され、検出テーブル内にトークン列BABがトークン列ABABAの区間情報に包含される区間情報で登録されているような場合、最長のトークン列ABABAだけを検出すればよく、そのトークン列に含まれるトークン列BABは検出する必要はない。このような場合、トークン列BABを検出することは過検出であり、ステップS320ではこの過検出の判定を行っている。   Subsequently, the inclusion clone deletion unit 105 compares the section information for each group between the detection table and the new detection table, and whether or not the section information of the combined table is completely included in the section information of the new combined table. Is determined (step S320). That is, in step S320, it is determined whether or not there is section information that is over-detected in the detection table. For example, when the token string ABABA is registered in the new detection table and the token string BAB is registered in the detection table with section information included in the section information of the token string ABABA, only the longest token string ABABA is stored. The token string BAB included in the token string need not be detected. In such a case, detecting the token string BAB is overdetection, and in step S320, this overdetection is determined.

結合テーブルの区間情報が新結合テーブルの区間情報に完全に包含されている場合、包含クローン削除部105は、結合テーブルの該当するレコードを削除する(ステップS321)。即ち、包含クローン削除部105は、結合テーブルにおける過検出の区間情報が登録されているレコードを削除する。   If the section information of the combined table is completely included in the section information of the new combined table, the included clone deletion unit 105 deletes the corresponding record from the combined table (step S321). That is, the included clone deletion unit 105 deletes a record in which overdetected section information is registered in the combined table.

図10の1001に示すように、結合テーブルのトークン列$(%,%,%,%)のファイル9の区間情報が(11,5)−(12,7)、同じく結合テーブルのトークン列$(%,%,%,%)のファイル10の区間情報が(12,5)−(13,7)である。また、図10の1002に示すように、新結合テーブルのトークン列$();[L%=N;$(%,%,%,%)のファイル9の区間情報が(10,3)−(12,7)、同じく新結合テーブルのトークン列$();[L%=N;$(%,%,%,%)のファイル10の区間情報が(11,3)−(13,7)である。このように、結合テーブルのトークン$(%,%,%,%)の区間情報は、新結合テーブルのトークン$();[L%=N;$(%,%,%,%)の区間情報に完全に包含されているため、結合テーブルのトークン$(%,%,%,%)のレコードは削除される。一方、新結合テーブルの区間情報に結合テーブルの区間情報が完全に包含されていない場合、処理はステップS321を実行せずにステップS322に移行する。   As indicated by 1001 in FIG. 10, the section information of the file 9 of the token sequence $ (%,%,%,%) of the join table is (11,5)-(12,7), and the token sequence $ of the join table is also the same. The section information of the file 10 of (%,%,%,%) is (12, 5)-(13, 7). Further, as indicated by 1002 in FIG. 10, the section information of the file 9 in the token string $ (); [L% = N; $ (%,%,%,%) of the new join table is (10, 3) − (12, 7), similarly, the section information of the file 10 in the token sequence $ (); [L% = N; $ (%,%,%,%) of the new join table is (11, 3)-(13, 7 ). In this way, the interval information of token $ (%,%,%,%) in the join table is the interval of token $ (); [L% = N; $ (%,%,%,%) in the new join table Since it is completely included in the information, the record of token $ (%,%,%,%) in the join table is deleted. On the other hand, when the section information of the join table is not completely included in the section information of the new join table, the process proceeds to step S322 without executing step S321.

続いて、包含クローン削除部105は、検出テーブルの全レコードを抽出し、クローンテーブルを生成する(ステップS322)。従って、図10の1001に示すように、クローンテーブルは、トークン列$();[L%=N;のレコード、及び、トークン列$();[L%=$(のレコードで構成されることになる。   Subsequently, the included clone deletion unit 105 extracts all the records in the detection table and generates a clone table (step S322). Therefore, as indicated by 1001 in FIG. 10, the clone table is composed of records of token sequence $ (); [L% = N; and records of token sequence $ (); [L% = $ ( It will be.

続いて、包含クローン削除部105は、新検出テーブルが生成されたか否かを判定する(ステップS323)。図10の例では、新検出テーブルが生成されたため、処理は図3−2のステップS324に移行する。クローン簡易結合部103は、新検出テーブルを検出テーブルに置き換える(ステップS324)。一方、新検出テーブルが生成されなかった場合、処理は終了する。   Subsequently, the included clone deletion unit 105 determines whether or not a new detection table has been generated (step S323). In the example of FIG. 10, since a new detection table is generated, the process proceeds to step S324 in FIG. The clone simple combining unit 103 replaces the new detection table with the detection table (step S324). On the other hand, if a new detection table has not been generated, the process ends.

包含クローン削除部105は、包含クローン削除部105で新検出テーブルから置き替えられた検出テーブルに対してステップS313のクローン簡易結合処理を実行する。即ち、図11の1101に示す新検出テーブルから置き替えられた検出テーブルは、ファイル9、ファイル10について、トークン列$();[L%=$();[L%=N;の区間情報として(9,5)−(11,5)、(10,5)−(12,5)が登録され、トークン列$();[L%=N;$(%,%,%,%)の区間情報として(10,3)−(12,7)、(11,3)−(13,7)が登録されている。従って、比較する区間情報は、全て同じオフセット(縦軸方向の1座標分、横軸方向の2座標分)を有することになり、区間情報の結合が行われる。図11の1102に示すように、区間情報の結合が行われた後の検出テーブルは、トークン列$();[L%=$();[L%=N;$(%,%,%,%)のレコードには、ファイル9について(9、5)−(12,7)の区間情報が登録され、ファイル10について(10,5)−(13,7)の区間情報が登録される。   The inclusion clone deletion unit 105 executes the clone simple combination process of step S313 on the detection table replaced from the new detection table by the inclusion clone deletion unit 105. That is, the detection table replaced from the new detection table 1101 in FIG. 11 is the section information of token strings $ (); [L% = $ (); [L% = N; (9,5)-(11,5), (10,5)-(12,5) are registered as token strings $ (); [L% = N; $ (%,%,%,%) (10,3)-(12,7), (11,3)-(13,7) are registered as the section information. Therefore, all the section information to be compared has the same offset (one coordinate in the vertical axis direction and two coordinates in the horizontal axis direction), and the section information is combined. As shown in 1102 of FIG. 11, the detection table after the combination of the section information is the token string $ (); [L% = $ (); [L% = N; $ (%,%,% ,%) Records the section information (9, 5)-(12, 7) for the file 9 and the section information (10, 5)-(13, 7) for the file 10. .

続いて、クローン結合部104は、図11の1102に示す検出テーブルに対してステップS314のクローン結合処理を実行するが、図11の1102に示す検出テーブルでは、前段のトークン列の区間情報と後段のトークン列の区間情報の始端とが重なっておらず、また、前段のトークン列の区間情報の終端と後段のトークン列の区間情報の始端とが接続されていない。従って、今回のクローン結合処理では、区間情報の結合は行われず、新検出テーブルへのレコードの登録は行われない。このように新検出テーブルが生成されなかった場合、処理はステップS316、S318及びS321をスキップし、ステップS322に移行する。   Subsequently, the clone combining unit 104 executes the clone combining process in step S314 on the detection table illustrated in FIG. 11 in 1102. In the detection table illustrated in FIG. The beginning of the section information of the token sequence of the previous token string does not overlap, and the end of the section information of the preceding token string is not connected to the beginning of the section information of the subsequent token string. Therefore, in this clone combining process, the section information is not combined and the record is not registered in the new detection table. When the new detection table is not generated in this way, the process skips steps S316, S318, and S321, and proceeds to step S322.

ステップS322では、包含クローン削除部105は、検出テーブルの全レコードを抽出し、クローンテーブルに追加する。即ち、図11の1102に示す検出テーブルの全レコードが抽出され、図10の1001に示すクローンテーブルに追加される。その結果、図12に示すクローンテーブルが生成される。図12に示すクローンテーブルには、最終的なクローンコードの検出結果が登録される。即ち、トークン列$();[L%=N;、$();[L%=$(、$();[L%=$();[L%=N;$(%,%,%,%)のクローンコードがファイル9、10の間で存在し、トークン列$();[L%=N;$();[L%=$(のクローンコードがファイル11、12の間で存在する。クローンテーブルに登録される区間情報はクローン簡易結合部103及びクローン結合部104による区間情報の結合処理によって最長一致の区間情報となっている。   In step S322, the included clone deletion unit 105 extracts all the records in the detection table and adds them to the clone table. That is, all the records in the detection table indicated by 1102 in FIG. 11 are extracted and added to the clone table indicated by 1001 in FIG. As a result, the clone table shown in FIG. 12 is generated. In the clone table shown in FIG. 12, the final clone code detection result is registered. That is, token sequence $ (); [L% = N ;, $ (); [L% = $ (, $ (); [L% = $ (); [L% = N; $ (%,%, %,%) Clone code exists between files 9 and 10, and token string $ (); [L% = N; $ (); [L% = $ (clone code between files 11 and 12 The section information registered in the clone table is the longest matching section information by the section information combining process by the clone simple combining unit 103 and the clone combining unit 104.

続いて、包含クローン削除部105は、新検出テーブルが生成されたか否かを判定する(ステップS323)。今回、新検出テーブルは生成されなかったため、処理は終了する。   Subsequently, the included clone deletion unit 105 determines whether or not a new detection table has been generated (step S323). Since the new detection table has not been generated this time, the process ends.

上述した実施形態においては、クローンコード検出対象のファイルと当該ファイルの比較対象となるファイル(本実施形態では、最後にクローンコード検出が行われた時点のファイル)との間の区間情報をファイル毎に結合し、結合した区間情報をクローンテーブルに登録するように構成している。従って、検出するクローンコードの最長一致を図ることが可能となり、クローンコードの過検出を防ぐことができる。   In the embodiment described above, the section information between the clone code detection target file and the file to be compared with the file (in this embodiment, the file at the time of the last clone code detection) is stored for each file. And the combined section information is registered in the clone table. Therefore, it is possible to achieve the longest match between the clone codes to be detected, and it is possible to prevent over-detection of the clone codes.

なお、図5に示した例では、n=10でn-gram化を行っているが、実際の処理においては計算の効率化の観点からn=56前後でn-gram化を行うことが好ましい。   In the example shown in FIG. 5, n-gram conversion is performed at n = 10. However, in actual processing, it is preferable to perform n-gram conversion at around n = 56 from the viewpoint of calculation efficiency. .

次に、本発明の第2の実施形態について説明する。本実施形態では、第1の実施形態で検出したクローンコードのなかでも、クローンコードの重要度合いを評価する一例について説明を行う。具体的には、第1の実施形態で検出したクローンコードについて同様の手順で再度クローン分析を行い、前記クローンコードにおいて最も占有率が高いトークン列(以下、繰り返し領域と称す)を検出し、繰り返し領域の属性を特定する。そして、特定した属性及び占有率より繰り返し領域の重要度合いを特定し、評価対象から排除すべきか否かを判定する。手順の詳細及び属性については以下に後述する。   Next, a second embodiment of the present invention will be described. In this embodiment, an example of evaluating the importance of a clone code among the clone codes detected in the first embodiment will be described. Specifically, the clone code detected in the first embodiment is subjected to clone analysis again in the same procedure, and the token sequence having the highest occupation rate (hereinafter referred to as a repeat region) is detected in the clone code. Identify region attributes. Then, the degree of importance of the repetitive region is specified from the specified attribute and occupancy rate, and it is determined whether or not to be excluded from the evaluation target. Details of the procedure and attributes will be described later.

図13は、本発明の第2の実施形態に係るクローンコード検出評価装置200の機能的な構成を示すブロック図である。図13に示されるブロック図は、第1の実施形態(図1)に示したブロック図と比べて、繰り返し領域選定部206、属性特定部207、クローンコード分析部208が新たに設けられている。また、以下に後述する図14、図15は、定義情報としてそれを表現するプログラムがROM203又はHD207に予め格納されている。なお、本実施形態に係るクローンコード検出評価装置のハードウェア構成は、図1に示した第1の実施形態に係るクローンコード検出評価装置のハードウェア構成と同様である。繰り返し領域選定部206、属性特定部207、クローンコード分析部208はそれぞれ、例えばHD207内に記憶され、必要に応じてRAM202にロードされるプログラム及びそれを実行するCPU201によって実現される構成である。   FIG. 13 is a block diagram showing a functional configuration of a clone code detection / evaluation apparatus 200 according to the second embodiment of the present invention. Compared to the block diagram shown in the first embodiment (FIG. 1), the block diagram shown in FIG. 13 is newly provided with a repeat area selecting unit 206, an attribute specifying unit 207, and a clone code analyzing unit 208. . In FIGS. 14 and 15 to be described later, a program that expresses it as definition information is stored in the ROM 203 or HD 207 in advance. The hardware configuration of the clone code detection / evaluation apparatus according to this embodiment is the same as the hardware configuration of the clone code detection / evaluation apparatus according to the first embodiment shown in FIG. Each of the repetitive region selection unit 206, the attribute specification unit 207, and the clone code analysis unit 208 has a configuration realized by a program stored in the HD 207 and loaded into the RAM 202 as necessary, and the CPU 201 that executes the program.

図14は、第1の実施形態で検出したクローンコード中において最大領域を占める繰り返し領域の属性を示す図である。「繰り返し領域の長さ」と「第1の実施形態で検出したクローンコード中における繰り返し領域の出現数」とにより、繰り返し領域の属性は特定される。   FIG. 14 is a diagram showing the attributes of the repetitive region occupying the maximum region in the clone code detected in the first embodiment. The attribute of the repeat region is specified by “the length of the repeat region” and “the number of occurrences of the repeat region in the clone code detected in the first embodiment”.

図15は、重要度合いを示す評価マップを示す図である。「繰り返し領域の属性」と「第1の実施形態で検出したクローンコード中における繰り返し領域の割合(カバー率)」とにより、重要度合いは特定される。なお、割合とは、「繰り返し領域の長さ」/「第1の実施形態で検出したクローンコードの長さ」である。   FIG. 15 is a diagram showing an evaluation map indicating the degree of importance. The degree of importance is specified by the “repetition region attribute” and the “repetition region ratio (cover rate) in the clone code detected in the first embodiment”. The ratio is “repetition region length” / “clone code length detected in the first embodiment”.

繰り返し領域の検出は、第2の実施形態において新たに設けられた繰り返し領域選定部206において検出される。検出手順は、第1の実施形態と同様であり、第1の実施形態においては複数ファイルに亘って行ったが、第2の実施形態においては第1の実施形態で検出した「最長のクローンコード」に対して行う。   The repetition area is detected by the repetition area selection unit 206 newly provided in the second embodiment. The detection procedure is the same as that in the first embodiment. In the first embodiment, the detection procedure is performed over a plurality of files. In the second embodiment, the “longest clone code detected in the first embodiment is used. Is performed.

例えば、第1の実施形態において抽出された「最長のクローンコード(トークン列)」が"ABCDABCDCD"であった場合、2gram化「"AB""BC"" CD""DA" "AB""BC""CD""DC""CD"」された後、結合すると、「ABCD」「CD」が抽出される。次に、繰り返し領域選定部206は、「最長のクローンコード」中における、上記抽出された「ABCD」「CD」夫々のカバー率を算出する。つまり、「ABCD/ABCDABCDCD=80%」「CD/ABCDABCDCD=60%」である。上述の通り、カバー率が最も高いトークンを「繰り返し領域」として抽出する。つまり、80%の割合を占める「ABCD」が「繰り返し領域」である。なお、カバー率が同率であれば、最も短いトークンを「繰り返し領域」として抽出する。   For example, when the “longest clone code (token string)” extracted in the first embodiment is “ABCDABCDCD”, the two-gram format “AB” “BC” “CD” “DA” “AB” “BC When “CD”, “DC”, and “CD” are combined, “ABCD” and “CD” are extracted. Next, the repetitive region selection unit 206 calculates the coverage of each of the extracted “ABCD” and “CD” in the “longest clone code”. That is, “ABCD / ABCDABCDCD = 80%” and “CD / ABCDABCDCD = 60%”. As described above, the token with the highest coverage is extracted as a “repetition area”. That is, “ABCD” occupying 80% of the ratio is the “repeated region”. If the coverage is the same, the shortest token is extracted as a “repetition area”.

次に、属性特定部207において、繰り返し領域の「属性」を求める。具体的には、属性特定部207は、図14に示す「繰り返し領域の長さ」及び「第1の実施形態で検出したクローンコード中における繰り返し領域の出現回数」の比率に応じた属性マップをROM203又はHD207より読み出し、繰り返し領域選定部206より算出した「繰り返し領域の長さ」及び「出現回数」の比率に応じて、属性マップに基づいて対応付けられた属性を特定する。上述の例「ABCD」であれば、「繰り返し領域の長さ」=4、「第1の実施形態で検出したクローンコード中における繰り返し領域の出現回数」=2であるため、「(5)junk」である。   Next, the attribute specifying unit 207 obtains the “attribute” of the repeated area. Specifically, the attribute specifying unit 207 displays an attribute map corresponding to the ratio between the “repetition area length” and the “number of occurrences of the repetition area in the clone code detected in the first embodiment” shown in FIG. Based on the attribute map, the associated attribute is specified in accordance with the ratio of the “repetition area length” and the “appearance count” read from the ROM 203 or HD 207 and calculated by the repetition area selection unit 206. In the above example “ABCD”, “repetition region length” = 4 and “number of occurrences of the repetition region in the clone code detected in the first embodiment” = 2, so “(5) junk” It is.

次に、クローンコード分析部208は、「属性」及び「カバー率」の比率に応じた評価マップをROM203又はHD207より読み出し、属性特定部207より特定された繰り返し領域の「属性」及び繰り返し領域選定部206において算出された「カバー率」の比率に応じて、対応付けられた重要度合い("大""中""小""N/A = not applicable")を特定する。上述の例「ABCD」であれば、「属性=junk」「カバー率=100%(1)」より「N/A」である。なお、図14は、最小トークン長が100以上を想定した評価マップである。実際に評価する際は、最小トークン長等に応じて適宜「属性」及び「カバー率」の具体的比率を変える。従って、上述の例のようにトークン長が10の場合は、図14とは具体的比率が異なった評価マップを参照して評価・分析する。   Next, the clone code analysis unit 208 reads an evaluation map corresponding to the ratio of “attribute” and “cover ratio” from the ROM 203 or the HD 207, and selects the “attribute” and repetition region of the repetition region identified by the attribute identification unit 207. According to the ratio of the “cover ratio” calculated in the unit 206, the associated importance level (“large”, “medium”, “small”, “N / A = not applicable”) is specified. In the above example “ABCD”, “attribute / junk” and “cover rate = 100% (1)” are “N / A”. FIG. 14 is an evaluation map assuming that the minimum token length is 100 or more. In actual evaluation, the specific ratio of “attribute” and “coverage” is appropriately changed according to the minimum token length and the like. Therefore, when the token length is 10 as in the above example, evaluation / analysis is performed with reference to an evaluation map having a specific ratio different from that in FIG.

図16は、重要度「小」と判断されたクローンコードの例を示す図である。クローンコードはJava(登録商標)のフィールド宣言部分だけである。繰り返し領域選定部206において検出した結果、クローン全体の最大領域を占める繰り返し領域は、フィールドの宣言1つと次のprivate識別子であった("private""Object""var"";""private")であり、「繰り返し領域の長さ」=5、第1の実施形態で検出したクローンコード中における繰り返し領域の出現回数=25のため、「繰返し領域の属性=Simple」「カバー率=25/25=1.00」「重要度合い=小」と判断し、評価対象外とみなす。   FIG. 16 is a diagram illustrating an example of a clone code determined to have an importance level of “small”. The clone code is only the field declaration part of Java (registered trademark). As a result of detection in the repeat area selection unit 206, the repeat area occupying the maximum area of the entire clone is one declaration of the field and the next private identifier ("private" "Object" "var" ";" "private") Since “repetition area length” = 5 and the number of repetition area appearances in the clone code detected in the first embodiment = 25, “repetition area attribute = Simple” “cover ratio = 25/25” = 1.00 ”and“ Importance = Small ”, and are deemed not to be evaluated.

実際フィールド宣言部分はロジックのクローンコードではないので、修正は不要であって、ソースコードの品質に影響を与えない重要度合いが低いものである。つまり、評価対象として見る必要が無いコードを評価対象より排除することによって、分析者の作業工数を削減し効率化を図ることが可能になる。   Actually, since the field declaration part is not a clone code of logic, no modification is necessary and the degree of importance that does not affect the quality of the source code is low. In other words, by excluding codes that do not need to be viewed as evaluation targets from the evaluation target, it is possible to reduce the number of analysts' work and improve efficiency.

以上、クローンコード検出評価装置の実施形態につき説明したが、本発明のクローンコード検出評価装置は、上記実施形態で説明した構成要件の全てを備えたクローンコード検出評価装置に限定されるものではなく、各種の変更及び修正が可能である。また、かかる変更及び修正についても本発明の特許請求の範囲に属することは言うまでもない。   As described above, the embodiment of the clone code detection / evaluation apparatus has been described. However, the clone code detection / evaluation apparatus of the present invention is not limited to the clone code detection / evaluation apparatus having all the configuration requirements described in the above embodiment. Various changes and modifications are possible. Further, it goes without saying that such changes and modifications belong to the scope of the claims of the present invention.

例えば、上述したROM203又はHD207に予め格納されている図14は「繰り返し領域の長さ」と「第1の実施形態で検出したクローンコード中における繰り返し領域の出現回数」との比率に応じて特定されるが、夫々の具体的数値が図14に限定される必要は無い。図15についても同様で、「属性」及び「カバー率」の比率に応じて特定されるが、夫々の具体的数値が図15に限定される必要は無い。   For example, FIG. 14 stored in advance in the ROM 203 or HD 207 described above is specified according to the ratio between the “repetition area length” and the “number of occurrences of the repetition area in the clone code detected in the first embodiment”. However, each specific numerical value does not need to be limited to FIG. The same applies to FIG. 15, which is specified according to the ratio of “attribute” and “cover ratio”, but each specific numerical value is not necessarily limited to FIG. 15.

100、200 クローン検出装置
101 基底テーブル作成部
102 検出テーブル作成部
103 クローン簡易結合部
104 クローン結合部
105 包含クローン削除部
206 繰り返し領域選定部
207 属性特定部
208 クローンコード分析部
100, 200 Clone detection device 101 Base table creation unit 102 Detection table creation unit 103 Clone simple combination unit 104 Clone combination unit 105 Included clone deletion unit 206 Repetitive region selection unit 207 Attribute specification unit 208 Clone code analysis unit

Claims (8)

クローンコード検出対象のファイルにおける第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を第1の検出テーブルに登録するとともに、前記クローンコード検出対象のファイルとの比較対象となるファイルにおける前記第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を前記第1の検出テーブルに登録する第1の検出テーブル生成手段と、
前記第1の検出テーブルにおいて登録される前記クローンコード検出対象のファイルにおける第1の単位のデータの区間情報と前記比較対象となるファイルにおける前記第1の単位のデータの区間情報との間で所定の条件を満たす場合、前記第1の検出テーブルにおける前記第1の単位のデータの区間情報を前記ファイル毎に結合させる合手段と、
前記結合手段により前記ファイル毎に結合された区間情報を前記第1の検出テーブルから抽出するとともに、前記結合手段により結合された区間情報に対応する前記第1の単位のデータを結合した第2の単位のデータであるクローンコードを抽出して、クローンコードテーブルに登録するクローンコードテーブル生成手段と、
前記クローンコードテーブルにおいて登録されるクローンコードに基づいて、前記クローンコードの重要度合いを評価するクローンコード評価手段とを有することを特徴とするクローンコード検出評価装置。
Registers the segment information indicating the segment to the end position from the start position of each data of the first unit in clone code detection target file in the first detection table, and compared with the clone code detection target file First detection table generating means for registering, in the first detection table, section information indicating a section from a start position to an end position for each of the first unit data in the file,
Predetermined between the section information of the first unit data in the clone code detection target file registered in the first detection table and the section information of the first unit data in the comparison target file If conditions are satisfied, a binding means for coupling said first section information data of the first unit in the detection table for each of the files,
Section information combined for each of the files by the combining unit is extracted from the first detection table, and a second unit is formed by combining the data of the first unit corresponding to the section information combined by the combining unit. Clone code table generation means for extracting the clone code that is unit data and registering it in the clone code table;
A clone code detection / evaluation apparatus comprising: clone code evaluation means for evaluating the importance of the clone code based on a clone code registered in the clone code table .
前記クローンコード評価手段は、前記クローンコードに含まれる所定のトークン列の長さと前記クローンコード中における前記所定のトークン列の出現回数とに基づいて、前記前記所定のトークン列の属性を特定し、特定した前記所定のトークン列の属性と前記クローンコード中における前記所定のトークン列の割合とに基づいて、前記クローンコードの重要度合いを評価することを特徴とする請求項1に記載のクローンコード検出評価装置。 The clone code evaluation means specifies the attribute of the predetermined token sequence based on the length of the predetermined token sequence included in the clone code and the number of appearances of the predetermined token sequence in the clone code, 2. The clone code detection according to claim 1 , wherein the degree of importance of the clone code is evaluated based on the attribute of the specified predetermined token string and a ratio of the predetermined token string in the clone code. Evaluation device. 前記所定のトークン列は、前記クローンコードから抽出されるトークン列のうち、前記クローンコード中における割合が最も高いトークン列であることを特徴とする請求項2に記載のクローンコード検出評価装置。The clone code detection / evaluation apparatus according to claim 2, wherein the predetermined token string is a token string having a highest ratio in the clone code among token strings extracted from the clone code. 前記合手段は、前記クローンコード検出対象のファイルにおける前記第1の単位のデータ間の区間情報の差と、前記比較対象となるファイルにおける前記第1の単位のデータ間の区間情報の差とが同じである場合、前記第1の検出テーブルにおける前記第1の単位のデータ間の区間情報を前記ファイル毎に結合させることを特徴とする請求項1乃至3の何れか1項に記載のクローンコード検出評価装置。 It said binding means includes a difference in section information between data of the first unit in the clones code detection target file, and the difference between the section information between data of the first unit in the comparison subject to file The clone according to any one of claims 1 to 3 , wherein, when the two are the same , the section information between the data of the first unit in the first detection table is combined for each file. Code detection evaluation device. 前記クローンコード検出対象のファイル及び前記比較対象となるファイルのうちの任意のファイル毎に、前記合手段による結合処理後の前記第1の検出テーブル内における前記第2の単位のデータの区間情報が重なる、又は接続される場合、前記任意のファイル毎に前記第2の単位のデータの区間情報を結合させた区間情報を第2の検出テーブルに登録する第2の検出テーブル生成手段を更に有し、
前記第2の検出テーブル生成手段により区間情報が前記第2の検出テーブルに登録された場合、前記結合手段は、前記第2の検出テーブルにおいて登録される前記クローンコード検出対象のファイルにおける前記第2の単位のデータの区間情報と前記比較対象となるファイルにおける前記第2の単位のデータの区間情報との間で前記所定の条件を満たす場合、前記第2の検出テーブルにおける前記第2の単位のデータの区間情報を前記任意のファイル毎に結合させ、前記クローンコードテーブル生成手段は、前記結合手段により前記任意のファイル毎に結合された区間情報を前記第2の検出テーブルから抽出するとともに、前記第2の検出テーブル生成手段により結合された区間情報に対応する前記第2の単位のデータを結合した第3の単位のデータであるクローンコードを抽出して、前記クローンコードテーブルに登録することを特徴とする請求項1乃至4の何れか1項に記載のクローンコード検出評価装置。
Wherein any each file of the clones code detection target file and the comparison subject to file, the sintering said binding after treatment by the coupling means a first said in the detection table second unit of data section A second detection table generating means for registering, in the second detection table, section information obtained by combining section information of the second unit data for each arbitrary file when the information overlaps or is connected; Have
When the section information is registered in the second detection table by the second detection table generation unit, the combining unit is configured to output the second code in the clone code detection target file registered in the second detection table. When the predetermined condition is satisfied between the section information of the unit data and the section information of the second unit data in the file to be compared, the second unit in the second detection table The section information of data is combined for each arbitrary file, and the clone code table generating unit extracts the section information combined for each arbitrary file by the combining unit from the second detection table, and A third unit obtained by combining the data of the second unit corresponding to the section information combined by the second detection table generating unit It extracts clones encoding the data, clones encoding detection evaluation apparatus according to any one of claims 1 to 4, characterized in that registering the clones code table.
前記第1の検出テーブルにおいて登録される前記第2の単位のデータの区間情報が、前記第2の検出テーブルにおいて登録される前記第2の単位のデータを含む前記第3の単位のデータの区間情報に包含される場合、前記第1の結合テーブルから前記第2の単位のデータの区間情報を削除する削除手段を更に有し、
前記クローンコードテーブル生成手段は、前記結合手段により前記ファイル毎に結合された区間情報のうち、前記削除手段により削除された区間情報を除く区間情報を前記第1の検出テーブルから抽出して前記クローンコードテーブルに登録することを特徴とする請求項に記載のクローンコード検出評価装置。
Section of data of the third unit including section information of data of the second unit registered in the first detection table includes data of the second unit registered in the second detection table. If it is included in the information, further comprising a deletion means for deleting the section information of the data of the second unit from the first combined table,
The clone code table generation unit extracts, from the first detection table, section information excluding section information deleted by the deletion unit from the section information combined for each file by the combination unit. The clone code detection / evaluation apparatus according to claim 5 , wherein the clone code detection / evaluation apparatus is registered in a code table.
クローンコード検出評価装置によるクローンコード検出評価方法であって、
クローンコード検出対象のファイルにおける第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を検出テーブルに登録するとともに、前記クローンコード検出対象のファイルとの比較対象となるファイルにおける前記第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を前記検出テーブルに登録する検出テーブル生成ステップと、
前記第1の検出テーブルにおいて登録される前記クローンコード検出対象のファイルにおける第1の単位のデータの区間情報と前記比較対象となるファイルにおける前記第1の単位のデータの区間情報との間で所定の条件を満たす場合、前記検出テーブルにおける前記第1の単位のデータの区間情報をファイル毎に結合させる結合ステップと、
前記結合ステップにより前記ファイル毎に結合された区間情報を前記検出テーブルから抽出するとともに、前記検出ステップにより結合された区間情報に対応する前記第1の単位のデータを結合した第2の単位のデータであるクローンコードを抽出して、クローンコードテーブルに登録するクローンコードテーブル生成ステップと、
前記クローンコードテーブルにおいて登録されるクローンコードに基づいて、前記クローンコードの重要度合いを評価するクローンコード評価ステップとを含むことを特徴とするクローンコード検出評価方法。
A clone code detection evaluation method using a clone code detection evaluation apparatus,
It registers the segment information indicating the segment to the end position from the start position of each data of the first unit in clone code detection target file to detection table, in comparison with the file to which the said clone code detection target file A detection table generating step of registering section information indicating a section from a start position to an end position for each data of the first unit in the detection table;
Predetermined between the section information of the first unit data in the clone code detection target file registered in the first detection table and the section information of the first unit data in the comparison target file If the above condition is satisfied, a combining step of combining the section information of the data of the first unit in the detection table for each file;
The section information combined for each file by the combining step is extracted from the detection table, and the second unit data is formed by combining the first unit data corresponding to the section information combined by the detection step. A clone code table generation step for extracting the clone code and registering it in the clone code table;
A clone code evaluation step for evaluating the importance of the clone code based on a clone code registered in the clone code table .
クローンコード検出対象のファイルにおける第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を検出テーブルに登録するとともに、前記クローンコード検出対象のファイルとの比較対象となるファイルにおける前記第1の単位のデータ毎の開始位置から終了位置までの区間を示す区間情報を前記検出テーブルに登録する検出テーブル生成ステップと、
前記第1の検出テーブルにおいて登録される前記クローンコード検出対象のファイルにおける第1の単位のデータの区間情報と前記比較対象となるファイルにおける前記第1の単位のデータの区間情報との間で所定の条件を満たす場合、前記検出テーブルにおける前記第1の単位のデータの区間情報をファイル毎に結合させる結合ステップと、
前記結合ステップにより前記ファイル毎に結合された区間情報を前記検出テーブルから抽出するとともに、前記結合ステップにより結合された区間情報に対応する前記第1の単位のデータを結合した第2の単位のデータであるクローンコードを抽出して、クローンコードテーブルに登録するクローンコードテーブル生成ステップと、
前記クローンコードテーブルにおいて登録されるクローンコードに基づいて、前記クローンコードの重要度合いを評価するクローンコード評価ステップとをコンピュータに実行させるためのプログラム。
It registers the segment information indicating the segment to the end position from the start position of each data of the first unit in clone code detection target file to detection table, in comparison with the file to which the said clone code detection target file A detection table generating step of registering section information indicating a section from a start position to an end position for each data of the first unit in the detection table;
Predetermined between the section information of the first unit data in the clone code detection target file registered in the first detection table and the section information of the first unit data in the comparison target file If the above condition is satisfied, a combining step of combining the section information of the data of the first unit in the detection table for each file;
The second unit data obtained by extracting the section information combined for each file by the combining step from the detection table and combining the first unit data corresponding to the section information combined by the combining step. A clone code table generation step for extracting the clone code and registering it in the clone code table;
A program for causing a computer to execute a clone code evaluation step for evaluating the importance of the clone code based on a clone code registered in the clone code table .
JP2009196688A 2009-08-27 2009-08-27 Clone code detection evaluation apparatus, clone code detection evaluation method and program Active JP5345020B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2009196688A JP5345020B2 (en) 2009-08-27 2009-08-27 Clone code detection evaluation apparatus, clone code detection evaluation method and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2009196688A JP5345020B2 (en) 2009-08-27 2009-08-27 Clone code detection evaluation apparatus, clone code detection evaluation method and program

Publications (2)

Publication Number Publication Date
JP2011048639A JP2011048639A (en) 2011-03-10
JP5345020B2 true JP5345020B2 (en) 2013-11-20

Family

ID=43834885

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2009196688A Active JP5345020B2 (en) 2009-08-27 2009-08-27 Clone code detection evaluation apparatus, clone code detection evaluation method and program

Country Status (1)

Country Link
JP (1) JP5345020B2 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9201649B2 (en) 2012-10-26 2015-12-01 Inforsys Limited Systems and methods for estimating an impact of changing a source file in a software
JP6070936B2 (en) 2013-01-31 2017-02-01 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation Information processing apparatus, information processing method, and program
KR101568224B1 (en) 2014-12-26 2015-11-11 고려대학교 산학협력단 Analysis device and method for software security
US11429380B2 (en) * 2018-09-25 2022-08-30 Fossid AB Method for converting source code into numeric identifiers and comparison against data sets

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5027765B2 (en) * 2008-09-02 2012-09-19 新日鉄ソリューションズ株式会社 Clone code detection device, clone code detection method and program

Also Published As

Publication number Publication date
JP2011048639A (en) 2011-03-10

Similar Documents

Publication Publication Date Title
TWI729472B (en) Method, device and server for determining feature words
JP5779077B2 (en) Apparatus and method for supporting program generation
CN109189519B (en) Universal user desktop behavior simulation system and method
JP5350428B2 (en) Automatic program generation apparatus, method and computer program
CN108875317B (en) Software clone detection method and device, detection equipment and storage medium
JP5345020B2 (en) Clone code detection evaluation apparatus, clone code detection evaluation method and program
JP2016531352A (en) Method, device, program and device for updating input system
WO2021120664A1 (en) Abnormal inode dynamic repair method and system, and related component
US8335757B2 (en) Extracting patterns from sequential data
JPWO2015015574A1 (en) Processing program, processing system, and processing method
JP5027765B2 (en) Clone code detection device, clone code detection method and program
JP5045517B2 (en) Design document creation program, apparatus, and method
US8489537B2 (en) Segmenting sequential data with a finite state machine
WO2004051470A1 (en) Program automatic converting method and program automatic converting device
JP2001357095A (en) Semiconductor device design supporting device
JP2006277127A (en) Method for comparing correction program
WO2020149242A1 (en) Work assistance device, work assistance method, program, and object detection model
JP5702265B2 (en) Program automatic generation apparatus and program automatic generation method
JP2009163566A (en) Job analysis support apparatus
JP4116660B2 (en) Verification support device, verification support method, verification support program, and recording medium
JP2008234080A (en) Semiconductor integrated circuit design support device, semiconductor integrated circuit design support method, semiconductor integrated circuit design support progrram, semiconductor integrated circuit, and method for manufacturing semiconductor integrated circuit
JP2009093491A (en) Verification-scenario generating program, recording medium recording the program, verification-scenario generating apparatus, and verification-scenario generating method
CN105094845A (en) Process modeling device and method
JP2006259805A (en) Processor design equipment, processor design method, and processor design program
JP2009053767A (en) Program analysis device and program analysis method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20120817

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20130328

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130402

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20130531

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20130730

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20130813

R150 Certificate of patent or registration of utility model

Ref document number: 5345020

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250