Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

Because we want to deliver software on a professional level, we do care about the code quality. The groovy source code is evaluated by CodeNarc tool. In Studio, the code quality is supported by the CodeNarc plugin that is available in IDEA.

Setup

Install CodeNarc Plugin

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

Add Code Quality Profile To The Project

For code quality, we are using the standard inspection functionality built-in IDEA. Due to Pricefx nature, some of the inspections are not relevant and are causing false alerts and some of them we would like to encourage you to follow. Therefore we have disabled some inspection rules that are enabled by default and enabled some that are initially disabled and that’s how we created a standard Pricefx code quality profile with the best rules we think to follow. The profile is copied to IDEA and assigned to the project during the action Add Framework Support:

Right-click on the root folder > Add Framework Support > check Pricefx > OK.

If you don’t have the “Add Framework Support” option in the menu, remove the “Pricefx API” library first: Right click on the root folder >  Open Module Settings > Libraries > Pricefx API (last in the list) > click [-] button above to remove this library > OK.

You should be able to see the inspection profile “Pricefx Configuration” in:

Preferences > Inspections > Profile.

Repeat this step for every Pricefx project you work with.

In case the you would need to manually install the profile, download it as XML file from

https://developer.pricefx.eu/studio/codenarc/Pricefx_Configuration.xml

and import using “Import Profile” from the popup menu under the gear icon in Preferences > Inspections > Profile.

https://www.jetbrains.com/help/idea/customizing-profiles.html

How To Use

Once the CodeNarc plugin is installed and inspection profile is added to the 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:

Inspection widget

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.

https://www.jetbrains.com/help/idea/file-and-project-analysis.html

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: Lot of the problems can be solved by auto-formatting the code: Code > Reformat Code or by pressing Ctrl + Alt + L (Windows) or ⌥ ⌘ L (Mac).

https://www.jetbrains.com/help/idea/problems-tool-window.html#current-file

Analyze the whole project

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

See also:

Code Conventions

/wiki/spaces/LEARN/pages/1748632039

Code Quality On Projects

  • No labels