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 PDFInfo
- 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
Links
Images
Abstract
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.
しかしながら、従来からクローンコードを検出する方法が存在するが、その検出処理の計算量が多く、クローンコードの検出に多くの時間がかかってしまい、実用的と言えるものではなかった。効率的にクローンコードを検出する技術が例えば特許文献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,
特許文献1には、テキストから同形パターンを検出する同形パターン検出システムが開示されている。特許文献1に開示される同形パターン検出システムでは、字句解析、規則による変形、パラメータ変換、同形検出、同形出力により対象のテキストの同形を検出する。しかしながら、特許文献1に開示される同形パターン検出システムは、計算量がO(N)〜O(NlogN)と高速であるが、抽出されたクローンコードが最長一致ではないので過検出が多くなるという問題があった。
一方、クローンコードは上述のようにフレームワークの生成によって生じるケース等、本来なら品質に影響は無く、評価する必要が無いものもある。このようにクローンコードには、ソースコードの品質向上に影響のある重要なものと、品質自体に影響を及ぼさない重要度合いの低いクローンコードがあり、この点を考慮せずに一緒くたにすると、評価対象は膨大になり、作業効率を下げることにつながる。 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.
以下、本発明を適用した好適な実施形態を、添付図面を参照しながら詳細に説明する。 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 /
基底テーブル作成部101は、最後にクローンコードの検出を行った時点における最新ファイルのソースコードをトークン列に変換し、n-gram化されたトークン列とそれらのトークン列の区間情報を基底テーブルに登録する。
The base
検出テーブル作成部102は、クローンコードの検出対象となるファイルのソースコードをトークン列に変換し、n-gram化されたトークン列とそれらのトークン列の区間情報とを検出テーブルに登録する。そして、検出テーブル作成部102は、基底テーブルに登録される区間情報を後述する方法によって検出テーブルに登録する。
The detection
クローン簡易結合部103は、検出テーブルのレコード同士の対応する区間情報を比較し、比較した区間情報が各ファイル間で同じオフセットを有するのであれば、区間情報の結合を行う。
The clone simple combining
クローン結合部104は、クローン簡易結合部103により生成された検出テーブルから、ファイル毎に区間情報を取得する。そして、クローン結合部104は、前段のトークン列の区間情報の終端と後段のトークン列の区間情報の始端とが重なる、又は、前段のトークン列の区間情報の終端と後段のトークン列の区間情報の始端とが接続される場合、それらの区間情報を結合した区間情報を新検出テーブルに登録する。
The
包含クローン削除部105は、検出テーブルと新検出テーブルとを比較し、検出テーブルの区間情報が新検出テーブルの区間情報に完全に包含されている場合、即ち、検出テーブル内に過検出となっている区間情報が存在する場合、検出テーブルにおける過検出の区間情報が登録されているレコードを削除する。
The inclusion
図2は、本実施形態に係るクローンコード検出評価装置100のハードウェア構成を示す図である。
FIG. 2 is a diagram illustrating a hardware configuration of the clone code detection /
CPU201は、システムバスに接続される各デバイスやコントローラを統括的に制御する。ROM203又はHD(ハードディスク)207には、CPU201の制御プログラムであるBIOS(Basic Input / Output System)やオペレーティングシステムプログラム、クローンコード検出評価装置100が実行する例えば図3−1乃至図3−3に示す処理のプログラム等が記憶されている。
The
なお、図2の例では、HD207はクローンコード検出評価装置100の内部に配置された構成としているが、他の実施形態としてHD207に相当する構成がクローンコード検出評価装置100の外部に配置された構成としてもよい。また、本実施形態に係る例えば図3−1乃至図3−3に示す処理を行うためのプログラムは、フレキシブルディスク(FD)やCD−ROM等、コンピュータ読み取り可能な記録媒体に記録され、それらの記録媒体から供給される構成としてもよいし、インターネット等の通信媒体を介して供給される構成としてもよい。
In the example of FIG. 2, the
RAM202は、CPU201の主メモリ、ワークエリア等として機能する。CPU201は、処理の実行に際して必要なプログラム等をRAM202にロードして、プログラムを実行することで各種動作を実現するものである。
The
HD207やFD206は、外部メモリとして機能する。CPU201は、処理の実行に際して必要なプログラム等をRAM202にロードして、プログラムを実行することで各種動作を実現するものである。
The
ディスクコントローラ205は、HD207やFD206等の外部メモリへのアクセスを制御する。通信I/Fコントローラ204は、インターネットやLANと接続し、例えばTCP/IPによって外部との通信を制御するものである。
The
ディスプレイコントローラ208は、ディスプレイ209における画像表示を制御する。
The
KBコントローラ210は、KB(キーボード)211からの操作入力を受け付け、CPU201に対して送信する。なお、図示していないが、KB211の他に、マウス等のポインティングデバイスもユーザの操作手段として本実施形態に係るクローンコード検出評価装置100に適用可能である。
The
図1に示す基底テーブル作成部101、検出テーブル作成部102、クローン簡易結合部103、クローン結合部104及び包含クローン削除部105は、例えばHD207内に記憶され、必要に応じてRAM202にロードされるプログラム及びそれを実行するCPU201によって実現される構成である。
The base
図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 /
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
次に、クローンコード検出評価装置100の動作について説明する。図3−1において、基底テーブル作成部101は、最後にクローンコードの検出を行った時点における最新ファイルをリポジトリから読み出す(ステップS301)。即ち、基底テーブル作成部101は、ファイル1のバージョン1、ファイル2のバージョン2、ファイル3のバージョン2を読み出す。
Next, the operation of the clone code detection /
続いて、基底テーブル作成部101は、リポジトリから取り出した各ファイル内に記述されるソースコードを構文解析し、voidであればVといったように、ソースコードをトークン列に変換する(ステップS302)。ここでの変換ルールはad hocを用いる。
Subsequently, the base
図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
また、トークン列$(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
図6は、検出テーブル作成部102による検出テーブルの作成処理を説明するための図である。図6においては、ファイル3のバージョン3をクローンコードの検出対象とした場合に作成される検出テーブルの構成例を示している。
FIG. 6 is a diagram for explaining detection table creation processing by the detection
続いて、検出テーブル作成部102は、基底テーブルに検出対象のファイル3の旧バージョンが存在するか否かを判定する(ステップS304)。ファイル3の旧バージョンが存在する場合、検出テーブル作成部102は、図6の601に示すように、基底テーブルから検出対象のファイル3の旧バージョンの区間情報を削除する(ステップS305)。これは、バージョン違いの同一種類のファイルである場合、新バージョンのファイルは旧バージョンのファイルが部分的に更新されて共通部分が多いため、その共通部分をクローンコードとして検出するのは適切ではないからである。一方、ファイル3の旧バージョンが存在しない場合、処理はステップS305を実行せずにステップS306に移行する。
Subsequently, the detection
続いて、検出テーブル作成部102は、ファイル3のバージョン3をリポジトリから読み出す(ステップS306)。そして、検出テーブル作成部102は、ファイル3のバージョン3内に記述されるソースコードを構文解析し、トークン列に変換する(ステップS307)。
Subsequently, the detection
続いて、検出テーブル作成部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
続いて、検出テーブル作成部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
図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
続いて、図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
続いて、クローン簡易結合部103は、検出テーブルの各レコードを区間情報の数毎に分類する(ステップS312)。図7の例においては、4つの区間情報を登録しているトークン列V$(I%)[L%=のレコードとトークン列(I%)[L%=&;のレコードとの分類と、3つの区間情報を登録しているトークン列$(I%)[L%=&のレコードとトークン列I%)[L%=&;%のレコードとの分類になる。
Subsequently, the clone
続いて、クローン簡易結合部103は、クローン簡易結合処理を行う(ステップS313)。即ち、クローン簡易結合部103は、分類毎に、レコード同士の対応する区間情報を比較し、比較した区間情報が各ファイル間で同じオフセットを有するのであれば、区間情報の結合を行う。
Subsequently, the clone
図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
図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
ファイル毎に各区間情報を結合させた場合、結合後の区間情報に該当するトークン列は複数のファイル間に亘って同一のトークン列であると看做せる。従って、上述したクローン簡易結合処理は、レコード間において、複数のファイルに亘って或るトークン列の区間情報が同じ数だけ登録され、且つ同一分類のレコード間において、夫々のトークン列の区間情報が複数のファイルに亘って同じオフセットで登録されている場合に行われる。 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
図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
また、トークン列$(%,%,%,%)のファイル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
続いて、クローン結合部104は、クローン結合処理により結合された区間情報が存在したか否かを判定する(ステップS315)。クローン結合処理により結合された区間情報が存在する場合、クローン結合部104は、新検出テーブルにおいて、結合後のトークン列に結合後の区間情報を対応付けて登録する(ステップS316)。一方、クローン結合処理により結合された区間情報が存在しない場合、処理はステップS316を実行せずに図3−3のステップS317に移行する。
Subsequently, the
続いて、クローン結合部104は、新検出テーブルにおいてファイル間で1つの区間情報の登録しかないレコードが存在するか否かを判定する(ステップS317)。新検出テーブルにおいてファイル間で1つの区間情報の登録しかないレコードが存在する場合、クローン結合部104は、該当するレコードを削除する(ステップS318)。これは、ファイル間で1つの区間情報しか登録されていないトークン列はクローンではないためである。図8の例では、トークン列$();[L%=$();[L%=$(のレコードが削除されることになる。一方、新検出テーブルにおいてファイル間で1つの区間情報の登録しかないレコードが存在しない場合、処理はステップS318を実行せずにステップS319に移行する。上述したステップS314〜S318の処理によって、図8の801に示す検出テーブルから図8の802に示す新検出テーブルが生成される。
Subsequently, the
図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
続いて、包含クローン削除部105は、検出テーブルと新検出テーブルとの間でグループ毎に区間情報を比較し、結合テーブルの区間情報が新結合テーブルの区間情報に完全に包含されているか否かを判定する(ステップS320)。即ち、ステップS320では、検出テーブル内に過検出となっている区間情報が存在するか否かを判定している。例えば、新検出テーブル内にトークン列ABABAが登録され、検出テーブル内にトークン列BABがトークン列ABABAの区間情報に包含される区間情報で登録されているような場合、最長のトークン列ABABAだけを検出すればよく、そのトークン列に含まれるトークン列BABは検出する必要はない。このような場合、トークン列BABを検出することは過検出であり、ステップS320ではこの過検出の判定を行っている。
Subsequently, the inclusion
結合テーブルの区間情報が新結合テーブルの区間情報に完全に包含されている場合、包含クローン削除部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
図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
続いて、包含クローン削除部105は、検出テーブルの全レコードを抽出し、クローンテーブルを生成する(ステップS322)。従って、図10の1001に示すように、クローンテーブルは、トークン列$();[L%=N;のレコード、及び、トークン列$();[L%=$(のレコードで構成されることになる。
Subsequently, the included
続いて、包含クローン削除部105は、新検出テーブルが生成されたか否かを判定する(ステップS323)。図10の例では、新検出テーブルが生成されたため、処理は図3−2のステップS324に移行する。クローン簡易結合部103は、新検出テーブルを検出テーブルに置き換える(ステップS324)。一方、新検出テーブルが生成されなかった場合、処理は終了する。
Subsequently, the included
包含クローン削除部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
続いて、クローン結合部104は、図11の1102に示す検出テーブルに対してステップS314のクローン結合処理を実行するが、図11の1102に示す検出テーブルでは、前段のトークン列の区間情報と後段のトークン列の区間情報の始端とが重なっておらず、また、前段のトークン列の区間情報の終端と後段のトークン列の区間情報の始端とが接続されていない。従って、今回のクローン結合処理では、区間情報の結合は行われず、新検出テーブルへのレコードの登録は行われない。このように新検出テーブルが生成されなかった場合、処理はステップS316、S318及びS321をスキップし、ステップS322に移行する。
Subsequently, the
ステップ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
続いて、包含クローン削除部105は、新検出テーブルが生成されたか否かを判定する(ステップS323)。今回、新検出テーブルは生成されなかったため、処理は終了する。
Subsequently, the included
上述した実施形態においては、クローンコード検出対象のファイルと当該ファイルの比較対象となるファイル(本実施形態では、最後にクローンコード検出が行われた時点のファイル)との間の区間情報をファイル毎に結合し、結合した区間情報をクローンテーブルに登録するように構成している。従って、検出するクローンコードの最長一致を図ることが可能となり、クローンコードの過検出を防ぐことができる。 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 /
図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
例えば、第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
次に、属性特定部207において、繰り返し領域の「属性」を求める。具体的には、属性特定部207は、図14に示す「繰り返し領域の長さ」及び「第1の実施形態で検出したクローンコード中における繰り返し領域の出現回数」の比率に応じた属性マップをROM203又はHD207より読み出し、繰り返し領域選定部206より算出した「繰り返し領域の長さ」及び「出現回数」の比率に応じて、属性マップに基づいて対応付けられた属性を特定する。上述の例「ABCD」であれば、「繰り返し領域の長さ」=4、「第1の実施形態で検出したクローンコード中における繰り返し領域の出現回数」=2であるため、「(5)junk」である。
Next, the
次に、クローンコード分析部208は、「属性」及び「カバー率」の比率に応じた評価マップをROM203又はHD207より読み出し、属性特定部207より特定された繰り返し領域の「属性」及び繰り返し領域選定部206において算出された「カバー率」の比率に応じて、対応付けられた重要度合い("大""中""小""N/A = not applicable")を特定する。上述の例「ABCD」であれば、「属性=junk」「カバー率=100%(1)」より「N/A」である。なお、図14は、最小トークン長が100以上を想定した評価マップである。実際に評価する際は、最小トークン長等に応じて適宜「属性」及び「カバー率」の具体的比率を変える。従って、上述の例のようにトークン長が10の場合は、図14とは具体的比率が異なった評価マップを参照して評価・分析する。
Next, the clone
図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
実際フィールド宣言部分はロジックのクローンコードではないので、修正は不要であって、ソースコードの品質に影響を与えない重要度合いが低いものである。つまり、評価対象として見る必要が無いコードを評価対象より排除することによって、分析者の作業工数を削減し効率化を図ることが可能になる。 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
100、200 クローン検出装置
101 基底テーブル作成部
102 検出テーブル作成部
103 クローン簡易結合部
104 クローン結合部
105 包含クローン削除部
206 繰り返し領域選定部
207 属性特定部
208 クローンコード分析部
100, 200
Claims (8)
前記第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 .
前記第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の検出テーブルから抽出して前記クローンコードテーブルに登録することを特徴とする請求項5に記載のクローンコード検出評価装置。 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の単位のデータを結合した第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 .
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)
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)
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 |
-
2009
- 2009-08-27 JP JP2009196688A patent/JP5345020B2/en active Active
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 |