| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>第7章 FindBugs™ Eclipse プラグインの使用方法</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs™ マニュアル"><link rel="up" href="index.html" title="FindBugs™ マニュアル"><link rel="prev" href="anttask.html" title="第6章 FindBugs™ Ant タスクの使用方法"><link rel="next" href="filter.html" title="第8章 フィルターファイル"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">第7章 <span class="application">FindBugs</span>™ Eclipse プラグインの使用方法</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="anttask.html">戻る</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="filter.html">次へ</a></td></tr></table><hr></div><div class="chapter" title="第7章 FindBugs™ Eclipse プラグインの使用方法"><div class="titlepage"><div><div><h2 class="title"><a name="eclipse"></a>第7章 <span class="application">FindBugs</span>™ Eclipse プラグインの使用方法</h2></div></div></div><div class="toc"><p><b>目次</b></p><dl><dt><span class="sect1"><a href="eclipse.html#d0e1677">1. 必要条件</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1684">2. インストール</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1731">3. プラグインの使用方法</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1754">4. Eclipse プラグインの拡張方法 (2.0.0 以降)</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1807">5. トラブルシューティング</a></span></dt></dl></div><p> |
| FindBugs Eclipse プラグインを使用することによって、 <span class="application">FindBugs</span> を <a class="ulink" href="http://www.eclipse.org/" target="_top">Eclipse</a> IDE で使用することができるようになります。 |
| このFindBugs Eclipse プラグインは、 Peter Friese 氏の多大な貢献によるものです。 |
| Phil Crosby 氏 と Andrey Loskutov 氏は、プラグインの重要な改良に貢献しました。 |
| </p><div class="sect1" title="1. 必要条件"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1677"></a>1. 必要条件</h2></div></div></div><p><span class="application">FindBugs</span> Eclipse Plugin を使用するためには、 Eclipse 3.3 あるいはそれ以降のバージョン、また、 JRE/JDK 1.5 あるいはそれ以降のバージョンが必要です。</p></div><div class="sect1" title="2. インストール"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1684"></a>2. インストール</h2></div></div></div><p>更新サイトが提供されています。更新サイトを利用して、機械的に FindBugs を Eclipse にインストールできます。また自動的に、最新版のアップデートを照会してインストールすることもできます。内容の異なる 3 つの更新サイトが存在します。</p><div class="variablelist" title="FindBugs Eclipse 更新サイト一覧"><p class="title"><b>FindBugs Eclipse 更新サイト一覧</b></p><dl><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse/" target="_top">http://findbugs.cs.umd.edu/eclipse/</a></span></dt><dd><p>FindBugs の公式リリース物を提供します。</p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-candidate/" target="_top">http://findbugs.cs.umd.edu/eclipse-candidate/</a></span></dt><dd><p>FindBugsの公式リリース物に加えて、公式リリース候補版を提供します。</p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-daily/" target="_top">http://findbugs.cs.umd.edu/eclipse-daily/</a></span></dt><dd><p>FindBugsの日次ビルド物を提供します。コンパイルができること以上のテストは行われていません。</p></dd></dl></div><p>また、次に示すリンクから手動でプラグインをダウンロードすることもできます : <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_3.0.0.20140706.zip?download" target="_top">http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_3.0.0.20140706.zip?download</a>. 展開して Eclipse の「plugins」サブディレクトリーに入れてください。(そうすると、 <eclipse インストールディレクトリー >/plugins/edu.umd.cs.findbugs.plugin.eclipse_3.0.0.20140706/findbugs.png が <span class="application">FindBugs</span> のロゴファイルへのパスになるはずです。)</p><p>プラグインの展開ができたら、 Eclipse を起動して <span class="guimenu">Help</span> → <span class="guimenuitem">About Eclipse Platform</span> → <span class="guimenuitem">Plug-in Details</span> を選択してください。「FindBugs Project」から提供された「FindBugs Plug-in」というプラグインがあることを確認してください。</p></div><div class="sect1" title="3. プラグインの使用方法"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1731"></a>3. プラグインの使用方法</h2></div></div></div><p>実行するには、 Java プロジェクト上で右クリックして「Find Bugs」を選択します。<span class="application">FindBugs</span> が実行されて、バグパターンの実例の可能性があると識別されたコード箇所に問題マーカーがつきます。 (ソース画面および Eclipse 問題ビューに表示されます。)</p><p>Java プロジェクトのプロパティーダイアログを開いて「Findbugs」プロパティーページを選択することで、 <span class="application">FindBugs</span> の動作をカスタマイズすることができます。選択できる項目には次のようなものがあります :</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>「Run FindBugs Automatically」チェックボックスの設定。チェックすると、プロジェクト内の Java クラスが修正されるたびに FindBugs が実行されます。</p></li><li class="listitem"><p>優先度とバグカテゴリーの選択。これらのオプションは、どの警告を表示するかを選択します。例えば、優先度で 「Medium」 を選択すると、優先度 (中) および優先度 (高) の警告のみが表示されます。同様に、「Style」チェックボックスのチェックマークを外すと、Style カテゴリーに属する警告は表示されません。</p></li><li class="listitem"><p>ディテクタの選択。表からプロジェクトで有効にしたいディテクタを選択することができます。</p></li></ul></div></div><div class="sect1" title="4. Eclipse プラグインの拡張方法 (2.0.0 以降)"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1754"></a>4. Eclipse プラグインの拡張方法 (2.0.0 以降)</h2></div></div></div><p> |
| Eclipse プラグインでは、 独自の <span class="application">FindBugs</span> ディテクタを追加することができます。 |
| (詳しく知りたい方は、 |
| <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a> |
| もご覧ください)。 |
| 独自のプラグインを Eclipse に追加するには以下の2通りの方法があります。 |
| </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> |
| 既存の標準 <span class="application">FindBugs</span> ディテクタパッケージは以下で設定できます。 |
| <span class="guimenu">Window</span> → <span class="guimenuitem">Preferences</span> → <span class="guimenuitem">Java</span> → <span class="guimenuitem">FindBugs</span> → <span class="guimenuitem">Misc. Settings</span> → <span class="guimenuitem">Custom Detectors</span>。 |
| ここで追加するプラグインライブラリの場所を指定するだけです。 |
| </p><p> |
| この方法の利点は、既存のディテクタパッケージは「そのまま」で、サードパーティーディテクタの品質をすばやく検証できることです。 |
| 欠点としては、この設定は Eclipse ワークスペース毎に適用する必要があり、この設定をチームメンバー間で共有することができないことです。 |
| </p></li><li class="listitem"><p> |
| Eclipse 標準の拡張機構を使って独自のディテクタを追加することができます。 |
| </p><p> |
| <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/eclipsePlugin/schema/detectorPlugins.exsd" target="_top"> |
| findBugsEclipsePlugin/schema/detectorPlugins.exsd</a> の documentation で plugin.xml の更新方法を確認してください。 |
| 既存の <span class="application">FindBugs</span> ディテクタプラグイン を簡単に「拡張」して強力な <span class="application">FindBugs</span> Eclipse ディテクタプラグイン にすることができます。 |
| 通常必要なのは、 META-INF/MANIFEST.MF および plugin.xml を jar に追加してかつ、 MANIFEST.MF がビルド時に上書きされないようにビルドスクリプトを更新するだけです。 |
| </p><p> |
| この方法の利点は、 Eclipse インストールを共有しさえすれば、チームメンバー同士で正確に同じディテクタ設定を使用できることです。 |
| 前提条件は現在使用しているディテクタパッケージを Eclipse プラグインに変換しておくことです。 |
| これはサードパーティのディテクタパッケージも同様です。 |
| もうひとつの主な差別化要因は、 FindBugs のデフォルト実行時クラスパス に当該サードパーティライブラリーを追加することが必要なことです(くわしくは |
| <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a> |
| をご覧ください)。 |
| </p></li></ul></div></div><div class="sect1" title="5. トラブルシューティング"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1807"></a>5. トラブルシューティング</h2></div></div></div><p> |
| このセクションでは、プラグインに関する一般的な問題と (判明していれば) それらの問題の解決方法を記述します。 |
| </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> |
| Eclipse において <span class="application">FindBugs</span> の分析開始後に OutOfMemory エラーダイアログが 出た場合は、 |
| JVM の使用メモリを増やしてください。すなわち、 eclipse.ini の末尾に以下の記述を追加してください。 |
| </p><pre class="programlisting"> |
| -vmargs |
| -Xmx1000m |
| </pre><p> |
| 重要:「-vmargs」で始まる設定引数は eclipse.ini ファイルの末尾に記述する必要があります。 |
| また、各行には引数を一つだけしか書くことができません! |
| </p></li><li class="listitem"><p> |
| <span class="application">FindBugs</span> 問題マーカーが (ソース画面および問題ビューに) 表示されない場合は、問題ビューのフィルター設定を変更してください。 |
| 詳細情報は <a class="ulink" href="http://findbugs.sourceforge.net/FAQ.html#q7" target="_top">http://findbugs.sourceforge.net/FAQ.html#q7</a> を参照してください。 |
| </p></li></ul></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="anttask.html">戻る</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="filter.html">次へ</a></td></tr><tr><td width="40%" align="left" valign="top">第6章 <span class="application">FindBugs</span>™ <span class="application">Ant</span> タスクの使用方法 </td><td width="20%" align="center"><a accesskey="h" href="index.html">ホーム</a></td><td width="40%" align="right" valign="top"> 第8章 フィルターファイル</td></tr></table></div></body></html> |