PyCharm 2018.3 Help

Running Inspections Offline

In addition to running code inspections from the main menu or from the context menus of the Project Tool Window, you can also launch the inspector from the command line, without actually running PyCharm.

This way you can perform regular code inspections as a part of your development process, which is especially important for large projects. Inspection results are stored in the XML format, and you can download and view these results at any time.

To launch a code inspection from the command line

  • In the command line, run the inspect command using the following syntax:

    inspect project-path inspection-path output-path [-vX] [-d subdirectory-path]

The command options are as follows:

Option

Description

inspect

The full path to the inspect.bat ( inspect.sh on macOS and Linux) script located in the <IDE_HOME>/bin directory.

project-path

The full path to the directory that contains the project to be inspected.

inspection-path

The full path to the inspection profile against which the project is to be inspected. By default, inspection profiles are stored under the following directory:
  • Windows: %HOMEPATH%\.PyCharm2018.3\config\inspection

  • macOS: ~/Library/Preferences/PyCharm2018.3/inspection

  • Linux: ~/.PyCharm2018.3/config/inspection

output-path

The full path to an existing directory where the XML file with the inspection report will be stored.

-vX

(optional) The verbosity level of the output, where X is 0 for quiet, 1 – for noisy, and 2 – for extra noisy.

-d subdirectory-path

(optional) The full path to the subdirectory to be inspected.

Examples

Syntax
<IDE_HOME>\bin\inspect.bat project-path inspection-path output-path -v2 -d subdirectory-path
Example
<IDE_HOME>\bin\inspect.bat E:\MyProject E:\MyProject\.idea\inspectionProfiles\Project_Default.xml E:\MyProject\inspection-results-dir -v2 -d E:\MyProject\subdirectory
Syntax
PyCharm.app/Contents/bin/inspect.sh project-path inspection-path output-path -v2 -d subdirectory-path
Example
PyCharm.app/Contents/bin/inspect.sh ~/MyProject ~/MyProject/.idea/inspectionProfiles/Project_Default.xml ~/MyProject/inspection-results-dir -v2 -d ~/MyProject/subdirectory
Syntax
<IDE_HOME>/bin/inspect.sh project-path inspection-path output-path -v2 -d subdirectory-path
Example
<IDE_HOME>/bin/inspect.sh ~/MyProject ~/MyProject/.idea/inspectionProfiles/Project_Default.xml ~/MyProject/inspection-results-dir -v2 -d ~/MyProject/subdirectory

Viewing the results of an offline inspection

Having performed an offline inspection and exported the inspection results to a directory in the XML format, you can always download and view these results.

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

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

  3. In the Select Path dialog box that opens, click the directory where the XML file with the inspection results is stored.

  4. Click OK. The Inspection results are displayed in the Offline View tab in the Inspection Results Tool Window.

Last modified: 13 December 2018

See Also