Applying quick fixes to rule results
A quick fix is an automated solution for an exception that is identified in the rule results.
Use a quick fix to save time fixing problems. The quick fix icon
identifies whether a quick fix is available
for a rule result.
To get additional information about a quick fix, including solutions and examples, press F1 or click the Help icon.
Even if a quick fix is available, you must open the source file and verify that the quick fix will fix the exception that is identified in the rule results.
To apply a quick fix to a rule result, right-click the rule result that has a quick fix and, on the pop-up menu, click a quick fix and follow instructions provided by the rule author.
Quick fixes migration
Starting
from the December release of 2018, the Core and UI code is separated
out. That is, a plugin that contains the core function must not have
any dependencies on the UI plugins, such as org.eclipse.ui.
This separation affects the code review rules and their quick fixes. A typical code review rule in analysis phase is going through source files and trying to find violations, which is an example of the core functionality. A quick fix, if it is applied, is then to modify the source file, refresh the text editor, and refresh any other UI elements if the file is opened in the Eclipse UI.
analysisRule and analysisRuleQuickFix extension
points are changed. Now the code review rules that the quick fix is
applied to are to be defined inside analysisRuleQuickFix elements. <analysisRule
category="codereview.java.category.examle"
class="com.ibm.rsar.analysis.codereview.java.rules.example.ExampleRule"
id="codereview.java.rules.ExampleRule"
severity="0">
<quickfix id="com.ibm.java.rules.example.quickfix.ExampleQuickFix1"/>
<quickfix id="com.ibm.java.rules.example.quickfix.ExampleQuickFix2"/>
</analysisRule>
<analysisRuleQuickFix
class="com.ibm.java.rules.example.quickfix.ExampleQuickFix1"
id="com.ibm.java.rules.example.quickfix.ExampleQuickFix1"/>
<analysisRuleQuickFix
class="com.ibm.java.rules.example.quickfix.ExampleQuickFix2"
id="com.ibm.java.rules.example.quickfix.ExampleQuickFix2"/>
<analysisRule
category="codereview.java.category.examle"
class="com.ibm.rsar.analysis.codereview.java.rules.example.ExampleRule"
id="codereview.java.rules.ExampleRule"
severity="0">
</analysisRule>
<analysisRuleQuickFix
class="com.ibm.java.rules.example.quickfix.ExampleQuickFix1"
id="com.ibm.java.rules.example.quickfix.ExampleQuickFix1">
codereview.java.rules.ExampleRule/>
</analysisRuleQuickFix>
<analysisRuleQuickFix
class="com.ibm.java.rules.example.quickfix.ExampleQuickFix2"
id="com.ibm.java.rules.example.quickfix.ExampleQuickFix2">
<rule id="codereview.java.rules.ExampleRule"/>
</analysisRuleQuickFix>- Create a plugin for quick fixes and move the quickfix classes into the plugin that you create.
- Move
<analysisRuleQuickFix>elements into the plugin.xml file of the new plugin.