JP2019219848A - Source code analysis method and source code analysis device - Google Patents

Source code analysis method and source code analysis device Download PDF

Info

Publication number
JP2019219848A
JP2019219848A JP2018116066A JP2018116066A JP2019219848A JP 2019219848 A JP2019219848 A JP 2019219848A JP 2018116066 A JP2018116066 A JP 2018116066A JP 2018116066 A JP2018116066 A JP 2018116066A JP 2019219848 A JP2019219848 A JP 2019219848A
Authority
JP
Japan
Prior art keywords
score
source code
long method
program element
program
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.)
Pending
Application number
JP2018116066A
Other languages
Japanese (ja)
Inventor
旭宏 堀
Akihiro Hori
旭宏 堀
誠 市井
Makoto Ichii
誠 市井
愛 利國
Ai Toshikuni
愛 利國
真澄 川上
Masumi Kawakami
真澄 川上
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.)
Faurecia Clarion Electronics Co Ltd
Original Assignee
Clarion Co Ltd
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 Clarion Co Ltd filed Critical Clarion Co Ltd
Priority to JP2018116066A priority Critical patent/JP2019219848A/en
Priority to CN201910378645.1A priority patent/CN110618926A/en
Publication of JP2019219848A publication Critical patent/JP2019219848A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3616Software analysis for verifying properties of programs using software metrics

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

To present a program element which is included in a source code and should be divided.SOLUTION: A processor 11 calculates code metrics on the basis of a source code 13B, calculates Long Method Score on the basis of the code metrics, calculates a maintainability index on the basis of the code metrics, identifies a program element to be divided on the basis of the Long Method Score, classifies the program element to be divided into sub-anti-patterns on the basis of sub-anti-pattern definition information, and presents improvement places of the source code on the basis of improvement catalog information.SELECTED DRAWING: Figure 1

Description

本発明は、ソースコード解析方法およびソースコード解析装置に関する。   The present invention relates to a source code analysis method and a source code analysis device.

近年のソフトウェア開発では、開発済みの母体ソフトウェアを拡張または変更することによって新しいソフトウェアを開発する派生開発が主流である。ソフトウェアの派生開発においては、長年に渡る機能の拡張または変更の繰り返しにより、ソフトウェアが複雑化し、ソースコードの可読性が低下しやすい。このような状況を解決するため、ソフトウェアのリファクタリングが一般的に行われている。リファクタリングとは、ソフトウェアの振る舞いを変えず、その内部構造を変更することである。保守性が低いメソッド、クラス、ファイルなどのプログラム構成要素(以下、プログラム要素と称す)を適切にリファクタリングすれば、ソフトウェアが拡張または変更しやすくなる。   In recent software development, derivative development in which new software is developed by extending or changing developed mother software is mainstream. In the derivative development of software, software is complicated and the readability of source code is liable to deteriorate due to repeated expansion or change of functions over many years. In order to solve such a situation, software refactoring is generally performed. Refactoring is changing the internal structure of a software without changing its behavior. By appropriately refactoring program components (hereinafter, referred to as program components) such as methods, classes, and files with low maintainability, the software can be easily extended or changed.

リファクタリングを支える技術にアンチパターンがある。アンチパターンとは、保守性が低いプログラム要素が持つ特徴(以下、問題特徴と称す)と、当該問題特徴を持つプログラム要素のリファクタリング方法のパターンをまとめたものである。リファクタリング対象ソフトウェアにおいて、アンチパターンが示すような問題特徴を持つプログラム要素を特定できれば、アンチパターンを適用することでリファクタリングすることができる。   Anti-patterns are a technology that supports refactoring. The anti-pattern is a collection of features of a program element having low maintainability (hereinafter referred to as problem features) and a pattern of a refactoring method of the program element having the problem feature. In the refactoring target software, if a program element having a problem characteristic as indicated by an anti-pattern can be specified, refactoring can be performed by applying the anti-pattern.

特許文献1には、ソースコード、構成管理システムまたは稼動ログからメトリクスを計測し、ソースコードのアンチパターン該当可否を評価する手法が記載されている。これにより、リファクタリングが必要ない複雑なソースコードを抽出せず、真にリファクタリングが必要なソースコードを特定することができる。   Patent Literature 1 describes a method of measuring metrics from a source code, a configuration management system, or an operation log and evaluating whether or not the source code corresponds to an anti-pattern. This makes it possible to specify a source code that truly requires refactoring without extracting a complicated source code that does not require refactoring.

特開2016−143107号公報JP 2016-143107 A

しかしながら、特許文献1の手法では、ソースコードをプログラム解析して得られるプログラム要素の特徴量(以下、コードメトリクスと称す)を用いて当該プログラム要素がアンチパターンに該当するかどうかを判定し、該当する場合は当該プログラム要素をリファクタリング手順および優先度と共に提示する。しかし、提示されるリファクタリング手順は、アンチパターンごとに予め設定されたプログラム要素全体の修正方針である。このため、リファクタリング作業者はプログラム要素中のどの箇所をどのように修正すべきかについては自ら判断する必要があり、リファクタリング作業者に高いスキルが必要だった。   However, in the method of Patent Document 1, it is determined whether or not the program element corresponds to an anti-pattern by using a feature amount (hereinafter, referred to as a code metric) of a program element obtained by analyzing a source code. If so, present the program element together with the refactoring procedure and priority. However, the presented refactoring procedure is a modification policy of the entire program element preset for each anti-pattern. For this reason, the refactoring worker had to judge for himself which part in the program element and how to correct it, and the refactoring worker required high skills.

以下、Long Methodというアンチパターンを例に説明する。
Long Methodとは、プログラム要素が大きすぎるメソッドであるためにプログラム要素の可読性が低いという問題特徴を持つプログラム要素をリファクタリングするためのパターンである。プログラムの可読性が低いと、プログラム要素の修正者は、プログラム要素の修正の際に、修正対象のプログラム要素の理解に時間がかかるだけでなく、修正対象のプログラム要素の挙動を誤って理解し間違った修正をする可能性がある。
Hereinafter, an anti-pattern called Long Method will be described as an example.
The Long Method is a pattern for refactoring a program element having a problem feature that the readability of the program element is low because the program element is a method that is too large. When the readability of the program is low, the person who corrects the program element not only takes a long time to understand the program element to be corrected, but also misunderstands the behavior of the program element to be corrected when correcting the program element. May be modified.

一般的に、Long Methodに該当するプログラム要素に対してはメソッド分割というリファクタリング手順が存在する。これは、大きすぎるメソッドを複数の小さなメソッドに分割することで、Long Methodへの該当を解消するというものである。   Generally, there is a refactoring procedure called method division for a program element corresponding to the Long Method. This is to divide a method that is too large into a plurality of small methods, thereby eliminating the Long Method.

特許文献1の手法では、Long Methodに該当するプログラム要素を発見し、リファクタリング手順および優先度と共に画面に提示することが可能である。しかし、Long Methodに対するリファクタリング手順について、メソッド分割と提示されるのみにとどまり、メソッド内のどの箇所でメソッド分割を行えばよいのかについては提示されない。そのため、リファクタリング作業者はメソッドの分割箇所について自ら判断する必要があり、高いスキルが必要だった。   According to the method of Patent Document 1, it is possible to find a program element corresponding to Long Method and present it on a screen together with a refactoring procedure and priority. However, regarding the refactoring procedure for the Long Method, only the method division is presented, and where in the method the method division should be performed is not presented. For this reason, the refactoring worker had to judge the division of the method by himself, and required high skills.

本発明は、上記事情に鑑みなされたものであり、その目的は、ソースコードに含まれる分割すべきプログラム要素を提示することが可能なソースコード解析方法およびソースコード解析装置を提供することにある。   The present invention has been made in view of the above circumstances, and an object of the present invention is to provide a source code analysis method and a source code analysis device capable of presenting a program element to be divided included in a source code. .

上記目的を達成するため、第1の観点に係るソースコード解析方法は、コードメトリクス取得部が、複数のプログラム要素を有するソースコードを解析してプログラム要素の長さ及び複雑度にかかるコードメトリクスを生成し、コミット情報取得部が、前記プログラム要素の変更履歴にかかるコミット情報を取得し、スコア計算部が、前記コードメトリクスと、前記コミット情報と、に基づいて、前記プログラム要素のスコアを算出し、保守性指標算出部が、前記コードメトリクスに基づき、前記プログラム要素の保守性指標を算出し、リスト生成部が、前記スコアと、前記保守性指標と、に基づいて、複数に分割する候補となる前記プログラム要素のリストを生成する。   In order to achieve the above object, in a source code analysis method according to a first aspect, a code metric acquisition unit analyzes a source code having a plurality of program elements, and obtains a code metric relating to the length and complexity of the program element. The commit information acquisition unit generates commit information related to the change history of the program element, and the score calculation unit calculates a score of the program element based on the code metrics and the commit information. A maintainability index calculation unit calculates a maintainability index of the program element based on the code metrics, and the list generation unit, based on the score and the maintainability index, a candidate to be divided into a plurality. A list of the program elements is generated.

本発明によれば、ソースコードに含まれる分割すべきプログラム要素を提示することができる。   According to the present invention, a program element to be divided included in a source code can be presented.

図1は、第1実施形態に係るソースコード解析装置のハードウェア構成を示すブロック図である。FIG. 1 is a block diagram illustrating a hardware configuration of the source code analysis device according to the first embodiment. 図2は、図1のソースコード解析装置の機能的な構成を示すブロック図である。FIG. 2 is a block diagram showing a functional configuration of the source code analysis device of FIG. 図3は、図2のソースコード解析装置で取得されるコードメトリクスの一例を示す図である。FIG. 3 is a diagram illustrating an example of code metrics acquired by the source code analysis device of FIG. 図4は、図2のソースコード解析装置に入力されるプログラム要素変更履歴の一例を示す図である。FIG. 4 is a diagram showing an example of a program element change history input to the source code analysis device of FIG. 図5は、図2のソースコード解析装置で計算されるLong Method Scoreの一例を示す図である。FIG. 5 is a diagram illustrating an example of a Long Method Score calculated by the source code analysis device of FIG. 図6は、図2のソースコード解析装置で計算される保守性指標の一例を示す図である。FIG. 6 is a diagram illustrating an example of the maintainability index calculated by the source code analysis device of FIG. 図7は、図2のソースコード解析装置で生成されるLong Methodリストの一例を示す図である。FIG. 7 is a diagram showing an example of a Long Method list generated by the source code analysis device of FIG. 図8は、図2のコードメトリクス取得部の処理を示すフローチャートである。FIG. 8 is a flowchart showing the processing of the code metrics acquisition unit in FIG. 図9は、図2のLong Method Score計算部の処理を示すフローチャートである。FIG. 9 is a flowchart showing the processing of the Long Method Score calculation unit in FIG. 図10は、保守性指標計算部の処理を示すフローチャートである。FIG. 10 is a flowchart illustrating a process of the maintainability index calculation unit. 図11は、図2のLong Method条件設定部の処理を示すフローチャートである。FIG. 11 is a flowchart showing the processing of the Long Method condition setting unit in FIG. 図12は、図2のLong Methodリスト生成部の処理を示すフローチャートである。FIG. 12 is a flowchart showing the processing of the Long Method list generation unit in FIG. 図13は、図2のLong Method条件設定部で表示される保守性指標を横軸、プログラム要素数を縦軸としたヒストグラムの一例を示す図である。FIG. 13 is a diagram illustrating an example of a histogram in which the horizontal axis indicates the maintainability index and the vertical axis indicates the number of program elements displayed in the Long Method condition setting unit of FIG. 図14は、図2のLong Method条件設定部で表示されるLong Method Scoreを横軸、プログラム要素数を縦軸としたヒストグラムの一例を示す図である。FIG. 14 is a diagram showing an example of a histogram in which the horizontal axis is Long Method Score and the vertical axis is the number of program elements displayed in the Long Method condition setting unit of FIG. 図15は、第2実施形態に係るソースコード解析装置の機能的な構成を示すブロック図である。FIG. 15 is a block diagram illustrating a functional configuration of the source code analysis device according to the second embodiment. 図16は、図15のソースコード解析装置に入力されるバグ履歴情報の一例を示す図である。FIG. 16 is a diagram showing an example of bug history information input to the source code analysis device of FIG. 図17は、図15のLong Method条件設定部の処理を示すフローチャートである。FIG. 17 is a flowchart showing the processing of the Long Method condition setting unit in FIG. 図18は、図15のLong Methodリスト生成部の処理を示すフローチャートである。FIG. 18 is a flowchart illustrating the processing of the Long Method list generation unit in FIG. 図19は、図15のLong Method条件設定部で表示される保守性指標を横軸、プログラム要素数を縦軸としたヒストグラムの一例を示す図である。FIG. 19 is a diagram showing an example of a histogram in which the horizontal axis represents the maintainability index and the vertical axis represents the number of program elements displayed in the Long Method condition setting unit of FIG. 図20は、図15のLong Method条件設定部で表示されるLong Method Scoreを横軸、プログラム要素数を縦軸としたヒストグラムの一例を示す図である。FIG. 20 is a diagram illustrating an example of a histogram in which the horizontal axis is Long Method Score and the vertical axis is the number of program elements displayed in the Long Method condition setting unit of FIG. 図21は、第3実施形態に係るソースコード解析装置で生成されるLong Methodリストの一例を示す図である。FIG. 21 is a diagram illustrating an example of a Long Method list generated by the source code analysis device according to the third embodiment. 図22は、第4実施形態に係るソースコード解析装置の機能的な構成を示すブロック図である。FIG. 22 is a block diagram illustrating a functional configuration of the source code analysis device according to the fourth embodiment. 図23は、図22のソースコード解析装置に入力されるサブアンチパターン定義情報の一例を示す図である。FIG. 23 is a diagram showing an example of sub-anti-pattern definition information input to the source code analysis device of FIG. 図24は、図22のソースコード解析装置で生成されるサブアンチパターンリストの一例を示す図である。FIG. 24 is a diagram showing an example of a sub-anti-pattern list generated by the source code analysis device of FIG. 図25は、図22のソースコード解析装置に入力される改善カタログ情報の一例を示す図である。FIG. 25 is a diagram showing an example of the improved catalog information input to the source code analysis device of FIG. 図26は、図22のサブアンチパターン分類部の処理を示すフローチャートである。FIG. 26 is a flowchart showing the processing of the sub-anti-pattern classification unit of FIG. 図27は、図22の改善箇所マッピング部の処理を示すフローチャートである。FIG. 27 is a flowchart showing the processing of the improvement point mapping unit in FIG. 図28は、第6実施形態に係るソースコード解析装置から出力される改善箇所を示したソースコードの一例を示す図である。FIG. 28 is a diagram illustrating an example of a source code indicating an improvement point output from the source code analysis device according to the sixth embodiment. 図29は、第8実施形態に係るソースコード解析装置の画面遷移の一例を示す図である。FIG. 29 is a diagram illustrating an example of a screen transition of the source code analysis device according to the eighth embodiment. 図30は、図22のソースコード解析装置の解析対象選択画面の一例を示す図である。FIG. 30 is a diagram showing an example of an analysis target selection screen of the source code analysis device of FIG. 図31は、図22のソースコード解析装置のLong Method条件設定画面の一例を示す図である。FIG. 31 is a diagram showing an example of a Long Method condition setting screen of the source code analysis device of FIG. 図32は、図22のソースコード解析装置のLong Method一覧画面の一例を示す図である。FIG. 32 is a diagram showing an example of a Long Method list screen of the source code analysis device of FIG. 図33は、図22のソースコード解析装置の改善箇所表示画面の一例を示す図である。FIG. 33 is a diagram showing an example of an improvement point display screen of the source code analysis device of FIG.

実施形態について、図面を参照して説明する。なお、以下に説明する実施形態は特許請求の範囲に係る発明を限定するものではなく、また実施形態の中で説明されている諸要素及びその組み合わせの全てが発明の解決手段に必須であるとは限らない。   An embodiment will be described with reference to the drawings. It should be noted that the embodiments described below do not limit the invention according to the claims, and that all of the elements and combinations thereof described in the embodiments are essential for solving the invention. Not necessarily.

(第1実施形態)
図1は、第1実施形態に係るソースコード解析装置のハードウェア構成を示すブロック図である。
図1において、ソースコード解析装置10Aは、プロセッサ11、主記憶装置12、補助記憶装置13、入力装置14、出力装置15および通信装置16を備える。プロセッサ11、主記憶装置12、補助記憶装置13、入力装置14、出力装置15および通信装置16は、バス17等の通信手段を介して互いに通信可能に接続されている。
(1st Embodiment)
FIG. 1 is a block diagram illustrating a hardware configuration of the source code analysis device according to the first embodiment.
1, the source code analysis device 10A includes a processor 11, a main storage device 12, an auxiliary storage device 13, an input device 14, an output device 15, and a communication device 16. The processor 11, the main storage device 12, the auxiliary storage device 13, the input device 14, the output device 15, and the communication device 16 are communicably connected to each other via communication means such as a bus 17.

プロセッサ11は、例えば、CPU(Central Processing Unit)またはMPU(Micro Processing Unit)を用いて構成されている。プロセッサ11が、主記憶装置12に格納されているプログラムを読み出して実行することにより、ソースコード解析装置10Aの様々な機能が実現される。主記憶装置12は、プログラムやデータを記憶する装置であり、例えば、ROM(Read Only Memory)、RAM(Random Access Memory)、不揮発性半導体メモリ(NVRAM(Non Volatile RAM))等である。   The processor 11 is configured using, for example, a CPU (Central Processing Unit) or an MPU (Micro Processing Unit). Various functions of the source code analysis device 10A are realized by the processor 11 reading and executing a program stored in the main storage device 12. The main storage device 12 is a device that stores programs and data, and is, for example, a ROM (Read Only Memory), a RAM (Random Access Memory), a nonvolatile semiconductor memory (NVRAM (Non Volatile RAM)), or the like.

補助記憶装置13は、例えば、ハードディスクドライブ、SSD(Solid State Drive)、光学式記憶装置(CD(Compact Disc)、DVD(Digital Versatile Disc)等)、ストレージシステム、ICカード、SDメモリカードや光学式記録媒体等の記録媒体の読取/書込装置、クラウドサーバの記憶領域等である。補助記憶装置13に格納されているプログラムやデータは主記憶装置12に随時ロードされる。   The auxiliary storage device 13 includes, for example, a hard disk drive, an SSD (Solid State Drive), an optical storage device (CD (Compact Disc), a DVD (Digital Versatile Disc), etc.), a storage system, an IC card, an SD memory card, and an optical storage device. A read / write device for a recording medium such as a recording medium, a storage area of a cloud server, and the like. The programs and data stored in the auxiliary storage device 13 are loaded into the main storage device 12 as needed.

入力装置14は、例えば、キーボード、マウス、タッチパネル、カードリーダ、音声入力装置等である。出力装置15は、ユーザに処理経過や処理結果等の各種情報を提供するユーザインターフェースである。出力装置15は、例えば、画面表示装置(液晶モニタ、有機ELディスプレイ、グラフィックカード等)、音声出力装置(スピーカ等)、印字装置等である。なお、例えば、ソースコード解析装置10Aが通信装置16を介して他の装置との間で情報の入力や出力を行う構成としてもよい。   The input device 14 is, for example, a keyboard, a mouse, a touch panel, a card reader, a voice input device, or the like. The output device 15 is a user interface that provides the user with various information such as the progress of the process and the result of the process. The output device 15 is, for example, a screen display device (a liquid crystal monitor, an organic EL display, a graphic card or the like), an audio output device (a speaker or the like), a printing device, or the like. Note that, for example, a configuration in which the source code analysis device 10A inputs and outputs information to and from another device via the communication device 16 may be employed.

通信装置16は、LAN(Local Area Network)やインターネット等の通信手段を介した他の装置との間の通信を実現する有線方式又は無線方式の通信インタフェースである。通信装置16は、例えば、NIC(Network Interface Card)、無線通信モジュール、USB(Universal Serial Interface)モジュール、シリアル通信モジュール等である。   The communication device 16 is a wired or wireless communication interface that realizes communication with another device via communication means such as a LAN (Local Area Network) or the Internet. The communication device 16 is, for example, a NIC (Network Interface Card), a wireless communication module, a USB (Universal Serial Interface) module, a serial communication module, or the like.

ここで、補助記憶装置13には、ソースコード解析プログラム13Aおよびソースコード13Bを格納することができる。そして、プロセッサ11が、ソースコード解析プログラム13Aおよびソースコード13Bを主記憶装置12にロードし、ソースコード解析プログラム13Aを実行することにより、ソースコード13Bを解析することができる。   Here, the auxiliary storage device 13 can store the source code analysis program 13A and the source code 13B. Then, the processor 11 loads the source code analysis program 13A and the source code 13B into the main storage device 12 and executes the source code analysis program 13A, whereby the source code 13B can be analyzed.

この時、プロセッサ11は、複数のプログラム要素を有するソースコード13Bを解析してプログラム要素の長さ及び複雑度にかかるコードメトリクスを生成し、プログラム要素の変更履歴にかかるコミット情報を取得し、コードメトリクスとコミット情報とに基づいて、プログラム要素のスコアを算出し、コードメトリクスに基づき、プログラム要素の保守性指標を算出し、スコアと保守性指標とに基づいて、複数に分割する候補となるプログラム要素のリストを生成することができる。スコアは、Long method Scoreであってもよい。   At this time, the processor 11 analyzes the source code 13B having a plurality of program elements, generates code metrics related to the length and complexity of the program elements, acquires commit information related to the change history of the program elements, A program that calculates a score of a program element based on the metrics and the commit information, calculates a maintainability index of the program element based on the code metrics, and is a candidate to be divided into a plurality of parts based on the score and the maintainability index. A list of elements can be generated. The score may be a Long method Score.

さらに、プロセッサ11は、サブアンチパターン定義情報に基づいて、分割すべきプログラム要素をサブアンチパターンに分類し、改善カタログ情報に基づいてソースコードの改善箇所を提示することができる。   Further, the processor 11 can classify the program elements to be divided into sub-anti-patterns based on the sub-anti-pattern definition information, and can present an improved part of the source code based on the improved catalog information.

コードメトリクスは、ソースコードの一連の基準に従ってソースコード13Bを数値化した値である。例えば、コードメトリクスとして、ソースコード13Bを解析して生成されたプログラム要素の長さ及び複雑度にかかる数値を用いることができる。プログラム要素は、プログラムの構成要素である。例えば、プログラム要素は、モジュール、クラス、ファイル、メソッド、フィールド、関数、変数などである。Long Method Scoreは、プログラム要素が大きすぎるメソッドであるためにプログラム要素の可読性が低いという特徴を数値で示したものである。保守性指標は、ソフトウェアの変更にかかる手間に影響する特性を数値で示したものである。サブアンチパターンは、Long Methodの種類ごとにアンチパターンを分類したものである。サブアンチパターン定義情報は、サブアンチパターンを定義した情報である。改善カタログ情報は、サブアンチパターンに対するプログラム改善方法を示す情報である。   The code metrics are values obtained by digitizing the source code 13B according to a series of criteria of the source code. For example, a numerical value related to the length and complexity of a program element generated by analyzing the source code 13B can be used as the code metric. The program element is a component of the program. For example, program elements are modules, classes, files, methods, fields, functions, variables, and the like. The Long Method Score numerically indicates a characteristic that the readability of the program element is low because the program element is a method that is too large. The maintainability index is a numerical value indicating a characteristic that affects the time required for software change. The sub-anti-pattern is obtained by classifying the anti-pattern for each type of Long Method. The sub-anti-pattern definition information is information defining a sub-anti-pattern. The improvement catalog information is information indicating a program improvement method for a sub-anti-pattern.

なお、ソースコード解析プログラム13Aの実行は、複数のプロセッサやコンピュータに分担させてもよい。あるいは、プロセッサ11は、通信装置16を介してクラウドコンピュータなどにソースコード解析プログラム13Aの全部または一部の実行を指示し、その実行結果を受け取るようにしてもよい。   The execution of the source code analysis program 13A may be shared by a plurality of processors or computers. Alternatively, the processor 11 may instruct a cloud computer or the like to execute all or part of the source code analysis program 13A via the communication device 16 and receive the execution result.

図2は、図1のソースコード解析装置の機能的な構成を示すブロック図である。
図2において、ソースコード解析装置10Aは、コミット情報取得部100と、コードメトリクス取得部101と、Long Method Score計算部102と、保守性指標計算部103と、Long Method条件設定部104Aと、Long Methodリスト生成部105Aと、情報記憶部200を備える。
FIG. 2 is a block diagram showing a functional configuration of the source code analysis device of FIG.
2, the source code analysis device 10A includes a commit information acquisition unit 100, a code metrics acquisition unit 101, a long method score calculation unit 102, a maintainability index calculation unit 103, a long method condition setting unit 104A, and a long method condition setting unit 104a. It includes a method list generation unit 105A and an information storage unit 200.

これらの機能は、例えば、プロセッサ11が、主記憶装置12や補助記憶装置13に格納されているプログラムを読み出して実行することにより実現することができる。あるいは、これらの機能は、例えば、ソースコード解析装置10Aが備えるハードウェア(ASIC(Application Specific Integrated Circuit)等)によって実現することができる。   These functions can be realized, for example, by the processor 11 reading and executing a program stored in the main storage device 12 or the auxiliary storage device 13. Alternatively, these functions can be realized by, for example, hardware (such as an ASIC (Application Specific Integrated Circuit)) included in the source code analysis device 10A.

ソースコード解析にあたって、ソースコード解析装置10Aには、ソースコード109、ソースコード109のプログラム要素変更履歴110、Long Method Score閾値112および保守性指標閾値113が入力される。コードメトリクス取得部101は、解析対象となるソースコード109を受け付けて、コードメトリクス117を生成し、Long Method Score計算部102および保守性指標計算部103に出力する。コミット情報取得部100は、解析対象となるソースコード109のプログラム要素変更履歴110を受け付けて、コミット情報108を生成し、Long Method Score計算部102に出力する。   At the time of source code analysis, the source code 109, the program element change history 110 of the source code 109, the Long Method Score threshold 112, and the maintainability index threshold 113 are input to the source code analysis device 10A. The code metric acquisition unit 101 receives the source code 109 to be analyzed, generates a code metric 117, and outputs the generated code metric 117 to the long method score calculation unit 102 and the maintainability index calculation unit 103. The commit information acquiring unit 100 receives the program element change history 110 of the source code 109 to be analyzed, generates commit information 108, and outputs the generated commit information 108 to the Long Method Score calculation unit 102.

Long Method Score計算部102は、コードメトリクス101およびコミット情報108を受け付けて、Long Method Score118を生成し、Long Method条件設定部104AおよびLong Methodリスト生成部105Aに出力する。保守性指標計算部103は、コードメトリクス117を受け付けて、保守性指標119を生成し、Long Method条件設定部104AおよびLong Methodリスト生成部105Aに出力する。   The Long Method Score calculation unit 102 receives the code metrics 101 and the commit information 108, generates a Long Method Score 118, and outputs the generated Long Method Score 118 to the Long Method condition setting unit 104A and the Long Method list generation unit 105A. The maintainability index calculation unit 103 receives the code metrics 117, generates the maintainability index 119, and outputs the generated code to the Long Method condition setting unit 104A and the Long Method list generation unit 105A.

Long Method条件設定部104Aは、Long Method Score118と保守性指標119を受け付けて、Long Method Score閾値112および保守性指標閾値113を設定可能にする。この時、Long Method条件設定部104Aは、プログラム要素数と保守性指標119との関係およびプログラム要素数とLong Method Score118との関係を表示させることができる。そして、閾値設定者は、これらの関係を参照しながら、Long Method Score閾値112および保守性指標閾値113を設定することができる。   The Long Method condition setting unit 104A receives the Long Method Score 118 and the maintainability index 119, and enables setting of the Long Method Score threshold 112 and the maintainability index threshold 113. At this time, the Long Method condition setting unit 104A can display the relationship between the number of program elements and the maintainability index 119 and the relationship between the number of program elements and the Long Method Score 118. Then, the threshold setter can set the Long Method Score threshold 112 and the maintainability index threshold 113 while referring to these relationships.

Long Method Score閾値112および保守性指標閾値113は、Long Methodリスト生成部105Aに入力される。Long Methodリスト生成部105Aは、Long Method Score118と、保守性指標119と、Long Method Score閾値112と、保守性指標閾値113を受け付けて、Long Methodリスト120Aを生成する。Long Methodリスト120Aは、Long Methodに該当するプログラム要素を、分割すべきプログラム要素として記録したものである。   The Long Method Score threshold 112 and the maintainability index threshold 113 are input to the Long Method list generation unit 105A. The Long Method list generation unit 105A receives the Long Method Score 118, the maintainability index 119, the Long Method Score threshold 112, and the maintainability index threshold 113, and generates the Long Method list 120A. The Long Method list 120A records program elements corresponding to the Long Method as program elements to be divided.

ここで、Long Methodリスト生成部105Aは、Long Method ScoreがLong Method Score閾値112以上かつ保守性指標が保守性指標閾値113以下のプログラム要素をLong Methodと判断することができる。あるいは、Long Methodリスト生成部105Aは、Long Method ScoreがLong Method Score閾値112以上のプログラム要素をLong Methodと判断するようにしてもよい。   Here, the Long Method list generation unit 105A can determine that the program element whose Long Method Score is equal to or greater than the Long Method Score threshold 112 and whose maintainability index is equal to or less than the maintainability index threshold 113 is Long Method. Alternatively, the long method list generation unit 105A may determine that a program element whose long method score is equal to or greater than the long method score threshold value 112 is long method.

情報記憶部200は、コードメトリクス117と、Long Method Score118と、保守性指標119を記憶する。情報記憶部200は、図1の補助記憶装置13を用いることができる。情報記憶部200は、これらの情報以外にも、コードメトリクス取得部101や、Long Method Score計算部102や、保守性指標計算部103や、Long Method条件設定部104Aや、Long Methodリスト生成部105Aが適宜参照もしくは生成する情報等を記憶する。情報記憶部200は、補助記憶装置13に記憶する情報を、例えば、ファイルシステムやDBMS(DataBase Management System)によって管理することができる。   The information storage unit 200 stores a code metric 117, a long method score 118, and a maintainability index 119. The information storage unit 200 can use the auxiliary storage device 13 of FIG. The information storage unit 200 includes a code metrics acquisition unit 101, a long method score calculation unit 102, a maintainability index calculation unit 103, a long method condition setting unit 104A, and a long method list generation unit 105A, in addition to the above information. Stores information or the like to be referenced or generated as appropriate. The information storage unit 200 can manage information stored in the auxiliary storage device 13 by, for example, a file system or a DBMS (DataBase Management System).

ここで、ソースコード解析装置10Aは、コードメトリクス117およびコミット情報108に基づいてLong Method Score118を生成し、Long Method Score118に基づいてプログラム要素がLong Methodかどうかを判定することにより、ソースコード109に含まれる分割すべきプログラム要素を提示することが可能となる。このため、リファクタリング作業者は、メソッドの分割箇所について自ら判断することなく、メソッド内のどの箇所でメソッド分割を行えばよいのかについて認識することができ、機能の拡張または変更が繰り返されたソフトウェアの可読性を向上させることができる。   Here, the source code analysis device 10A generates a Long Method Score 118 based on the code metrics 117 and the commit information 108, and determines whether the program element is a Long Method based on the Long Method Score 118, to determine whether the program element is a Long Method. It is possible to present the program elements to be included that are to be divided. For this reason, the refactoring operator can recognize which part of the method should be used for dividing the method without having to judge the division of the method. Readability can be improved.

図3は、図2のソースコード解析装置で取得されるコードメトリクスの一例を示す図である。
図3において、コードメトリクス117は、解析対象となるプログラムのソースコード109を入力としてコードメトリクス取得部101によって計算された様々なメトリクス値をコードメトリクスレコード303として記録したものである。コードメトリクスレコード303は、当該コードメトリクスレコード303の計算対象プログラム要素を記録したプログラム要素名301と、当該プログラム要素名301の様々なメトリクス値を示したコードメトリクス302を備える。例えば、プログラム要素1では、メトリクスM1=75、メトリクスM2=0.3という値が記録される。
FIG. 3 is a diagram illustrating an example of code metrics acquired by the source code analysis device of FIG.
In FIG. 3, a code metric 117 records various metric values calculated by the code metric acquisition unit 101 using a source code 109 of a program to be analyzed as an input, as a code metric record 303. The code metric record 303 includes a program element name 301 in which the calculation target program element of the code metric record 303 is recorded and a code metric 302 indicating various metric values of the program element name 301. For example, in the program element 1, values of Metrics M1 = 75 and Metrics M2 = 0.3 are recorded.

図4は、図2のソースコード解析装置に入力されるプログラム要素変更履歴の一例を示す図である。
図4において、プログラム要素変更履歴110は、解析対象となるプログラムに発生した変更の履歴を、変更が発生するたびに変更履歴レコード403として記録したものである。変更履歴レコード403は、当該変更履歴レコード403を識別するために一意に付与されるコミット番号401と、当該変更履歴レコード403に対応するプログラム変更発生時に同時変更された一つ以上の変更プログラム要素名402を備える。例えば、コミット番号401がT1の変更履歴レコード403に対応する変更発生時には、変更プログラム要素名402に記載されたプログラム要素1、プログラム要素2およびプログラム要素3が同時変更されている。
FIG. 4 is a diagram showing an example of a program element change history input to the source code analysis device of FIG.
In FIG. 4, a program element change history 110 is a record of a change history that has occurred in a program to be analyzed as a change history record 403 each time a change occurs. The change history record 403 is composed of a commit number 401 uniquely assigned to identify the change history record 403, and one or more changed program element names simultaneously changed when a program change corresponding to the change history record 403 occurs. 402 is provided. For example, when a change occurs in which the commit number 401 corresponds to the change history record 403 of T1, the program element 1, the program element 2, and the program element 3 described in the changed program element name 402 have been changed simultaneously.

図5は、図2のソースコード解析装置で計算されるLong Method Scoreの一例を示す図である。
図5において、Long Method Score118は、コードメトリクス117とコミット情報108を入力としてLong Method Score計算部102において計算した値をLong Method Scoreレコード503として記録したものである。Long Method Scoreレコード503は、当該Long Methodレコード503の計算対象プログラム要素を記録したプログラム要素名501と、当該プログラム要素名501のLong Method Score502を備える。例えば、プログラム要素1では、Long Method Score=57という値が記録される。Long Method Score502が大きいほど、当該プログラム要素のLong Methodアンチパターンへの該当性が高いことを表す。
FIG. 5 is a diagram illustrating an example of a Long Method Score calculated by the source code analysis device of FIG.
In FIG. 5, a Long Method Score 118 records a value calculated by the Long Method Score calculation unit 102 with the code metric 117 and the commit information 108 as inputs, as a Long Method Score record 503. The Long Method Score record 503 includes a program element name 501 in which the calculation target program element of the Long Method record 503 is recorded, and a Long Method Score 502 of the program element name 501. For example, in the program element 1, a value of Long Method Score = 57 is recorded. The larger the Long Method Score 502, the higher the relevance of the program element to the Long Method anti-pattern.

図6は、図2のソースコード解析装置で計算される保守性指標の一例を示す図である。
図6において、保守性指標119は、コードメトリクス117を入力として保守性指標計算部103において計算した値を保守性指標レコード603として記録したものである。保守性指標レコード603は、当該保守性指標レコード603の計算対象プログラム要素を記録したプログラム要素名601と、当該プログラム要素名601の保守性指標602を備える。保守性指標602の計算方法として、一般的に用いられる計算式を用いてもよい。保守性指標602が大きいほど、当該プログラム要素の保守性が高いことを表す。
FIG. 6 is a diagram illustrating an example of the maintainability index calculated by the source code analysis device of FIG.
In FIG. 6, the maintainability index 119 is obtained by recording the value calculated by the maintainability index calculation unit 103 using the code metrics 117 as an input, as a maintainability index record 603. The maintainability index record 603 includes a program element name 601 in which the calculation target program element of the maintainability index record 603 is recorded, and a maintainability index 602 of the program element name 601. As a calculation method of the maintainability index 602, a generally used calculation formula may be used. The larger the maintainability index 602, the higher the maintainability of the program element.

図2において、Long Method Score閾値112は、Long Method生成部105で各プログラム要素がLong Methodか否かを判断する時に用いるLong Method Score118の閾値を記録したものである。例えば、Long Method Score閾値112として60を設定する。保守性指標閾値113は、Long Method生成部105で各プログラム要素がLong Methodか否かを判断する時に用いる保守性指標119の閾値を記録したものである。例えば、保守性指標閾値113として30を設定する。   In FIG. 2, a Long Method Score threshold 112 records a threshold of a Long Method Score 118 used when the Long Method generating unit 105 determines whether each program element is a Long Method. For example, 60 is set as the Long Method Score threshold 112. The maintainability index threshold 113 records the threshold of the maintainability index 119 used when the Long Method generation unit 105 determines whether or not each program element is Long Method. For example, 30 is set as the maintainability index threshold value 113.

図7は、図2のソースコード解析装置で生成されるLong Methodリストの一例を示す図である。
図7において、Long Methodリスト120Aは、Long Methodリスト生成部105AによってLong Methodに該当すると判断されたプログラム要素をLong Methodレコード702として記録したものである。Long Methodレコード702は、Long Methodに該当するプログラム要素名701を備える。例えば、プログラム要素1、2は、Long Methodに該当するものとしてLong Methodリスト120Aに記録されている。
FIG. 7 is a diagram showing an example of a Long Method list generated by the source code analysis device of FIG.
In FIG. 7, a Long Method list 120 </ b> A is a program in which the Long Method list generation unit 105 </ b> A records a program element determined to correspond to the Long Method as a Long Method record 702. The Long Method record 702 includes a program element name 701 corresponding to the Long Method. For example, the program elements 1 and 2 are recorded in the Long Method list 120A as corresponding to the Long Method.

図8は、図2のコードメトリクス取得部の処理を示すフローチャートである。
図8において、コードメトリクス取得部101は、解析対象プログラムのソースコード109を読み込む(801)。次に、コードメトリクス取得部101は、ソースコード109をプログラム要素に分割する(802)。次に、コードメトリクス取得部101は、全てのプログラム要素に対してコードメトリクス117を取得したかどうかを判断する(803)。全てのプログラム要素に対してコードメトリクス117を取得していない場合、コードメトリクス取得部101は、そのプログラム要素のコードメトリクス117を取得し、803に戻る(804)。取得するコードメトリクス117の種類としては、Long Method Score計算部102および保守性指標計算部103で用いるものを選択する。全てのプログラム要素に対してコードメトリクス117を取得すると、処理を終了する。
FIG. 8 is a flowchart showing the processing of the code metrics acquisition unit in FIG.
8, the code metrics acquisition unit 101 reads the source code 109 of the analysis target program (801). Next, the code metrics acquisition unit 101 divides the source code 109 into program elements (802). Next, the code metrics acquisition unit 101 determines whether the code metrics 117 have been acquired for all program elements (803). If the code metrics 117 have not been acquired for all the program elements, the code metrics acquisition unit 101 acquires the code metrics 117 for the program elements, and returns to 803 (804). As the type of the code metric 117 to be obtained, the type used by the long method score calculation unit 102 and the maintainability index calculation unit 103 is selected. When the code metrics 117 have been obtained for all the program elements, the process ends.

図9は、図2のLong Method Score計算部の処理を示すフローチャートである。
図9において、Long Method Score計算部102は、全てのプログラム要素に対してLong Method Score118を計算したかどうかを判断する(901)。全てのプログラム要素に対してLong Method Score118を計算していない場合、Long Method Score計算部102は、そのプログラム要素のコミット情報108およびコードメトリクス117を読み込む(902、903)。ただし、Long Method Score計算(904)においてコミット情報108を必要としない場合は、コミット情報108の読み込みは省略される。また、Long Method Score計算(904)においてコードメトリクス117を必要としない場合は、コードメトリクス117の読み込みは省略される。
FIG. 9 is a flowchart showing the processing of the Long Method Score calculation unit in FIG.
In FIG. 9, the Long Method Score calculation unit 102 determines whether or not the Long Method Score 118 has been calculated for all program elements (901). If the Long Method Score 118 has not been calculated for all the program elements, the Long Method Score calculation unit 102 reads the commit information 108 and the code metrics 117 of the program elements (902, 903). However, when the commit information 108 is not required in the Long Method Score calculation (904), the reading of the commit information 108 is omitted. If the code metric 117 is not required in the Long Method Score calculation (904), the reading of the code metric 117 is omitted.

この時、Long Method Score118は、コミット情報108とコードメトリクス117のいずれか一方または両方から計算される。Long Method Scoreの計算方法については問わない。コミット情報108の読み込み(902)とコードメトリクス117の読み込み(903)の順序については問わない。   At this time, the Long Method Score 118 is calculated from one or both of the commit information 108 and the code metrics 117. It does not matter how to calculate the Long Method Score. The order of reading the commit information 108 (902) and reading the code metrics 117 (903) does not matter.

次に、Long Method Score計算部102は、そのプログラム要素のコミット情報108およびコードメトリクス117に基づいてLong Method Score118を計算し、901に戻る(904)。全てのプログラム要素に対してLong Method Score118を計算すると、処理を終了する。   Next, the Long Method Score calculation unit 102 calculates the Long Method Score 118 based on the commit information 108 and the code metrics 117 of the program element, and returns to 901 (904). When the Long Method Score 118 is calculated for all the program elements, the processing ends.

Long Method Score118の計算に用いられるコードメトリクス117は、例えば、コメント抜き行数、循環的複雑度、コメント行数およびローカル変数宣言数である。Long Method Score118の計算に用いられるコミット情報108は、例えば、コミット当たりの変更箇所数および重み付きコミット回数である。   The code metrics 117 used for calculating the Long Method Score 118 are, for example, the number of lines without comments, the cyclic complexity, the number of comment lines, and the number of local variable declarations. The commit information 108 used for the calculation of the Long Method Score 118 is, for example, the number of changed parts per commit and the number of weighted commits.

図10は、保守性指標計算部の処理を示すフローチャートである。
図10において、保守性指標計算部103は、全てのプログラム要素に対して保守性指標119を計算したかどうかを判断する(1001)。全てのプログラム要素に対して保守性指標119を計算していない場合、保守性指標計算部103は、そのプログラム要素のコードメトリクス117を読み込む(1002)。次に、保守性指標計算部103は、そのプログラム要素のコードメトリクス117に基づいて保守性指標119を計算し、1001に戻る(1003)。全てのプログラム要素に対して保守性指標119を計算すると、処理を終了する。
FIG. 10 is a flowchart illustrating a process of the maintainability index calculation unit.
In FIG. 10, the maintainability index calculation unit 103 determines whether the maintainability index 119 has been calculated for all the program elements (1001). When the maintainability index 119 has not been calculated for all the program elements, the maintainability index calculation unit 103 reads the code metrics 117 of the program elements (1002). Next, the maintainability index calculation unit 103 calculates the maintainability index 119 based on the code metrics 117 of the program element, and returns to 1001 (1003). When the maintainability index 119 is calculated for all the program elements, the process ends.

保守性指標とはソフトウェアの保守のしやすさを示すコードメトリクスである。保守性指標の1つとして、例えば、保守容易性指数がある。保守容易性指数は、例えば、以下の式で計算することができる。
保守容易性指数=171−5.2*ln((N1+N2)*log2(n1+n2))−0.23*(G)−16.2*ln(LOC))*100/171
The maintainability index is a code metric indicating the ease of software maintenance. One of the maintainability indexes is, for example, a maintainability index. The maintainability index can be calculated, for example, by the following equation.
Maintainability index = 171-5.2 * ln ((N1 + N2) * log2 (n1 + n2))-0.23 * (G) -16.2 * ln (LOC)) * 100/171

ただし、N1=(オペレータ総数)、N2=(オペランド総数)、n1=(オペレータ種類数)、n2=(オペランド種類数)、G=(サイクロマチック数)、LOC=(コメント抜き行数)である。保守性指標として用いるものは保守容易性指数に限らず、プログラムの保守性に関与する任意の指標でよい。   However, N1 = (total number of operators), N2 = (total number of operands), n1 = (number of operator types), n2 = (number of operand types), G = (number of cyclomatics), LOC = (number of lines without comments). . The index used as the maintainability index is not limited to the maintainability index, but may be any index related to the maintainability of the program.

図11は、図2のLong Method条件設定部の処理を示すフローチャートである。
図11において、Long Method条件設定部104Aは、全てのプログラム要素に対してLong Method Score118および保守性指標119を読み込んだかどうかを判断する(1101)。全てのプログラム要素に対してLong Method Score118および保守性指標119を読み込んでいない場合、Long Method条件設定部104Aは、そのプログラム要素のLong Method Score118および保守性指標119を読み込む(1102、1103)。
FIG. 11 is a flowchart showing the processing of the Long Method condition setting unit in FIG.
In FIG. 11, the Long Method condition setting unit 104A determines whether the Long Method Score 118 and the maintainability index 119 have been read for all program elements (1101). If the Long Method Score 118 and the maintainability index 119 have not been read for all the program elements, the Long Method condition setting unit 104A reads the Long Method Score 118 and the maintainability index 119 of the program element (1102, 1103).

Long Method条件設定部104Aは、全てのプログラム要素に対してLong Method Score118および保守性指標119を読み込むと、Long Method Score閾値112および保守性指標閾値113に対して初期値を設定する(1104)。ここで、初期値としてどのような値を選んでもよい。   When reading the Long Method Score 118 and the maintainability index 119 for all program elements, the Long Method condition setting unit 104A sets initial values for the Long Method Score threshold 112 and the maintainability index threshold 113 (1104). Here, any value may be selected as the initial value.

次に、Long Method条件設定部104Aは、保守性指標を横軸、プログラム要素数を縦軸としたヒストグラムを表示する(1105)。このヒストグラムの表示は、閾値設定者がLong Method Score閾値112および保守性指標閾値113の設定を行うのを支援する。   Next, the Long Method condition setting unit 104A displays a histogram with the maintainability index on the horizontal axis and the number of program elements on the vertical axis (1105). The display of the histogram assists the threshold setter in setting the Long Method Score threshold 112 and the maintainability index threshold 113.

次に、Long Method条件設定部104Aは、Long Method Scoreを横軸、プログラム要素数を縦軸としたヒストグラムを表示する(1106)。このヒストグラムの表示は、閾値設定者がLong Method Score閾値112および保守性指標閾値113の設定を行うのを支援する。   Next, the Long Method condition setting unit 104A displays a histogram with the Long Method Score as the horizontal axis and the number of program elements as the vertical axis (1106). The display of the histogram assists the threshold setter in setting the Long Method Score threshold 112 and the maintainability index threshold 113.

次に、Long Method条件設定部104Aは、閾値設定者による閾値の設定を続けるか否かの判断を受け付ける(1107)。閾値設定者が閾値の設定を続けると判断した場合、Long Method条件設定部104Aは、閾値設定者によるLong Method Score閾値112の数値入力を受け付け、Long Method Score閾値112として設定する(1108)。次に、Long Method条件設定部104Aは、閾値設定者による保守性指標閾値113の数値入力を受け付け、保守性指標閾値113として設定する(1109)。   Next, the Long Method condition setting unit 104A receives a determination as to whether or not to continue setting the threshold by the threshold setter (1107). If the threshold setter determines to continue setting the threshold, the Long Method condition setting unit 104A accepts the numerical input of the Long Method Score threshold 112 by the threshold setter and sets it as the Long Method Score threshold 112 (1108). Next, the Long Method condition setting unit 104A receives a numerical value input of the maintainability index threshold value 113 by the threshold value setter and sets the value as the maintainability index threshold value 113 (1109).

次に、Long Method条件設定部104Aは、閾値設定者にて入力された数値をLong Method Score閾値112および保守性指標閾値113として設定すると、1105に戻る。そして、Long Method条件設定部104Aは、閾値設定者が閾値の設定を続けないと判断するまで、1105〜1109の処理を繰り返し、閾値設定者が閾値の設定を続けないと判断すると、処理を終了する。   Next, the Long Method condition setting unit 104A sets the values input by the threshold setter as the Long Method Score threshold 112 and the maintainability index threshold 113, and returns to 1105. Then, the Long Method condition setting unit 104A repeats the processing of steps 1105 to 1109 until the threshold setter determines not to continue setting the threshold, and ends the processing when the threshold setter determines not to continue setting the threshold. I do.

なお、Long Method Score118の読み込み(1102)および保守性指標119の読み込み(1103)の順序については問わない。また、保守性指標119を横軸、プログラム要素数を縦軸としたヒストグラムの表示(1105)およびLong Method Score118を横軸、プログラム要素数を縦軸としたヒストグラムの表示(1106)の順序については問わない。また、閾値設定者によるLong Method Score閾値112の入力(1108)および閾値設定者による保守性指標閾値113の入力(1109)の順序については問わない。   Note that the order of reading the Long Method Score 118 (1102) and reading the maintainability index 119 (1103) does not matter. The order of the display of the histogram with the maintainability index 119 as the horizontal axis and the number of program elements as the vertical axis (1105) and the display of the histogram with the Long Method Score 118 as the horizontal axis and the number of program elements as the vertical axis (1106) are as follows. It doesn't matter. Further, the order of the input of the Long Method Score threshold 112 by the threshold setter (1108) and the input of the maintainability index threshold 113 by the threshold setter (1109) does not matter.

図12は、図2のLong Methodリスト生成部の処理を示すフローチャートである。
図12において、Long Methodリスト生成部105Aは、空のLong Methodリスト120Aを用意する(1201)。次に、Long Methodリスト生成部105Aは、プログラム要素のLong Method Score閾値112および保守性指標閾値113を読み込む(1202、1203)。
FIG. 12 is a flowchart showing the processing of the Long Method list generation unit in FIG.
12, the Long Method list generation unit 105A prepares an empty Long Method list 120A (1201). Next, the Long Method list generation unit 105A reads the Long Method Score threshold 112 and the maintainability index threshold 113 of the program element (1202, 1203).

次に、Long Methodリスト生成部105Aは、全てのプログラム要素に対してLong Method Score118および保守性指標119をLong Method Score閾値112および保守性指標閾値113とそれぞれ比較したかどうかを判断する(1204)。全てのプログラム要素に対してLong Method Score118および保守性指標119をLong Method Score閾値112および保守性指標閾値113とそれぞれ比較していない場合、Long Methodリスト生成部105Aは、そのプログラム要素のLong Method Score118および保守性指標119を読み込む(1205、1206)。   Next, the Long Method list generation unit 105A determines whether or not the Long Method Score 118 and the maintainability index 119 are compared with the Long Method Score threshold 112 and the maintainability index threshold 113 for all the program elements, respectively (1204). . When the Long Method Score 118 and the maintainability index 119 are not compared with the Long Method Score threshold 112 and the maintainability index threshold 113, respectively, for all the program elements, the Long Method Score generation unit 105A of the program element generates the Long Method Score 118. Then, the maintainability index 119 is read (1205, 1206).

次に、Long Methodリスト生成部105Aは、Long Method Score118がLong Method Score閾値112以上、かつ、保守性指標119が保守性指標閾値113以下であるかを判断する(1207)。1207の条件を満たす場合、Long Methodリスト生成部105Aは、Long Methodリスト120Aにプログラム要素およびその他の情報を追加し(1208)、1204に戻る。1207の条件を満たさない場合、1208をスキップし、1204に戻る。全てのプログラム要素に対してLong Method Score118および保守性指標119をLong Method Score閾値112および保守性指標閾値113とそれぞれ比較すると、処理を終了する。   Next, the Long Method List generation unit 105A determines whether the Long Method Score 118 is equal to or greater than the Long Method Score threshold 112 and the maintainability index 119 is equal to or less than the maintainability index threshold 113 (1207). If the condition of 1207 is satisfied, the Long Method list generation unit 105A adds a program element and other information to the Long Method list 120A (1208), and returns to 1204. If the condition of 1207 is not satisfied, skip 1208 and return to 1204. When the Long Method Score 118 and the maintainability index 119 are compared with the Long Method Score threshold 112 and the maintainability index threshold 113, respectively, for all the program elements, the process ends.

なお、空のLong Methodリスト120Aの用意(1201)、Long Method Score閾値112の読み込み(1202)および保守性指標閾値113の読み込み(1203)の順序については問わない。また、Long Method Score118の読み込み(1205)および保守性指標119の読み込み(1206)の順序については問わない。   The order of preparing the empty Long Method list 120A (1201), reading the Long Method Score threshold 112 (1202), and reading the maintainability index threshold 113 (1203) does not matter. Further, the order of reading the Long Method Score 118 (1205) and reading the maintainability index 119 (1206) does not matter.

図13は、図2のLong Method条件設定部で表示される保守性指標を横軸、プログラム要素数を縦軸としたヒストグラムの一例を示す図である。
図13の例では、Long Method Score閾値112として60を、保守性指標閾値113として30を設定した場合を示す。ヒストグラムは、凡例1301、保守性指標閾値軸1302、縦軸としてプログラム要素数1303、横軸として保守性指標1304を備える。ヒストグラム本体1305は、全プログラム要素のヒストグラム1306およびLong Method Scoreが閾値以上のプログラム要素のヒストグラム1307を備える。Long Method Scoreが閾値以上のプログラム要素のうち、保守性指標閾値軸1302よりも左に存在するプログラム要素が、Long Methodリスト生成部105AにおいてLong Methodと判定される。閾値設定者は、このヒストグラムを参考にLong Method Score閾値112と保守性指標閾値113を変更することができる。
FIG. 13 is a diagram illustrating an example of a histogram in which the horizontal axis indicates the maintainability index and the vertical axis indicates the number of program elements displayed in the Long Method condition setting unit of FIG.
In the example of FIG. 13, a case where 60 is set as the Long Method Score threshold 112 and 30 is set as the maintainability index threshold 113 is shown. The histogram has a legend 1301, a maintainability index threshold axis 1302, the number of program elements 1303 as the vertical axis, and the maintainability index 1304 as the horizontal axis. The histogram main body 1305 includes a histogram 1306 of all program elements and a histogram 1307 of program elements whose Long Method Score is equal to or larger than a threshold. Among the program elements whose Long Method Score is equal to or larger than the threshold value, the program element existing to the left of the maintainability index threshold axis 1302 is determined to be Long Method by the Long Method list generation unit 105A. The threshold setter can change the Long Method Score threshold 112 and the maintainability index threshold 113 with reference to this histogram.

図14は、図2のLong Method条件設定部で表示されるLong Method Scoreを横軸、プログラム要素数を縦軸としたヒストグラムの一例を示す図である。
図14の例では、Long Method Score閾値112として60を、保守性指標閾値113として30を設定した場合を示す。ヒストグラムは、凡例1401、Long Method Score閾値軸1402、縦軸としてプログラム要素数1403、横軸としてLong Method Score1404を備える。ヒストグラム本体1405は、全プログラム要素のヒストグラム1406および保守性指標が閾値以下のプログラム要素のヒストグラム1407を備える。保守性指標が閾値以下のプログラム要素のうち、Long Method Score閾値軸1402よりも右に存在するプログラム要素が、Long Methodリスト生成部105AにおいてLong Methodと判定される。閾値設定者は、このヒストグラムを参考にLong Method Score閾値112と保守性指標閾値113を変更することができる。
FIG. 14 is a diagram showing an example of a histogram in which the horizontal axis is Long Method Score and the vertical axis is the number of program elements displayed in the Long Method condition setting unit of FIG.
The example of FIG. 14 illustrates a case where 60 is set as the Long Method Score threshold 112 and 30 is set as the maintainability index threshold 113. The histogram includes a legend 1401, a Long Method Score threshold axis 1402, a number of program elements 1403 as a vertical axis, and a Long Method Score 1404 as a horizontal axis. The histogram body 1405 includes a histogram 1406 of all program elements and a histogram 1407 of program elements whose maintainability index is equal to or less than a threshold. Among the program elements whose maintainability index is equal to or smaller than the threshold value, the program element existing to the right of the Long Method Score threshold axis 1402 is determined as Long Method by the Long Method list generation unit 105A. The threshold setter can change the Long Method Score threshold 112 and the maintainability index threshold 113 with reference to this histogram.

このように、Long Method Score118および保守性指標119を用いることで、アンチパターンの1つであるLong Methodに該当するプログラム要素を見つけ出し、分割すべきプログラム要素としてリスト化することができる。この時、閾値設定者は、図13または図14のヒストグラムを参考にLong Method Score閾値112と保守性指標閾値113を変更することにより、Long Methodとして抽出されるプログラム要素の個数を変化させることができる。   As described above, by using the Long Method Score 118 and the maintainability index 119, a program element corresponding to one of the anti-patterns, Long Method, can be found and listed as a program element to be divided. At this time, the threshold setter can change the number of program elements extracted as the Long Method by changing the Long Method Score threshold 112 and the maintainability index threshold 113 with reference to the histogram of FIG. 13 or FIG. it can.

(第2実施形態)
第2実施形態は、第1実施形態で示したLong Method条件設定部104AおよびLong Methodリスト生成部105Aにおいて、実施例1で示した入力に加え、バグ履歴情報および可読性低下ワード条件も入力として用いる場合について示したものである。
(2nd Embodiment)
In the second embodiment, in addition to the input shown in the first embodiment, bug history information and a low readability word condition are used as inputs in the Long Method condition setting unit 104A and the Long Method list generation unit 105A shown in the first embodiment. This is shown for the case.

図15は、第2実施形態に係るソースコード解析装置の機能的な構成を示すブロック図である。
図15において、ソースコード解析装置10Bは、図2のソースコード解析装置10AのLong Method条件設定部104AおよびLong Methodリスト生成部105Aの代わりにLong Method条件設定部104BおよびLong Methodリスト生成部105Bを備える。
FIG. 15 is a block diagram illustrating a functional configuration of the source code analysis device according to the second embodiment.
In FIG. 15, the source code analysis device 10B includes a long method condition setting unit 104B and a long method list generation unit 105B instead of the long method condition setting unit 104A and the long method list generation unit 105A of the source code analysis device 10A of FIG. Prepare.

ソースコード解析にあたって、ソースコード解析装置10Bには、ソースコード109、ソースコード109のプログラム要素変更履歴110、Long Method Score閾値112および保守性指標閾値113に加え、バグ履歴情報111および可読性低下ワード条件114が入力される。バグ履歴情報111は、各プログラム要素について過去に発生したバグの内容とその原因を記録したものである。可読性低下ワード条件114は、Long Method生成部105Bで各プログラム要素がLong Methodか否かを判断するときに用いるバグ履歴情報111におけるバグ発生原因の判断条件を記録したものである。   In the source code analysis, the source code analysis device 10B includes, in addition to the source code 109, the program element change history 110 of the source code 109, the Long Method Score threshold 112, and the maintainability index threshold 113, the bug history information 111 and the readability reduction word condition. 114 is input. The bug history information 111 is a record of the content of a bug that has occurred in the past for each program element and its cause. The readability-decreasing word condition 114 records the condition for determining the cause of the bug in the bug history information 111 used when the Long Method generation unit 105B determines whether each program element is the Long Method.

Long Method条件設定部104Bは、Long Method Score118と保守性指標119とバグ履歴情報111を受け付けて、Long Method Score閾値112、保守性指標閾値113および可読性低下ワード条件114を設定可能にする。この時、Long Method条件設定部104Bは、可読性低下ワードの有無別に、プログラム要素数と保守性指標119との関係およびプログラム要素数とLong Method Score118との関係を表示させることができる。そして、閾値設定者は、これらの関係を参照しながら、Long Method Score閾値112、保守性指標閾値113および可読性低下ワード条件114を設定することができる。   The Long Method condition setting unit 104B receives the Long Method Score 118, the maintainability index 119, and the bug history information 111, and enables setting of the Long Method Score threshold 112, the maintainability index threshold 113, and the readability reduction word condition 114. At this time, the Long Method condition setting unit 104B can display the relationship between the number of program elements and the maintainability index 119 and the relationship between the number of program elements and the Long Method Score 118 depending on the presence or absence of a low-readability word. Then, the threshold value setting person can set the Long Method Score threshold value 112, the maintainability index threshold value 113, and the readability reduction word condition 114 while referring to these relationships.

Long Method Score閾値112、保守性指標閾値113、バグ履歴情報111および可読性低下ワード条件114は、Long Methodリスト生成部105Bに入力される。Long Methodリスト生成部105Bは、Long Method Score118と、保守性指標119と、Long Method Score閾値112と、保守性指標閾値113と、バグ履歴情報111と、可読性低下ワード条件114を受け付けて、Long Methodリスト120Aを生成する。   The Long Method Score threshold value 112, the maintainability index threshold value 113, the bug history information 111, and the readability reduction word condition 114 are input to the Long Method list generation unit 105B. The long method list generation unit 105B receives the long method score 118, the maintainability index 119, the long method score threshold 112, the maintainability index threshold 113, the bug history information 111, and the readability reduction word condition 114, and receives the long method. Generate the list 120A.

ここで、Long Methodリスト生成部105Bは、Long Method ScoreがLong Method Score閾値112以上かつ保守性指標が保守性指標閾値113以下、さらにバグ発生要因が可読性低下ワード条件114を満たすプログラム要素をLong Methodと判断することができる。あるいは、Long Methodリスト生成部105Bは、Long Method ScoreがLong Method Score閾値112以上、さらにバグ発生要因が可読性低下ワード条件114を満たすプログラム要素をLong Methodと判断するようにしてもよい。あるいは、Long Methodリスト生成部105Bは、保守性指標が保守性指標閾値113以下、さらにバグ発生要因が可読性低下ワード条件114を満たすプログラム要素をLong Methodと判断するようにしてもよい。   Here, the Long Method list generation unit 105B determines that the Long Method Score is equal to or greater than the Long Method Score threshold 112, the maintainability index is equal to or less than the maintainability index threshold 113, and the program element whose bug occurrence factor satisfies the readability decrease word condition 114 is a Long Method score. Can be determined. Alternatively, the Long Method list generation unit 105B may determine that a program element whose Long Method Score is equal to or greater than the Long Method Score threshold value 112 and whose bug occurrence factor satisfies the readability-reduced word condition 114 is Long Method. Alternatively, the Long Method list generation unit 105B may determine that a program element whose maintainability index satisfies the maintainability index threshold value 113 or less and whose bug occurrence factor satisfies the low readability word condition 114 is Long Method.

ここで、ソースコード解析装置10Bは、コードメトリクス117およびコミット情報108に基づいてLong Method Score118を生成し、Long Method Score118およびバグ発生要因に基づいてプログラム要素がLong Methodかどうかを判定することにより、ソースコード109に含まれる分割すべきプログラム要素を提示することが可能となる。この時、バグ発生要因が可読性低下ワード条件114を満たす場合、プログラムの読み間違えを引き起こしやすく、そのプログラム要素がLong Methodである可能性が高くなる。このため、Long Method Score118および保守性指標119に加え、バグ履歴情報111を参照しつつ、ソースコード109のプログラム要素がLong Methodであるかどうかを判断することにより、Long Methodの判定精度を向上させることが可能となる。   Here, the source code analysis device 10B generates the Long Method Score 118 based on the code metrics 117 and the commit information 108, and determines whether the program element is the Long Method based on the Long Method Score 118 and the bug occurrence factor. The program elements to be divided included in the source code 109 can be presented. At this time, when the cause of the bug satisfies the readability-reduced word condition 114, it is easy to cause a misread of the program, and the possibility that the program element is Long Method is increased. For this reason, by referring to the bug history information 111 in addition to the Long Method Score 118 and the maintainability index 119, it is determined whether or not the program element of the source code 109 is the Long Method, thereby improving the accuracy of the Long Method determination. It becomes possible.

図16は、図15のソースコード解析装置に入力されるバグ履歴情報の一例を示す図である。
図16において、バグ履歴情報111はプログラム要素ごとに存在する。バグ履歴情報111は、バグ履歴情報111がどのプログラム要素に対応しているかを示すプログラム要素名1601と、当該プログラム要素における過去のバグ情報1602を備える。過去のバグ情報1602は、当該プログラム要素におけるバグレコード1605を備える。バグレコード1605は、当該プログラム要素における当該バグのバグ内容1603と、バグ発生原因1604を備える。例えば、プログラム要素1のバグ履歴情報111において、バグ内容1603として、バグ内容B1、B2、バグ発生原因1604として、例外処理見落としおよび条件分岐の検討漏れが記録されている。ただし、バグ内容1603については省略することも可能である。
FIG. 16 is a diagram showing an example of bug history information input to the source code analysis device of FIG.
In FIG. 16, the bug history information 111 exists for each program element. The bug history information 111 includes a program element name 1601 indicating which program element the bug history information 111 corresponds to, and past bug information 1602 for the program element. The past bug information 1602 includes a bug record 1605 of the program element. The bug record 1605 includes a bug content 1603 of the bug in the program element and a bug occurrence cause 1604. For example, in the bug history information 111 of the program element 1, a bug content 1603 records a bug content B1, B2, and a bug occurrence cause 1604 includes exception processing oversight and omission of consideration of a conditional branch. However, the bug content 1603 can be omitted.

また、可読性低下ワード条件114として、例えば、「(理解|認識|考慮|確認|見直|検討|修正)*(漏れ|不足|不十分|怠|忘れ|失念)」を設定する。この例では、可読性低下ワード条件114を正規表現の形で示しているが、この方法に限らず自然言語のマッチング条件を表現可能な任意の方法でよい。また、可読性低下ワード条件114に用いる単語およびその組合せについても、可読性低下を表すものであれば任意の単語の任意の組合せでよい。   As the readability lowering word condition 114, for example, “(understanding | recognition | consideration | confirmation | review | review | review | correction) * (leakage | insufficient | insufficient | neglected | forgotten | forgot)" is set. In this example, the readability-reducing word condition 114 is shown in the form of a regular expression. However, the present invention is not limited to this method, and any method capable of expressing a natural language matching condition may be used. Also, the words and combinations thereof used in the readability-decreasing word condition 114 may be any combination of any words as long as they indicate a decrease in readability.

図17は、図15のLong Method条件設定部の処理を示すフローチャートである。
図17において、Long Method条件設定部104Bは、全てのプログラム要素に対してLong Method Score118、保守性指標119およびバグ履歴情報111を読み込んだかどうかを判断する(1701)。全てのプログラム要素に対してLong Method Score118、保守性指標119およびバグ履歴情報111を読み込んでいない場合、Long Method条件設定部104Bは、そのプログラム要素のLong Method Score118、保守性指標119およびバグ履歴情報111を読み込む(1702、1703、1704)。
FIG. 17 is a flowchart showing the processing of the Long Method condition setting unit in FIG.
In FIG. 17, the Long Method condition setting unit 104B determines whether the Long Method Score 118, the maintainability index 119, and the bug history information 111 have been read for all program elements (1701). If the Long Method Score 118, the maintainability index 119, and the bug history information 111 have not been read for all the program elements, the Long Method condition setting unit 104B sets the Long Method Score 118, the maintainability index 119, and the bug history information of the program element. 111 is read (1702, 1703, 1704).

Long Method条件設定部104Bは、全てのプログラム要素に対してLong Method Score118、保守性指標119およびバグ履歴情報111を読み込むと、Long Method Score閾値112、保守性指標閾値113およびバグ履歴情報111に対して初期値を設定する(1705)。ここで、初期値としてどのような値を選んでもよい。   When the Long Method Score setting unit 104B reads the Long Method Score 118, the maintainability index 119, and the bug history information 111 for all the program elements, the Long Method Score threshold 112, the maintainability index threshold 113, and the bug history information 111 are read from the Long Method Score 118 and the bug history information 111. To set an initial value (1705). Here, any value may be selected as the initial value.

次に、Long Method条件設定部104Bは、保守性指標を横軸、プログラム要素数を縦軸としたヒストグラムを可読性低下ワードの有無別に表示する(1706)。このヒストグラムの表示は、閾値設定者がLong Method Score閾値112、保守性指標閾値113および可読性低下ワード条件114の設定を行うのを支援する。   Next, the Long Method condition setting unit 104B displays a histogram with the maintainability index on the horizontal axis and the number of program elements on the vertical axis according to the presence or absence of a low readability word (1706). The display of the histogram assists the threshold setter in setting the Long Method Score threshold 112, the maintainability index threshold 113, and the readability reduction word condition 114.

次に、Long Method条件設定部104Bは、Long Method Scoreを横軸、プログラム要素数を縦軸としたヒストグラムを可読性低下ワードの有無別に表示する(1707)。このヒストグラムの表示は、閾値設定者がLong Method Score閾値112、保守性指標閾値113および可読性低下ワード条件114の設定を行うのを支援する。   Next, the Long Method condition setting unit 104B displays a histogram with the Long Method Score as the horizontal axis and the number of program elements as the vertical axis, depending on the presence or absence of the readability-reducing word (1707). The display of the histogram assists the threshold setter in setting the Long Method Score threshold 112, the maintainability index threshold 113, and the readability reduction word condition 114.

次に、Long Method条件設定部104Bは、閾値設定者による閾値の設定を続けるか否かの判断を受け付ける(1708)。閾値設定者が閾値の設定を続けると判断した場合、Long Method条件設定部104Bは、閾値設定者によるLong Method Score閾値112の数値入力を受け付け、Long Method Score閾値112として設定する(1709)。次に、Long Method条件設定部104Bは、閾値設定者による保守性指標閾値113の数値入力を受け付け、保守性指標閾値113として設定する(1710)。次に、Long Method条件設定部104Bは、閾値設定者による可読性低下ワード条件114の文字入力を受け付け、可読性低下ワード条件114として設定する(1711)。   Next, the Long Method condition setting unit 104B receives a determination as to whether to continue setting the threshold by the threshold setter (1708). If the threshold setter determines that the threshold setting is to be continued, the Long Method condition setting unit 104B accepts the numerical input of the Long Method Score threshold 112 by the threshold setter, and sets it as the Long Method Score threshold 112 (1709). Next, the Long Method condition setting unit 104B receives the numerical value input of the maintainability index threshold 113 by the threshold setter and sets the value as the maintainability index threshold 113 (1710). Next, the Long Method condition setting unit 104B accepts a character input of the readability lowering word condition 114 by the threshold value setter and sets it as the readability lowering word condition 114 (1711).

次に、Long Method条件設定部104Bは、閾値設定者の入力をLong Method Score閾値112、保守性指標閾値113および可読性低下ワード条件114として設定すると、1706に戻る。そして、Long Method条件設定部104Bは、閾値設定者が閾値の設定を続けないと判断するまで、1706〜1711の処理を繰り返し、閾値設定者が閾値の設定を続けないと判断すると、処理を終了する。   Next, the Long Method condition setting unit 104B sets the threshold setter's input as the Long Method Score threshold 112, the maintainability index threshold 113, and the readability reduction word condition 114, and returns to 1706. The Long Method condition setting unit 104B repeats the processes 1706 to 1711 until the threshold setter determines not to continue setting the threshold, and ends the process when the threshold setter determines not to continue setting the threshold. I do.

なお、Long Method Score118の読み込み(1702)、保守性指標119の読み込み(1703)およびバグ履歴情報111の読み込み(1704)の順序については問わない。また、閾値設定者によるLong Method Score閾値112の入力(1709)、保守性指標閾値113の入力(1710)および可読性低下ワード条件114の入力(1711)の順序については問わない。   Note that the order of reading the Long Method Score 118 (1702), reading the maintainability index 119 (1703), and reading the bug history information 111 (1704) does not matter. The order of the input of the Long Method Score threshold 112 (1709), the input of the maintainability index threshold 113 (1710), and the input of the low readability word condition 114 (1711) by the threshold setter does not matter.

図18は、図15のLong Methodリスト生成部の処理を示すフローチャートである。
図18において、Long Methodリスト生成部105Bは、空のLong Methodリスト120Aを用意する(1801)。次に、Long Methodリスト生成部105Bは、プログラム要素のLong Method Score閾値112、保守性指標閾値113および可読性低下ワード条件114を読み込む(1802、1803、1804)。
FIG. 18 is a flowchart illustrating the processing of the Long Method list generation unit in FIG.
In FIG. 18, the Long Method list generation unit 105B prepares an empty Long Method list 120A (1801). Next, the Long Method list generation unit 105B reads the Long Method Score threshold 112, the maintainability index threshold 113, and the readability reduction word condition 114 of the program element (1802, 1803, 1804).

次に、Long Methodリスト生成部105Bは、全てのプログラム要素に対してLong Method Score118、保守性指標119およびバグ履歴情報111のバグ発生要因をLong Method Score閾値112、保守性指標閾値113および可読性低下ワード条件114とそれぞれ比較したかどうかを判断する(1805)。全てのプログラム要素に対してLong Method Score118、保守性指標119およびバグ履歴情報111のバグ発生要因をLong Method Score閾値112、保守性指標閾値113および可読性低下ワード条件114とそれぞれ比較していない場合、Long Methodリスト生成部105Bは、そのプログラム要素のLong Method Score118、保守性指標119およびバグ履歴情報111を読み込む(1806、1807、1808)。   Next, the Long Method list generation unit 105B determines the Long Method Score 118, the maintainability index 119 and the bug occurrence factor of the bug history information 111 for all the program elements by using the Long Method Score threshold 112, the maintainability index threshold 113, and the readability reduction. It is determined whether or not each is compared with the word condition 114 (1805). When the cause of the bug of the Long Method Score 118, the maintainability index 119 and the bug history information 111 is not compared with the Long Method Score threshold 112, the maintainability index threshold 113 and the readability reduction word condition 114 for all the program elements, The Long Method list generation unit 105B reads the Long Method Score 118, the maintainability index 119, and the bug history information 111 of the program element (1806, 1807, 1808).

次に、Long Methodリスト生成部105Bは、Long Method Score118がLong Method Score閾値112以上、かつ、保守性指標119が保守性指標閾値113以下、かつ、バグ発生要因が可読性低下ワード条件114を満たすかどうかを判断する(1809)。1809の条件を満たす場合、Long Methodリスト生成部105Bは、Long Methodリスト120Aにプログラム要素を追加し(1810)、1805に戻る。1809の条件を満たさない場合、1810をスキップし、1805に戻る。全てのプログラム要素に対してLong Method Score118、保守性指標119およびバグ履歴情報111のバグ発生要因をLong Method Score閾値112、保守性指標閾値113および可読性低下ワード条件114とそれぞれ比較すると、処理を終了する。   Next, the Long Method list generation unit 105B determines whether the Long Method Score 118 is equal to or greater than the Long Method Score threshold 112, the maintainability index 119 is equal to or less than the maintainability index threshold 113, and the bug occurrence factor satisfies the readability reduction word condition 114. It is determined whether it is (1809). If the condition of 1809 is satisfied, the Long Method list generation unit 105B adds a program element to the Long Method list 120A (1810), and returns to 1805. If the condition of 1809 is not satisfied, the process skips 1810 and returns to 1805. Comparing the Long Method Score 118, the maintainability index 119, and the cause of the bug in the bug history information 111 with the Long Method Score threshold 112, the maintainability index threshold 113, and the low readability word condition 114 for all the program elements, the process ends. I do.

なお、空のLong Methodリストの用意(1801)、Long Method Score閾値112の読み込み(1802)、保守性指標閾値113の読み込み(1803)および可読性低下ワード条件114の読み込み(1804)の順序については問わない。また、Long Method Score118の読み込み(1806)、保守性指標119の読み込み(1807)およびバグ履歴情報111の読み込み(1808)の順序については問わない。   Note that the order of preparing an empty Long Method list (1801), reading the Long Method Score threshold 112 (1802), reading the maintainability index threshold 113 (1803), and reading the readability degrading word condition 114 (1804) does not matter. Absent. Also, the order of reading the Long Method Score 118 (1806), reading the maintainability index 119 (1807), and reading the bug history information 111 (1808) does not matter.

図19は、図15のLong Method条件設定部で表示される保守性指標を横軸、プログラム要素数を縦軸としたヒストグラムの一例を示す図である。
図19の例では、Long Method Score閾値112として60を、保守性指標閾値113として30を設定した場合を示す。ヒストグラムは、凡例1901、保守性指標閾値軸1302、縦軸としてプログラム要素数1303、横軸として保守性指標1304を備える。ヒストグラム本体1905は、全プログラム要素のヒストグラム1306、Long Method Scoreが閾値以上のプログラム要素のヒストグラム1307およびLong Method Scoreが閾値以上かつ可読性低下ワードを含むプログラム要素のヒストグラム1902を備える。Long Method Scoreが閾値以上かつ可読性低下ワードを含むプログラム要素のうち、保守性指標閾値軸1302よりも左に存在するプログラム要素が、Long Methodリスト生成部105BにおいてLong Methodと判定される。閾値設定者は、このヒストグラムを参考にLong Method Score閾値112と保守性指標閾値113と可読性低下ワード条件114を変更することができる。
FIG. 19 is a diagram showing an example of a histogram in which the horizontal axis represents the maintainability index and the vertical axis represents the number of program elements displayed in the Long Method condition setting unit of FIG.
The example of FIG. 19 shows a case where 60 is set as the Long Method Score threshold 112 and 30 is set as the maintainability index threshold 113. The histogram includes a legend 1901, a maintainability index threshold axis 1302, the number of program elements 1303 as a vertical axis, and a maintainability index 1304 as a horizontal axis. The histogram main body 1905 includes a histogram 1306 of all program elements, a histogram 1307 of a program element whose Long Method Score is equal to or larger than a threshold, and a histogram 1902 of a program element whose Long Method Score is equal to or larger than the threshold and including a readability-decreasing word. Among the program elements whose Long Method Score is equal to or larger than the threshold value and including the readability-decreasing word, the program element existing to the left of the maintainability index threshold axis 1302 is determined as Long Method by the Long Method list generation unit 105B. The threshold value setter can change the Long Method Score threshold value 112, the maintainability index threshold value 113, and the readability reduction word condition 114 with reference to this histogram.

図20は、図15のLong Method条件設定部で表示されるLong Method Scoreを横軸、プログラム要素数を縦軸としたヒストグラムの一例を示す図である。
図20の例では、Long Method Score閾値112として60を、保守性指標閾値113として30を設定した場合を示す。ヒストグラムは、凡例2001、Long Method Score閾値軸1402、縦軸としてプログラム要素数1403、横軸としてLong Method Score1404を備える。ヒストグラム本体2005は、全プログラム要素のヒストグラム1406、保守性指標が閾値以下のプログラム要素のヒストグラム1407および保守性指標が閾値以下かつ可読性低下ワードを含むプログラム要素のヒストグラム2002を備える。保守性指標が閾値以下かつ可読性低下ワードを含むプログラム要素のうち、Long Method Score閾値軸1402よりも右に存在するプログラム要素が、Long Methodリスト生成部105BにおいてLong Methodと判定される。閾値設定者は、このヒストグラムを参考にLong Method Score閾値112と保守性指標閾値113と可読性低下ワード条件114を変更することができる。
FIG. 20 is a diagram illustrating an example of a histogram in which the horizontal axis is Long Method Score and the vertical axis is the number of program elements displayed in the Long Method condition setting unit of FIG.
The example of FIG. 20 shows a case where 60 is set as the Long Method Score threshold 112 and 30 is set as the maintainability index threshold 113. The histogram includes a legend 2001, a Long Method Score threshold axis 1402, a number of program elements 1403 as a vertical axis, and a Long Method Score 1404 as a horizontal axis. The histogram body 2005 includes a histogram 1406 of all program elements, a histogram 1407 of program elements whose maintainability index is equal to or less than the threshold value, and a histogram 2002 of program elements whose maintainability index is equal to or less than the threshold value and includes a low readability word. Among the program elements whose maintainability index is equal to or less than the threshold value and includes the readability-decreasing word, the program element existing to the right of the Long Method Score threshold axis 1402 is determined as Long Method by the Long Method list generation unit 105B. The threshold value setter can change the Long Method Score threshold value 112, the maintainability index threshold value 113, and the readability reduction word condition 114 with reference to this histogram.

このように、Long Method Score118および保守性指標119を用いるとともに、プログラム要素が可読性低下ワードを含むかどうかを判断することでアンチパターンの1つであるLong Methodに該当するプログラム要素の判定精度を向上させることができる。   As described above, by using the Long Method Score 118 and the maintainability index 119, it is possible to improve the determination accuracy of the program element corresponding to the Long Method, which is one of the anti-patterns, by determining whether or not the program element includes a low readability word. Can be done.

(第3実施形態)
第3実施形態は、図7のLong Methodリスト120AのLong Methodレコード702において、Long Methodに該当するプログラム要素名701に加え、当該プログラム要素のLong Method Scoreや保守性指標等も記録するものである。
図21は、第3実施形態に係るソースコード解析装置で生成されるLong Methodリストの一例を示す図である。
図21において、Long Methodリスト120Bは、各Long Methodリスト生成部105A、105BによってLong Methodに該当すると判断されたプログラム要素をLong Methodレコード2104として記録したものである。Long Methodレコード2104は、Long Methodに該当するプログラム要素名2101と、Long Method Score2102と、保守性指標2103等を備える。Long Methodレコード2104にはさらに他の情報を含めてもよい。
(Third embodiment)
In the third embodiment, in the Long Method record 702 of the Long Method list 120A in FIG. 7, in addition to the program element name 701 corresponding to the Long Method, a Long Method Score, a maintainability index, and the like of the program element are also recorded. .
FIG. 21 is a diagram illustrating an example of a Long Method list generated by the source code analysis device according to the third embodiment.
In FIG. 21, a Long Method list 120B records the program elements determined to correspond to the Long Method by the respective Long Method list generation units 105A and 105B as a Long Method record 2104. The Long Method record 2104 includes a program element name 2101 corresponding to the Long Method, a Long Method Score 2102, a maintainability index 2103, and the like. The Long Method record 2104 may further include other information.

(第4実施形態)
第4実施形態は、図7のLong Methodリスト120Aまたは図21のLong Methodリスト120Bを生成後、さらに、Long Methodリスト120A、120B中の各プログラム要素をサブアンチパターンに分類し、サブアンチパターンに応じて改善箇所を示したソースコードを生成する。
(Fourth embodiment)
In the fourth embodiment, after generating the Long Method list 120A of FIG. 7 or the Long Method list 120B of FIG. 21, each program element in the Long Method lists 120A and 120B is further classified into sub-anti-patterns, and Generates source code indicating the points of improvement accordingly.

図22は、第4実施形態に係るソースコード解析装置の機能的な構成を示すブロック図である。
図22において、ソースコード解析装置10Cは、図15のソースコード解析装置10Bの構成に加え、サブアンチパターン分類部106と、改善箇所マッピング部107を備える。これらの機能は、第1実施形態から第3実施形態の場合と同様に実現される。
FIG. 22 is a block diagram illustrating a functional configuration of the source code analysis device according to the fourth embodiment.
22, the source code analysis device 10C includes a sub-anti-pattern classification unit 106 and an improvement location mapping unit 107 in addition to the configuration of the source code analysis device 10B in FIG. These functions are realized in the same manner as in the first to third embodiments.

ソースコード解析にあたって、ソースコード解析装置10Cには、ソースコード109、ソースコード109のプログラム要素変更履歴110、Long Method Score閾値112および保守性指標閾値113、バグ履歴情報111および可読性低下ワード条件114に加え、サブアンチパターン定義情報115および改善カタログ情報116が入力される。   In analyzing the source code, the source code analysis device 10C includes, in the source code 109, the program element change history 110 of the source code 109, the Long Method Score threshold 112, the maintainability index threshold 113, the bug history information 111, and the readability reduction word condition 114. In addition, sub-anti-pattern definition information 115 and improvement catalog information 116 are input.

サブアンチパターン分類部106は、解析対象となるソースコード109と、サブアンチパターン定義情報115と、プログラム要素変更履歴110と、コードメトリクス117と、Long Methodリスト120Bを受け付けて、サブアンチパターンリスト121を生成する。改善箇所マッピング部107は、ソースコード109と、改善カタログ情報116を受け付けて、改善箇所を示したソースコード122を生成する。ソースコードの改善箇所はプログラムの行単位またトークン単位で示すことができる。   The sub-anti-pattern classifying unit 106 receives the source code 109 to be analyzed, the sub-anti-pattern definition information 115, the program element change history 110, the code metrics 117, and the long method list 120B, and receives the sub-anti-pattern list 121. Generate The improvement location mapping unit 107 receives the source code 109 and the improvement catalog information 116 and generates a source code 122 indicating the improvement location. Improvements in the source code can be indicated by lines or tokens in the program.

Long Methodの改善箇所は、例えば、以下のA)〜D)に分類することができる。
A)処理の切れ目があれば、その切れ目
B)分岐先に共通部分があれば、その共通部分を括りだして関数化するような箇所
C)次にどの状態に遷移するかを判断する処理と、その状態で実行する処理を分割する切れ目
D)本来の処理に例外処理が追加されている場合、本来の処理と例外処理を分割する切れ目
The improvement points of the Long Method can be classified into, for example, the following A) to D).
A) If there is a break in the processing, B) If there is a common part at the branch destination, a part where the common part is extracted and converted into a function C) Processing to determine which state to transition to next D) A break for dividing the processing to be executed in that state D) When an exception processing is added to the original processing, a break for dividing the original processing and the exception processing

情報記憶部200は、コードメトリクス117と、Long Method Score118と、保守性指標119に加えて、Long Methodリスト120Bおよびサブアンチパターンリスト121を記憶する。情報記憶部200は、これらの情報以外にも、コードメトリクス取得部101や、Long Method Score計算部102や、保守性指標計算部103や、Long Method条件設定部104Bや、Long Methodリスト生成部105Bや、サブアンチパターン分類部106や、改善箇所マッピング部107が適宜参照もしくは生成する情報等を記憶する。情報記憶部200は、補助記憶装置13に記憶する情報を、例えば、ファイルシステムやDBMS(DataBase Management System)によって管理することができる。   The information storage unit 200 stores a Long Method list 120B and a sub-anti-pattern list 121 in addition to the code metrics 117, the Long Method Score 118, and the maintainability index 119. The information storage unit 200 includes a code metric acquisition unit 101, a long method score calculation unit 102, a maintainability index calculation unit 103, a long method condition setting unit 104B, and a long method list generation unit 105B, in addition to the above information. Also, information and the like that the sub-anti-pattern classification unit 106 and the improvement location mapping unit 107 refer to or generate as appropriate are stored. The information storage unit 200 can manage information stored in the auxiliary storage device 13 by, for example, a file system or a DBMS (DataBase Management System).

ここで、ソースコード解析装置10Cは、サブアンチパターン定義情報115に基づいて、分割すべきプログラム要素をサブアンチパターンに分類し、改善カタログ情報116に基づいて改善箇所を示したソースコード122を提示することにより、リファクタリング作業者は、メソッドの分割箇所について自ら判断することなく、メソッド内のどの箇所でメソッド分割を行えばよいのかについて認識することができ、機能の拡張または変更が繰り返されたソフトウェアの可読性を向上させることができる。   Here, the source code analysis device 10C classifies the program elements to be divided into sub-anti-patterns based on the sub-anti-pattern definition information 115, and presents a source code 122 indicating an improved part based on the improvement catalog information 116. By doing so, the refactoring worker can recognize where in the method the method should be split without having to judge the method split location. Can be improved.

なお、図22では、図15のソースコード解析装置10Bの構成にサブアンチパターン分類部106と改善箇所マッピング部107を追加した構成を示したが、図2のソースコード解析装置10Aの構成にサブアンチパターン分類部106と改善箇所マッピング部107を追加してもよい。   FIG. 22 shows a configuration in which a sub-anti-pattern classification unit 106 and an improved location mapping unit 107 are added to the configuration of the source code analysis device 10B in FIG. An anti-pattern classification unit 106 and an improvement location mapping unit 107 may be added.

図23は、図22のソースコード解析装置に入力されるサブアンチパターン定義情報の一例を示す図である。
図23において、サブアンチパターン定義情報115は、アンチパターンの1つであるLong Methodをさらにサブアンチパターンへと分類するための定義情報をサブアンチパターン定義レコード2303として記録したものである。サブアンチパターンレコード2303は、当該サブアンチパターンの名称2301と、当該サブアンチパターンの定義2302を備える。
FIG. 23 is a diagram showing an example of sub-anti-pattern definition information input to the source code analysis device of FIG.
In FIG. 23, the sub-anti-pattern definition information 115 records definition information for further classifying Long Method, which is one of the anti-patterns, into a sub-anti-pattern as a sub-anti-pattern definition record 2303. The sub-anti-pattern record 2303 includes a name 2301 of the sub-anti-pattern and a definition 2302 of the sub-anti-pattern.

サブアンチパターン定義2302において、1つのプログラム要素が複数のサブアンチパターンに当てはまるような定義になっていてもよい。また、サブアンチパターン定義2302の記述方法は問わないが、ソースコード109と、コードメトリクス117と、プログラム要素変更履歴110の組合せで定義することができる。サブアンチパターンとして、例えば、「箇条書き」が挙げられる。これは複数の処理ブロックを一連の処理として記述したサブアンチパターンである。その他にも、多くの条件文からなるサブアンチパターンである「大量の条件文」や、状態遷移を行っているコード中で当該状態での処理本体と、状態遷移のための処理を混同して記述したサブアンチパターンである「状態遷移」が挙げられる。さらに、本来の処理に例外処理が追加されているサブアンチパターンである「塩漬け」が挙げられる。   The sub-anti-pattern definition 2302 may be defined such that one program element applies to a plurality of sub-anti-patterns. The method of describing the sub-anti-pattern definition 2302 does not matter, but it can be defined by a combination of the source code 109, the code metrics 117, and the program element change history 110. As the sub-anti-pattern, for example, “bulleted list” is given. This is a sub-anti-pattern that describes a plurality of processing blocks as a series of processing. In addition, confusing the "large amount of conditional statements", which is a sub-anti-pattern composed of many conditional statements, and the processing itself in the relevant state in the code performing the state transition, and the processing for the state transition “State transition” which is the described sub-anti-pattern is exemplified. Another example is “salt pickling” which is a sub anti-pattern in which exception processing is added to the original processing.

図24は、図22のソースコード解析装置で生成されるサブアンチパターンリストの一例を示す図である。
図24において、サブアンチパターンリスト121は、図21のLong Methodリスト120Bの各Long Methodレコード2104に対し、Long Methodとして分類されたサブアンチパターンの名称2301が追記されたサブアンチパターン分類レコード2402を備える。
FIG. 24 is a diagram showing an example of a sub-anti-pattern list generated by the source code analysis device of FIG.
24, the sub-anti-pattern list 121 includes a sub-anti-pattern classification record 2402 in which the name 2301 of the sub-anti-pattern classified as Long Method is added to each of the Long Method records 2104 of the Long Method list 120B of FIG. Prepare.

例えば、プログラム要素1は、図23のサブアンチパターン定義2302で定義されたサブアンチパターンA1に該当するものとすると、プログラム要素1のサブアンチパターン分類レコード2402にサブアンチパターンA1という名称2301が追記される。また、プログラム要素2は、図23のサブアンチパターン定義2302で定義されたサブアンチパターンA2に該当するものとすると、プログラム要素2のサブアンチパターン分類レコード2402にサブアンチパターンA2という名称2301が追記される。   For example, assuming that the program element 1 corresponds to the sub-anti-pattern A1 defined in the sub-anti-pattern definition 2302 of FIG. 23, the name 2301 of the sub-anti-pattern A1 is added to the sub-anti-pattern classification record 2402 of the program element 1. Is done. Further, assuming that the program element 2 corresponds to the sub-anti-pattern A2 defined by the sub-anti-pattern definition 2302 in FIG. 23, the name 2301 of the sub-anti-pattern A2 is added to the sub-anti-pattern classification record 2402 of the program element 2. Is done.

なお、当該プログラム要素に複数のサブアンチパターンが当てはまる場合、同一のプログラム要素名でサブアンチパターンの異なる複数のサブアンチパターン分類レコード2405が存在してよい。
また、図24では、図21のLong Methodリスト120Bの各Long Methodレコード2104に対し、Long Methodとして分類されたサブアンチパターンの名称2301を追記した例を示したが、図7のLong Methodリスト120Aの各Long Methodレコード702に対し、Long Methodとして分類されたサブアンチパターンの名称2301を追記してもよい。
When a plurality of sub-anti-patterns apply to the program element, a plurality of sub-anti-pattern classification records 2405 having the same program element name but different sub-anti-patterns may exist.
FIG. 24 shows an example in which the name 2301 of the sub-anti-pattern classified as Long Method is added to each Long Method record 2104 of the Long Method list 120B of FIG. 21, but the Long Method list 120A of FIG. The name 2301 of the sub-anti-pattern classified as Long Method may be added to each of the Long Method records 702.

図25は、図22のソースコード解析装置に入力される改善カタログ情報の一例を示す図である。
図25において、改善カタログ情報116は、サブアンチパターン定義情報115に定義された各サブアンチパターンに対するプログラム改善方法を、改善方法レコード2503として記録したものである。改善方法レコード2503は、当該サブアンチパターンの名称2501と、当該サブアンチパターンの改善方法2502を備える。改善方法2502の記述方法は問わない。
FIG. 25 is a diagram showing an example of the improved catalog information input to the source code analysis device of FIG.
In FIG. 25, the improvement catalog information 116 records a program improvement method for each sub-anti-pattern defined in the sub-anti-pattern definition information 115 as an improvement method record 2503. The improvement method record 2503 includes the name 2501 of the sub-anti-pattern and the improvement method 2502 of the sub-anti-pattern. The description method of the improvement method 2502 does not matter.

図26は、図22のサブアンチパターン分類部の処理を示すフローチャートである。
図26において、サブアンチパターン分類部106は、空のサブアンチパターンリスト121を用意する(2601)。次に、サブアンチパターン分類部106は、解析対象プログラムのソースコード109、サブアンチパターン定義情報115およびLong Methodリスト120Bを読み込む(2602、2603、2604)。
FIG. 26 is a flowchart showing the processing of the sub-anti-pattern classification unit of FIG.
In FIG. 26, the sub-anti-pattern classification unit 106 prepares an empty sub-anti-pattern list 121 (2601). Next, the sub-anti-pattern classification unit 106 reads the source code 109 of the analysis target program, the sub-anti-pattern definition information 115, and the Long Method list 120B (2602, 2603, 2604).

次に、サブアンチパターン分類部106は、Long Methodリスト120B中の全てのプログラム要素に対してコードメトリクス117およびプログラム要素変更履歴110を読み込んだかどうかを判断する(2605)。Long Methodリスト120B中の全てのプログラム要素に対してコードメトリクス117およびプログラム要素変更履歴110を読み込んでいない場合、サブアンチパターン分類部106は、コードメトリクス117およびプログラム要素変更履歴110を読み込む(2606、2607)。取得するコードメトリクスの種類としては、サブアンチパターン定義情報115に記載のあるものを選択する。   Next, the sub-anti-pattern classification unit 106 determines whether or not the code metrics 117 and the program element change history 110 have been read for all program elements in the Long Method list 120B (2605). If the code metrics 117 and the program element change history 110 have not been read for all the program elements in the Long Method list 120B, the sub-anti-pattern classification unit 106 reads the code metrics 117 and the program element change history 110 (2606, 2607). As the type of the code metric to be acquired, a type described in the sub-anti-pattern definition information 115 is selected.

次に、サブアンチパターン分類部106は、Long Methodリスト120B中のプログラム要素のソースコードパターン、コードメトリクス117およびプログラム要素変更履歴110がサブアンチパターン定義を満たすかどうかの判断を全てのサブアンチパターン定義情報115に対して実施したかどうかを判断する(2608)。Long Methodリスト120B中のプログラム要素のソースコードパターン、コードメトリクス117およびプログラム要素変更履歴110がサブアンチパターン定義を満たすかどうかの判断を全てのサブアンチパターン定義情報115に対して実施していない場合、サブアンチパターン分類部106は、プログラム要素のソースコードパターン、コードメトリクス117およびプログラム要素変更履歴110がサブアンチパターン定義を満たすかどうかを判断する(2609)。   Next, the sub-anti-pattern classification unit 106 determines whether or not the source code pattern, the code metric 117, and the program element change history 110 of the program element in the Long Method list 120B satisfy the sub-anti-pattern definition. It is determined whether the process has been performed for the definition information 115 (2608). When it is not determined whether the source code pattern of the program element in the Long Method list 120B, the code metric 117, and the program element change history 110 satisfy the sub-anti-pattern definition for all the sub-anti-pattern definition information 115. The sub-anti-pattern classification unit 106 determines whether the source code pattern of the program element, the code metrics 117, and the program element change history 110 satisfy the sub-anti-pattern definition (2609).

2609の条件を満たす場合、サブアンチパターン分類部106は、サブアンチパターンリスト121にプログラム要素およびサブアンチパターンを追加し(2610)、2608に戻る。2609の条件を満たさない場合、2610をスキップし、2608に戻る。Long Methodリスト120B中のプログラム要素のソースコードパターン、コードメトリクス117およびプログラム要素変更履歴110がサブアンチパターン定義を満たすかどうかの判断を全てのサブアンチパターン定義情報115に対して実施すると、2605に戻る。Long Methodリスト120B中の全てのプログラム要素に対して2606〜2610の処理を実行すると、処理を終了する。   If the condition of 2609 is satisfied, the sub-anti-pattern classification unit 106 adds the program element and the sub-anti-pattern to the sub-anti-pattern list 121 (2610), and returns to 2608. If the condition of 2609 is not satisfied, skip 2610 and return to 2608. When it is determined whether the source code pattern of the program element in the Long Method list 120B, the code metric 117, and the program element change history 110 satisfy the sub-anti-pattern definition for all the sub-anti-pattern definition information 115, the result becomes 2605. Return. When the processing of steps 2606 to 2610 is performed on all the program elements in the long method list 120B, the processing ends.

なお、空のサブアンチパターンリスト121の用意(2601)、ソースコード109の読み込み(2602)、サブアンチパターン定義情報115の読み込み(2603)およびLong Methodリスト120Bの読み込み(2604)の順序については問わない。また、コードメトリクス117の読み込み(2606)およびプログラム要素変更履歴110の読み込み(2607)の順序については問わない。   The order of preparing the empty sub-anti-pattern list 121 (2601), reading the source code 109 (2602), reading the sub-anti-pattern definition information 115 (2603), and reading the Long Method list 120B (2604) is not limited. Absent. Further, the order of reading the code metrics 117 (2606) and reading the program element change history 110 (2607) does not matter.

図27は、図22の改善箇所マッピング部の処理を示すフローチャートである。
図27において、改善箇所マッピング部107は、解析対象プログラムのソースコード109、改善カタログ情報116およびサブアンチパターンリスト121を読み込む(2701、2702、2703)。次に、改善箇所マッピング部107は、サブアンチパターンリスト121中の全てのプログラム要素に対して改善箇所を示したソースコード122を生成したかどうかを判断する(2704)。サブアンチパターンリスト121中の全てのプログラム要素に対して改善箇所を示したソースコード122を生成していない場合、改善箇所マッピング部107は、改善カタログ情報116に従い、プログラム要素のソースコードに分割すべき箇所をマッピングし、改善箇所を示したソースコード122を生成し、2704に戻る(2705)。改善箇所の示し方については問わない。サブアンチパターンリスト121中の全てのプログラム要素に対して改善箇所を示したソースコード122を生成すると、処理を終了する。
FIG. 27 is a flowchart showing the processing of the improvement point mapping unit in FIG.
In FIG. 27, the improvement location mapping unit 107 reads the source code 109 of the analysis target program, the improvement catalog information 116, and the sub-anti-pattern list 121 (2701, 2702, 2703). Next, the improvement point mapping unit 107 determines whether the source code 122 indicating the improvement point has been generated for all the program elements in the sub-anti-pattern list 121 (2704). If the source code 122 indicating the improvement points has not been generated for all the program elements in the sub-anti-pattern list 121, the improvement point mapping unit 107 divides the program elements into source codes according to the improvement catalog information 116. It maps the point to be improved, generates the source code 122 indicating the point of improvement, and returns to 2704 (2705). It does not matter how the improvement points are indicated. When the source code 122 indicating the improvement points for all the program elements in the sub-anti-pattern list 121 is generated, the processing ends.

なお、ソースコード109の読み込み(2701)、改善カタログ情報116の読み込み(2702)およびサブアンチパターンリスト121の読み込み(2703)の順序については問わない。このように、Long Methodリスト生成後に、Long Methodの改善箇所を示すことで、プログラム修正者のプログラム修正を支援することができる。   The order of reading the source code 109 (2701), reading the improved catalog information 116 (2702), and reading the sub-anti-pattern list 121 (2703) does not matter. As described above, after the Long Method list is generated, the improvement points of the Long Method are indicated, so that the program corrector can be supported by the program corrector.

(第5実施形態)
Long Method Score計算部102は、Long Method Scoreの計算方法として可読性スコアおよび変更発生スコアを用いる。上述した第1実施形態では、Long Method Score計算部102の処理を図9のフローチャートで示した際、Long Method Score118の計算方法(904)については問わないとしたが、本実施形態では、その計算方法として、可読性スコアおよび変更発生スコアを用いる。可読性スコアとは、当該プログラム要素の可読性を数値化したものであり、その計算方法は問わない。変更発生スコアとは、当該プログラム要素に対する変更発生の度合いを数値化したものであり、その計算方法は問わない。また、可読性スコアと変更発生スコアをどのように用いてLong Method Score118を計算するかについても問わない。
(Fifth embodiment)
The Long Method Score calculation unit 102 uses the readability score and the change occurrence score as the calculation method of the Long Method Score. In the above-described first embodiment, when the processing of the Long Method Score calculation unit 102 is shown in the flowchart of FIG. 9, the calculation method (904) of the Long Method Score 118 does not matter, but in this embodiment, the calculation is performed. As a method, a readability score and a change occurrence score are used. The readability score is a numerical value of the readability of the program element, and the calculation method does not matter. The change occurrence score is a numerical value of the degree of change occurrence for the program element, and the calculation method is not limited. Further, there is no limitation on how to use the readability score and the change occurrence score to calculate the Long Method Score 118.

(第6実施形態)
図28は、第6実施形態に係るソースコード解析装置から出力される改善箇所を示したソースコードの一例を示す図である。
図28において、改善箇所を示したソースコード122は、当該プログラム要素のソースコード2801と、当該プログラム要素のソースコード2801中の改善対象箇所2802と、改善方法を示すソースコード2803を備える。
(Sixth embodiment)
FIG. 28 is a diagram illustrating an example of a source code indicating an improvement point output from the source code analysis device according to the sixth embodiment.
In FIG. 28, a source code 122 indicating an improvement portion includes a source code 2801 of the program element, an improvement target portion 2802 in the source code 2801 of the program element, and a source code 2803 indicating an improvement method.

図28の例では、プログラム要素のソースコード2801がLong Methodとして抽出されている。この時、Long Methodリスト生成部105Bは、当該プログラム要素のソースコード2801をLong Methodリスト120Bに登録する。   In the example of FIG. 28, the source code 2801 of the program element is extracted as a Long Method. At this time, the Long Method list generation unit 105B registers the source code 2801 of the program element in the Long Method list 120B.

このソースコード2801は、本来の処理に例外処理R1、R2が追加されているサブアンチパターンである。この時、サブアンチパターン分類部106は、本来の処理に例外処理R1、R2が追加されているサブアンチパターンとして、当該プログラム要素のソースコード2801をサブアンチパターンリスト121に登録する。   This source code 2801 is a sub-anti-pattern in which exception processing R1 and R2 are added to the original processing. At this time, the sub-anti-pattern classification unit 106 registers the source code 2801 of the program element in the sub-anti-pattern list 121 as a sub-anti-pattern in which exception processing R1 and R2 are added to the original processing.

改善箇所マッピング部107は、当該プログラム要素のソースコード2801中の改善対象箇所2802として例外処理R1、R2を特定する。そして、改善箇所マッピング部107は、例外処理R1、R2を関数化したコードを、改善方法を示すソースコード2803として提示する。   The improvement location mapping unit 107 specifies the exception processing R1 and R2 as the improvement target location 2802 in the source code 2801 of the program element. Then, the improvement point mapping unit 107 presents a code obtained by functionalizing the exception processing R1 and R2 as a source code 2803 indicating an improvement method.

これにより、リファクタリング作業者は、メソッドの分割箇所について自ら判断することなく、当該プログラム要素のソースコード2801から例外処理R1、R2を分割することができ、本来の処理に例外処理R1、R2が追加されたソフトウェアの可読性を向上させることができる。   As a result, the refactoring operator can divide the exception processes R1 and R2 from the source code 2801 of the program element without having to judge the method division part, and add the exception processes R1 and R2 to the original process. It is possible to improve the readability of the implemented software.

(第7実施形態)
Long Method Score計算部102は、Long Method Scoreの計算方法として可読性スコアおよび変更発生スコアの調和平均を用いる。上述した第5実施形態では、可読性スコアと変更発生スコアをどのように用いてLong Method Score118を計算するかについては問わないとしたが、本実施形態では、その計算方法を可読性スコアおよび変更発生スコアの調和平均とする。ただし、可読性スコアおよび変更発生スコアの計算方法は問わない。調和平均は、逆数の算術平均の逆数として定義される。すなわち、本実施例では何らかの方法で求めた可読性スコアの逆数と、何らかの方法で求めた変更発生スコアの逆数の算術平均を計算し、その逆数をLong Method Score118とする。
(Seventh embodiment)
The Long Method Score calculation unit 102 uses the harmonic mean of the readability score and the change occurrence score as a method of calculating the Long Method Score. In the above-described fifth embodiment, how to use the readability score and the change occurrence score to calculate the Long Method Score 118 does not matter, but in the present embodiment, the calculation method is a readability score and a change occurrence score. And the harmonic mean of However, the method of calculating the readability score and the change occurrence score does not matter. The harmonic mean is defined as the reciprocal of the arithmetic mean of the reciprocal. That is, in this embodiment, an arithmetic average of the reciprocal of the readability score obtained by some method and the reciprocal of the change occurrence score obtained by some method is calculated, and the reciprocal is set to Long Method Score 118.

例えば、可読性低下スコアは、コメント抜き行数、循環的複雑度、コメント行数およびローカル変数宣言数を正規化した4値の調和平均値とすることができる。変更発生スコアは、コミット当たりの変更箇所数および重み付きコミット回数を正規化した2値の調和平均値とすることができる。Long Method Score118は、可読性低下スコアおよび変更発生スコアの調和平均値とすることができる。   For example, the readability reduction score can be a four-valued harmonic mean value obtained by normalizing the number of comment lines, the cyclic complexity, the number of comment lines, and the number of local variable declarations. The change occurrence score can be a binary harmonic mean value obtained by normalizing the number of change points per commit and the number of weighted commits. The Long Method Score 118 can be a harmonic mean value of the readability decrease score and the change occurrence score.

(第8実施形態)
図29は、第8実施形態に係るソースコード解析装置の画面遷移の一例を示す図である。
図29において、ソースコード解析装置10Cの画面は、解析対象選択画面2901と、Long Method条件設定画面2902と、Long Method一覧画面2903と、改善箇所表示画面2904を備える。解析対象選択画面2901とLong Method条件設定画面2902の間は双方向に遷移可能である。Long Method条件設定画面2902とLong Method一覧画面2903の間は双方向に遷移可能である。Long Method一覧画面2903と改善箇所表示画面2904の間は双方向に遷移可能である。改善箇所表示画面2904からは、解析対象選択画面2901に遷移可能である。
(Eighth embodiment)
FIG. 29 is a diagram illustrating an example of a screen transition of the source code analysis device according to the eighth embodiment.
In FIG. 29, the screen of the source code analysis device 10C includes an analysis target selection screen 2901, a Long Method condition setting screen 2902, a Long Method list screen 2903, and an improvement point display screen 2904. A bidirectional transition can be made between the analysis target selection screen 2901 and the Long Method condition setting screen 2902. A transition can be made between the Long Method condition setting screen 2902 and the Long Method list screen 2903 in both directions. A transition can be made between the Long Method list screen 2903 and the improvement point display screen 2904 in both directions. From the improvement point display screen 2904, a transition can be made to an analysis target selection screen 2901.

図30は、図22のソースコード解析装置の解析対象選択画面の一例を示す図である。
図30において、解析対象選択画面2901は、解析タブ3001と設定タブ3002を備える。解析タブ3001は、解析対象ソースコード109を選択するための解析対象ソースコード選択部3003と、バグ履歴情報111を選択するためのバグ履歴情報選択部3004と、プログラム要素変更履歴110を選択するためのプログラム要素変更履歴選択部3005と、解析開始ボタン3006を備える。
FIG. 30 is a diagram showing an example of an analysis target selection screen of the source code analysis device of FIG.
In FIG. 30, the analysis target selection screen 2901 includes an analysis tab 3001 and a setting tab 3002. An analysis tab 3001 is for selecting an analysis target source code selection unit 3003 for selecting the analysis target source code 109, a bug history information selection unit 3004 for selecting the bug history information 111, and for selecting the program element change history 110. , A program element change history selection unit 3005 and an analysis start button 3006.

ソースコード解析装置10Cの利用者は、解析のたびに解析対象ソースコード選択部3003と、バグ履歴情報選択部3004と、プログラム要素変更履歴選択部3005を用いて各データを選択し、解析ボタン3006を押下し、解析を開始させる。ソースコード解析装置10Cの利用者が解析ボタン3006を押下すると、ソースコード解析装置10内のコードメトリクス計算部101と、Long Method Score計算部102と、保守性指標計算部103と、Long Method条件設定部104Bが動作し、ソースコード解析装置10Cの画面はLong Method条件設定画面2902へと遷移する。   The user of the source code analysis device 10C selects each data by using the analysis target source code selection unit 3003, the bug history information selection unit 3004, and the program element change history selection unit 3005 every time the analysis is performed. Press to start analysis. When the user of the source code analysis device 10C presses the analysis button 3006, the code metrics calculation unit 101, the long method score calculation unit 102, the maintainability index calculation unit 103, and the long method condition setting in the source code analysis device 10 are set. The unit 104B operates, and the screen of the source code analysis device 10C transits to a Long Method condition setting screen 2902.

設定タブ3002は、改善カタログ情報116を選択するための改善カタログ情報選択部3007と、サブアンチパターン定義情報115を選択するためのサブアンチパターン定義情報選択部3008を備える。ソースコード解析装置10Cの利用者は、ソースコード解析装置10Cの初回利用時に改善カタログ情報選択部3007と、サブアンチパターン定義情報選択部3008を用いて各データを選択する。2回目以降の利用であっても、改善カタログ情報116およびサブアンチパターン定義情報115を変更する必要がある場合は、改善カタログ情報選択部3007およびサブアンチパターン定義情報選択部3008を用いて各データを選択する。   The setting tab 3002 includes an improved catalog information selecting unit 3007 for selecting the improved catalog information 116 and a sub-anti-pattern definition information selecting unit 3008 for selecting the sub-anti-pattern definition information 115. The user of the source code analysis device 10C selects each data by using the improved catalog information selection unit 3007 and the sub-anti-pattern definition information selection unit 3008 when using the source code analysis device 10C for the first time. If it is necessary to change the improved catalog information 116 and the sub-anti-pattern definition information 115 even in the second and subsequent uses, the improved catalog information selecting unit 3007 and the sub-anti-pattern definition information selecting unit 3008 are used to change each data. Select

図31は、図22のソースコード解析装置のLong Method条件設定画面の一例を示す図である。
図31において、Long Method条件設定画面2902は、閾値設定タブ3101とヒストグラムタブ3102と解析対象選択戻るボタン3113と設定完了ボタン3114を備える。
FIG. 31 is a diagram showing an example of a Long Method condition setting screen of the source code analysis device of FIG.
In FIG. 31, the Long Method condition setting screen 2902 includes a threshold setting tab 3101, a histogram tab 3102, an analysis target selection return button 3113, and a setting completion button 3114.

閾値設定タブ3101は、Lone Method Score閾値112を設定するためのLong Method Score閾値選択部3105と、保守性指標閾値113を選択するための保守性指標閾値選択部3106と、可読性低下ワード条件114を選択するための可読性低下ワード条件選択部3107を備える。   The threshold setting tab 3101 includes a Long Method Score threshold selection unit 3105 for setting the Lone Method Score threshold 112, a maintainability index threshold selection unit 3106 for selecting the maintainability index threshold 113, and a readability reduction word condition 114. A readability-reduced word condition selection unit 3107 for selection is provided.

ソースコード解析装置10Cの利用者がLong Method Score閾値選択部3105、保守性指標閾値選択部3106および可読性低下ワード条件選択部3107の値および条件を変更すると、それに応じてヒストグラムタブ3102内の保守性指標ヒストグラムタブ3103およびLong Method Scoreヒストグラムタブ3104の内容が変更される。   When the user of the source code analysis device 10C changes the values and conditions of the Long Method Score threshold value selection unit 3105, the maintainability index threshold value selection unit 3106, and the low readability word condition selection unit 3107, the maintainability in the histogram tab 3102 is accordingly changed. The contents of the index histogram tab 3103 and the Long Method Score histogram tab 3104 are changed.

ヒストグラムタブ3102は、保守性指標ヒストグラムタブ3103と、Long Method Scoreヒストグラムタブ3104を備える。保守性指標ヒストグラムタブ3103内には図19に示した内容が描かれており、Long Method Scoreヒストグラムタブ3104内には図20に示した内容が描かれている。   The histogram tab 3102 includes a maintainability index histogram tab 3103 and a long method score histogram tab 3104. The contents shown in FIG. 19 are drawn in the maintainability index histogram tab 3103, and the contents shown in FIG. 20 are drawn in the Long Method Score histogram tab 3104.

ソースコード解析装置10Cの利用者は保守性指標ヒストグラムタブ3103およびLong Method Scoreヒストグラムタブ3104の内容を参考に、Long Method Score閾値選択部3105、保守性指標閾値選択部3106および可読性低下ワード条件選択部3107の値および条件を設定する。ソースコード解析装置10Cの利用者が設定を完了した後、設定完了ボタン3114を押下すると、ソースコード解析装置10C内のLong Methodリスト生成部105Bとサブアンチパターン分類部106が動作し、画面はLong Method一覧画面2903へと遷移する。一方、解析対象選択戻るボタン3113を押下すると、解析対象選択画面2901へと遷移する。   The user of the source code analysis device 10C refers to the contents of the maintainability index histogram tab 3103 and the Long Method Score histogram tab 3104, and refers to the Long Method Score threshold value selection unit 3105, the maintainability index threshold value selection unit 3106, and the readability reduction word condition selection unit. The value and condition of 3107 are set. When the user of the source code analysis device 10C completes the setting and presses the setting completion button 3114, the Long Method list generation unit 105B and the sub-anti-pattern classification unit 106 in the source code analysis device 10C operate, and the screen is Long. The screen transits to the Method list screen 2903. On the other hand, when an analysis target selection return button 3113 is pressed, the screen transitions to an analysis target selection screen 2901.

図32は、図22のソースコード解析装置のLong Method一覧画面の一例を示す図である。
図32において、Long Method一覧画面2903は、サブアンチパターンリスト表示部3201と、Long Method条件設定戻るボタン3202を備える。サブアンチパターンリスト表示部3201はサブアンチパターンリスト121を表示する。ソースコード解析装置10Cの利用者がサブアンチパターンリスト121中の各サブアンチパターン分類レコード2401のLong Methodのプログラム要素を押下すると、改善箇所マッピング部107が動作し、画面は改善箇所表示画面2904へと遷移する。一方、Long Method条件設定戻るボタン3202を押下すると、Long Method条件設定画面2902へと遷移する。
FIG. 32 is a diagram showing an example of a Long Method list screen of the source code analysis device of FIG.
In FIG. 32, the Long Method list screen 2903 includes a sub anti-pattern list display section 3201 and a Long Method condition setting return button 3202. The sub-anti-pattern list display section 3201 displays the sub-anti-pattern list 121. When the user of the source code analysis device 10C presses the Long Method program element of each sub-anti-pattern classification record 2401 in the sub-anti-pattern list 121, the improvement point mapping unit 107 operates, and the screen changes to the improvement point display screen 2904. Transits. On the other hand, when a Long Method condition setting return button 3202 is pressed, the screen transitions to a Long Method condition setting screen 2902.

図33は、図22のソースコード解析装置の改善箇所表示画面の一例を示す図である。
図33において、改善箇所表示画面2904は、改善箇所を示したソースコード表示部3301と、解析対象選択戻るボタン3302と、Long Method一覧戻るボタン3303を備える。改善箇所を示したソースコード表示部3301は改善箇所を示したソースコード122を表示する。ソースコード解析装置10Cの利用者は改善箇所表示画面2904を閲覧することで、ソースコードの改善箇所および改善方法を知ることができる。
FIG. 33 is a diagram showing an example of an improvement point display screen of the source code analysis device of FIG.
In FIG. 33, the improvement point display screen 2904 includes a source code display section 3301 indicating an improvement point, an analysis target selection return button 3302, and a Long Method list return button 3303. The source code display unit 3301 indicating the improvement point displays the source code 122 indicating the improvement point. The user of the source code analysis device 10C can see the improvement point of the source code and the improvement method by viewing the improvement point display screen 2904.

ソースコード解析装置10Cの利用者が解析対象選択戻るボタン3302を押下すると、解析対象選択画面2901へと遷移する。一方、Long Method一覧戻るボタン3303を押下すると、Long Method一覧画面2903へと遷移する。   When the user of the source code analysis device 10C presses the analysis object selection return button 3302, the screen transitions to an analysis object selection screen 2901. On the other hand, when a long method list return button 3303 is pressed, the screen transits to a long method list screen 2903.

10…ソースコード解析装置、11…プロセッサ、12…主記憶装置、13…補助記憶装置、14…入力装置、15…出力装置、16…通信装置、17…バス   DESCRIPTION OF SYMBOLS 10 ... Source code analysis device, 11 ... Processor, 12 ... Main storage device, 13 ... Auxiliary storage device, 14 ... Input device, 15 ... Output device, 16 ... Communication device, 17 ... Bus

Claims (10)

コードメトリクス取得部が、複数のプログラム要素を有するソースコードを解析してプログラム要素の長さ及び複雑度にかかるコードメトリクスを生成し、
コミット情報取得部が、前記プログラム要素の変更履歴にかかるコミット情報を取得し、
スコア計算部が、前記コードメトリクスと、前記コミット情報と、に基づいて、前記プログラム要素のスコアを算出し、
保守性指標算出部が、前記コードメトリクスに基づき、前記プログラム要素の保守性指標を算出し、
リスト生成部が、前記スコアと、前記保守性指標と、に基づいて、複数に分割する候補となる前記プログラム要素のリストを生成するソースコード解析方法。
A code metrics acquisition unit analyzes a source code having a plurality of program elements and generates code metrics related to the length and complexity of the program elements,
A commit information acquiring unit for acquiring commit information relating to a change history of the program element;
A score calculation unit calculates a score of the program element based on the code metrics and the commit information,
A maintainability index calculation unit calculates a maintainability index of the program element based on the code metrics,
A source code analysis method in which a list generation unit generates a list of the program elements that are candidates for division into a plurality of pieces based on the score and the maintainability index.
請求項1において、
前記スコアは、Long method Scoreであるソースコード解析方法。
In claim 1,
The source code analysis method, wherein the score is a Long method Score.
請求項1において、
前記リスト生成部は、スコア閾値または/及び保守性指標閾値を用いて、前記リストを作成するソースコード解析方法。
In claim 1,
A source code analysis method, wherein the list generation unit creates the list using a score threshold and / or a maintainability index threshold.
請求項3において、
条件設定部は、前記スコアまたは保守指標性の軸と、前記スコアまたは保守指標性に該当するプログラム要素数の軸を有するグラフを出力し、ユーザから前記スコア閾値または/及び保守性指標閾値の設定を受け付けるソースコード解析方法。
In claim 3,
The condition setting unit outputs a graph having the axis of the score or the maintenance index and the axis of the number of program elements corresponding to the score or the maintenance index, and sets the score threshold or / and the maintenance index threshold from a user. Source code analysis method that accepts.
請求項4において、
前記グラフは、前記スコア及び前記保守指標性の両方が視認できるグラフであるソースコード解析方法。
In claim 4,
The source code analysis method, wherein the graph is a graph in which both the score and the maintenance index can be visually recognized.
請求項1において、
前記スコア計算部は、さらに各プログラム要素のバグ発生にかかるバグ履歴情報を用いて、前記プログラム要素のスコアを算出するソースコード解析方法。
In claim 1,
The source code analysis method, wherein the score calculation unit further calculates a score of the program element by using bug history information relating to a bug occurrence of each program element.
請求項6において、
前記バグ履歴情報には、バグの原因が含まれており、
前記バグ原因に含まれうる特定のワードを規定した可読性低下ワード条件をさらに用いて、前記スコア計算部は、前記プログラム要素のスコアを算出するソースコード解析方法。
In claim 6,
The bug history information includes the cause of the bug,
The source code analysis method, wherein the score calculation unit calculates a score of the program element by further using a readability-decreasing word condition defining a specific word that may be included in the bug cause.
請求項1において、
サブアンチパターンを定義したサブアンチパターン定義情報を有し、
サブアンチパターン分類部は、前記スコア、前記ソースコード、前記コードメトリクスに基づいて、前記スコアに記載されたプログラム要素をサブアンチパターンに分類したサブアンチパターンリストを生成するソースコード解析方法。
In claim 1,
Has sub-anti-pattern definition information that defines a sub-anti-pattern,
A source code analysis method, wherein a sub-anti-pattern classification unit generates a sub-anti-pattern list in which program elements described in the score are classified into sub-anti patterns based on the score, the source code, and the code metrics.
請求項8において、
改善箇所マッピング部が、前記アンチパターンリストと、改善カタログとに基づいて、改善個所を示したソースコードを生成するソースコード解析方法。
In claim 8,
A source code analysis method in which an improvement location mapping unit generates a source code indicating an improvement location based on the anti-pattern list and an improvement catalog.
複数のプログラム要素を有するソースコードを解析してプログラム要素の長さ及び複雑度にかかるコードメトリクスを生成するコードメトリクス取得部と、
前記プログラム要素の変更履歴にかかるコミット情報を取得するコミット情報取得部と、
前記コードメトリクスと、前記コミット情報と、に基づいて、前記プログラム要素のスコアを算出するスコア計算部と、
前記コードメトリクスに基づき、前記プログラム要素の保守性指標を算出する保守性指標算出部と、
前記スコアと、前記保守性指標と、に基づいて、複数に分割する候補となる前記プログラム要素のリストを生成するリスト生成部とを備えるソースコード解析装置。

A code metrics acquisition unit that analyzes a source code having a plurality of program elements and generates code metrics related to the length and complexity of the program elements;
A commit information acquiring unit for acquiring commit information relating to a change history of the program element;
A score calculation unit that calculates a score of the program element based on the code metrics and the commit information;
A maintainability index calculation unit that calculates a maintainability index of the program element based on the code metrics,
A source code analysis device, comprising: a list generation unit configured to generate a list of the program elements that are candidates to be divided into a plurality based on the score and the maintainability index.

JP2018116066A 2018-06-19 2018-06-19 Source code analysis method and source code analysis device Pending JP2019219848A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2018116066A JP2019219848A (en) 2018-06-19 2018-06-19 Source code analysis method and source code analysis device
CN201910378645.1A CN110618926A (en) 2018-06-19 2019-05-08 Source code analysis method and source code analysis device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2018116066A JP2019219848A (en) 2018-06-19 2018-06-19 Source code analysis method and source code analysis device

Publications (1)

Publication Number Publication Date
JP2019219848A true JP2019219848A (en) 2019-12-26

Family

ID=68921164

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2018116066A Pending JP2019219848A (en) 2018-06-19 2018-06-19 Source code analysis method and source code analysis device

Country Status (2)

Country Link
JP (1) JP2019219848A (en)
CN (1) CN110618926A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506563A (en) * 2020-12-24 2021-03-16 ***通信集团江苏有限公司 Method, device and equipment for calculating user story man-hour and computer storage medium
EP4099156A1 (en) 2021-06-04 2022-12-07 Hitachi, Ltd. Source code analysis apparatus and source code analysis method

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115113921B (en) * 2022-08-29 2022-11-08 云账户技术(天津)有限公司 Code reconstruction value evaluation method and device, electronic equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8627287B2 (en) * 2007-11-29 2014-01-07 Microsoft Corporation Prioritizing quality improvements to source code
CN101261604B (en) * 2008-04-09 2010-09-29 中兴通讯股份有限公司 Software quality evaluation apparatus and software quality evaluation quantitative analysis method
JP5725359B2 (en) * 2011-09-20 2015-05-27 日本電気株式会社 Source code comparison device, source code comparison method, and source code comparison program
JP6310865B2 (en) * 2015-01-30 2018-04-11 株式会社日立製作所 Source code evaluation system and method
CN107239396A (en) * 2017-05-11 2017-10-10 东南大学 A kind of Software Evolution appraisal procedure measured based on code cyclomatic complexity

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506563A (en) * 2020-12-24 2021-03-16 ***通信集团江苏有限公司 Method, device and equipment for calculating user story man-hour and computer storage medium
EP4099156A1 (en) 2021-06-04 2022-12-07 Hitachi, Ltd. Source code analysis apparatus and source code analysis method

Also Published As

Publication number Publication date
CN110618926A (en) 2019-12-27

Similar Documents

Publication Publication Date Title
US11880270B2 (en) Pruning and prioritizing event data for analysis
US9454454B2 (en) Memory leak analysis by usage trends correlation
US20110154117A1 (en) Methods and apparatus to perform log file analyses
US20150032708A1 (en) Database analysis apparatus and method
US20190114711A1 (en) Financial analysis system and method for unstructured text data
JP2019219848A (en) Source code analysis method and source code analysis device
JP2017041171A (en) Test scenario generation support device and test scenario generation support method
US8782626B2 (en) Search suggestions for static code analysis
JP6921598B2 (en) Arithmetic logic unit, impact output system
CN113780365A (en) Sample generation method and device
US20220206788A1 (en) Version control method for program project and associated electric device
WO2023037399A1 (en) Information processing device, information processing method, and program
CN114385155A (en) vue project visualization tool generation method, device, equipment and storage medium
JP2018124901A (en) Program analyzing apparatus, program analyzing method, and program analyzing program
JP2013218381A (en) Software evaluation support device and program
JP6676792B2 (en) Reviewer management system and method
US10515330B2 (en) Real time visibility of process lifecycle
JP6609216B2 (en) Apparatus and method for analyzing static analysis result of source code
CN112732681B (en) Data platform migration method and system
JP2020166443A (en) Data processing method recommendation system, data processing method recommendation method, and data processing method recommendation program
CN116483735B (en) Method, device, storage medium and equipment for analyzing influence of code change
JP7349927B2 (en) Risk assessment system and risk assessment method
JPWO2019012674A1 (en) Integrated analysis management system of program and integrated analysis management method therefor
JP2018025852A (en) Program analysis method, program analyzer and analysis program
JP6621432B2 (en) Computer and analysis data classification method

Legal Events

Date Code Title Description
RD02 Notification of acceptance of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7422

Effective date: 20190801