TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

Inspections

Last modified: 20 April 2023

The Inspections (IntelliJ IDEA) Build Runner is intended to run code analysis based on IntelliJ IDEA inspections for your project. Since TeamCity 2017.1, in addition to the bundled version, it is possible to install another version of JetBrains IntelliJ Inspections and Duplicates Engine and/or change the defaults using the Administration | Tools page.

IntelliJ IDEA's code analysis engine is capable of inspecting your Java, JavaScript, HTML, XML and other code and allows you to:

  • Find probable bugs

  • Locate "dead" code

  • Detect performance issues

  • Improve the code structure and maintainability

  • Ensure the code conforms to guidelines, standards and specifications

Refer to IntelliJ IDEA documentation for more details.

This page contains reference information about the following Inspections (IntelliJ IDEA) Build Runner fields:

IntelliJ IDEA Project Settings



Unresolved Project Modules and Path Variables



This section is displayed when an IntelliJ IDEA module file (.iml) referenced from an IntelliJ IDEA project file:

  • cannot be found

  • allows you to enter the values of path variables used in the IPR-file.

To refresh the values in this section, click Check/Reparse Project.

Project SDKs



This section provides the list of SDKs detected in the project.

Inspection Parameters



In IntelliJ IDEA-based IDEs, the code inspections reported are configured by an inspection profile. When running the inspections in TeamCity, you can specify the inspection profile to use: first you need to configure the inspection profile in IntelliJ IDEA-based IDE and then specify it in TeamCity.

Follow these rules when preparing inspection profiles:

  • if your inspection profile uses scopes, make sure the scopes are shared;

  • lock the profile (this ensures that inspections present in TeamCity but not enabled in your IDEA installation will not be run by TeamCity);

  • ensure the profile does not have inspections provided by plugins not included into the default IntelliJ IDEA Ultimate distribution (otherwise they will just be ignored by TeamCity);

  • for best results, edit the inspection profile in the IntelliJ IDEA of the same version as used by TeamCity (can be looked up in the inspection build log).

The logic of selecting an inspection profile is as follows:

  • if the path to the inspection profile is specified, then the profile will be loaded from the file. If the loading fails, the inspection runner will fail too.

  • if the name of the inspection profile is specified, the profile is searched for in the project's shared profiles. If there is no such profile, the inspection runner will fail.

  • if neither the name nor path is specified, the default profile of the project is used.

For Maven inspections run, to ensure correct Java is used for the project JDK, define env.JAVA_HOME configuration parameter pointing to the JDK to be used as the project JDK.

Getting the same results in IntelliJ IDEA and TeamCity Inspections Build



The code inspections reported by IntelliJ IDEA and TeamCity Java Code Inspections build depend on a number of factors. You would need to ensure equal settings in IntelliJ IDEA and the build to get the same reports. The relevant settings include:

  • inspections profile used in IntelliJ IDEA and TeamCity build;

  • environment-specific project dependencies (files not in version control, etc.);

  • IDE-level settings, like defined SDKs, path variables, etc.;

  • generated files: should be present in the TeamCity agent if they are present when working with the project in IntelliJ IDEA;

  • IntelliJ IDEA version. It is recommended to use the same IntelliJ IDEA version that is used in the TeamCity build. TeamCity bundled an installation of IntelliJ IDEA. The version is written in the Inspections build log;

  • the set and versions of the IntelliJ IDEA plugins that the project relies on.