JP2019219848A - Source code analysis method and source code analysis device - Google Patents
Source code analysis method and source code analysis device Download PDFInfo
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3604—Software analysis for verifying properties of programs
- G06F11/3616—Software 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
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には、ソースコード、構成管理システムまたは稼動ログからメトリクスを計測し、ソースコードのアンチパターン該当可否を評価する手法が記載されている。これにより、リファクタリングが必要ない複雑なソースコードを抽出せず、真にリファクタリングが必要なソースコードを特定することができる。
しかしながら、特許文献1の手法では、ソースコードをプログラム解析して得られるプログラム要素の特徴量(以下、コードメトリクスと称す)を用いて当該プログラム要素がアンチパターンに該当するかどうかを判定し、該当する場合は当該プログラム要素をリファクタリング手順および優先度と共に提示する。しかし、提示されるリファクタリング手順は、アンチパターンごとに予め設定されたプログラム要素全体の修正方針である。このため、リファクタリング作業者はプログラム要素中のどの箇所をどのように修正すべきかについては自ら判断する必要があり、リファクタリング作業者に高いスキルが必要だった。
However, in the method of
以下、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
本発明は、上記事情に鑑みなされたものであり、その目的は、ソースコードに含まれる分割すべきプログラム要素を提示することが可能なソースコード解析方法およびソースコード解析装置を提供することにある。 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.
実施形態について、図面を参照して説明する。なお、以下に説明する実施形態は特許請求の範囲に係る発明を限定するものではなく、また実施形態の中で説明されている諸要素及びその組み合わせの全てが発明の解決手段に必須であるとは限らない。 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
プロセッサ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
補助記憶装置13は、例えば、ハードディスクドライブ、SSD(Solid State Drive)、光学式記憶装置(CD(Compact Disc)、DVD(Digital Versatile Disc)等)、ストレージシステム、ICカード、SDメモリカードや光学式記録媒体等の記録媒体の読取/書込装置、クラウドサーバの記憶領域等である。補助記憶装置13に格納されているプログラムやデータは主記憶装置12に随時ロードされる。
The
入力装置14は、例えば、キーボード、マウス、タッチパネル、カードリーダ、音声入力装置等である。出力装置15は、ユーザに処理経過や処理結果等の各種情報を提供するユーザインターフェースである。出力装置15は、例えば、画面表示装置(液晶モニタ、有機ELディスプレイ、グラフィックカード等)、音声出力装置(スピーカ等)、印字装置等である。なお、例えば、ソースコード解析装置10Aが通信装置16を介して他の装置との間で情報の入力や出力を行う構成としてもよい。
The
通信装置16は、LAN(Local Area Network)やインターネット等の通信手段を介した他の装置との間の通信を実現する有線方式又は無線方式の通信インタフェースである。通信装置16は、例えば、NIC(Network Interface Card)、無線通信モジュール、USB(Universal Serial Interface)モジュール、シリアル通信モジュール等である。
The
ここで、補助記憶装置13には、ソースコード解析プログラム13Aおよびソースコード13Bを格納することができる。そして、プロセッサ11が、ソースコード解析プログラム13Aおよびソースコード13Bを主記憶装置12にロードし、ソースコード解析プログラム13Aを実行することにより、ソースコード13Bを解析することができる。
Here, the
この時、プロセッサ11は、複数のプログラム要素を有するソースコード13Bを解析してプログラム要素の長さ及び複雑度にかかるコードメトリクスを生成し、プログラム要素の変更履歴にかかるコミット情報を取得し、コードメトリクスとコミット情報とに基づいて、プログラム要素のスコアを算出し、コードメトリクスに基づき、プログラム要素の保守性指標を算出し、スコアと保守性指標とに基づいて、複数に分割する候補となるプログラム要素のリストを生成することができる。スコアは、Long method Scoreであってもよい。
At this time, the
さらに、プロセッサ11は、サブアンチパターン定義情報に基づいて、分割すべきプログラム要素をサブアンチパターンに分類し、改善カタログ情報に基づいてソースコードの改善箇所を提示することができる。
Further, the
コードメトリクスは、ソースコードの一連の基準に従ってソースコード13Bを数値化した値である。例えば、コードメトリクスとして、ソースコード13Bを解析して生成されたプログラム要素の長さ及び複雑度にかかる数値を用いることができる。プログラム要素は、プログラムの構成要素である。例えば、プログラム要素は、モジュール、クラス、ファイル、メソッド、フィールド、関数、変数などである。Long Method Scoreは、プログラム要素が大きすぎるメソッドであるためにプログラム要素の可読性が低いという特徴を数値で示したものである。保守性指標は、ソフトウェアの変更にかかる手間に影響する特性を数値で示したものである。サブアンチパターンは、Long Methodの種類ごとにアンチパターンを分類したものである。サブアンチパターン定義情報は、サブアンチパターンを定義した情報である。改善カタログ情報は、サブアンチパターンに対するプログラム改善方法を示す情報である。
The code metrics are values obtained by digitizing the
なお、ソースコード解析プログラム13Aの実行は、複数のプロセッサやコンピュータに分担させてもよい。あるいは、プロセッサ11は、通信装置16を介してクラウドコンピュータなどにソースコード解析プログラム13Aの全部または一部の実行を指示し、その実行結果を受け取るようにしてもよい。
The execution of the source
図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
これらの機能は、例えば、プロセッサ11が、主記憶装置12や補助記憶装置13に格納されているプログラムを読み出して実行することにより実現することができる。あるいは、これらの機能は、例えば、ソースコード解析装置10Aが備えるハードウェア(ASIC(Application Specific Integrated Circuit)等)によって実現することができる。
These functions can be realized, for example, by the
ソースコード解析にあたって、ソースコード解析装置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
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
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
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
ここで、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
情報記憶部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
ここで、ソースコード解析装置10Aは、コードメトリクス117およびコミット情報108に基づいてLong Method Score118を生成し、Long Method Score118に基づいてプログラム要素がLong Methodかどうかを判定することにより、ソースコード109に含まれる分割すべきプログラム要素を提示することが可能となる。このため、リファクタリング作業者は、メソッドの分割箇所について自ら判断することなく、メソッド内のどの箇所でメソッド分割を行えばよいのかについて認識することができ、機能の拡張または変更が繰り返されたソフトウェアの可読性を向上させることができる。
Here, the source
図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
図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
図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
図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
図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
図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
図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
図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
この時、Long Method Score118は、コミット情報108とコードメトリクス117のいずれか一方または両方から計算される。Long Method Scoreの計算方法については問わない。コミット情報108の読み込み(902)とコードメトリクス117の読み込み(903)の順序については問わない。
At this time, the
次に、Long Method Score計算部102は、そのプログラム要素のコミット情報108およびコードメトリクス117に基づいてLong Method Score118を計算し、901に戻る(904)。全てのプログラム要素に対してLong Method Score118を計算すると、処理を終了する。
Next, the Long Method
Long Method Score118の計算に用いられるコードメトリクス117は、例えば、コメント抜き行数、循環的複雑度、コメント行数およびローカル変数宣言数である。Long Method Score118の計算に用いられるコミット情報108は、例えば、コミット当たりの変更箇所数および重み付きコミット回数である。
The
図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
保守性指標とはソフトウェアの保守のしやすさを示すコードメトリクスである。保守性指標の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
Long Method条件設定部104Aは、全てのプログラム要素に対してLong Method Score118および保守性指標119を読み込むと、Long Method Score閾値112および保守性指標閾値113に対して初期値を設定する(1104)。ここで、初期値としてどのような値を選んでもよい。
When reading the
次に、Long Method条件設定部104Aは、保守性指標を横軸、プログラム要素数を縦軸としたヒストグラムを表示する(1105)。このヒストグラムの表示は、閾値設定者がLong Method Score閾値112および保守性指標閾値113の設定を行うのを支援する。
Next, the Long Method
次に、Long Method条件設定部104Aは、Long Method Scoreを横軸、プログラム要素数を縦軸としたヒストグラムを表示する(1106)。このヒストグラムの表示は、閾値設定者がLong Method Score閾値112および保守性指標閾値113の設定を行うのを支援する。
Next, the Long Method
次に、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
次に、Long Method条件設定部104Aは、閾値設定者にて入力された数値をLong Method Score閾値112および保守性指標閾値113として設定すると、1105に戻る。そして、Long Method条件設定部104Aは、閾値設定者が閾値の設定を続けないと判断するまで、1105〜1109の処理を繰り返し、閾値設定者が閾値の設定を続けないと判断すると、処理を終了する。
Next, the Long Method
なお、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
図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
次に、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
次に、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
なお、空のLong Methodリスト120Aの用意(1201)、Long Method Score閾値112の読み込み(1202)および保守性指標閾値113の読み込み(1203)の順序については問わない。また、Long Method Score118の読み込み(1205)および保守性指標119の読み込み(1206)の順序については問わない。
The order of preparing the empty
図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
図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
このように、Long Method Score118および保守性指標119を用いることで、アンチパターンの1つであるLong Methodに該当するプログラム要素を見つけ出し、分割すべきプログラム要素としてリスト化することができる。この時、閾値設定者は、図13または図14のヒストグラムを参考にLong Method Score閾値112と保守性指標閾値113を変更することにより、Long Methodとして抽出されるプログラム要素の個数を変化させることができる。
As described above, by using the
(第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
図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
ソースコード解析にあたって、ソースコード解析装置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
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閾値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
ここで、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
ここで、ソースコード解析装置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
図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
また、可読性低下ワード条件114として、例えば、「(理解|認識|考慮|確認|見直|検討|修正)*(漏れ|不足|不十分|怠|忘れ|失念)」を設定する。この例では、可読性低下ワード条件114を正規表現の形で示しているが、この方法に限らず自然言語のマッチング条件を表現可能な任意の方法でよい。また、可読性低下ワード条件114に用いる単語およびその組合せについても、可読性低下を表すものであれば任意の単語の任意の組合せでよい。
As the readability lowering
図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条件設定部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条件設定部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
次に、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
次に、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
次に、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
なお、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リスト生成部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リスト生成部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リストの用意(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
図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
このように、Long Method Score118および保守性指標119を用いるとともに、プログラム要素が可読性低下ワードを含むかどうかを判断することでアンチパターンの1つであるLong Methodに該当するプログラム要素の判定精度を向上させることができる。
As described above, by using the
(第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
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
(第4実施形態)
第4実施形態は、図7のLong Methodリスト120Aまたは図21のLong Methodリスト120Bを生成後、さらに、Long Methodリスト120A、120B中の各プログラム要素をサブアンチパターンに分類し、サブアンチパターンに応じて改善箇所を示したソースコードを生成する。
(Fourth embodiment)
In the fourth embodiment, after generating the
図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-
ソースコード解析にあたって、ソースコード解析装置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
サブアンチパターン分類部106は、解析対象となるソースコード109と、サブアンチパターン定義情報115と、プログラム要素変更履歴110と、コードメトリクス117と、Long Methodリスト120Bを受け付けて、サブアンチパターンリスト121を生成する。改善箇所マッピング部107は、ソースコード109と、改善カタログ情報116を受け付けて、改善箇所を示したソースコード122を生成する。ソースコードの改善箇所はプログラムの行単位またトークン単位で示すことができる。
The sub-anti-
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
ここで、ソースコード解析装置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-
なお、図22では、図15のソースコード解析装置10Bの構成にサブアンチパターン分類部106と改善箇所マッピング部107を追加した構成を示したが、図2のソースコード解析装置10Aの構成にサブアンチパターン分類部106と改善箇所マッピング部107を追加してもよい。
FIG. 22 shows a configuration in which a sub-anti-
図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-
サブアンチパターン定義2302において、1つのプログラム要素が複数のサブアンチパターンに当てはまるような定義になっていてもよい。また、サブアンチパターン定義2302の記述方法は問わないが、ソースコード109と、コードメトリクス117と、プログラム要素変更履歴110の組合せで定義することができる。サブアンチパターンとして、例えば、「箇条書き」が挙げられる。これは複数の処理ブロックを一連の処理として記述したサブアンチパターンである。その他にも、多くの条件文からなるサブアンチパターンである「大量の条件文」や、状態遷移を行っているコード中で当該状態での処理本体と、状態遷移のための処理を混同して記述したサブアンチパターンである「状態遷移」が挙げられる。さらに、本来の処理に例外処理が追加されているサブアンチパターンである「塩漬け」が挙げられる。
The sub-anti-
図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-
例えば、プログラム要素1は、図23のサブアンチパターン定義2302で定義されたサブアンチパターンA1に該当するものとすると、プログラム要素1のサブアンチパターン分類レコード2402にサブアンチパターンA1という名称2301が追記される。また、プログラム要素2は、図23のサブアンチパターン定義2302で定義されたサブアンチパターンA2に該当するものとすると、プログラム要素2のサブアンチパターン分類レコード2402にサブアンチパターンA2という名称2301が追記される。
For example, assuming that the
なお、当該プログラム要素に複数のサブアンチパターンが当てはまる場合、同一のプログラム要素名でサブアンチパターンの異なる複数のサブアンチパターン分類レコード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
図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
図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-
次に、サブアンチパターン分類部106は、Long Methodリスト120B中の全てのプログラム要素に対してコードメトリクス117およびプログラム要素変更履歴110を読み込んだかどうかを判断する(2605)。Long Methodリスト120B中の全てのプログラム要素に対してコードメトリクス117およびプログラム要素変更履歴110を読み込んでいない場合、サブアンチパターン分類部106は、コードメトリクス117およびプログラム要素変更履歴110を読み込む(2606、2607)。取得するコードメトリクスの種類としては、サブアンチパターン定義情報115に記載のあるものを選択する。
Next, the sub-anti-
次に、サブアンチパターン分類部106は、Long Methodリスト120B中のプログラム要素のソースコードパターン、コードメトリクス117およびプログラム要素変更履歴110がサブアンチパターン定義を満たすかどうかの判断を全てのサブアンチパターン定義情報115に対して実施したかどうかを判断する(2608)。Long Methodリスト120B中のプログラム要素のソースコードパターン、コードメトリクス117およびプログラム要素変更履歴110がサブアンチパターン定義を満たすかどうかの判断を全てのサブアンチパターン定義情報115に対して実施していない場合、サブアンチパターン分類部106は、プログラム要素のソースコードパターン、コードメトリクス117およびプログラム要素変更履歴110がサブアンチパターン定義を満たすかどうかを判断する(2609)。
Next, the sub-anti-
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-
なお、空のサブアンチパターンリスト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
図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
なお、ソースコード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
(第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
図28の例では、プログラム要素のソースコード2801がLong Methodとして抽出されている。この時、Long Methodリスト生成部105Bは、当該プログラム要素のソースコード2801をLong Methodリスト120Bに登録する。
In the example of FIG. 28, the
このソースコード2801は、本来の処理に例外処理R1、R2が追加されているサブアンチパターンである。この時、サブアンチパターン分類部106は、本来の処理に例外処理R1、R2が追加されているサブアンチパターンとして、当該プログラム要素のソースコード2801をサブアンチパターンリスト121に登録する。
This
改善箇所マッピング部107は、当該プログラム要素のソースコード2801中の改善対象箇所2802として例外処理R1、R2を特定する。そして、改善箇所マッピング部107は、例外処理R1、R2を関数化したコードを、改善方法を示すソースコード2803として提示する。
The improvement
これにより、リファクタリング作業者は、メソッドの分割箇所について自ら判断することなく、当該プログラム要素のソースコード2801から例外処理R1、R2を分割することができ、本来の処理に例外処理R1、R2が追加されたソフトウェアの可読性を向上させることができる。
As a result, the refactoring operator can divide the exception processes R1 and R2 from the
(第7実施形態)
Long Method Score計算部102は、Long Method Scoreの計算方法として可読性スコアおよび変更発生スコアの調和平均を用いる。上述した第5実施形態では、可読性スコアと変更発生スコアをどのように用いてLong Method Score118を計算するかについては問わないとしたが、本実施形態では、その計算方法を可読性スコアおよび変更発生スコアの調和平均とする。ただし、可読性スコアおよび変更発生スコアの計算方法は問わない。調和平均は、逆数の算術平均の逆数として定義される。すなわち、本実施例では何らかの方法で求めた可読性スコアの逆数と、何らかの方法で求めた変更発生スコアの逆数の算術平均を計算し、その逆数をLong Method Score118とする。
(Seventh embodiment)
The Long Method
例えば、可読性低下スコアは、コメント抜き行数、循環的複雑度、コメント行数およびローカル変数宣言数を正規化した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
(第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
図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
ソースコード解析装置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
設定タブ3002は、改善カタログ情報116を選択するための改善カタログ情報選択部3007と、サブアンチパターン定義情報115を選択するためのサブアンチパターン定義情報選択部3008を備える。ソースコード解析装置10Cの利用者は、ソースコード解析装置10Cの初回利用時に改善カタログ情報選択部3007と、サブアンチパターン定義情報選択部3008を用いて各データを選択する。2回目以降の利用であっても、改善カタログ情報116およびサブアンチパターン定義情報115を変更する必要がある場合は、改善カタログ情報選択部3007およびサブアンチパターン定義情報選択部3008を用いて各データを選択する。
The
図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
閾値設定タブ3101は、Lone Method Score閾値112を設定するためのLong Method Score閾値選択部3105と、保守性指標閾値113を選択するための保守性指標閾値選択部3106と、可読性低下ワード条件114を選択するための可読性低下ワード条件選択部3107を備える。
The
ソースコード解析装置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
ヒストグラムタブ3102は、保守性指標ヒストグラムタブ3103と、Long Method Scoreヒストグラムタブ3104を備える。保守性指標ヒストグラムタブ3103内には図19に示した内容が描かれており、Long Method Scoreヒストグラムタブ3104内には図20に示した内容が描かれている。
The
ソースコード解析装置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
図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
図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
ソースコード解析装置10Cの利用者が解析対象選択戻るボタン3302を押下すると、解析対象選択画面2901へと遷移する。一方、Long Method一覧戻るボタン3303を押下すると、Long Method一覧画面2903へと遷移する。
When the user of the source code analysis device 10C presses the analysis object
10…ソースコード解析装置、11…プロセッサ、12…主記憶装置、13…補助記憶装置、14…入力装置、15…出力装置、16…通信装置、17…バス
DESCRIPTION OF
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.
前記スコアは、Long method Scoreであるソースコード解析方法。 In claim 1,
The source code analysis method, wherein the score is a Long method Score.
前記リスト生成部は、スコア閾値または/及び保守性指標閾値を用いて、前記リストを作成するソースコード解析方法。 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.
条件設定部は、前記スコアまたは保守指標性の軸と、前記スコアまたは保守指標性に該当するプログラム要素数の軸を有するグラフを出力し、ユーザから前記スコア閾値または/及び保守性指標閾値の設定を受け付けるソースコード解析方法。 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.
前記グラフは、前記スコア及び前記保守指標性の両方が視認できるグラフであるソースコード解析方法。 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.
前記スコア計算部は、さらに各プログラム要素のバグ発生にかかるバグ履歴情報を用いて、前記プログラム要素のスコアを算出するソースコード解析方法。 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.
前記バグ履歴情報には、バグの原因が含まれており、
前記バグ原因に含まれうる特定のワードを規定した可読性低下ワード条件をさらに用いて、前記スコア計算部は、前記プログラム要素のスコアを算出するソースコード解析方法。 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.
サブアンチパターンを定義したサブアンチパターン定義情報を有し、
サブアンチパターン分類部は、前記スコア、前記ソースコード、前記コードメトリクスに基づいて、前記スコアに記載されたプログラム要素をサブアンチパターンに分類したサブアンチパターンリストを生成するソースコード解析方法。 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.
改善箇所マッピング部が、前記アンチパターンリストと、改善カタログとに基づいて、改善個所を示したソースコードを生成するソースコード解析方法。 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.
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)
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)
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)
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 |
-
2018
- 2018-06-19 JP JP2018116066A patent/JP2019219848A/en active Pending
-
2019
- 2019-05-08 CN CN201910378645.1A patent/CN110618926A/en active Pending
Cited By (2)
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 |