Fixes

Recipes contain a list of availableFixes. A fix defines a name, the actions that will be executed, and configuration regarding the import processing functionality of Sensei.

availableFixes:
- name: My first fix
  actions:
  - rewrite:
      to: Logger.log({{{arguments}}})

name

The name that will be shown while selecting the fix from the intentions menu.

actions

This is a collection of Actions that define what this fix will do.

processImports

By default Sensei imports the qualified names this behaviour can be changed using processImports. When processImports is true the fully qualified references will be dequalified and imported, when processImports is false the fully qualified references will stay fully qualified.

availableFixes:
- actions:
  - addField:
      field: private static org.slf4j.Logger LOGGER = LoggerFactory.getLogger({{{containingClass.name}}}.class);
  processImports: false
   class MyClass {
+      private static org.slf4j.Logger LOGGER = LoggerFactory.getLogger(MyClass.class);
   }
availableFixes:
- actions:
  - addField:
      field: private static org.slf4j.Logger LOGGER = LoggerFactory.getLogger({{{containingClass.name}}}.class);
  processImports: true
+  import org.slf4j.Logger;

   class MyClass {
+      private static Logger LOGGER = LoggerFactory.getLogger(MyClass.class);
   }

doStaticImports

The doStaticImports option can be used to let Sensei statically import the fully qualified references.

availableFixes:
- actions:
  - rewrite:
      to: org.junit.assert.Assert.assertEquals({{{arguments.2}}}, {{{arguments.1}}})
  doStaticImports: true
+  import static org.junit.assert.Assert.assertEquals;

-  Assert.assertEquals(actual, expected);
+  assertEquals(expected, actual);

Warning

doStaticImports will not have any impact when processImports is false as that setting completely negates any import processing.