IntelliJ IDEA 2019.3 Help

Run code inspections from the command line

When working in the IntelliJ IDEA editor, it constantly runs code inspections to find and highlight syntax errors, dead code, possible bugs, bad coding style, and so on. You can also run all the configured inspections from the command line, without opening your project in IntelliJ IDEA. This way you can perform regular code analysis as a part of your development process, which is especially important for large projects with big teams. Inspection results can be stored as an XML, JSON, or plain text file with a report.

Syntax
idea.bat 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:

idea.bat inspect C:\MyProject C:\MyProject\.idea\inspectionProfiles\MyProfile.xml C:\MyProject\InspectionResults -v2 -d C:\MyProject\src
Syntax
idea 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:

idea inspect ~/MyProject ~/MyProject/.idea/inspectionProfiles/MyProfile.xml ~/MyProject/InspectionResults -v2 -d ~/MyProject/src
Syntax
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:

idea.sh inspect ~/MyProject ~/MyProject/.idea/inspectionProfiles/MyProfile.xml ~/MyProject/InspectionResults -v2 -d ~/MyProject/src

Options

Option

Description

-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 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 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 Inspection Results Tool Window:

View inspection results

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

  2. From the main menu, choose Analyze | View Offline Inspection Results.

  3. Select the XML file with the inspection results and click OK.

Last modified: 21 February 2020