# コマンドラインからコードインスペクションを実行する

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/ja-jp/help/clion/llms.txt).

CLion は [コードインスペクションを実行](code-inspection.html)して、構文エラー、デッドコード、考えられるバグ、不適切なコーディングスタイル、その他の問題を見つけてハイライトします。 コマンドラインから特定のプロジェクト用に構成されたすべてのインスペクションを実行し、結果をレポート付きの XML、JSON、プレーンテキストファイルとして保存することもできます。

The command-line inspector launches an instance of CLion in the background where it runs the inspections. すでに別の CLion のインスタンスが実行中の場合は機能しません。 この場合、実行中のインスタンスでインスペクションを使用できます。 コマンドラインインスペクターを使用して、多くのコントリビューターがいる大規模プロジェクトの自動化された定期的なコード分析を行います。

Windows:

CLion を実行するための実行可能ファイルは、 [インストールディレクトリ](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html)の  `bin`  にあります。 この実行ファイルをコマンドラインランチャーとして使用するには、 [コマンドラインインターフェース](working-with-the-ide-features-from-command-line.html)の説明に従って、システム  `PATH`  に追加してください。

構文
: ```PLAINTEXT
: clion64.exe inspect <project> <inspection-profile> <output> [<options>]
:
: ```

サンプル
: 最大の詳細度で  `C:\MyProject\.idea\inspectionProfiles\MyProfile.xml`  プロファイルを使用して  `C:\MyProject`  プロジェクトの  `C:\MyProject\src`  ディレクトリをインスペクションし、結果を  `C:\MyProject\InspectionResults`  の XML ファイルに保存します。
:
:
:
:
: ```SHELL
: clion64.exe inspect C:\MyProject C:\MyProject\.idea\inspectionProfiles\MyProfile.xml C:\MyProject\InspectionResults -v2 -d C:\MyProject\src
:
: ```

macOS:

CLion includes a script for running the command-line code inspector. デフォルトでは、アプリケーションパッケージ  `CLion.app/Contents/bin/inspect.sh`  にあります。

構文
: ```PLAINTEXT
:
: inspect.sh <project> <inspection-profile> <output> [<options>]
:
: ```

サンプル
: 最大の詳細度で  `~/MyProject/.idea/inspectionProfiles/MyProfile.xml`  プロファイルを使用して  `~/MyProject`  プロジェクトの  `~/MyProject/src`  ディレクトリをインスペクションし、結果を  `~/MyProject/InspectionResults`  の XML ファイルに保存します。
:
:
:
:
: ```SHELL
:
: inspect.sh ~/MyProject ~/MyProject/.idea/inspectionProfiles/MyProfile.xml ~/MyProject/InspectionResults -v2 -d ~/MyProject/src
:
: ```

Linux:

CLion を実行するためのスクリプトは、 [インストールディレクトリ](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html)の  `bin`  にあります。 このスクリプトをコマンドラインランチャーとして使用するには、 [コマンドラインインターフェース](working-with-the-ide-features-from-command-line.html)の説明に従って、システムの  `PATH`  に追加してください。

構文
: ```PLAINTEXT
: clion.sh inspect <project> <inspection-profile> <output> [<options>]
:
: ```

サンプル
: 最大の詳細度で  `~/MyProject/.idea/inspectionProfiles/MyProfile.xml`  プロファイルを使用して  `~/MyProject`  プロジェクトの  `~/MyProject/src`  ディレクトリをインスペクションし、結果を  `~/MyProject/InspectionResults`  の XML ファイルに保存します。
:
:
:
:
: ```SHELL
: clion.sh inspect ~/MyProject ~/MyProject/.idea/inspectionProfiles/MyProfile.xml ~/MyProject/InspectionResults -v2 -d ~/MyProject/src
:
: ```

> **Note:**
> When you launch an instance of CLion in the headless mode, the project is in the [trusted mode](project-security.html) by default.

## オプション

|  オプション  |  説明  |
| --- | --- |
|   `-changes`   |  ローカルのコミットされていない変更に対してのみインスペクションを実行します。  |
|   `-d`   |  プロジェクト全体をインスペクションしたくない場合は、サブディレクトリへのフルパスを指定します。  |
|   `-format`   |     インスペクションの結果で出力ファイルの形式を指定します:  `xml`  （デフォルト）、  `json`  、  `plain`      |
|   `-v`   |     出力の詳細レベルを設定します:        * `-v0` はデフォルトの低冗長度です。    * `-v1` は中程度の詳細度です。    * `-v2` は最大の冗長性です。    |

## インスペクションプロファイル

An [inspection profile](customizing-profiles.html) is an  `.xml`  file that specifies enabled inspections and their options.

デフォルトでは、  プロジェクトインスペクションプロファイル はプロジェクトディレクトリ  `.idea/inspectionProfiles`  に保存されます。

グローバル  IDE インスペクションプロファイル は、  `inspection`  の [IDE 構成ディレクトリ](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-directory)に保管されます。

## インスペクション結果

You can open the generated XML file with inspection results in CLion or any text editor as a regular file. ただし、   オフラインビュー  の [問題ツールウィンドウ](problems-tool-window.html)を使用して分析する方が便利です:

Procedure: インスペクションの結果を見る

1. インスペクションを実行したプロジェクトを開きます。

2. メインメニューで  `コード | コードの解析 | オフラインインスペクション結果の表示`  に移動します

3. インスペクションの結果が含まれるディレクトリを選択し、   OK   をクリックします。

