This section will walk through the main parts of the GUI and how we can use them. For more detailed information, please visit GUI Reference.
The Cookbook Manager tool window, which can be opened from the Sensei Menu, lists all the cookbooks that you have available.
This tool window also allows us to add, remove and edit cookbooks.
The checkboxes in the list can switch cookbooks on and off.
Recipes in the project's
.sensei folder have been automatically loaded.
You can manage them to see what recipes are available by clicking the Manage recipes button.
The Recipe Editor has four main components.
The list of recipes where we can add, delete, and duplicate recipes
The General Settings tab where we can configure the recipe
Recipe Settings tab where we create the search and matching conditions
QuickFix settings where we configure the Quick Fix changes to amend or generate code
The list of recipes on the left side of the recipe editor provides an overview of which recipes are present in the cookbook that we are currently editing. At the top of the list several controls are present to add, remove, duplicate, import and export recipes. The list itself displays any folders present in the cookbook along with the recipes present in those folders.
By clicking on a Recipe, you can edit it.
General Settings is where we primarily configure the:
Name and Description, which are shown in the contextual popup when we hover the mouse over a violation in the code.
Level, which defines how the matching Recipe is rendered in the IDE
If you configure a recipe as ‘Error’ then the code will typically have a red underline and show as a syntax error, but a Warning will have a light highlighting. Sensei will use the highlighting properties of the IntelliJ 'Error'/'Warning'/'Info' levels by default.
There are other settings but these are for more advanced use and will be covered later in the documentation.
The ‘Recipe Settings’ contains the search configuration. This is the search we perform in the code to match coding patterns.
In this example the search looks for any annotations on a method which are a Junit 5 Test annotations. The annotations are highlighted in the code itself.
The QuickFix Settings are the QuickFixes which are shown in IntelliJ when you use Alt+Enter or ⌘↵ to fix the problem.
And you can see at the bottom of the screen a diff view that shows the results of applying a QuickFix.
The recipe shown in the screenshot adds a
Logger into the class and the diff view shows the before and after state in the code.
In the code, at the point you want to start a search, pressing Alt+Enter or ⌘↵ shows the context menu that has theoption.
Often we ‘start from scratch’ with an empty recipe.
A recipe can also be created by clicking the
+ button in the Recipe Editor.
When recipes have been activated, they will be marked in the editor.
The following code shows some ‘errors’ and some ‘warnings’ have been found in the code.
There are many ways to apply a QuickFix.
In the Problems Tab, right click on the reported problem and choose “Show Quick Fixes”
Then, choose the quick fix from the list.
The most common way to fix code is with Alt+Enter or ⌘↵ where we will see any IntelliJ suggestions and Sensei quickfixes.
And if you choose the action then the code will be amended.