JP2011258076A - Java source code check program - Google Patents

Java source code check program Download PDF

Info

Publication number
JP2011258076A
JP2011258076A JP2010133272A JP2010133272A JP2011258076A JP 2011258076 A JP2011258076 A JP 2011258076A JP 2010133272 A JP2010133272 A JP 2010133272A JP 2010133272 A JP2010133272 A JP 2010133272A JP 2011258076 A JP2011258076 A JP 2011258076A
Authority
JP
Japan
Prior art keywords
java
source code
comment
java source
line
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.)
Granted
Application number
JP2010133272A
Other languages
Japanese (ja)
Other versions
JP5419804B2 (en
Inventor
Naokazu Watabe
直和 渡部
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Exa Corp
Original Assignee
Exa Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Exa Corp filed Critical Exa Corp
Priority to JP2010133272A priority Critical patent/JP5419804B2/en
Publication of JP2011258076A publication Critical patent/JP2011258076A/en
Application granted granted Critical
Publication of JP5419804B2 publication Critical patent/JP5419804B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a quality check program capable of recognizing a tendency for each programmer with respect to an item which has an impact on quality of Java source code.SOLUTION: A Java source code check program according to the present invention extracts a programmer name from a tag part in which the programmer name of a Java class described in the Java source code is described, and totalizes the number of creation steps per a class for each programmer.

Description

本発明は、Java(登録商標)言語で記述されたプログラムソースコードの品質をチェックするプログラムに関するものである。   The present invention relates to a program for checking the quality of a program source code written in Java (registered trademark) language.

ソフトウェア開発では常に高品質な成果物が求められており、品質向上のために様々な点検活動が行われている。開発の期間は限られているため、品質点検を素早く高精度に実施する必要がある。   Software development always requires high-quality deliverables, and various inspection activities are being conducted to improve quality. Since the development period is limited, it is necessary to conduct quality inspections quickly and with high accuracy.

開発下流工程の成果物であるソースコードの品質点検に目を向けると、大きくテストと目視点検の2つの方法がある。このうちテストではソフトウェアに要求される仕様を確認し、目視点検では仕様確認に加えてテストで発見しにくい誤作動、非効率な記述、保守性などの品質も確認する。このように多くの内容を確認する目視点検は品質確保の活動として重要であるが、時間がかかる割に見落としが発生しやすく、さらに属人的で精度がばらつくという問題を含んでいる。   Looking at the quality check of the source code that is the product of the downstream development process, there are two main methods: a test and a visual check. Of these, the specifications required for the software are confirmed during the test, and the quality such as malfunction, inefficiency description, maintainability, etc. that are difficult to find in the test is confirmed in addition to the specification confirmation by visual inspection. Visual inspection to confirm such a large amount of content is important as an activity for ensuring quality, but it involves the problem that it tends to be overlooked even though it takes time, and it is personal and varies in accuracy.

近年、Javaなどのオープン系言語では、目視点検をサポートするツールとしてFindBugs(非特許文献1)やCheckstyle(非特許文献2)のようなツールが登場して、様々なプロジェクトで利用されている。   In recent years, in open languages such as Java, tools such as FindBugs (Non-Patent Document 1) and Checkstyle (Non-Patent Document 2) have emerged as tools that support visual inspection, and are used in various projects.

URL:http://findbugs.sourceforge.net/URL: http://findbugs.sourceforge.net/ URL:http://checkstyle.sourceforge.net/URL: http://checkstyle.sourceforge.net/

上記非特許文献1〜2に記載の技術では、あらかじめ定めておいた検出規則に基づき、Javaソースコードのバグを自動的に検出したり、Javaソースコードの記述スタイルが規則に適合しているか否かを判定したりすることができる。   In the technologies described in Non-Patent Documents 1 and 2, a bug in the Java source code is automatically detected based on a detection rule set in advance, or whether the description style of the Java source code conforms to the rule. Can be determined.

しかし、ソフトウェア開発プロジェクトにおいては、バグの発生やソースコードの記述スタイルは各開発者固有の傾向が反映されやすいといえる。かかる属人的な傾向は、従来の品質チェックツールではあまり意識されてこなかった。   However, in software development projects, it can be said that the development of bugs and the description style of the source code tend to reflect the unique trends of each developer. Such personal tendency has not been recognized much by conventional quality check tools.

本発明は、上記のような課題を解決するためになされたものであり、Javaソースコードの品質に影響を与える事項について、プログラム作成者毎の傾向を把握することができる品質チェックプログラムを提供することを目的とする。   The present invention has been made in order to solve the above-described problems, and provides a quality check program capable of grasping the tendency of each program creator with respect to matters affecting the quality of Java source code. For the purpose.

本発明に係るJavaソースコードチェックプログラムは、Javaソースコード内に記述されているJavaクラスの作成者名を記述したタグ部分から作成者名を抽出し、作成者毎の1クラス当たりの作成ステップ数を集計する。   The Java source code check program according to the present invention extracts the creator name from the tag portion describing the creator name of the Java class described in the Java source code, and the number of creation steps per class for each creator Are counted.

本発明に係るJavaソースコードチェックプログラムによれば、各プログラム作成者の1クラスあたりのステップ数傾向を把握することができる。1クラスあたりのステップ数が多いということは、サイズが大きいクラスを作成しているということであるため、ソースコードの保守性の観点で好ましくない。本発明に係るJavaソースコードチェックプログラムによれば、かかる傾向のある作成者を特定し、改善を促すなどの対策を適切に取ることができる。   According to the Java source code check program of the present invention, it is possible to grasp the tendency of the number of steps per class of each program creator. A large number of steps per class means that a large class is created, which is not preferable from the viewpoint of maintainability of source code. According to the Java source code check program according to the present invention, it is possible to identify a creator having such a tendency and appropriately take measures such as prompting improvement.

実施形態1に係るJavaソースコードチェックプログラム110を実行するコンピュータ100および関連するデータの入出力を示す図である。It is a figure which shows the input / output of the computer 100 which executes the Java source code check program 110 which concerns on Embodiment 1, and related data. Javaソースコード200のサンプルを示す。A sample Java source code 200 is shown. Javaソースコード200のサンプルを示す。A sample Java source code 200 is shown.

<実施の形態1>
図1は、本発明の実施形態1に係るJavaソースコードチェックプログラム110を実行するコンピュータ100および関連するデータの入出力を示す図である。コンピュータ100は、Javaプログラムのチェック作業を行うために用いるコンピュータである。
<Embodiment 1>
FIG. 1 is a diagram showing a computer 100 that executes a Java source code check program 110 according to Embodiment 1 of the present invention and related data input / output. The computer 100 is a computer used for checking a Java program.

コンピュータ100は、チェック対象であるJavaソースコード200と、チェック規則を定義するチェック規則データ300を入力として受け取り、Javaソースコード200のチェック結果を出力する。これらのデータは、必要に応じてコンピュータ100が備える記憶装置に格納される。   The computer 100 receives the Java source code 200 to be checked and the check rule data 300 defining the check rule as inputs, and outputs the check result of the Java source code 200. These data are stored in a storage device included in the computer 100 as necessary.

コンピュータ100は、Javaソースコードチェックプログラム110を格納するHDD(Hard Disk Drive)などの記憶装置と、Javaソースコードチェックプログラム110を実行するCPU(Central Processing Unit)などの演算装置を備える。また、各データを入出力するインタフェース、メモリなどを適宜備える。以下では説明の便宜上、Javaソースコードチェックプログラム110を動作主体として説明する場合があるが、実際にJavaソースコードチェックプログラム110を実行するのはCPUなどの演算装置であることを付言しておく。   The computer 100 includes a storage device such as an HDD (Hard Disk Drive) that stores the Java source code check program 110 and an arithmetic device such as a CPU (Central Processing Unit) that executes the Java source code check program 110. In addition, an interface for inputting / outputting each data, a memory, and the like are provided as appropriate. Hereinafter, for convenience of explanation, the Java source code check program 110 may be described as an operation subject. However, it is added that the Java source code check program 110 is actually executed by an arithmetic unit such as a CPU.

チェック規則データ300は、Javaソースコードチェックプログラム110がJavaソースコード200をチェックする際の基準となるチェック規則を1以上定義する。チェック規則データ300が規定する具体的な手順については、以下の図2を用いて改めて説明する。   The check rule data 300 defines one or more check rules that serve as a reference when the Java source code check program 110 checks the Java source code 200. A specific procedure defined by the check rule data 300 will be described again with reference to FIG.

図2は、Javaソースコード200のサンプルを示す。説明の便宜上、行番号をソースコードの左側に併記した。図2中、「/*」と「*/」で囲まれている部分は、コメント部分である。具体的には、3〜7行目、11〜13行目、17〜20行目がコメント部分である。   FIG. 2 shows a sample Java source code 200. For convenience of explanation, the line number is shown on the left side of the source code. In FIG. 2, the part enclosed by “/ *” and “* /” is a comment part. Specifically, the third to seventh lines, the 11th to 13th lines, and the 17th to 20th lines are comment portions.

各コメント内に記載されている項目のうち、「@」で始まる部分は、Javaソースコードのコメント特有の情報を記述することを指定するタグ部分である。各タグの内容には、以下の項目を記述すべきであることが、Java標準のコメント規則であるJavadoc仕様によって規定されている。
(図2:@authorタグ)当該Javaクラスの作成者名を記述するタグである。
(図2:@versionタグ)当該Javaクラスのリリースバージョンを表す数値を記述するタグである。
(図2:@paramタグ)Javaクラス内のメソッド引数を記述するタグである。
Of the items described in each comment, the part beginning with “@” is a tag part that specifies that comment-specific information of the Java source code is described. The contents of each tag stipulate that the following items should be described by the Javadoc specification, which is a Java standard comment rule.
(FIG. 2: @author tag) This tag describes the creator name of the Java class.
(FIG. 2: @version tag) This tag describes a numerical value representing the release version of the Java class.
(FIG. 2: @param tag) This tag describes a method argument in the Java class.

Javadoc形式のコメントは、本来はJavaクラスの仕様書を自動的に生成するために記述するものである。例えば、各Javaクラスが有するメソッド、その引数と戻り型、などの情報を、Javaソースコード本体およびJavadoc内の各タグから抽出することにより、Javaクラス仕様書を自動生成することができる。   A comment in the Javadoc format is originally described in order to automatically generate a Java class specification. For example, a Java class specification can be automatically generated by extracting information such as methods, arguments and return types of each Java class from the Java source code main body and each tag in Javadoc.

かかるJavadoc仕様の目的に起因して、一般にJavadocコメントはJavaクラスの属性をコメント内に記述するために用いられており、したがって「@author」タグは補助的な情報として用いられるに留まっていた。   Due to the purpose of the Javadoc specification, Javadoc comments are generally used to describe the attributes of Java classes in comments, and therefore, the “@author” tag has only been used as auxiliary information.

本発明は、Javaソースコード内にJavaクラスの作成者名が埋め込まれていることに着目し、Javaソースコードの品質傾向をプログラム作成者毎に把握するために用いることを図るものである。   The present invention pays attention to the fact that the creator name of the Java class is embedded in the Java source code, and is intended to be used for grasping the quality trend of the Java source code for each program creator.

プログラム作成者毎の品質傾向を測定する目安として、1クラス当たりのステップ数が挙げられる。一般にJavaクラスは、その目的に特化したJava命令のみを記述するのが通常であるため、各Javaクラスのステップ数は、当該Javaクラスの目的に相当するステップ数内に収まるはずである。しかし、1つのJavaクラスが複数の目的に対応するようにJavaクラスを作成すると、そのJavaクラスのステップ数は相応に多くなると予想される。   As a guideline for measuring the quality tendency for each program creator, the number of steps per class can be mentioned. Generally, a Java class normally describes only a Java instruction specialized for its purpose. Therefore, the number of steps of each Java class should be within the number of steps corresponding to the purpose of the Java class. However, if a Java class is created so that one Java class corresponds to a plurality of purposes, the number of steps of the Java class is expected to increase accordingly.

1つのJavaクラスが複数の目的に対応していると、どの機能がどのJavaクラスに属しているか分からなくなり、Javaクラスの保守性が低下する。このような保守性の低いJavaクラスを作成する傾向は、プログラム作成者毎に固有のものであることが多い。そこで本実施形態1では、1クラス当たりのステップ数をプログラム作成者毎に集計し、極端にステップ数の多いJavaクラスを作成する傾向のあるプログラム作成者を特定して注意を喚起するなどの対策を取ることを図る。   When one Java class corresponds to a plurality of purposes, it is not known which function belongs to which Java class, and the maintainability of the Java class is lowered. Such a tendency to create a Java class with low maintainability is often unique to each program creator. Therefore, in the first embodiment, the number of steps per class is totaled for each program creator, and measures such as calling a program creator who tends to create a Java class having an extremely large number of steps are called. To take.

Javaソースコードチェックプログラム110は、上記集計処理を以下の手順で実行する。   The Java source code check program 110 executes the above aggregation process according to the following procedure.

(Javaソースコードチェック手順:ステップ1)
Javaソースコードチェックプログラム110は、Javaソースコード200(ソースコードファイル)を、HDDなどの記憶装置から読み込む。複数のJavaソースコード200をまとめて読み込んでもよいし、1つずつ読み込んでもよい。
(Java source code check procedure: Step 1)
The Java source code check program 110 reads the Java source code 200 (source code file) from a storage device such as an HDD. A plurality of Java source codes 200 may be read together or may be read one by one.

(Javaソースコードチェック手順:ステップ2)
Javaソースコードチェックプログラム110は、ステップ1で読み込んだJavaソースコード200のコメント部分を特定する。具体的には、「/*」と「*/」で囲まれた部分、および「//」で開始する行がコメント部分であると特定する。
(Java source code check procedure: Step 2)
The Java source code check program 110 identifies the comment portion of the Java source code 200 read in step 1. Specifically, the part surrounded by “/ *” and “* /” and the line starting with “//” are specified as the comment part.

(Javaソースコードチェック手順:ステップ2:補足)
厳密には、Javadoc仕様のタグは、「/**」と「*/」で囲まれた部分に記述される。したがって本ステップでは、単なるコメント部分を検出するのみならず、Javadocの対象となるコメント部分を検出する必要がある。ただし、Javaソースコードチェックプログラム110固有のルールとして、任意のコメント内から「@author」タグを検出することとした場合や、「@author」以外の記述方式でプログラム作成者名を記述することとした場合などは、これに限られるものではない。いずれの場合でも、プログラム作成者名をコメント内に記述しておき、Javaソースコードチェックプログラム110がこれを認識できればよい。
(Java source code check procedure: Step 2: Supplement)
Strictly speaking, a tag of the Javadoc specification is described in a portion surrounded by “/ **” and “* /”. Therefore, in this step, it is necessary not only to detect a mere comment part but also to detect a comment part that is a target of Javadoc. However, as a rule specific to the Java source code check program 110, when the “@author” tag is detected from an arbitrary comment, or the program creator name is described using a description method other than “@author”. However, this is not the only case. In any case, it is sufficient that the name of the program creator is described in the comment and the Java source code check program 110 can recognize this.

(Javaソースコードチェック手順:ステップ3)
Javaソースコードチェックプログラム110は、ステップ2で特定したコメント部分から、「@author」タグに記載されているプログラム作成者名を抽出する。図2に示した例では、プログラム作成者名は「AUTHOR_001」である。
(Java source code check procedure: Step 3)
The Java source code check program 110 extracts the program creator name described in the “@author” tag from the comment part specified in step 2. In the example illustrated in FIG. 2, the program creator name is “AUTHOR — 001”.

(Javaソースコードチェック手順:ステップ4)
Javaソースコードチェックプログラム110は、Javaソースコード200内に記述されているJavaクラスのステップ数をカウントする。Java言語は1つのJavaソースコード200ファイル内に1つのJavaクラスを記述するという規則があるので、Javaソースコード200の行数をカウントすればよい。図2に示した例では、HelloWorldクラスのステップ数は25である。
(Java source code check procedure: Step 4)
The Java source code check program 110 counts the number of steps of the Java class described in the Java source code 200. Since the Java language has a rule that one Java class is described in one Java source code 200 file, the number of lines of the Java source code 200 may be counted. In the example shown in FIG. 2, the number of steps of the HelloWorld class is 25.

(Javaソースコードチェック手順:ステップ5)
Javaソースコードチェックプログラム110は、ステップ1〜4を、品質検査対象とする全てのJavaソースコード200について実行する。
(Java source code check procedure: Step 5)
The Java source code check program 110 executes steps 1 to 4 for all the Java source codes 200 to be subjected to quality inspection.

(Javaソースコードチェック手順:ステップ6)
Javaソースコードチェックプログラム110は、Javaクラス1つあたりのステップ数を、プログラム作成者毎に集計する。具体的には、ステップ3で抽出したプログラム作成者毎にステップ数を合算し、さらにそのステップ数を、当該プログラム作成者が作成したJavaクラス数で除算すればよい。
(Java source code check procedure: Step 6)
The Java source code check program 110 counts the number of steps per Java class for each program creator. Specifically, the number of steps may be added for each program creator extracted in step 3, and the number of steps may be further divided by the number of Java classes created by the program creator.

(Javaソースコードチェック手順:ステップ7)
Javaソースコードチェックプログラム110は、ステップ6の結果を、ファイル出力、画面出力などの形態で出力する。
(Java source code check procedure: Step 7)
The Java source code check program 110 outputs the result of step 6 in the form of file output, screen output, or the like.

以上、図2のソースコードをチェックする過程を例に取り、Javaソースコードチェックプログラム110の動作を説明した。   The operation of the Java source code check program 110 has been described above by taking the process of checking the source code of FIG. 2 as an example.

<実施の形態1:まとめ>
以上のように、本実施形態1に係るJavaソースコードチェックプログラム110は、Javaソースコード200の作成者毎に1クラス当たりのステップ数を集計してその結果を出力する。この結果を利用して、プログラム作成者毎のクラスサイズの傾向を把握することができる。これにより、極端にサイズの大きいJavaクラスを作成する傾向のあるプログラム作成者には、クラスを分割するなどの改善を促すことができるので、結果としてJavaソースコード200の品質改善につながる。
<Embodiment 1: Summary>
As described above, the Java source code check program 110 according to the first embodiment aggregates the number of steps per class for each creator of the Java source code 200 and outputs the result. By using this result, the tendency of the class size for each program creator can be grasped. As a result, a program creator who tends to create an extremely large Java class can be encouraged to improve the class by dividing the class. As a result, the quality of the Java source code 200 is improved.

また、本実施形態1に係るJavaソースコードチェックプログラム110は、Javaソースコード200の「@author」タグからプログラム作成者名を抽出する。これにより、プログラム作成者の名称などの情報を、Javaソースコード200とは別に管理する必要がなくなる。この機能がないと、Javaソースコード200とは別にプログラム作成者の属性情報を管理する必要が生じ、ソースコード品質チェックとは直接の関係がない作業負担が生じる。この点、本実施形態1に係るJavaソースコードチェックプログラム110によれば、Javaソースコード200そのものからプログラム作成者名を取得するので、かかる作業負担は生じず、プログラム作成者毎の集計作業を自動化することができる点で有利である。以下の実施形態でも同様である。   Also, the Java source code check program 110 according to the first embodiment extracts the program creator name from the “@author” tag of the Java source code 200. This eliminates the need to manage information such as the name of the program creator separately from the Java source code 200. Without this function, it is necessary to manage the attribute information of the program creator separately from the Java source code 200, resulting in a work load that is not directly related to the source code quality check. In this regard, according to the Java source code check program 110 according to the first embodiment, since the name of the program creator is acquired from the Java source code 200 itself, such work burden does not occur, and the tabulation work for each program creator is automated. This is advantageous in that it can be done. The same applies to the following embodiments.

<実施の形態2>
本発明の実施形態2では、Javaソースコードチェックプログラム110がJavaソースコード200内のコメントアウト部分を検出する手法を説明する。Javaソースコードチェックプログラム110および周辺環境の構成は、実施形態1と同様である。実施形態1で説明した手法と、本実施形態2で説明する手法は、組み合わせて用いてもよいし、個別に用いてもよい。
<Embodiment 2>
In the second embodiment of the present invention, a method in which the Java source code check program 110 detects a comment-out portion in the Java source code 200 will be described. The configuration of the Java source code check program 110 and the surrounding environment is the same as that of the first embodiment. The method described in the first embodiment and the method described in the second embodiment may be used in combination or may be used individually.

Javaソースコード200内のコメントには、メモ書き目的、クラスやメソッドの役割を説明する目的などでプログラム作成者が付与した一般コメントと、古いJava命令を無効化するためにコメントアウトしたものがある。このうち古いJava命令をコメントアウトしたものについては、Javaソースコード200内に残したままにしておくと可読性が低下するので、保守性など品質維持の観点から好ましくない。   The comments in the Java source code 200 include general comments given by the program creator for the purpose of writing notes, explaining the role of classes and methods, and comments commented out to invalidate old Java instructions. Of these, the commented out old Java instruction is not preferable from the standpoint of quality maintenance such as maintainability because it is left unreadable if it is left in the Java source code 200.

そこで本実施形態2では、Javaソースコード200内のコメントアウト部分を、他の一般コメントと区別した上で、コメントアウト部分のみを抽出する手法を説明する。   Therefore, in the second embodiment, a method of extracting only the comment-out portion after distinguishing the comment-out portion in the Java source code 200 from other general comments will be described.

図3は、Javaソースコード200のサンプルを示す。図2で示したサンプルと概ね同様であるが、29〜30行目、および17〜21行目にコメントが追加されている。これらコメントの内訳は、以下の通りである。   FIG. 3 shows a sample Java source code 200. Although generally the same as the sample shown in FIG. 2, comments are added to the 29th to 30th lines and the 17th to 21st lines. The breakdown of these comments is as follows.

(図3:30行目のコメント)
30行目は、32行目に記載しているJava命令の古いバージョンをコメントアウトしたものである。コメントアウトとは、Javaソースコードのうち不要な部分を無効化するため、当該部分をコメントとして取り扱うように所定の記号を付与したものである。ここでは、行初に「//」を追加することにより、当該行をコメントとして取り扱うことを示している。
(Figure 3: Comment on line 30)
The 30th line is a commented out old version of the Java instruction described in the 32nd line. “Comment out” means that a predetermined symbol is assigned so that an unnecessary part of Java source code is invalidated so that the part is treated as a comment. Here, “//” is added to the beginning of a line to indicate that the line is handled as a comment.

(図3:29行目のコメント)
29行目は、30行目をコメントアウトする際に、プログラム作成者がメモ書きとして付与したものであると思われる。このようなコメントは、Java命令をコメントアウトしたものとは異なり、一般コメントに分類することができる。
(Figure 3: Comment on line 29)
The 29th line seems to have been given as a note by the program creator when commenting out the 30th line. Such comments can be categorized as general comments, unlike comments that comment out Java instructions.

(図3:17〜21行目のコメント)
17〜21行目は、「/*」と「*/」で囲むことによりコメント部分となっている。このうち18行目と19行目は、30行目と同様に古いソースコードをコメントアウトしたものである。20行目は、プログラム作成者がメモ書きとして付与した一般コメントである。
(Figure 3: Comments on lines 17-21)
The 17th to 21st lines are commented by being surrounded by “/ *” and “* /”. Of these, the 18th and 19th lines are commented out of the old source code as in the 30th line. The 20th line is a general comment given as a memo by the program creator.

以上例示したように、コメント部分のなかには、一般コメントとコメントアウトが混在している。Javaソースコード200の保守性の観点からは、古いソースコードが残っていることは好ましくないので、本実施形態2ではコメントアウト部分のみを検出する。以下、その手順を説明する。   As illustrated above, general comments and comment-outs are mixed in the comment portion. From the viewpoint of maintainability of the Java source code 200, it is not preferable that the old source code remains, so only the commented-out portion is detected in the second embodiment. The procedure will be described below.

(コメントアウト検出手順:ステップ1〜2)
これらのステップは、実施形態1のステップ1〜2と同様である。
(Comment out detection procedure: Steps 1-2)
These steps are the same as steps 1-2 in the first embodiment.

(コメントアウト検出手順:ステップ3)
Javaソースコードチェックプログラム110は、ステップ2でコメント行であると判定した行の末尾に、Java命令文の終端子(セミコロン)、Java言語における開始括弧「{」もしくは「(」、またはJava言語における終了括弧「}」もしくは「)」が存在するか否かを判定する。これらが行末に存在する行は、コメントアウト行であるとみなす。これら括弧のいずれか一方のみを検出するようにしてもよい。
(Comment out detection procedure: Step 3)
The Java source code check program 110 adds an end terminal (semi-colon) of a Java statement, a start parenthesis “{” or “(” in the Java language, or in the Java language to the end of the line determined to be a comment line in Step 2. It is determined whether or not the closing parenthesis “}” or “)” exists. Lines where these exist at the end of a line are considered to be commented out lines. Only one of these parentheses may be detected.

(コメントアウト検出手順:ステップ3:補足)
本ステップにおいて、セミコロン、開始括弧、または終了括弧が行末に存在するか否かを判定するのは、行末にこれらが存在する場合、当該行はJava命令を記述していると想定されるからである。例えば図3の30行目は、コメントアウトされる前はJava命令文を記述していたので、末尾にJava命令の終端子であるセミコロンが存在する。同様に18〜19行目には、Javaソースコードにおいて頻繁に用いられる開始括弧と終端括弧が存在している。これら括弧は行末に記載されるので、行末にこれら括弧が存在している行は、Java命令を記述していると考えられる。
(Comment out detection procedure: Step 3: Supplement)
In this step, it is assumed that a semicolon, start parenthesis, or end parenthesis is present at the end of the line because if it exists at the end of the line, it is assumed that the line describes a Java instruction. is there. For example, the 30th line in FIG. 3 describes the Java statement before commenting out, so there is a semicolon that is the end terminal of the Java command at the end. Similarly, in the 18th to 19th lines, there are opening and closing parentheses frequently used in Java source code. Since these parentheses are described at the end of a line, it is considered that a line having these parentheses at the end of the line describes a Java instruction.

(コメントアウト検出手順:ステップ4)
Javaソースコードチェックプログラム110は、ステップ3の結果を、ファイル出力、画面出力などの形態で出力する。
(Comment out detection procedure: Step 4)
The Java source code check program 110 outputs the result of step 3 in the form of file output, screen output, or the like.

以上、図3のソースコードを例に取り、Javaソースコードチェックプログラム110がコメントアウト部分を検出する動作を説明した。   The operation in which the Java source code check program 110 detects the comment-out portion has been described above using the source code of FIG. 3 as an example.

<実施の形態2:まとめ>
以上のように、本実施形態2に係るJavaソースコードチェックプログラム110は、Java命令をコメントアウトした部分と、一般コメント部分とを区別し、Java命令をコメントアウトした部分のみを検出する。これにより、古いJava命令を残したままの状態になっているJavaソースコード200を検出することができるので、Javaソースコード200の保守性を向上させることができる。
<Embodiment 2: Summary>
As described above, the Java source code check program 110 according to the second embodiment distinguishes between the commented out portion of the Java instruction and the general comment portion, and detects only the portion of the commented out Java instruction. As a result, it is possible to detect the Java source code 200 in which the old Java instruction remains, so that the maintainability of the Java source code 200 can be improved.

また、一般コメント部分とコメントアウト部分の区別は一概にはつけ難いが、本実施形態2に係るJavaソースコードチェックプログラム110は、行末のJava命令特有の記号に着目し、コメントアウトを適切に検出することに成功した。これにより、コメントアウト部分を適切に検出することができる。   In addition, although it is difficult to distinguish between a general comment part and a comment-out part, the Java source code check program 110 according to the second embodiment pays attention to a symbol unique to the Java instruction at the end of the line and appropriately detects comment-out. succeeded in. Thereby, the comment-out part can be detected appropriately.

<実施の形態3>
Javaソースコードチェックプログラム110は、以上説明した実施形態1〜2と併用して、またはこれらとは別に、Javaソースコード200の全行数に対するコメント行の割合をプログラム作成者毎に集計することもできる。
<Embodiment 3>
The Java source code check program 110 may be used in combination with the above-described first and second embodiments, or separately, and may total the ratio of comment lines to the total number of lines in the Java source code 200 for each program creator. it can.

一般に、Javaソースコード200の全行数に対するコメント行の割合は、適正な範囲が存在する。コメントが少なすぎてもJavaソースコードの内容が分かりにくくなるので好ましくないし、コメントが多すぎても却って効率がよくない。   In general, there is an appropriate range for the ratio of comment lines to the total number of lines in the Java source code 200. Even if there are too few comments, it is not preferable because the contents of the Java source code are difficult to understand, and if there are too many comments, it is not efficient.

そこで本実施形態3に係るJavaソースコードチェックプログラム110は、Javaソースコード200の全行数に対するコメント行の割合をプログラム作成者毎に集計して、コメント行の割合が適正範囲にない傾向のあるプログラム作成者を特定する。   Therefore, the Java source code check program 110 according to the third embodiment aggregates the ratio of comment lines to the total number of lines in the Java source code 200 for each program creator, and the ratio of comment lines tends not to be within the appropriate range. Identify the program creator.

具体的には、「@author」タグに記載されているプログラム作成者名毎に、作成したJavaソースコード200の全ステップ数とコメント行数をカウントし、後者を前者で除算して割合を求めればよい。算出結果は、ファイル出力、画面出力などの形態で出力する。   Specifically, for each program creator name listed in the “@author” tag, the total number of steps and the number of comment lines in the created Java source code 200 are counted, and the latter is divided by the former to obtain the ratio. That's fine. The calculation result is output in the form of file output, screen output, or the like.

<実施の形態4>
Javaソースコードチェックプログラム110は、以上説明した実施形態1〜3と併用して、またはこれらとは別に、プログラム作成者毎のクラス作成数を算出することもできる。
<Embodiment 4>
The Java source code check program 110 can calculate the number of classes created for each program creator in combination with Embodiments 1 to 3 described above or separately from them.

特定のプログラム作成者のみクラス作成数が極端に多い場合、そのプログラム作成者は既存のJavaソースコード200をコピーするなどしてJavaクラスを作成しているのではないかと想定される。これはプログラムの品質低下につながるので、かかる行為を検出するため、クラス作成数をプログラム作成者毎に集計し、ファイル出力、画面出力などの形態で出力する。   If only a specific program creator has an extremely large number of classes, it is assumed that the program creator has created a Java class by copying the existing Java source code 200 or the like. Since this leads to deterioration in the quality of the program, in order to detect such an action, the number of classes created is totaled for each program creator and output in the form of file output, screen output, and the like.

一方、特定のプログラム作成者のみクラス作成数が極端に少ない場合も、当該プログラム作成者が何らかの問題を抱えているか、またはスキル面で不足しているなどの状況が想定される。このような開発進捗管理の観点からも、本実施形態4に係る手法は有用であるといえる。   On the other hand, even when the number of classes created by only a specific program creator is extremely small, it is assumed that the program creator has some problem or lack of skills. From the viewpoint of such development progress management, it can be said that the method according to the fourth embodiment is useful.

<実施の形態5>
Javaソースコードチェックプログラム110は、以上説明した実施形態1〜4と併用して、またはこれらとは別に、Javaクラス内のメソッドの循環的複雑度を、プログラム作成者毎に集計することもできる。
<Embodiment 5>
The Java source code check program 110 can also add up the cyclic complexity of the methods in the Java class for each program creator in combination with Embodiments 1 to 4 described above or separately from them.

循環的複雑度(Cyclomatic Complexity)とは、メソッドの複雑さを表す指標として一般に用いられているものである。これは主に、メソッド内の分岐が多いと当該メソッドは複雑度が高いものとして取り扱う手法である。例えば、if文内の分岐、メソッド内で他メソッドをコールする、などの処理が分岐に相当する。   The cyclic complexity is generally used as an index representing the complexity of a method. This is mainly a technique in which a method is treated as having a high degree of complexity when there are many branches in the method. For example, processing such as branching in an if statement or calling another method in a method corresponds to branching.

循環的複雑度は、10以下であることが好ましいとされる。循環的複雑度が50を超えるとテストが不可能、75を超えるといかなる変更も誤修正を生む原因となる、とされている。どの程度の循環的複雑度を許容するかは、Javaソースコードチェックプログラム110を利用する者が適宜定めればよい。   The cyclic complexity is preferably 10 or less. If the cyclic complexity exceeds 50, the test is impossible, and if it exceeds 75, any change will cause a false correction. The degree to which the cyclic complexity is allowed may be appropriately determined by a person using the Java source code check program 110.

メソッドの複雑さは、プログラム作成者毎にある程度の傾向が見られることが経験的に分かっている。そこで本実施形態5に係るJavaソースコードチェックプログラム110は、プログラム作成者が作成したメソッドの循環的複雑度を、チェック規則の基準値を超えるメソッドについて合算し、さらにプログラム作成者毎の合算結果を、ファイル出力、画面出力などの形態で出力する。これにより、複雑なメソッドを作成する傾向のあるプログラム開発者を特定することができる。   It has been empirically known that the complexity of the method shows a certain tendency for each program creator. Therefore, the Java source code check program 110 according to the fifth embodiment adds up the cyclic complexity of the method created by the program creator for the methods exceeding the reference value of the check rule, and further displays the summation result for each program creator. , File output, screen output, etc. This makes it possible to identify program developers who tend to create complex methods.

100:コンピュータ、110:Javaソースコードチェックプログラム、200:Javaソースコード、300:チェック規則データ。   100: Computer, 110: Java source code check program, 200: Java source code, 300: Check rule data.

Claims (6)

Java(登録商標)ソースコードの品質をチェックする処理をコンピュータに実行させるプログラムであって、前記コンピュータに、
Javaソースコードを記憶装置から読み込む読込ステップと、
前記Javaソースコードに記述されているコメント部分のうち前記Javaソースコード内に記述されているJavaクラスの作成者名を記述したタグ部分を検出し、そのタグ部分から前記作成者名を抽出する作成者抽出ステップと、
前記Javaクラスのステップ数をカウントするカウントステップと、
前記読込ステップ、前記作成者抽出ステップ、および前記カウントステップを1以上の前記Javaソースコードについて実行するステップと、
前記Javaクラス1つ当たりのステップ数を前記作成者毎に集計してその結果を出力するステップと、
を実行させることを特徴とするJavaソースコードチェックプログラム。
A program for causing a computer to execute processing for checking the quality of Java (registered trademark) source code,
A reading step of reading Java source code from a storage device;
Creation of detecting a tag portion describing the creator name of the Java class described in the Java source code from the comment portion described in the Java source code, and extracting the creator name from the tag portion The person extraction step,
A counting step for counting the number of steps of the Java class;
Executing the reading step, the creator extracting step, and the counting step for one or more Java source codes;
Counting the number of steps per Java class for each creator and outputting the results;
A Java source code check program characterized in that
前記コンピュータに、
前記Javaソースコードに記述されているコメント部分のうち、Java命令をコメントアウトした部分と、一般コメント部分とを区別し、Java命令をコメントアウトした部分のみを検出するコメントアウト検出ステップを実行させる
ことを特徴とする請求項1記載のJavaソースコードチェックプログラム。
In the computer,
The comment part described in the Java source code is distinguished from a part commented out of a Java instruction and a general comment part, and a comment out detection step of detecting only a part commented out of the Java instruction is executed. The Java source code check program according to claim 1.
前記コメントアウト検出ステップでは、前記コンピュータに、
前記Javaソースコードを1行分読み込むステップと、
前記行読込ステップで読み込んだ行がコメント行であるか否かを判定するコメント行判定ステップと、
前記コメント行判定ステップにおいてコメント行であると判定した行の末尾に、Java命令文の終端子、Java言語における開始括弧、またはJava言語における終了括弧が存在するか否かを判定するJava命令判定ステップと、
前記Java命令判定ステップにおいて、前記終端子、前記開始括弧、または前記終了括弧が行末に存在すると判定した場合、当該行は一般コメント行ではなく、Java命令をコメントアウトしたコメントアウト行であると判定するステップと、
を実行させることを特徴とする請求項2記載のJavaソースコードチェックプログラム。
In the comment out detection step, the computer
Reading one line of the Java source code;
A comment line determination step for determining whether or not the line read in the line reading step is a comment line;
Java instruction determination step for determining whether or not there is an end terminal of a Java statement, a start parenthesis in Java language, or an end parenthesis in Java language at the end of the line determined to be a comment line in the comment line determination step When,
In the Java instruction determination step, if it is determined that the end terminal, the start parenthesis, or the end parenthesis is present at the end of the line, the line is determined not to be a general comment line but to a comment-out line in which the Java instruction is commented out. When,
The Java source code check program according to claim 2, wherein:
前記コンピュータに、
1人の前記作成者が作成した全ての前記Javaソースコードについて、全行数に対するコメント行の割合を算出するステップと、
前記作成者毎に前記割合を集計してその結果を出力するステップと、
を実行させることを特徴とする請求項1から3のいずれか1項記載のJavaソースコードチェックプログラム。
In the computer,
Calculating the ratio of comment lines to the total number of lines for all the Java source code created by one creator;
Summing up the percentages for each creator and outputting the results;
The Java source code check program according to any one of claims 1 to 3, wherein:
前記コンピュータに、
前記作成者毎の前記Javaクラスの作成数を集計してその結果を出力するステップを実行させる
ことを特徴とする請求項1から4のいずれか1項記載のJavaソースコードチェックプログラム。
In the computer,
The Java source code check program according to any one of claims 1 to 4, wherein a step of counting the number of Java classes created for each creator and outputting the result is executed.
前記コンピュータに、
前記Javaクラス内のメソッドの循環的複雑度を算出するステップと、
1人の前記作成者が作成した全ての前記Javaクラスについて前記循環的複雑度を合算するステップと、
前記作成者毎に前記合算の結果を集計してその結果を出力するステップと、
を実行させることを特徴とする請求項1から5のいずれか1項記載のJavaソースコードチェックプログラム。
In the computer,
Calculating a cyclic complexity of a method in the Java class;
Summing the cyclic complexity for all the Java classes created by one creator,
Aggregating the summation results for each creator and outputting the results;
The Java source code check program according to claim 1, wherein the Java source code check program is executed.
JP2010133272A 2010-06-10 2010-06-10 Java source code check program Active JP5419804B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010133272A JP5419804B2 (en) 2010-06-10 2010-06-10 Java source code check program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010133272A JP5419804B2 (en) 2010-06-10 2010-06-10 Java source code check program

Publications (2)

Publication Number Publication Date
JP2011258076A true JP2011258076A (en) 2011-12-22
JP5419804B2 JP5419804B2 (en) 2014-02-19

Family

ID=45474165

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010133272A Active JP5419804B2 (en) 2010-06-10 2010-06-10 Java source code check program

Country Status (1)

Country Link
JP (1) JP5419804B2 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104123273B (en) * 2014-07-24 2017-06-06 扬州大学 A kind of annotation quality evaluation of object-oriented program and annotation suggesting method
WO2018073865A1 (en) * 2016-10-17 2018-04-26 三菱電機株式会社 Program development assistance device, program development assistance method, program development assistance program, and recording medium
US11392371B2 (en) 2018-11-28 2022-07-19 Fujitsu Limited Identification of a partial code to be refactored within a source code

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08123674A (en) * 1994-10-28 1996-05-17 Nippon Steel Corp Comment analyzing device for program
JPH1145177A (en) * 1997-07-29 1999-02-16 Meidensha Corp Object-oriented analytic design support tool
JP2000250749A (en) * 1999-03-03 2000-09-14 Hitachi Ltd Software quality managing device
JP2004038490A (en) * 2002-07-02 2004-02-05 Hitachi Kokusai Electric Inc Method for measuring step of program according to classification by development
JP2008071110A (en) * 2006-09-14 2008-03-27 Xanavi Informatics Corp Source record review supporting device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08123674A (en) * 1994-10-28 1996-05-17 Nippon Steel Corp Comment analyzing device for program
JPH1145177A (en) * 1997-07-29 1999-02-16 Meidensha Corp Object-oriented analytic design support tool
JP2000250749A (en) * 1999-03-03 2000-09-14 Hitachi Ltd Software quality managing device
JP2004038490A (en) * 2002-07-02 2004-02-05 Hitachi Kokusai Electric Inc Method for measuring step of program according to classification by development
JP2008071110A (en) * 2006-09-14 2008-03-27 Xanavi Informatics Corp Source record review supporting device

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
CSND200900161004; 池田 俊 Suguru IKEDA: 'Web-DBアプリ開発からテストまで 現場で使えるEclipseプラグイン実践ガイド' DB Magazine 第18巻 第12号 第18巻, 株式会社翔泳社 *
CSNG199901465010; 小笠原 秀人 Hideto Ogasawara: 'ソフトウェア品質評価支援システムESQUTの適用と評価 Evaluation of software quality management sy' 情報処理学会研究報告 Vol.92 No.79 IPSJ SIG Notes 第92巻, 社団法人情報処理学会 Information Processing Socie *
JPN6013042202; 池田 俊 Suguru IKEDA: 'Web-DBアプリ開発からテストまで 現場で使えるEclipseプラグイン実践ガイド' DB Magazine 第18巻 第12号 第18巻, 株式会社翔泳社 *
JPN6013042207; 小笠原 秀人 Hideto Ogasawara: 'ソフトウェア品質評価支援システムESQUTの適用と評価 Evaluation of software quality management sy' 情報処理学会研究報告 Vol.92 No.79 IPSJ SIG Notes 第92巻, 社団法人情報処理学会 Information Processing Socie *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104123273B (en) * 2014-07-24 2017-06-06 扬州大学 A kind of annotation quality evaluation of object-oriented program and annotation suggesting method
WO2018073865A1 (en) * 2016-10-17 2018-04-26 三菱電機株式会社 Program development assistance device, program development assistance method, program development assistance program, and recording medium
JP6355861B1 (en) * 2016-10-17 2018-07-11 三菱電機株式会社 Program development support apparatus, program development support method, program development support program, and recording medium
US11392371B2 (en) 2018-11-28 2022-07-19 Fujitsu Limited Identification of a partial code to be refactored within a source code

Also Published As

Publication number Publication date
JP5419804B2 (en) 2014-02-19

Similar Documents

Publication Publication Date Title
Wehaibi et al. Examining the impact of self-admitted technical debt on software quality
US8850581B2 (en) Identification of malware detection signature candidate code
US8539475B2 (en) API backward compatibility checking
US9015666B2 (en) Updating product documentation using automated test scripts
US20160357519A1 (en) Natural Language Engine for Coding and Debugging
US20100162212A1 (en) Debugging pipeline
CN106776334B (en) Comment-based test case generation method and device
US20200004385A1 (en) Method and system for determining user interface usage
JP4946651B2 (en) Specification verification program, computer-readable recording medium recording the program, specification verification apparatus, and specification verification method
KR101623174B1 (en) Source code analysis apparatus, Computer program for the same, Recording medium storing computer program for the same
US20100095274A1 (en) System, Computer Program, and Method for a Static Code Coverage Analyzer for Computer Programs
CN104281805B (en) Method for security protection and processor
JP5419804B2 (en) Java source code check program
US9715372B2 (en) Executable guidance experiences based on implicitly generated guidance models
Castor Filho et al. Extracting error handling to aspects: A cookbook
JP2011145996A (en) Reviewer evaluation apparatus, reviewer evaluation method and program
US9286036B2 (en) Computer-readable recording medium storing program for managing scripts, script management device, and script management method
CN107885489A (en) A kind of method and system of quick detection real name registration data index
US8291389B2 (en) Automatically detecting non-modifying transforms when profiling source code
Tang et al. A tool for rejuvenating feature logging levels via git histories and degree of interest
JP2018147106A (en) Program analyzer, program analysis method and program analysis program
JP6960270B2 (en) Design document learning device and design document learning method
JP5755861B2 (en) Test case generation apparatus, test case generation method, and test case generation program
KR101116770B1 (en) Apparatus for?diagnosing and curing malicious code and method thereof
JP2011100420A (en) Test program creation device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20121219

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20130821

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130827

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20131017

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: 20131105

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20131119

R150 Certificate of patent or registration of utility model

Ref document number: 5419804

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250