IntelliJ IDEA 2022.3 Help

Run inspections

IntelliJ IDEA analyses code in the files that are opened in the editor and highlights problematic code as you type. Additionally, you can run the necessary inspection or a set of inspections on the selected scope of files manually. In this case, you will get a comprehensive report of all problems detected in the files.

Run inspections manually

Some inspections require global code analysis, and that is why they are disabled in the editor. These inspections are listed in Settings | Editor | Inspections. Click Filter Inspections and select Show only batch-mode inspections.

If you want to get a full report of all detected problems, run inspections manually.

Run all inspections

  1. From the main menu, select Code | Inspect Code.

  2. Select the scope of files that you want to analyze.

    Click the the Browse button icon to configure a new scope.

  3. Select the inspection profile that you want to apply.

    To create a new profile or modify one of the existing profiles, click Configure.

  4. Click OK to start the analysis.

The Specify Inspection Scope dialog

Run a single inspection

Running a single inspection is useful in case you want to track a specific problem. If you find a warning in a file, you can inspect your entire project, or the necessary scope of files, to ensure that there are no more such warnings in your code base.

  1. From the main menu, select Code | Analyze Code | Run Inspection by Name… or press Ctrl+Alt+Shift+I.

  2. Type the inspection name in the popup. Use CamelHumps to match camel case words and white spaces with initial letters of the words. The suggestion list will show you inspections that match your search request.

    If you are not sure that you are selecting the correct inspection, you can view its description. To do so, select an inspection in the popup and press Ctrl+Q.

  3. Double-click the necessary inspection to open its settings.

  4. In the dialog that opens, select the scope of files that you want to analyze.

    The File mask(s) option helps you narrow down the number of files that will be inspected.

    Select the checkbox and specify a pattern of characters and wildcards that matches the names of files you want to analyse. Use a comma to separate multiple file masks.

  5. Some inspections might have additional options that you will be prompted to configure.

    These settings will only be applied to this run, and will not affect this inspection's configuration in your current profile.

    The IDE will show you the inspection results in the dedicated tool window tool window. There you can examine and fix detected problems.

Analyze code before committing it to Git

If your project is under Git version control, you can configure the IDE to analyze modified files before committing them.

  1. Press Ctrl+K or select Git | Commit from the main menu.

  2. In the Commit tool window, click Show Commit Options and in the Before commit area, select the Analyze code checkbox.

    Alternatively, if you're using the Commit Changes dialog, in the Before Commit area, select the Analyze code checkbox.

  3. Click Configure and select the required inspection profile from which the IDE will run inspections.

    Commit tool window
    Modal Commit dialog
  4. Click Commit.

    IntelliJ IDEA analyzes the code from the modified files by running inspections from the selected profile.

    If any errors or warnings are detected, you will see a notification.

    Notification on detected problems
  5. In the notification, click Review code analysis to see the list of the detected problems in the Messages tool window. Click Commit to commit your changes without fixing the detected problems.

Run inspections offline

In addition to running code inspections from the IDE, you can launch inspections from the command line without actually running IntelliJ IDEA. The inspection results will be stored in an XML file. For more information, refer to Run code inspections from the command line.

Change the order of scopes

By default, all enabled code inspections analyze all files in your project. Depending on your needs, you can run the same inspection in more than one scope of files with different settings.

If one file is included in two or more scopes, and you enable an inspection in these scopes, IntelliJ IDEA will process them according to their order in the list of scopes — the uppermost scope will have the highest priority, and therefore, it will be analyzed first.

  1. In the Settings dialog (Ctrl+Alt+S), select Editor | Inspections.

  2. Select any inspection from the list.

  3. From the In All Scopes list, select Edit Scopes Order.

  4. Select the necessary scope, and use the Up button and the Down button to move it up and down the list.

    Changing the order of scopes
  5. If needed, create a new scope. To do so, click the Edit button (Edit Scopes), specify scope settings, and select the files and folders that you want to include in it.

Last modified: 28 November 2022