Launching Code Inspection from Command Line
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
inspectcommand using the following syntax:inspect project-path inspection-path output-path [-vX] [-d subdirectory-path]
The command options are as follows:
| || |
The full path to the inspect.bat ( inspect.sh on macOS and Linux) script located in the <IDE_HOME>/bin directory.
The full path to the directory that contains the project to be inspected.
| || |
The full path to the inspection profile against which the project is to be inspected.
An inspection profile is an .xml file that specifies enabled inspections and their options.
There are two types of profiles: project profiles and IDE profiles, and they are kept in different locations.
By default, project inspection profiles are stored in the project directory under the .idea/inspectionProfiles node.
IDE profiles are located under the following directory:
The full path to an existing directory where the XML file with the inspection report will be stored.
(optional) The verbosity level of the output, where
(optional) The full path to the subdirectory to be inspected.
- <IDE_HOME>\bin\inspect.bat project-path inspection-path output-path -v2 -d subdirectory-path
- <IDE_HOME>\bin\inspect.bat E:\MyProject E:\MyProject\.idea\inspectionProfiles\Project_Default.xml E:\MyProject\inspection-results-dir -v2 -d E:\MyProject\subdirectory
- PyCharm.app/Contents/bin/inspect.sh project-path inspection-path output-path -v2 -d subdirectory-path
- PyCharm.app/Contents/bin/inspect.sh ~/MyProject ~/MyProject/.idea/inspectionProfiles/Project_Default.xml ~/MyProject/inspection-results-dir -v2 -d ~/MyProject/subdirectory
- <IDE_HOME>/bin/inspect.sh project-path inspection-path output-path -v2 -d subdirectory-path
- <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.
Open the project against which you ran the inspection.
From the main menu, choose.
In the Select Path dialog that opens, click the directory where the XML file with the inspection results is stored.
Click OK. The Inspection results are displayed in the Offline View tab in the Inspection Results Tool Window.