Code Quality in IDEA

As part of our commitment to delivering software at a professional level, we emphasize the importance of code quality. To evaluate Groovy source code, CodeNarc tool is used. In Pricefx Studio, the code quality evaluation is supported by the CodeNarc plugin that is available in IDEA.

Setup

Install CodeNarc Plugin

Make sure you install IDEA 2023 or later, since older versions work with older versions of CodeNarc plugin which was causing issues.

If you have not installed CodeNarc yet, navigate to Preferences > Plugins > Marketplace > search for “codenarc” and click Install. When asked, restart IDEA for the changes to take effect.

Add Code Quality Profile to Project

To ensure code quality, we utilize IDEA's standard inspection functionality. Due to the unique nature of Pricefx, certain inspections can produce false alerts, but other inspections we encourage you to follow. To align with this, we have adjusted the inspection rules – some defaults are disabled, while others initially disabled are enabled. This approach has led us to create a standard Pricefx code quality profile that encompasses the most fitting rules.

To copy the profile with Pricefx inspections to IDEA and assign it to the project:

You should then see the inspection profile “Pricefx Configuration” in Preferences > Inspections > Profile.

 

Repeat this step for every Pricefx project you work at.

In case you’d need to install the profile manually e.g. if there would be a newer version published, download it as XML file from https://developer.pricefx.eu/studio/codenarc/Pricefx_Configuration.xml and import it under the gear icon in Preferences > Inspections > Profile by selecting Import Profile from the popup menu.

For more details see Configure profiles | IntelliJ IDEA.

How To Use

Once the CodeNarc plugin is installed and the inspection profile is added to your project, you can start checking the inspections IDEA is displaying.

Current File in Editor

The IDE continuously checks your code and searches for problems. The widget in the top-right corner of the editor displays the number of problems of each severity detected in the current file:

Click the widget to open the list of problems on the Current File tab of the Problems tool window. You can also access the Problems tool window by selecting View > Tool Windows > Problems or by pressing CTRL+6 (Windows) or ⌘+6 (Mac).

The color stripe in the scrollbar also marks the detected code problems and helps you quickly access the corresponding lines without scrolling the file. Hover over a mark on the stripe to see the detected problem in a tooltip. Click a mark to jump to the corresponding line.

For details see File and project analysis | IntelliJ IDEA.

Current File in Problems Tool Window

When the design-time code inspection is enabled, this tab lists all code issues found in the current file. The list is updated as you switch between files in the editor.

You can select any problem in the window and press ⌘ ↓ or double-click any problem to jump to the corresponding line in the editor.

To see more detailed information about the rule, right click on any problem > Inspection xxx options > Show Quick-Fixes > Edit inspection profile setting.

Hint: Many inspection problems can be solved by auto-formatting the code: Code > Reformat Code or by pressing Ctrl+Alt+L (Windows) or ⌥ ⌘ L (Mac).

For details see Problems tool window | IntelliJ IDEA.

Analyze the Whole Project

To get a list of all problems across a project, navigate to Code > Inspect Code > Analyze. The tool window Problems will open and you will get a report with problems, their count and occurrences:

See also:

Found an issue in documentation? Write to us.