# Run code inspections from the command line

IntelliJ IDEA [runs code inspections](code-inspection.html) to find and highlight syntax errors, dead code, possible bugs, bad coding style, and other problems. You can also run all the configured inspections for a specific project from the command line and store the results as an XML, JSON, or plain text file with a report.

The command-line inspector launches an instance of IntelliJ IDEA in the background where it runs the inspections. It will not work if another instance of IntelliJ IDEA is already running. In this case, you can use inspections in the running instance. Use the command-line inspector for automated regular code analysis of large projects with many contributors.

> **Note:**
> Code inspections rely on a properly defined [project SDK](sdk.html).

Windows:

You can find the executable for running IntelliJ IDEA in the [installation directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html) under `bin`. To use this executable as the command-line launcher, add it to your system `PATH` as described in [Command-line interface](working-with-the-ide-features-from-command-line.html).

Syntax
: ```PLAINTEXT
: idea64.exe inspect <project> <inspection-profile> <output> [<options>]
: ```

Example
: Inspect the `C:\MyProject\src` directory of the `C:\MyProject` project using the `C:\MyProject\.idea\inspectionProfiles\MyProfile.xml` profile with maximum verbosity, and save results to an XML file under `C:\MyProject\InspectionResults`:
:
:
:
:
:
:
: ```SHELL
: idea64.exe inspect C:\MyProject C:\MyProject\.idea\inspectionProfiles\MyProfile.xml C:\MyProject\InspectionResults -v2 -d C:\MyProject\src
: ```

macOS:

IntelliJ IDEA includes a script for running the command-line code inspector. By default, it is located in the application package:  `IntelliJ IDEA.app/Contents/bin/inspect.sh`

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

Example
: Inspect the `~/MyProject/src` directory of the `~/MyProject` project using the `~/MyProject/.idea/inspectionProfiles/MyProfile.xml` profile with maximum verbosity, and save results to an XML file under `~/MyProject/InspectionResults`:
:
:
:
:
:
:
:
:
: ```SHELL
:
: inspect.sh ~/MyProject ~/MyProject/.idea/inspectionProfiles/MyProfile.xml ~/MyProject/InspectionResults -v2 -d ~/MyProject/src
: ```

Linux:

You can find the script for running IntelliJ IDEA in the [installation directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html) under `bin`. To use this script as the command-line launcher, add it to your system `PATH` as described in [Command-line interface](working-with-the-ide-features-from-command-line.html).

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

Example
: Inspect the `~/MyProject/src` directory of the `~/MyProject` project using the `~/MyProject/.idea/inspectionProfiles/MyProfile.xml` profile with maximum verbosity, and save results to an XML file under `~/MyProject/InspectionResults`:
:
:
:
:
:
:
:
:
:
:
: ```SHELL
: idea.sh inspect ~/MyProject ~/MyProject/.idea/inspectionProfiles/MyProfile.xml ~/MyProject/InspectionResults -v2 -d ~/MyProject/src
: ```

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

## Options

| Option | Description |
| --- | --- |
| `-changes` | Run inspections only on local uncommitted changes. |
| `-d` | Specify the full path to the subdirectory if you don't want to inspect the whole project. |
| `-format` |    Specify the format of the output file with inspection results: `xml` (default), `json`, or `plain`.    |
| `-v` |    Set the verbosity level of the output:                            * `-v0` is the default low verbosity.    * `-v1` is medium verbosity.    * `-v2` is maximum verbosity.    |

## Inspection profiles

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

By default, project inspection profiles are stored in the project directory: `.idea/inspectionProfiles`.

Global IDE inspection profiles are stored in the [IDE configuration directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-directory) under `inspection`.

## Inspection results

You can open the generated XML file with inspection results in IntelliJ IDEA or any text editor as a regular file. However, it is more convenient to analyze it using the Offline View of the [Problems tool window](problems-tool-window.html):

Procedure: View inspection results

1. Open the project for which you ran the inspection.

2. In the main menu, go to `Code | Analyze Code | View Offline Inspection Results`

3. Select the directory with the inspection results and click OK.

