JP7029915B2 - Source code analyzer and source code analysis method - Google Patents
Source code analyzer and source code analysis method Download PDFInfo
- Publication number
- JP7029915B2 JP7029915B2 JP2017184915A JP2017184915A JP7029915B2 JP 7029915 B2 JP7029915 B2 JP 7029915B2 JP 2017184915 A JP2017184915 A JP 2017184915A JP 2017184915 A JP2017184915 A JP 2017184915A JP 7029915 B2 JP7029915 B2 JP 7029915B2
- Authority
- JP
- Japan
- Prior art keywords
- graph
- program
- program element
- source code
- software
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Stored Programmes (AREA)
Description
本発明は、ソースコード解析装置およびソースコード解析方法に係り、特に、ソフトウェア開発におけるソースコードにおける保守性を低下させる要因の有無を解析するのに好適なソースコード解析装置およびソースコード解析方法に関する。 The present invention relates to a source code analysis device and a source code analysis method, and more particularly to a source code analysis device and a source code analysis method suitable for analyzing the presence or absence of factors that reduce maintainability in source code in software development.
近年のソフトウェア開発では、開発済みの母体ソフトウェアを拡張または変更することによって新しいソフトウェアを開発する派生開発が主流である。ソフトウェアの派生開発においては、長年に渡る機能拡張または変更の繰り返しにより、ソフトウェアが複雑化し、ソースコードの可読性が低下しやすい。このような状況を解決するため、ソフトウェアのリファクタリング(refactoring)が一般的に行われている。リファクタリングとは、ソフトウェアの振る舞いを変えず、その内部構造を改善していくことである。保守性が低い関数、クラス、ファイルなどのプログラム構成要素(以下、「プログラム要素」という)を適切にリファクタリングすれば、ソフトウェアが拡張または変更しやすくなる。 In recent software development, derivative development that develops new software by extending or modifying the developed parent software is the mainstream. In the development of derivative software, the readability of the source code tends to decrease due to the complexity of the software due to repeated enhancements or changes over many years. Software refactoring is commonly used to solve this situation. Refactoring is to improve the internal structure of software without changing its behavior. Appropriate refactoring of program components (hereinafter referred to as "program elements") such as functions, classes, and files that are not maintainable makes it easier for software to extend or change.
リファクタリングにおける重要な概念として、「アンチパターン」がある。アンチパターンとは、保守性が低いプログラム要素が持つ特徴(以下、「問題特徴」という)と、当該問題特徴を持つプログラム要素のリファクタリング方法のパターンをまとめたものである。リファクタリング対象ソフトウェアにおいて、アンチパターンが示すような問題特徴を持つプログラム要素を特定できれば、アンチパターンを適用することでリファクタリングすることができる。 An important concept in refactoring is "anti-patterns". An anti-pattern is a collection of features of a program element with low maintainability (hereinafter referred to as "problem feature") and a pattern of refactoring method of the program element having the problem feature. In the software to be refactored, if a program element having a problem characteristic as shown by the anti-pattern can be identified, it can be refactored by applying the anti-pattern.
例えば、特許文献1には、ソースコード、構成管理システムまたは稼動ログからメトリクスを計測し、ソースコードのアンチパターン該当可否を評価する手法が記載されている。これにより、リファクタリングが必要ない複雑なソースコードを抽出せず、真にリファクタリングが必要なソースコードを特定することができる。
For example,
上記特許文献1に記載されている手法では、ソースコードをプログラム解析して得られるプログラム要素の特徴量(以下、「ソフトウェアメトリクス」という)を用いて、当該プログラム要素が問題特徴を備えているか否かを判定している。しかしながら、アンチパターンが示す問題特徴の中には、ソフトウェアメトリクスを用いるだけではプログラム要素が当該問題特徴を備えているか否かを判定しづらいものがある。ここでは、そのような以下、Shotgun surgeryおよびThe Blobという二つのアンチパターンを例に採って説明する。
In the method described in
Shotgun surgeryは、当該プログラム要素を拡張または変更すると多くの他のプログラム要素も同時に拡張または変更されるという問題特徴を持つプログラム要素をリファクタリングするためのパターンである。Shotgun surgeryが示す問題特徴は、プログラム要素そのものの特徴ではなく、プログラム要素の変更に関する特徴であるため、ソフトウェアメトリクスを用いて当該問題特徴を持つプログラム要素を特定するのは難しい。 Shotgun surgery is a pattern for refactoring a program element that has the problem feature that when the program element is extended or changed, many other program elements are also extended or changed at the same time. Since the problem characteristics shown by Shotgun surgery are not the characteristics of the program element itself but the characteristics related to the change of the program element, it is difficult to identify the program element having the problem characteristic by using software metrics.
The Blobは、複数の機能が1箇所にまとめて実装されているという問題特徴を持つプログラム要素をリファクタリングするためのパターンである。The Blobが示す問題特徴を持つプログラム要素は、大規模化または複雑化する傾向があるため、その特定には、プログラム要素の規模または複雑度というソフトウェアメトリクスが有効である。しかしながら、単一の機能が実装されたプログラム要素でも規模や複雑度が大きくなる場合はあるため、判定結果にはノイズが載りやすく、判定結果に信頼性が欠けがちになるという傾向がある。一方で、The Blobが示す問題特徴を持つプログラム要素は、当該プログラム要素が実装する複数の機能が拡張または変更されるたびに併せて拡張または変更される場合が多く、The Blobに対処することは特に重要な課題になることが多い。 The Blob is a pattern for refactoring program elements that have the problematic feature that multiple functions are implemented together in one place. Since the program elements with the problematic characteristics shown by The Blob tend to be large or complicated, the software metric of the scale or complexity of the program elements is effective for identifying them. However, since the scale and complexity of a program element in which a single function is implemented may increase, noise tends to appear in the judgment result, and the judgment result tends to lack reliability. On the other hand, a program element with the problematic characteristics indicated by The Blob is often expanded or changed at the same time when multiple functions implemented by the program element are expanded or changed, and it is not possible to deal with The Blob. Often it is a particularly important issue.
リファクタリングを適切におこなうためには、プログラム要素の変更をどうように管理するかが特に重要である。しかしながら、上記特許文献1に記載の技術では、アンチパターンが示す問題特徴をプログラム要素が備えているか否かを判定するためには、ソフトウェアメトリクスを考慮しているが、プログラム要素の変更に関する情報については考慮されていない。
How to manage changes in program elements is especially important for proper refactoring. However, in the technique described in
本発明の目的は、プログラム要素が問題特徴を備えているか否かを、プログラム要素の変更履歴を用いて判定し、解析結果を表示するソースコード解析装置を提供することにある。 An object of the present invention is to provide a source code analysis device that determines whether or not a program element has a problem feature by using a change history of the program element and displays an analysis result.
本発明のソースコード解析装置の構成は、好ましくは、解析対象のプログラムのソースコードの保守性に関する問題を指摘するソースコード解析装置であって、解析対象のプログラムの変更履歴と、プログラムの変更に関する指標の閾値を入力して、プログラム要素の変更依存関係ルールを出力するロジカルカップリング分析部と、変更依存関係ルールに基づいて、プログラム要素をノード、変更前のプログラム要素のノードから変更後のプログラム要素のノードに向けた有向辺として、プログラム要素の変更依存関係を表現したロジカルカップリンググラフを生成するロジカルカップリング生成部と、生成されたロジカルカップリンググラフと、プログラム要素毎に定められたグラフパラメータに関する情報に基づいて、ロジカルカップリンググラフにおいて保守性の低いプログラム要素を検出して、保守性の低いプログラム要素のノードを強調したアンチパターングラフとするアンチパターン検出部と、アンチパターングラフを表示するアンチパターン表示部とからなるようにしたものである。 The configuration of the source code analysis device of the present invention is preferably a source code analysis device that points out a problem regarding the maintainability of the source code of the program to be analyzed, and is related to the change history of the program to be analyzed and the change of the program. The logical coupling analysis unit that inputs the threshold value of the index and outputs the change dependency rule of the program element, and the program element after the change from the node of the program element before the change and the node of the program element before the change based on the change dependency rule. As the directed side toward the node of the element, the logical coupling generator that generates the logical coupling graph expressing the change dependency of the program element, the generated logical coupling graph, and the generated logical coupling graph are defined for each program element. An anti-pattern detector that detects a program element with low maintainability in a logical coupling graph based on information about graph parameters and makes it an anti-pattern graph that emphasizes the nodes of the program element with low maintainability, and an anti-pattern graph. It consists of an anti-pattern display unit to be displayed.
本発明によれば、プログラム要素が問題特徴を備えているか否かを、プログラム要素の変更履歴を用いて判定し、解析結果を表示するソースコード解析装置を提供することができる。 According to the present invention, it is possible to provide a source code analysis device that determines whether or not a program element has a problem feature by using a change history of the program element and displays an analysis result.
以下、本発明に係る各実施形態を、図1ないし図32を用いて説明する。 Hereinafter, each embodiment of the present invention will be described with reference to FIGS. 1 to 32.
〔実施形態1〕
以下、本発明の実施形態1を、図1ないし図18を用いて説明する。
先ず、図1および図2を用いて実施形態1のソースコード解析装置の構成について説明する。
[Embodiment 1]
Hereinafter,
First, the configuration of the source code analysis apparatus of the first embodiment will be described with reference to FIGS. 1 and 2.
ソースコード解析装置10は、図1に示すように、ロジカルカップリング分析部101と、ロジカルカップリンググラフ生成部103と、アンチパターン検出部104と、情報記憶部105、アンチパターン表示部119の各機能部を備える。
As shown in FIG. 1, the source
これらの機能は、例えば、プロセッサ11が、主記憶装置12や補助記憶装置13に格納されているプログラムを読み出して実行することにより実現される。またこれらの機能は、例えば、ソースコード解析装置10が備えるハードウェア(ASIC(Application Specific Integrated Circuit)等)によって実現される。
These functions are realized, for example, by the
情報記憶部105は、変更依存関係ルールテーブル114と、ロジカルカップリンググラフ116と、プログラム要素情報117を、補助記憶装置13に記憶する。情報記憶部105は、これらの情報以外にも、ロジカルカップリング分析部101や、ロジカルカップリンググラフ生成部103や、アンチパターン検出部104が適宜参照もしくは生成する情報等を記憶する。情報記憶部105は、補助記憶装置13に記憶する情報を、例えば、ファイルシステムやDBMS(DataBase Management System)によって管理する。なお、これらのデータについての具体例は後に詳述する。
The
ロジカルカップリング分析部101は、ソースコード解析にあたって、解析対象となるソースコードのプログラム要素変更履歴106と、バスケット解析閾値テーブル107を受け付けて、変更依存関係ルールテーブル114を生成する機能部である。
The logical
ロジカルカップリンググラフ生成部103は、変更依存関係ルールテーブル114と、グラフパターンマッチロジックを受け付けて、ロジカルカップリンググラフ116およびプログラム要素情報117を生成する機能部である。
The logical coupling
アンチパターン検出部104は、ロジカルカップリンググラフ116と、上記プログラム要素情報117を受け付けて、アンチパターングラフ118を生成する機能部である。
The
アンチパターン表示部119は、アンチパターングラフ118を表示する機能部である。
The
次に、図2を用いて実施形態1のソースコード解析装置のハードウェア・ソフトウェア構成について説明する。 Next, the hardware / software configuration of the source code analysis device of the first embodiment will be described with reference to FIG.
ソースコード解析装置10は、ソフトウェアシステムの開発や保守等に利用される情報処理装置(コンピュータ)である。ソースコード解析装置10は、クラウドシステムにより提供されるクラウドサーバ等のように仮想的に実現されるものであてもよい。
The source
ソースコード解析装置10は、図2に示されるように、プロセッサ11、主記憶装置12、補助記憶装置13、入力装置14、出力装置15、通信装置16がバス5により接続され、互いに通信可能になっている。
As shown in FIG. 2, the source
プロセッサ11は、例えば、CPU(Central Processing Unit)やMPU(Micro Processing Unit)を用いて構成されている。プロセッサ11が、主記憶装置12に格納されているプログラムを読み出して実行することにより、ソースコード解析装置10の様々な機能が実現される。主記憶装置12は、プログラムやデータを記憶する装置であり、例えば、ROM(Read Only Memory)、RAM(Random Access Memory)、不揮発性半導体メモリ(NVRAM(Non Volatile RAM))等である。
The
補助記憶装置13は、例えば、HDD(Hard Disk Drive:ハードディスクドライブ)、SSD(Solid State Drive)、光学式記憶装置(CD(Compact Disc)、DVD(Digital Versatile Disc)等)、ストレージシステム、ICカード、SDメモリカードや光学式記録媒体等の記録媒体の読取/書込装置、クラウドサーバの記憶領域等である。補助記憶装置13に格納されているプログラムやデータは主記憶装置12に随時ロードされて、実行される。
The
本実施形態では、図示しないOS(Operating System)や各種ユーティリティのほか、ロジカルカップリング分析プログラム1301、ロジカルカップリンググラフ生成プログラム1302、アンチパターン検出プログラム1303、アンチパターン表示プログラム1304がインストールされている。ロジカルカップリング分析プログラム1301、ロジカルカップリンググラフ生成プログラム1302、アンチパターン検出プログラム1303、アンチパターン表示プログラム1304は、それぞれロジカルカップリング分析部101や、ロジカルカップリンググラフ生成部103や、アンチパターン検出部104、アンチパターン表示部119の各機能を実行するためのプログラムである。
In this embodiment, in addition to an OS (Operating System) and various utilities (not shown), a logical
また、補助記憶装置13は、プログラム要素変更履歴106と、バスケット解析閾値テーブル107、グラフパターンマッチロジック110、グラフパラメータ閾値テーブル112、パラメータ論理式113、変更依存関係ルールテーブル114、ロジカルカップリンググラフ116、プログラム要素情報117、アンチパターングラフ118を格納している。なお、各種データの詳細は後に詳述する。
Further, the
入力装置14は、例えば、キーボード、マウス、タッチパネル、カードリーダ、音声入力装置等である。出力装置15は、ユーザに処理経過や処理結果等の各種情報を提供するユーザインターフェースを実現するための装置であり、例えば、画面表示装置(液晶モニタ:LCD(Liquid Crystal Display))、グラフィックカード、音声出力装置(スピーカ等)、印字装置等である。なお、例えば、ソースコード解析装置10が通信装置16を介して他の装置との間で情報の入力や出力を行う構成としてもよい。
The
通信装置16は、LANやインターネット等の通信手段を介した他の装置との間の通信を実現する有線方式または無線方式の通信インタフェースであり、例示すれば、NIC(Network Interface Card)、無線通信モジュール、USB(Universal Serial Interface)モジュール、シリアル通信モジュール等である。
The
次に、図3ないし図13を用いて実施形態1のソースコード解析装置に使用されるデータ構造について説明する。 Next, the data structure used in the source code analysis apparatus of the first embodiment will be described with reference to FIGS. 3 to 13.
図3に示されるプログラム要素変更履歴106は、解析対象となるプログラムに発生した変更の履歴を、変更が発生するたびに変更履歴レコード303として記録したものである。変更履歴レコード303は、変更番号301と、以上の変更プログラム要素名302のフィールドで構成される。変更番号301は、当該変更履歴レコード303を識別するために一意に付与される識別子を格納するフィールドである。変更プログラム要素名302は、当該変更履歴レコード303に対応するプログラム変更発生時に同時変更された一つ以上の変更プログラム要素名を格納するフィールドである。プログラム要素とは、既に説明したように、関数、クラス、ファイルなどのプログラム構成要素である。
The program
例えば、変更番号301が「1」の変更履歴レコード303に対応する変更発生時には、変更プログラム要素名302に記載された「プログラム要素A、プログラム要素B、プログラム要素C」のプログラム要素が同時変更されている。
For example, when a change corresponding to the
プログラム要素変更履歴106には、例えば、解析対象となるプログラムをバージョン管理するバージョン管理システムの変更履歴情報を用いてもよい。この場合、一般的なバージョン管理システムではファイル単位でバージョン管理するため、解析対象となるプログラム要素の種類はファイルとなる。または、プログラム要素変更履歴106には、当該変更履歴情報をプログラム構造情報に基づいてクラス単位またはファイル単位の変更履歴情報に変換したものを用いてもよい。この場合、解析対象となるプログラム要素の種類はクラスまたはファイルとなる。
また、変更履歴として、プログラム要素の更新日付が加わっていてもよい。
For the program
Further, the update date of the program element may be added as the change history.
図4に示されるバスケット解析閾値テーブル107は、ロジカルカップリング分析部101でバスケット解析を行うときに用いる閾値を記録したものである。ここで、なお、「バスケット解析」とは、データ分析の用語であり、同時に変更されるプログラム要素を、スーパーマーケットなどにおけるバスケットの中の商品と見立てて名づけられたものである。バスケット解析閾値テーブル107は、ルール評価値名401、閾値402の各フィールドを有する。閾値402は、ルール評価値名401に記載されたルール評価値を評価するときの0以上1以下の閾値が格納される。
The basket analysis threshold table 107 shown in FIG. 4 records the thresholds used when performing basket analysis in the logical
本実施形態のルール評価値には、支持度403、確信度404、リフト値405の三つがあり、それぞれに対して0以上1以下の閾値が記述されている。各々のルール評価値とその閾値の適用については、後に詳述する。
There are three rule evaluation values of the present embodiment, a
図5に示される変更依存関係ルールテーブル114は、同時変更されやすいプログラム要素の順序対を変更依存関係ルールレコード504として記録したものである。変更依存関係ルールテーブル114は、ロジカルカップリング分析部101でバスケット解析を行った結果得られる情報を変更依存関係ルールとして、格納するテーブルである。
The change dependency rule table 114 shown in FIG. 5 records the ordered pair of program elements that are easily changed at the same time as the change
ここで、プログラム要素の順序対の順序対は、順序対の一つ目のプログラム要素が変更されたときに、当該順序対の二つ目のプログラム要素も同時に変更されやすいというルールを表している。変更依存関係ルールレコード504は、ルール番号501と、変更対象プログラム要素名502と、同時変更プログラム要素名503の各フィールドを有する。
Here, the ordered pair of the ordered pair of program elements represents a rule that when the first program element of the ordered pair is changed, the second program element of the ordered pair is also likely to be changed at the same time. .. The change
ルール番号501は、当該変更依存関係ルールレコード504を識別するために一意に付与される識別子を格納する。変更対象プログラム要素名502は、プログラム要素の順序対における一つ目のプログラム要素を格納する。同時変更プログラム要素名503は、上記順序対における二つ目のプログラム要素を格納する。
変更依存関係ルールテーブル114は、ロジカルカップリング分析部101でバスケット解析を行う前にレコードが登録されていない状態に初期化されているものとする。
It is assumed that the change dependency rule table 114 is initialized to a state in which no record is registered before the basket analysis is performed by the logical
図6に示されるロジカルカップリンググラフ116は、プログラム要素を頂点701とし、同時変更されやすいプログラム要素の順序対を有向辺702とした有向グラフである。このロジカルカップリンググラフ116は、ロジカルカップリンググラフ生成部103で作成され、出力装置15を用いてユーザに出力される。ユーザは、ロジカルカップリンググラフ116を見ることによって、プログラム要素間にどのような同時変更されやすい関係があるかを確認できる。ロジカルカップリンググラフ116は、ロジカルカップリンググラフ生成部103でロジカルカップリング作成処理を行う前に頂点と有向辺が登録されていない状態に初期化されているものとする。
The
図7に示されるグラフパターンマッチロジック110は、図6に示したロジカルカップリンググラフ116のグラフの頂点ごとに値が定まるグラフパラメータ値を取得するためのロジックを記録したものである。グラフパターンマッチロジック110は、取得したいグラフパラメータ値の種類ごとに作成され、グラフパラメータ名601とグラフパターンマッチロジック本体602で構成される。グラフパラメータ名601は、グラフの特徴を表すパラメータであり、例えば、有向グラフの頂点の入次数、出次数である。また、グラフパラメータとは、一般的にグラフ理論で定義されるような他の値を用いてもよい。グラフパターンマッチロジック本体602は、独自の論理記述言語を用いてもよいし、実行可能なプログラミング言語やスクリプトで記述してもよい。
The graph
図8に示されるプログラム要素情報117は、プログラム要素ごとに、図6に示したロジカルカップリンググラフ116の頂点701に関するグラフパラメータ値を記録したものである。プログラム要素情報117は、プログラム要素ごとに作成され、プログラム要素名801、当該プログラム要素に対応するパラメータテーブル802で構成される。パラメータテーブル802は、パラメータレコード805毎に、グラフパラメータ名803、パラメータ値804の各フィールドを有する。グラフパラメータ名803には、グラフパターンマッチロジック110で定義されたグラフパラメータ名が格納される。パラメータ値804は、グラフパラメータ名803に対応するパラメータの値が格納される。パラメータ値804の値には、図7に示した対応するグラフパターンマッチロジック110で定義されたグラフパターンマッチロジック本体602を用いて取得したグラフパラメータ値が記録される。このプログラム要素情報117は、出力装置15を用いてユーザに出力される。ユーザは、プログラム要素情報117を見ることによって、プログラム要素に対応するグラフ要素がどのようなグラフパラメータ値を持つかを確認できる。プログラム要素情報117は、ロジカルカップリンググラフ生成部103でプログラム要素情報作成処理を行う前に、未作成状態に初期化されているものとする。
The
図9に示されるグラフパラメータ閾値テーブル112は、グラフパターンマッチロジック110で定義したグラフパラメータ名601に対し、当該パラメータ値が異常であると判断するための閾値をグラフパラメータ閾値レコード905として記録したテーブルである。グラフパラメータ閾値レコード905は、グラフパラメータ識別子901と、グラフパラメータ名902と、グラフパラメータ閾値903と、グラフパラメータ判定条件904のフィールドで構成される。
The graph parameter threshold table 112 shown in FIG. 9 is a table in which a threshold value for determining that the parameter value is abnormal is recorded as a graph
グラフパラメータ識別子901には、当該グラフパラメータ閾値レコード905を識別するために一意に付与される識別子が格納される。グラフパラメータ名902には、グラフパラメータの名称が格納される。グラフパラメータ閾値903には、異常であると判断するための閾値が格納される。グラフパラメータ判定条件904には、例えば、グラフパラメータに対応するグラフパラメータ値がグラフパラメータ閾値903と比べてどんな値をとる場合に異常とみなすかを判断するための判定条件が格納される。
The
ここで、グラフパラメータ判定条件904には、グラフパラメータ値とグラフパラメータ閾値903を比較するための関係演算子を記述している。なお、グラフパラメータ値をグラフパラメータ判定条件904およびグラフパラメータ閾値903を用いて評価した結果を、当該グラフパラメータ値に対する判定結果という。
Here, the graph
図10に示されるパラメータ論理式113は、複数のパラメータ値に対する判定結果を総合的に評価して、当該パラメータ値の組が異常であるか否かを判断するための論理式である。パラメータ論理式113は、論理学で用いられる一般的な文字や記号を用いて記述し、一般的な推論規則によってその真偽値が評価可能であるとする。例えば、パラメータ論理式113は、グラフパラメータ識別子901、論理演算記号(&または|)、括弧記号((または))などを用いて記述する。ここで、グラフパラメータ閾値テーブル112のグラフパラメータ識別子901の真偽値は、当該グラフパラメータ値804に対する判定結果とし、グラフパラメータ識別子901を原始論理式として論理演算記号を用いて得られる論理式の真偽値は、論理学の一般的な推論規則に従うものとする。
The parameter
図10に示される例では、グラフパラメータ閾値テーブル112のグラフパラメータ識別子901の表す論理式G1,G2に対し、G1またはG2であるときに、真であることを示している。すなわち、これは、(グラフパラメータA≧4)OR(グラフパラメータB≧6)でとるときに、真であることを意味している。
In the example shown in FIG. 10, it is shown that the logical expressions G1 and G2 represented by the
図11に示されるアンチパターングラフ118は、ロジカルカップリンググラフ116の頂点701において、特に問題特徴を有する頂点703を強調的に表現したものである。ロジカルカップリンググラフ116の頂点701が問題特徴を有する頂点703か否かは、当該頂点703に対応するプログラム要素のプログラム要素情報117に記録されたパラメータ値804およびグラフパラメータ閾値テーブル112を用いて、パラメータ論理式113で定義した方法によって評価した真偽値により判断する。ここで、当該真偽値が真である場合は、当該頂点は問題特徴を有する頂点703であり、当該真偽値が偽である場合は、当該頂点は問題特徴を有する頂点703であると判断する。問題特徴を有する頂点703の表現方法としては、当該頂点を着色または発光または点滅または拡大などの手法を採用してもよい。アンチパターングラフ118は、アンチパターン表示部119によって、出力装置15を用いてユーザに出力される。ユーザは、アンチパターングラフ118を見ることによって、プログラム要素間にどのような同時変更されやすい関係があるかを確認できる。
The
ここで、例として採り上げたThe Blobのアンチパターングラフの一例を示すと、図12に示されるようになる。頂点703aの入次数が極端に大きくなっている。すなわち、頂点703aの示すプログラム要素が複数の機能が1箇所にまとめて実装されているという問題特徴を有することを意味している。
Here, an example of the anti-pattern graph of The Blob taken as an example is shown in FIG. The degree of the
また、Shotgun surgeryのアンチパターングラフの一例を示すと、図13に示されるようになる。頂点703bの出次数が極端に大きくなっている。すなわち、頂点703bの示すプログラム要素が当該プログラム要素を拡張または変更すると多くの他のプログラム要素も同時に拡張または変更されるという問題特徴を有することを意味している。
Further, an example of an anti-pattern graph of Shotgun surgery is shown in FIG. The order of the
次に、図14ないし図18を用いて実施形態1のソースコード解析装置の処理について説明する。 Next, the processing of the source code analysis apparatus of the first embodiment will be described with reference to FIGS. 14 to 18.
先ず、図14を用いてロジカルカップリング分析部101の処理について説明する。
先ず、ロジカルカップリング分析部101は、図3に示したプログラム要素変更履歴106を読み込む(S1201)。次に、バスケット解析閾値テーブル107を読み込む(S1202)。
First, the processing of the logical
First, the logical
ロジカルカップリング分析部101は、読み込んだプログラム要素変更履歴106からプログラム要素の全ての順序対を生成し、各順序対(E1,E2)に対して以下のS1203~S1209の処理を実施する(S1203)。
The logical
順序対(E1,E2)に対する支持度を計算する(S1204)。ここで、順序対(E1,E2)に対する支持度とは、プログラム要素E1とE2の同時変更されやすさを表す0以上1以下の値であり、E1とE2を変更プログラム要素名302に含む変更履歴レコード303の数を全ての変更履歴レコード303の数で割った値である。
The degree of support for ordered pairs (E1, E2) is calculated (S1204). Here, the support degree for the ordered pair (E1, E2) is a value of 0 or more and 1 or less indicating the ease of simultaneous change of the program elements E1 and E2, and the change including E1 and E2 in the change
すなわち、順序対(E1,E2)に対する支持度は、次の(式1)で表される値である。 That is, the degree of support for the ordered pair (E1, E2) is a value represented by the following (Equation 1).
次に、順序対(E1,E2)に対する確信度を計算する(S1205)。ここで、順序対(E1,E2)に対する確信度とは、プログラム要素E1が変更されたときのE2の変更されやすさを表す0以上1以下の値であり、E1とE2を変更プログラム要素名302に含む変更履歴レコード303の数を、E1を変更プログラム要素名302に含む変更履歴レコード303の数で割った値である。
Next, the conviction for the ordered pair (E1, E2) is calculated (S1205). Here, the conviction for the ordered pair (E1, E2) is a value of 0 or more and 1 or less indicating the ease of change of E2 when the program element E1 is changed, and E1 and E2 are changed program element names. It is a value obtained by dividing the number of
すなわち、順序対(E1,E2)に対する確信度は、次の(式2)で表される値である。 That is, the conviction for the ordered pair (E1, E2) is a value represented by the following (Equation 2).
順序対(E1,E2)に対するリフト値を計算する(S1206)。ここで、順序対(E1,E2)に対するリフト値とは、プログラム要素E1の変更とE2の変更の相関関係について、値が1の場合は無相関、1より大きい場合は正の相関、1より小さい場合は負の相関があることを表す0以上の値である。順序対(E1,E2)に対するリフト値は、次の(式3)で表される値である。 The lift value for the ordered pair (E1, E2) is calculated (S1206). Here, the lift value for the ordered pair (E1, E2) is uncorrelated when the value is 1 and positive correlation when the value is larger than 1, regarding the correlation between the change of the program element E1 and the change of E2. When it is small, it is a value of 0 or more indicating that there is a negative correlation. The lift value for the ordered pair (E1, E2) is a value represented by the following (Equation 3).
次に、順序対(E1,E2)に対する支持度、確信度、およびリフト値の全てが、バスケット解析閾値テーブル107で与えたそれぞれのルール評価値401の閾値402を超過しているか否かを判定する(S1207)。
Next, it is determined whether all of the support, certainty, and lift values for the ordered pair (E1, E2) exceed the
支持度、確信度、リフト値およびリフト値の全てが閾値を超過している場合には(S1207:YES)、図5に示した変更依存関係ルールテーブル114に、一意的なルール番号501を付与した新しい変更依存関係ルールレコード504を追加し、当該変更依存関係ルールレコード504の変更対象プログラム要素名502にプログラム要素E1を、同時変更プログラム要素名503にプログラム要素E2を記録する(S1208)。
When the support level, the certainty level, the lift value, and the lift value all exceed the threshold value (S1207: YES), the change dependency rule table 114 shown in FIG. 5 is given a
支持度、確信度、リフト値およびリフト値のいずれかが閾値を超過していない場合には(S1207:NO)、何もしない。
以上を、全ての順序対(E1,E2)に対して実施する(S1203~S1209)。
If any of the support, certainty, lift value, and lift value does not exceed the threshold value (S1207: NO), nothing is done.
The above is carried out for all ordered pairs (E1, E2) (S1203 to S1209).
次に、図15を用いてロジカルカップリンググラフ生成部103の処理について説明する。
先ず、ロジカルカップリンググラフ生成部103は、図5に示した変更依存関係ルールテーブル114を読み込む(S1301)。
次に、図7に示したグラフパターンマッチロジックを読み込む(S1302)。
次に、ロジカルカップリンググラフ生成処理をおこなう(S1303)。ロジカルカップリンググラフ生成処理は、サブルーチンとして、次に、図16を用いて説明する。
次に、プログラム要素情報生成処理をおこなう(S1304)。プログラム要素情報生成処理は、サブルーチンとして、後に、図17を用いて説明する。
Next, the processing of the logical coupling
First, the logical coupling
Next, the graph pattern matching logic shown in FIG. 7 is read (S1302).
Next, a logical coupling graph generation process is performed (S1303). The logical coupling graph generation process will be described as a subroutine next with reference to FIG.
Next, the program element information generation process is performed (S1304). The program element information generation process will be described later as a subroutine with reference to FIG.
次に、図16を用いてロジカルカップリンググラフ生成処理(図15のS1303)について説明する。
ロジカルカップリンググラフ生成部103は、全てのプログラム要素Eに対して以下の処理を実施する(S1401~S1404)。図6に示したロジカルカップリンググラフ116に、プログラム要素Eに対応する頂点Nを追加する(S1402)。ロジカルカップリンググラフ生成部103は、頂点Nに対応する図8のプログラム要素情報117を作成し、プログラム要素名801にプログラム要素名としてプログラム要素Eを記録する(S1403)。
以上を、全てのプログラム要素Eに対して実施する(S1401~S1404)。
Next, the logical coupling graph generation process (S1303 in FIG. 15) will be described with reference to FIG.
The logical coupling
The above is carried out for all program elements E (S1401 to S1404).
次に、プログラム要素の全ての順序対(E1,E2)に対して以下の処理を実施する(S1405~S1407)。
次に、ロジカルカップリンググラフ116に、E1を始点、E2を終点とする有向辺を追加する(S1406)。
以上を、プログラム要素の全ての順序対(E1,E2)に対して実施する(S1405~S1407)。
Next, the following processing is performed for all ordered pairs (E1, E2) of the program elements (S1405 to S1407).
Next, a directed edge with E1 as the starting point and E2 as the ending point is added to the logical coupling graph 116 (S1406).
The above is carried out for all ordered pairs (E1, E2) of the program elements (S1405 to S1407).
次に、図17を用いてプログラム要素情報生成処理(図15のS1304)について説明する。
先ず、ロジカルカップリンググラフ116の全ての頂点Nに対して以下の処理を実施する(S1501~S1506)。
図7に示したグラフパターンマッチロジック110のグラフパターンマッチロジックLの全てに対して以下の処理を実施する(S1502~S1504)。
グラフパターンマッチロジックLのグラフパターンマッチロジック本体602を用いて、頂点NのグラフパターンマッチロジックLに対応するパラメータ値を取得する(S1503)。
以上を、全てのグラフパターンマッチロジックLに対して実施する(S1502~S1504)。
Next, the program element information generation process (S1304 in FIG. 15) will be described with reference to FIG.
First, the following processing is performed on all the vertices N of the logical coupling graph 116 (S1501 to S1506).
The following processing is performed on all of the graph pattern matching logic L of the graph
Using the graph pattern matching logic
The above is carried out for all graph pattern matching logic L (S1502 to S1504).
そして、頂点Nのグラフパラメータ値を頂点Nのプログラム要素情報117に追加する(S1505)。
以上を、ロジカルカップリンググラフの全ての頂点Nに対して実施する(S1501~S1506)。
Then, the graph parameter value of the vertex N is added to the
The above is carried out for all the vertices N of the logical coupling graph (S1501 to S1506).
次に、図18を用いてアンチパターン検出部104の処理について説明する。
先ず、図10に示したパラメータ論理式113を読み込む(S1601)。
Next, the process of the
First, the
次に、ロジカルカップリンググラフの全ての頂点Nに対して以下の処理を実施する(S1602~S1606)。
図8に示した頂点Nに対するプログラム要素情報117のグラフパラメータとその値、また、図9に示したグラフパラメータ閾値テーブルよりそのグラフパラメータの閾値、条件を読み込み、パラメータ論理式の真偽値を計算する(S1603)。そして、真偽値が真か偽かを判定する(S1604)。真偽値が真ならば(S1604:真)、アンチパターングラフ118における頂点Nを異常のあるプログラム要素に対応する頂点であるとして、強調表示するように設定する(S1605)。真偽値が偽ならば何もしない。これにより、頂点Nに対応するプログラム要素が問題特徴を有することが示されたことになる。
以上を、ロジカルカップリンググラフの全ての頂点Nに対して実施する(S1601~S1606)。
Next, the following processing is performed on all the vertices N of the logical coupling graph (S1602 to S1606).
The graph parameter and its value of the
The above is carried out for all the vertices N of the logical coupling graph (S1601 to S1606).
このように、問題特徴を有するプログラム要素をアンチパターングラフ118における問題特徴を有する頂点703として可視化することによって、アンチパターンが示す問題特徴をプログラム要素が備えているか否かをプログラム要素の変更履歴に基づき判定することができる。
In this way, by visualizing the program element having the problem feature as the
〔実施形態2〕
以下、本発明の実施形態2を、図19ないし図29を用いて説明する。
[Embodiment 2]
Hereinafter,
実施形態1では、アンチパターングラフを生成するための問題特徴を有するプログラム要素の特定を、プログラム要素の変更履歴によりおこなった。
本実施形態は、それに加えて、問題特徴を有するプログラム要素の特定を、ソフトウェアメトリクスにも基づいておこなおうとするものである。本実施形態では、実施形態1と異なる所を中心に説明する。
In the first embodiment, the program element having the problematic feature for generating the anti-pattern graph is specified by the change history of the program element.
In addition to that, the present embodiment attempts to identify a program element having a problematic feature based on software metrics. In this embodiment, the points different from those in the first embodiment will be mainly described.
先ず、図19および図20を用いて実施形態2のソースコード解析装置の構成について説明する。
ロック図である。
本実施形態のソースコード解析装置10は、図19に示すように、図1に示した実施形態1の場合に加えて、プログラム解析部102を備える。
First, the configuration of the source code analysis apparatus of the second embodiment will be described with reference to FIGS. 19 and 20.
It is a lock diagram.
As shown in FIG. 19, the source
情報記憶部105は、実施形態1の場合に加えて、ソフトウェアメトリクス情報115を、補助記憶装置13に記憶する。情報記憶部105は、これらの情報以外にも、プログラム解析部102部が適宜参照もしくは生成する情報等を記憶する。
In addition to the case of the first embodiment, the
ソフトウェアメトリクスとは、既に説明したように、ソースコードをプログラム解析して得られるプログラム要素の特徴量であり、具体的には、ソースコードの複雑度、ソースコードのステップ数、ソースコードの保守容易性指数、関数やサブルーチンの引数の個数、ソースコードに埋め込むコメントの割合などが考えられる。 As already explained, software metrics are the feature quantities of program elements obtained by program analysis of source code. Specifically, the complexity of source code, the number of steps in source code, and the ease of maintenance of source code. The sex index, the number of arguments of functions and subroutines, the ratio of comments to be embedded in the source code, etc. can be considered.
ソースコード解析装置10は、実施形態1の場合に加えて、プログラム解析部102を具備しており、ソースコード解析にあたって、プログラム解析部102は、解析対象となるソースコード108と、ソフトウェアメトリクス取得ロジック109を受け付けて、ソフトウェアメトリクス情報115を生成する。また、ロジカルカップリンググラフ生成部103は、実施形態1の場合に加えて、ソフトウェアメトリクス情報115を受け付けて、ソフトウェアメトリクスに関する情報を含むプログラム要素情報117を生成する。また、アンチパターン検出部104は、実施形態1の場合に加えて、ソフトウェアメトリクス閾値テーブル111を受け付けて、ソフトウェアメトリクスも考慮したアンチパターングラフ118を生成する。
In addition to the case of the first embodiment, the source
ロジカルカップリング分析部101の動作は、実施形態1の場合と同じである。
また、アンチパターン検出部104の動作は、実施形態1の場合と同じである。
The operation of the logical
Further, the operation of the
次に、図20を用いて実施形態2のソースコード解析装置のハードウェア・ソフトウェア構成について説明する。
本実施形態のソースコード解析装置10は、実施形態1のソースコード解析装置10とハードウェア構成は同一である。
Next, the hardware / software configuration of the source code analysis apparatus of the second embodiment will be described with reference to FIG.
The source
補助記憶装置13には、実施形態1のプログラムに加えて、プログラム解析プログラム1305がインストールされている。プログラム解析プログラム1305は、プログラム解析部102の機能を実行するプログラムである。
In addition to the program of the first embodiment, the
また、補助記憶装置13には、実施形態1のデータに加えて、ソースコード108、ソフトウェアメトリクス取得ロジック109、ソフトウェアメトリクス情報115が格納されている。これらのデータの詳細は後述する。
Further, in the
次に、図21ないし図26を用いて実施形態2のソースコード解析装置に使用されるデータ構造について説明する。
図21に示されるソフトウェアメトリクス取得ロジック109は、プログラム要素ごとに値が定まるソフトウェアメトリクス値を取得するためのロジックを記録したものである。ソフトウェアメトリクス取得ロジック109は、取得したいソフトウェアメトリクス値の種類ごとに作成され、ソフトウェアメトリクス名1801およびソフトウェアメトリクス取得ロジック本体1802で構成される。ここで、ソフトウェアメトリクス名1801には、プログラム要素の規模や複雑度などの、一般的にプログラム解析で評価されるような値を用いてもよい。また、ソフトウェアメトリクス取得ロジック本体1802は、独自の論理記述言語を用いてもよいし、実行可能なプログラミング言語やスクリプトで記述してもよい。
Next, the data structure used in the source code analysis apparatus of the second embodiment will be described with reference to FIGS. 21 to 26.
The software
図22に示されるソフトウェアメトリクス情報115は、ソフトウェアメトリクス取得ロジック109で定義したソフトウェアメトリクスのプログラム要素ごとの値をメトリクスレコード1903として記録したものである。メトリクスレコード1903は、プログラム要素名1901と、ソフトウェアメトリクス値1902のフィールドからなる。
The software
プログラム要素名1901には、メトリクス取得対象のプログラム要素の名称が格納される。ソフトウェアメトリクス値1902には、ソフトウェアメトリクス取得ロジック109で定義したソフトウェアメトリクス名1901ごとのソフトウェアメトリクス値が格納される。
The
ソフトウェアメトリクス情報115は、プログラム解析部102でプログラム解析を行う前にメトリクスレコード1903が登録されていない状態に初期化されているものとする。
It is assumed that the software
図23に示されるプログラム要素情報117は、実施形態1に加えて、ソフトウェアメトリクスに関する情報を考慮したものである。プログラム要素情報117には、実施形態1の場合に加えて、プログラム要素に関するソフトウェアメトリクス値1904を、当該プログラム要素に対応するプログラム要素情報117のパラメータテーブル802のパラメータレコード805として記録する。
The
プログラム要素情報117は、出力装置15を用いてユーザに出力される。ユーザは、プログラム要素情報117を見ることによって、プログラム要素がどのようなソフトウェアメトリクスを持つかを確認できる。
The
図24に示されるソフトウェアメトリクス閾値テーブル111は、ソフトウェアメトリクス情報115に記録されたソフトウェアメトリクス名1902に対し、当該ソフトウェアメトリクス値1904が異常であると判断するための閾値をソフトウェアメトリクス閾値レコード2105として記録したものである。ソフトウェアメトリクス閾値レコード2105は、ソフトウェアメトリクス識別子2101と、ソフトウェアメトリクス名2102と、ソフトウェアメトリクス閾値2103と、ソフトウェアメトリクス判定条件2104のフィールドからなる。
The software metric threshold table 111 shown in FIG. 24 records the threshold value for determining that the software
ソフトウェアメトリクス識別子2101には、当該ソフトウェアメトリクス閾値レコード2105を識別するために一意に付与される識別子が格納される。ソフトウェアメトリクス名2102には、当該ソフトウェアメトリクスの名称が格納される。ソフトウェアメトリクス閾値2103には、当該ソフトウェアメトリクスに対応する閾値が格納される。ソフトウェアメトリクス判定条件2104には、ソフトウェアメトリクス値1904がソフトウェアメトリクス閾値2103と比べてどんな値をとる場合に異常とみなすかを判断するための条件が格納される。
The software
ここで、ソフトウェアメトリクス判定条件2104には、例えば、ソフトウェアメトリクス値1904とソフトウェアメトリクス閾値2103を比較するための関係演算子を記述する。なお、ソフトウェアメトリクス値1904をソフトウェアメトリクス判定条件2104およびソフトウェアメトリクス閾値2103を用いて評価した結果を、当該ソフトウェアメトリクス値に対する判定結果という。
Here, in the software
図25に示されるパラメータ論理式113は、実施形態1に加えてソフトウェアメトリクスに関する情報を考慮したものである。
The
パラメータ論理式113には、実施形態1の場合に加えて、ソフトウェアメトリクス識別子2101などを用いて記述してもよい。ここで、ソフトウェアメトリクス識別子2101の真偽値は、当該ソフトウェアメトリクス値804に対する判定結果とし、ソフトウェアメトリクス識別子2101を原始論理式として論理演算記号を用いて得られる論理式の真偽値は、論理学の一般的な推論規則に従うものとする。
In addition to the case of the first embodiment, the parameter
図25に示される例では、ソフトウェアメトリクス閾値テーブル111のソフトウェアメトリクス識別子2101の表す論理式S1と、グラフパラメータ閾値テーブル112(実施形態1と同じ)のグラフパラメータ識別子901の表す論理式G1,G2に対し、S1かつ(G1またはG2)であるときに、真であることを示している。すなわち、これは、(ソフトウェアメトリクスA<25)AND((グラフパラメータA≧4)OR(グラフパラメータB≧6))でとるときに、真であることを意味している。
In the example shown in FIG. 25, the logical formula S1 represented by the software
図26に示されるアンチパターングラフ118は、ソフトウェアメトリクスに関する情報を考慮したものである。アンチパターングラフ118では、実施形態1では問題特徴を有する頂点703であった頂点の一部が通常の頂点702になっている。これは、グラフパラメータ値に対する判定結果に加えてソフトウェアメトリクス値に対する判定結果も考慮して、プログラム要素が問題特徴を持つか否かを判定したためである。グラフパラメータ値に対する判定結果では当該プログラム要素が問題特徴を持つと判定されていたのが、ソフトウェアメトリクス値に対する判定結果では当該プログラム要素が問題特徴を持たないと判定され、そのようなプログラム要素は問題特徴を有する頂点703ではなく通常の頂点702になっている。
The
次に、図27ないし図29を用いて実施形態2のソースコード解析装置の処理について説明する。
先ず、プログラム解析部102は、ソースコード108を読み込む(S2401)。
次に、ソフトウェアメトリクス取得ロジック109を読み込む(S2402)。
次に、全てのプログラム要素Eに対して以下の処理を実施する(S2403~S2408)。
次に、全てのソフトウェアメトリクス取得ロジックLに対して以下の処理を実施する(S2406~S2404)。
Next, the processing of the source code analysis apparatus of the second embodiment will be described with reference to FIGS. 27 to 29.
First, the
Next, the software
Next, the following processing is performed for all the program elements E (S2403 to S2408).
Next, the following processing is performed for all software metrics acquisition logic L (S2406 to S2404).
図21のソフトウェアメトリクス取得ロジック109で示されるソフトウェアメトリクス取得ロジックLのソフトウェアメトリクス取得ロジック本体1802を用いて、プログラム要素Eのソフトウェアメトリクス取得ロジックLに対応するソフトウェアメトリクスを取得する(S2405)。
以上を、全てのソフトウェアメトリクス取得ロジックLに対して実施する(S2404~S2406)。
Using the software metric acquisition logic
The above is carried out for all software metrics acquisition logic L (S2404 to S2406).
プログラム要素Eのメトリクス値を図22のソフトウェアメトリクス情報115に追加する(S2407)。
以上を、全てのプログラム要素Eに対して実施する(S2408)。
The metric value of the program element E is added to the software
The above is carried out for all program elements E (S2408).
なお、プログラム解析部102の動作は、商用ツールとして販売されているプログラム解析ツールや、オープンソースで公開されているプログラム解析ツールで実施してもよい。
The operation of the
次に、図28を用いてロジカルカップリンググラフ生成部103の処理について説明する。
本実施形態では、実施形態1の図15に示したロジカルカップリンググラフ生成部103の処理に対して、最初にソフトウェアメトリクスを読み込む(S1305)処理が追加されている。また、プログラム要素情報の生成(S1304)において、図29のフローチャートに示したソフトウェアメトリクスに関する処理が追加されている。
Next, the processing of the logical coupling
In the present embodiment, a process of first reading software metrics (S1305) is added to the process of the logical coupling
なお、上記以外の処理は、実施形態1の図15に示したロジカルカップリンググラフ生成部103の処理と同じである。
The processing other than the above is the same as the processing of the logical coupling
次に、図29を用いてプログラム要素情報生成処理(図28のS1304)について説明する。 Next, the program element information generation process (S1304 in FIG. 28) will be described with reference to FIG. 29.
本実施形態では、実施形態1の図17に示したプログラム要素情報生成処理の場合に比べて、ロジカルカップリンググラフの全ての頂点Nに対して実施する処理(S1501)の最初に、以下の処理が追加されている。 In the present embodiment, as compared with the case of the program element information generation processing shown in FIG. 17 of the first embodiment, the following processing is performed at the beginning of the processing (S1501) performed for all the vertices N of the logical coupling graph. Has been added.
全てのプログラム要素Eに対して以下の処理を実施する(S1507~S1509)。
頂点Nに対応するプログラム要素Eのソフトウェアメトリクス値を、頂点Nのプログラム要素情報に追加する(S1508)。
以上を、全てのプログラム要素Eに対して実施する(S1507~S1509)。
The following processing is performed for all program elements E (S1507 to S1509).
The software metric value of the program element E corresponding to the vertex N is added to the program element information of the vertex N (S1508).
The above is carried out for all program elements E (S1507 to S1509).
なお、上記以外の処理は、実施形態1の図17に示したプログラム要素情報生成処理と同じである。 The processing other than the above is the same as the program element information generation processing shown in FIG. 17 of the first embodiment.
このように、本実施形態によれば、プログラム要素の変更履歴だけでなく、ソフトウェアメトリクスを考慮することによって、アンチパターンが示す問題特徴をプログラム要素が備えているか否かをより高い精度で判定できるようになる。 As described above, according to the present embodiment, it is possible to determine with higher accuracy whether or not the program element has the problematic feature indicated by the anti-pattern by considering not only the change history of the program element but also the software metric. It will be like.
〔実施形態3〕
以下、本発明に係る実施形態3を、図30ないし図32を用いて説明する。
[Embodiment 3]
Hereinafter, the third embodiment according to the present invention will be described with reference to FIGS. 30 to 32.
実施形態1では、過去のプログラム要素の変更履歴に基づいてアンチパターングラフを生成するソースコード解析装置、実施形態2では、実施形態1の機能に加えて、ソースコードやソフトウェアメトリクス情報を加味して、アンチパターングラフを生成するソースコード解析装置について説明した。 In the first embodiment, a source code analysis device that generates an anti-pattern graph based on the change history of past program elements, and in the second embodiment, in addition to the functions of the first embodiment, source code and software metrics information are added. , A source code analyzer that generates anti-pattern graphs has been described.
本実施形態は、実施形態1または実施形態2におけるソフトウェアメトリクス閾値テーブル111、グラフパラメータ閾値テーブル112、パラメータ論理式113の情報を表示して、それらのソフトウェアメトリクス閾値テーブル111、グラフパラメータ閾値テーブル112、パラメータ論理式113のデータをユーザから入力させて、その値の変化に伴うアンチパターングラフ118の出力を、ユーザインターフェース上でインタラクティブに行うものである。
The present embodiment displays the information of the software metric threshold table 111, the graph parameter threshold table 112, and the
本実施形態では、実施形態1、実施形態2と異なる所を中心に説明する。
先ず、図30および図31を用いて実施形態2のソースコード解析装置の構成について説明する。
In this embodiment, the points different from those of the first and second embodiments will be mainly described.
First, the configuration of the source code analysis apparatus of the second embodiment will be described with reference to FIGS. 30 and 31.
本実施形態のソースコード解析装置10は、図30に示すように、図Tに示した実施形態2の場合に加えて、システムパラメータ入出力部120を備える。
As shown in FIG. 30, the source
システムパラメータ入出力部120は、ソフトウェアメトリクス閾値テーブル111、グラフパラメータ閾値テーブル112、パラメータ論理式113に対し入出力を行う機能部である。これらの入出力は、後に説明するシステムパラメータ更新画面2700によって行われる。
The system parameter input /
本実施形態のソースコード解析装置10は、実施形態1、実施形態2のソースコード解析装置10とハードウェア構成は同一である。
The source
補助記憶装置13には、実施形態2のプログラムに加えて、システムパラメータ入出力プログラム1306がインストールされている。システムパラメータ入出力プログラム1306は、システムパラメータ入出力部120の機能を実行するプログラムである。
In addition to the program of the second embodiment, the system parameter input /
次に、図32を用いてソースコード解析装置のユーザインターフェースについて説明する。
ユーザは、システムパラメータ更新画面2700を表示して、ディスプレイなどの出力装置15に、ソフトウェアメトリクス閾値テーブル111およびグラフパラメータ閾値テーブル112およびパラメータ論理式113の情報を表示し、データを入力して更新することができる。
Next, the user interface of the source code analyzer will be described with reference to FIG. 32.
The user displays the system parameter update screen 2700, displays the information of the software metric threshold table 111, the graph parameter threshold table 112, and the parameter
システムパラメータ更新画面2700は、ソフトウェアメトリクス閾値入力欄2701、グラフパラメータ閾値入力欄2702、パラメータ論理式入力欄2703で構成される。
The system parameter update screen 2700 is composed of a software metric
ソフトウェアメトリクス閾値入力欄2701は、1個以上のソフトウェアメトリクス閾値要素入力欄2704からなる。ソフトウェアメトリクス閾値要素入力欄2704は、ソフトウェアメトリクス識別子表示欄2705、ソフトウェアメトリクス名表示欄2706、ソフトウェアメトリクス閾値入力欄2707、ソフトウェアメトリクス判定条件入力欄2708、ソフトウェアメトリクス閾値入力スライダー2709からなる。
The software metric
ソフトウェアメトリクス識別子表示欄2705は、ソフトウェアメトリクス識別子2101が表示される欄である。ソフトウェアメトリクス名表示欄2706は、ソフトウェアメトリクス名2102が表示される欄である。ソフトウェアメトリクス閾値入力欄2707は、図24に示したソフトウェア閾値テーブル111におけるソフトウェアメトリクス閾値2103を入力するための欄である。ソフトウェアメトリクス判定条件入力欄2708は、ソフトウェアメトリクス判定条件2104を入力するための欄である。ソフトウェアメトリクス閾値入力スライダー2709は、ソフトウェアメトリクス閾値2103を視覚的に入力する欄である。
The software metric
グラフパラメータ閾値入力欄2702は、1個以上のグラフパラメータ閾値要素入力欄2710からなる。グラフパラメータ閾値要素入力欄2710は、グラフパラメータ識別子表示欄2711、グラフパラメータ名表示欄2712、グラフパラメータ閾値入力欄2713、グラフパラメータ判定条件入力欄2714、グラフパラメータ閾値入力スライダー2715からなる。
The graph parameter
グラフパラメータ識別子表示欄2711は、グラフパラメータ識別子901が表示される欄である。グラフパラメータ名表示欄2712は、グラフパラメータ名902が表示される欄である。グラフパラメータ閾値入力欄2713は、グラフパラメータ閾値903を入力するための欄である。グラフパラメータ判定条件入力欄2714は、グラフパラメータ判定条件904を入力するための欄である。グラフパラメータ閾値入力スライダー2715は、グラフパラメータ閾値903を視覚的に入力する欄である。
The graph parameter
パラメータ論理式入力欄2703は、図10および図25に示したパラメータ論理式113を入力する欄である。
The parameter logical
ユーザは、このようなソフトウェアメトリクス閾値入力欄2707、ソフトウェアメトリクス判定条件入力欄2708、ソフトウェアメトリクス閾値入力スライダー2709、グラフパラメータ閾値入力欄2707、グラフパラメータ判定条件入力欄2708、グラフパラメータ閾値入力スライダー2709、パラメータ論理式入力欄2703を用いて、ソフトウェアメトリクス閾値、グラフパラメータ閾値、パラメータ論理式を入力し、出力されるアンチパターングラフ118を確認することにより、ソフトウェアメトリクス値のインタラクティブな入力が可能になる。
The user can use such a software metric
5…バス、10…ソースコード解析装置、11…プロセッサ、12…主記憶装置、13…補助記憶装置、14…入力装置、15…出力装置、16…通信装置、
101…ロジカルカップリング分析部、102…プログラム解析部、103…ロジカルカップリンググラフ生成部、104…アンチパターン検出部、105…情報記憶部、119…アンチパターン表示部、120…システムパラメータ入出力部、
108…ソースコード、109…ソフトウェアメトリクス取得ロジック、114…変更依存関係ルールテーブル、115…ソフトウェアメトリクス情報、116…ロジカルカップリンググラフ、117…プログラム要素情報
5 ... Bus, 10 ... Source code analyzer, 11 ... Processor, 12 ... Main storage device, 13 ... Auxiliary storage device, 14 ... Input device, 15 ... Output device, 16 ... Communication device,
101 ... Logical coupling analysis unit, 102 ... Program analysis unit, 103 ... Logical coupling graph generation unit, 104 ... Anti-pattern detection unit, 105 ... Information storage unit, 119 ... Anti-pattern display unit, 120 ... System parameter input / output unit ,
108 ... Source code, 109 ... Software metric acquisition logic, 114 ... Change dependency rule table, 115 ... Software metric information, 116 ... Logical coupling graph, 117 ... Program element information
Claims (8)
解析対象のプログラムの変更履歴と、プログラムの変更に関する指標の閾値を入力して、プログラム要素の変更依存関係ルールを出力するロジカルカップリング分析部と、
前記変更依存関係ルールに基づいて、プログラム要素をノード、同時変更されやすいプログラム要素の順序対を有向辺として、プログラム要素の変更依存関係を表現したロジカルカップリンググラフを生成するロジカルカップリング生成部と、
生成された前記ロジカルカップリンググラフと、プログラム要素毎に定められたグラフパラメータに関する情報に基づいて、ロジカルカップリンググラフにおいて保守性の低いプログラム要素を検出して、保守性の低いプログラム要素のノードを強調したアンチパターングラフとするアンチパターン検出部と、
前記アンチパターングラフを表示するアンチパターン表示部とからなることを特徴とするソースコード解析装置。 A source code analysis device that points out problems related to the maintainability of the source code of the program to be analyzed.
A logical coupling analysis unit that inputs the change history of the program to be analyzed and the threshold value of the index related to the program change and outputs the change dependency rule of the program element.
Based on the change dependency rule, a logical coupling generator that generates a logical coupling graph that expresses the change dependency of a program element, with the program element as a node and the ordered pair of program elements that are easily changed at the same time as directed edges. When,
Based on the generated logical coupling graph and the information about the graph parameters defined for each program element, the program element with low maintainability is detected in the logical coupling graph, and the node of the program element with low maintainability is detected. An anti-pattern detector that makes an emphasized anti-pattern graph,
A source code analysis device including an anti-pattern display unit that displays the anti-pattern graph.
前記アンチパターン検出部は、生成された前記ロジカルカップリンググラフと、プログラム要素毎に定められたグラフパラメータに関する情報と、さらに、ソフトウェアメトリクスに関する情報に基づいて、前記ロジカルカップリンググラフを保守性の低いプログラム要素のノードを強調したアンチパターングラフとすることを特徴とする請求項1記載のソースコード解析装置。 Further, a program analysis unit that inputs the source code of the program to be analyzed and the software metric acquisition logic that defines the software metric logic for each software metric, and outputs the software metric information that defines the software metric value for each program element. Have,
The anti-pattern detection unit has low maintainability of the logical coupling graph based on the generated logical coupling graph, information on graph parameters defined for each program element, and information on software metrics. The source code analysis device according to claim 1, wherein the anti-pattern graph emphasizes the nodes of the program element.
解析対象のプログラムの変更履歴と、プログラムの変更に関する指標の閾値を入力して、プログラム要素の変更依存関係ルールを出力するロジカルカップリング分析ステップと、
前記変更依存関係ルールに基づいて、プログラム要素をノード、同時変更されやすいプログラム要素の順序対を有向辺として、プログラム要素の変更依存関係を表現したロジカルカップリンググラフを生成するロジカルカップリング生成ステップと、
生成された前記ロジカルカップリンググラフと、プログラム要素毎に定められたグラフパラメータに関する情報に基づいて、ロジカルカップリンググラフにおいて保守性の低いプログラム要素を検出して、保守性の低いプログラム要素のノードを強調したアンチパターングラフとするアンチパターン検出ステップと、
前記アンチパターングラフを表示するアンチパターン表示ステップとからなることを特徴とするソースコード解析方法。 It is a source code analysis method that points out problems related to the maintainability of the source code of the program to be analyzed.
A logical coupling analysis step that outputs the change dependency rule of the program element by inputting the change history of the program to be analyzed and the threshold value of the index related to the change of the program.
Based on the change dependency rule, the logical coupling generation step to generate a logical coupling graph expressing the change dependency of the program element by using the program element as a node and the ordered pair of the program elements that are easily changed at the same time as the directed edge. When,
Based on the generated logical coupling graph and the information about the graph parameters defined for each program element, the program element with low maintainability is detected in the logical coupling graph, and the node of the program element with low maintainability is detected. An anti-pattern detection step with an emphasized anti-pattern graph,
A source code analysis method comprising an anti-pattern display step for displaying the anti-pattern graph.
前記アンチパターン検出ステップは、生成された前記ロジカルカップリンググラフと、プログラム要素毎に定められたグラフパラメータに関する情報と、さらに、ソフトウェアメトリクスに関する情報に基づいて、前記ロジカルカップリンググラフを保守性の低いプログラム要素のノードを強調したアンチパターングラフとすることを特徴とする請求項5記載のソースコード解析方法。 Further, a program analysis step in which the source code of the program to be analyzed and the software metric acquisition logic that defines the software metric logic for each software metric are input, and the software metric information that defines the software metric value for each program element is output. Have,
The anti-pattern detection step makes the logical coupling graph less maintainable based on the generated logical coupling graph, information about graph parameters defined for each program element, and information about software metrics. The source code analysis method according to claim 5, wherein the anti-pattern graph emphasizes the nodes of the program element.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2017184915A JP7029915B2 (en) | 2017-09-26 | 2017-09-26 | Source code analyzer and source code analysis method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2017184915A JP7029915B2 (en) | 2017-09-26 | 2017-09-26 | Source code analyzer and source code analysis method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2019061438A JP2019061438A (en) | 2019-04-18 |
JP7029915B2 true JP7029915B2 (en) | 2022-03-04 |
Family
ID=66176643
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2017184915A Active JP7029915B2 (en) | 2017-09-26 | 2017-09-26 | Source code analyzer and source code analysis method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP7029915B2 (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170091073A1 (en) | 2015-09-30 | 2017-03-30 | International Business Machines Corporation | Detection of antipatterns through statistical analysis |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9690553B1 (en) * | 2016-09-26 | 2017-06-27 | International Business Machines Corporation | Identifying software dependency relationships |
-
2017
- 2017-09-26 JP JP2017184915A patent/JP7029915B2/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170091073A1 (en) | 2015-09-30 | 2017-03-30 | International Business Machines Corporation | Detection of antipatterns through statistical analysis |
Also Published As
Publication number | Publication date |
---|---|
JP2019061438A (en) | 2019-04-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6985350B2 (en) | Data system summary | |
CN109710306B (en) | Source code analysis device, source code analysis method, and computer-readable recording medium | |
KR101631978B1 (en) | Mapping dataset elements | |
US8726236B2 (en) | Determining context specific content | |
JP6158623B2 (en) | Database analysis apparatus and method | |
US8086997B2 (en) | Detecting aspectual behavior in unified modeling language artifacts | |
JP6256115B2 (en) | Operation search program, operation search method, and operation search device | |
US11922230B2 (en) | Natural language processing of API specifications for automatic artifact generation | |
JP2016157290A (en) | Document search apparatus, document search method, and document search program | |
CN106484389B (en) | Action stream segment management | |
CN110618926A (en) | Source code analysis method and source code analysis device | |
JP6800716B2 (en) | Data analyzers, data analysis methods, and data analysis programs | |
Ackermann et al. | Black-box learning of parametric dependencies for performance models | |
JP7029915B2 (en) | Source code analyzer and source code analysis method | |
US11971813B2 (en) | Data driven testing automation using machine learning | |
JP7275591B2 (en) | Evaluation support program, evaluation support method, and information processing device | |
US20210182701A1 (en) | Virtual data scientist with prescriptive analytics | |
Raamesh et al. | Reliable mining of automatically generated test cases from software requirements specification (SRS) | |
JP7235269B2 (en) | Data item name estimation device, data item name estimation program, and data item name estimation method | |
JP2018190219A (en) | Software specification analyzer and software specification analytical method | |
EP3671467A1 (en) | Gui application testing using bots | |
Dogan et al. | Parallelism-based session creation to identify high-level activities in event log abstraction | |
JP7075011B2 (en) | Information processing device, patch application confirmation system, patch application confirmation method, and patch application confirmation program | |
US20180227183A1 (en) | Refining of Applicability Rules of Management Activities According to Missing Fulfilments Thereof | |
JP7239519B2 (en) | Machine learning model operation management system and operation management method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20200305 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20210113 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20210126 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20210311 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20210817 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20210907 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20220201 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20220221 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 7029915 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |