DataGrip 2018.3 Help

Code inspection

DataGrip features robust, fast, and flexible static code analysis. It detects syntax errors, suggests corrections and improvements.

DataGrip performs code analysis by applying inspections to your code. Code inspections work for SQL, HTML, JSON, XML, and other supported languages.

DataGrip's code analysis is configurable. You can enable or disable each code inspection and change its severity, create profiles with custom sets of inspections, apply inspections differently in different scopes, suppress inspections in specific pieces of code, and more.

The analysis can be performed in several ways:

  • By default, DataGrip analyses all open files and highlights all detected code issues right in the editor. On the right side of the editor you can see the analysis status of the whole file (the icon in the top-right corner).

    The severity levels are the following: an error (The error icon), a warning The warning icon, no issues found (The OK icon).

  • Alternatively, you can run code analysis in a bulk mode for the specified scope, which can be as large as the whole project.

  • If necessary, you can apply a single code inspection in a specific scope.

For some detected code issues, DataGrip provides quick fix suggestions. You can quickly review errors in a file by navigating from one highlighted line to another by pressing F2Shift+F2.

Inspection severity

Inspection severity indicates how seriously the detected code issues impact the project and determines how the detected issues are highlighted in the editor. By default, each inspection has one of the following severity levels:

  • Server problem server problem

  • Typo typo

  • No highlighting, only fix info

  • Weak Warning weak warning

  • Warning warning

  • Error error

You can increase or decrease the severity level of each inspection. For example, you can force DataGrip to display some warnings as errors or weak warnings. In a similar way, what is initially considered a weak warning can be displayed as a warning, an error, or just as a reference information.

You can also configure the color and font style used to highlight each severity level. Besides, you can create custom severity levels and set them for specific inspections.

If necessary, you can set different severity levels for the same inspection in different scopes.

All modifications to inspections mentioned above are saved in the inspection profile currently selected in the inspection settings and apply when this profile is used.

Inspection scope

By default, all enabled code inspections apply to all project files. If necessary, you can configure each code inspection (enable or disable, change its severity level and options) individually for different scopes. Such configurations, like any other inspection settings, are saved and applied as part of a specific profile.

There may be complicated cases when an inspection has different configurations associated with different scopes. When such inspection is executed in a file belonging to some or all of these scopes, the settings of the highest priority scope-specific configuration are applied. The priorities are defined by the relative position of the inspection's scope-specific configuration in inspection settings: the uppermost configuration has the highest priority. The Everywhere else configuration always has the lowest priority.

Examples of code inspections

To see the list of available inspections, open Settings | Preferences (Ctrl+Alt+S) and navigate to Editor | Inspections.

An unused subquery item

Detects an unused item in the subquery (for example, a field).

Unused subquery item

DELETE or UPDATE statements without the WHERE clause

If you forgot to put the WHERE clause in DELETE and UPDATE statements, DataGrip displays a notification to remind you about that. If you omitted the WHERE clause intentionally, you can execute current statements as you planned.

Notification when you run DELETE and UPDATE without WHERE
Last modified: 6 February 2019