Help Center/ CodeArts Check/ User Guide/ Managing Code with AI/ Generating AI-powered fix suggestions
Updated on 2026-05-19 GMT+08:00

Generating AI-powered fix suggestions

Once a task is executed, you can generate batch or single issue fix suggestions, enabling quick resolution. This enhances issue detection and fix accuracy and efficiency, and safeguards code quality.

Constraints

Currently, the function of AI-powered fix suggestions is available only for some rules of Java, C/C++. For details, see the following tables.

Prerequisites

  • Check whether your environment supports the intelligent feature (see the icon on the top navigation bar). If not, submit a service ticket.
  • Contact your tenant administrator to grant you access to CodeArts Doer on the All Account Settings > General > Service Permission page.
  • After the intelligent re-architecting is performed, execute the existing code check tasks again to generate AI-powered fix suggestions.

Generate Fix Suggestions

  1. Access CodeArts Check.
  2. In the Tasks page, click a task name.
  3. Click the Issues tab.
  4. Click Generate Fixes in the upper right corner of the page to generate fix suggestions in batches. (Currently, this function is available only for some rules of Java, C/C++. For details, see Rules Supporting the Function of AI-powered Fix Suggestions.)

    The progress bar displays the generation status. Click the bar to view the generated fix suggestions in real time.

  5. In the Generate Fixes window, you can perform the following operations:

    • On the Fix tab area, you can view the list of issues that can be fixed.

      In the issue list, click in the Operation column to go to the issue context area and view issue details.

      In the Context > Generate Fix area, you can view the reason, solution, conclusion, and comparison before and after the fix, as shown in the following figure.

      Figure 1 Issue context
      • You can click Side or Inline on the right to choose either vertical (top-to-bottom) or horizontal (side-by-side) display mode.
      • Click Submit to Branch in the lower left corner. In the displayed window, click Submit to submit the fixed code to the existing branch.
      • Click Copy Repair Code in the lower left corner to quickly copy the fixed code.
    • On the Shield tab area, you can view the list of issues that need can be shielded.

      In the issue list, click in the Operation column to go to the issue context area and view issue details.

      In the Context > Generate Fix area, you can view the reason and conclusion.

Generating a Fix Suggestion

  1. Access CodeArts Check.
  2. In the Tasks page, click a task name.
  3. Click the Issues tab.
  4. Click Generate Fix in the issue area to view the fix suggestions. (Currently, this function is available only for some rules of Java, C/C++. For details, see Rules Supporting the Function of AI-powered Fix Suggestions.)

    • The following figure shows the fix suggestions for issues whose conclusion is risky.
      Figure 2 Risky issue
      • You can click Side or Inline on the right to choose either vertical (top-to-bottom) or horizontal (side-by-side) display mode.
      • Click Submit to Branch in the lower left corner. In the displayed window, click Submit to submit the fixed code to the existing branch.
      • Click Copy Repair Code in the lower left corner to quickly copy the fixed code.
    • The following figure shows the fix suggestion for issues whose conclusion is no risk (recommended to be shielded).

Rules Supporting the Function of AI-powered Fix Suggestions

Table 1 Java rules

Rule Name

Engine

Language

G.FMT.17 Each annotation applying to a class, method, or field is listed on a line of its own

fixbotengine-java

Java

G.TYP.09 Point out the correct encoding mode for conversion between characters and bytes

fixbotengine-java

Java

G.PRM.02 Use System.arraycopy() or Arrays.copyOf() to copy arrays

fixbotengine-java

Java

G.FMT.07 Avoid empty blocks

fixbotengine-java

Java

G.ERR.02 Do not directly catch base exception classes such as Throwable, Exception, and RuntimeException

fixbotengine-java

Java

G.NAM.08 Boolean variables should start with auxiliary verbs

fixbotengine-java

Java

G.NAM.07 Avoid using Boolean variable names with negative meanings

fixbotengine-java

Java

G.FMT.06 For a non-empty block structure, the opening brace should be placed at the end of a line, and the closing brace should be placed in a new line

fixbotengine-java

Java

G.OTH.03 Delete unused code segments instead of commenting them out--remove unused code lines

fixbotengine-java

Java

G.MET.05 Use an array or container whose length is 0 instead of null as the return value of a method

fixbotengine-java

Java

G.FMT.18 Block comments should be indented to the same level as the code they describe

fixbotengine-java

Java

G.CMT.06 There should be a blank line or space between the comment and the code, and a space between the comment character and the comment content

fixbotengine-java

Java

G.TYP.06 Do not compare against NaN. Use the isNaN() method of the Double or Float class to determine whether the value is NaN

fixbotengine-java

Java

G.TYP.12 Use explicit type conversion rather than implicit type conversion

fixbotengine-java

Java

G.CTL.01 Do not assign values or conduct complex condition judgment in controlling conditional expressions

fixbotengine-java

Java

G.NAM.05 Capitalize a constant name, with each word separated by an underscore (_)

fixbotengine-java

Java

G.OBJ.02 Do not call methods that may be overridden by child classes in constructors of parent classes

fixbotengine-java

Java

G.LOG.01 Use a log framework in the Facade pattern

fixbotengine-java

Java

G.CON.06 Use new concurrency utilities to replace wait() and notify()

fixbotengine-java

Java

G.CTL.02 An else branch should be added at the end of the else if statement

fixbotengine-java

Java

G.ERR.01 Do not use an empty catch block to ignore exceptions

fixbotengine-java

Java

G.FMT.15 Separate enumeration constants by commas (,), with or without line breaks

fixbotengine-java

Java

G.OBJ.06 Override the hashCode() method when the equals() method is overridden

fixbotengine-java

Java

G.EXP.04 When comparing expressions--expression left side tends to change and the right side tends to remain unchanged

fixbotengine-java

Java

G.FMT.16 If 'break' is not added to the end of the case statement block, comments should be provided (fall-through)

fixbotengine-java

Java

G.OBJ.01 Avoid defining public and non-final fields

fixbotengine-java

Java

G.TYP.07 Do not hardcode the characters that indicate new lines and file path separators--hard-code file path separators

fixbotengine-java

Java

G.ERR.08 Do not use return, break, or continue, or throw an exception to abruptly terminate the finally block

fixbotengine-java

Java

G.MET.04 Exercise caution when using a variable number of arguments

fixbotengine-java

Java

G.TYP.05 Do not directly use == to determine the equivalence of floating point data. Do not use equals() or flt.compareTo(another) == 0 to compare floating-point boxed primitives

fixbotengine-java

Java

G.COL.04 Do not modify the collection by performing remove() / add() on elements in a foreach loop

fixbotengine-java

Java

G.ERR.11 Log GeneralSecurityException and its subclass exceptions

fixbotengine-java

Java

G.COL.03 Limit available generic types through qualifiers in a generic class declaration

fixbotengine-java

Java

G.COL.02 Prefer generic collections to arrays

fixbotengine-java

Java

G.OBJ.04 Avoid reusing names between unrelated variables or concepts

fixbotengine-java

Java

G.FMT.14 Redundant spaces should not be inserted for vertical alignment

fixbotengine-java

Java

G.NAM.01 An identifier must contain a maximum of 64 characters, including letters, digits, and underscores (_)

fixbotengine-java

Java

G.CMT.03 The Javadoc for methods should contain function descriptions. Use @param, @return, and @throws in sequence to add comments for parameters, return values, and exceptions if necessary

fixbotengine-java

Java

G.CMT.01 Javadoc comments should be present for every public or protected element

fixbotengine-java

Java

G.TYP.08 Use Locale.ROOT or Locale.ENGLISH for conversion between uppercase and lowercase strings and formatting to Western Arabic numerals

fixbotengine-java

Java

G.LOG.03 Grade logs

fixbotengine-java

Java

G.LOG.02 Declare logger instances private static final or private final

fixbotengine-java

Java

G.LOG.04 Do not print logs in Chinese for products sold outside China

fixbotengine-java

Java

G.CTL.05 Do not modify loop control variables in the loop body

fixbotengine-java

Java

G.TYP.03 Do not use floating-point numbers as loop counters

fixbotengine-java

Java

G.PRM.08 Do not use active GC (unless in password and RMI)

fixbotengine-java

Java

G.NAM.04 Methods should be named in lowerCamelCase style

fixbotengine-java

Java

G.MET.01 Methods should be short--the number of method parameters less than 5

fixbotengine-java

Java

G.EXP.01 Do not assign the same variable more than once in one expression

fixbotengine-java

Java

G.DCL.01 Declare one variable in each line

fixbotengine-java

Java

G.DCL.05 Do not define a mutable object as a constant

fixbotengine-java

Java

G.FMT.05 Braces should be used in conditional statements and loop blocks

fixbotengine-java

Java

G.DCL.03 Do not declare C-style arrays

fixbotengine-java

Java

G.NAM.06 Name variables in lowerCamelCase style

fixbotengine-java

Java

G.FMT.09 Each line contains one statement only

fixbotengine-java

Java

G.EXP.03 Use the same type for the second and third operands in the ?: conditional expression

fixbotengine-java

Java

G.MET.06 Use Optional to replace null as a return value or possible missing value; do not assign null to the Optional object

fixbotengine-java

Java

G.DCL.04 Avoid generating serial numbers of enumeration constants based on the ordinal() method

fixbotengine-java

Java

G.NAM.02 Package names should consist of lowercase letters separated by dots (.)

fixbotengine-java

Java

G.MET.03 Do not treat method arguments as temporary variables

fixbotengine-java

Java

G.EXP.02 Use parentheses to specify the operation sequence of expressions, thereby avoiding excessive dependence on the default priority

fixbotengine-java

Java

G.FMT.12 Reduce unnecessary blank lines to keep the code compact

fixbotengine-java

Java

G.OBJ.10 Remove redundant modifiers from interface definitions

fixbotengine-java

Java

G.PRM.07 Release resources in try-with-resource or finally during I/O operations

fixbotengine-java

Java

G.PRM.10 Do not create a temporary variable as the return value of a return statement

fixbotengine-java

Java

G.OBJ.03 Constructors with more arguments should be reused

fixbotengine-java

Java

G.ERR.03 Do not directly catch RuntimeException (such as NullPointerException and IndexOutOfBoundsException ) that can be identified through pre-check

fixbotengine-java

Java

G.SER.02 Ensure that classes that can implement the Serializable interface support explicit declaration of serialVersionUID

fixbotengine-java

Java

G.SER.04 Do not directly serialize information pointing to system resources

fixbotengine-java

Java

G.EXP.04 When comparing expressions--Use equals method to compare strings

fixbotengine-java

Java

G.ERR.10 Try to eliminate unchecked exceptions and do not use SuppressWarning on the entire class

fixbotengine-java

Java

G.CTL.03 A switch statement must have a default branch

fixbotengine-java

Java

G.CON.12 Use a thread pool to control resources and to prevent excessive creation of new threads

fixbotengine-java

Java

G.CON.08 Use the setUncaughtExceptionHandler() method of the thread object to register handlers of uncaught exceptions

fixbotengine-java

Java

G.CON.07 Name a thread when creating it

fixbotengine-java

Java

G.ERR.07 A maximum of 5 exceptions can be thrown by one method. Record exceptions and their conditions in the @throws annotation of Javadoc

fixbotengine-java

Java

G.PRM.01 Use the Collection<T>.toArray(T[]) method to convert collections into arrays (use Collection<T>.toArray(IntFunction<T[]>) for Java 11 and later versions)

fixbotengine-java

Java

G.CMT.07 No TODO/FIXME comments should be contained in the code delivered to customers

fixbotengine-java

Java

G.TYP.13 Use instanceof to check if the object belongs to the specific type before downcasting

fixbotengine-java

Java

G.NAM.03 Classes, enumerations, and interfaces should be named in UpperCamelCase style

fixbotengine-java

Java

G.PRM.05 Do not create unnecessary objects

fixbotengine-java

Java

G.OBJ.08 Correctly implement the singleton pattern

fixbotengine-java

Java

G.OTH.03 Delete unused code segments instead of commenting them out--remove unused import

fixbotengine-java

Java

G.FMT.20 A proper suffix should be set for the numeric literal, and the long type should use L as the suffix

fixbotengine-java

Java

G.TYP.11 Prefer primitive types to boxed primitives

fixbotengine-java

Java

G.CMT.02 The Javadoc of the top-level public class should contain the function description and creation

fixbotengine-java

Java

G.CMT.04 Do not write empty-content method header comments

fixbotengine-java

Java

G.CMT.05 File header comments should contain the copyright notice

fixbotengine-java

Java

G.ERR.04 Prevent sensitive information leakage caused by exceptions

codemars

Java

G.ERR.05 Throw exceptions appropriate to the level of abstraction

fixbotengine-java

Java

G.ERR.06 Prevent the original exception information from being lost when a new exception is thrown in

secbrella

Java

G.EXP.06 Do not use asserts in code

codemars

Java

G.FIO.01 Validate and canonicalize path names constructed using external data

codemars

Java

G.FMT.13 Use spaces to highlight keywords and important information

fixbotengine-java

Java

G.FMT.19 Class and member modifiers (if present) appear in the order recommended by the Java

fixbotengine-java

Java

G.OTH.05 Remove code that has no effect or is never executed

secbrella

Java

G.PRM.04 Do not precompile regexes repeatedly

fixbotengine-java

Java

G.PRM.09 Do not use the Finalizer mechanism.

fixbotengine-java

Java

G.SEC.04 Protect sensitive operations by a security manager

codemars

Java

G.SER.05 Do not serialize non-static inner classes

codemars

Java

G.CON.05 Do not override thread-safe methods with methods that are not thread-safe

secbrella

Java

G.CON.10 A thread should be interrupted by service code. Exercise caution when using the

fixbotengine-java

Java

G.ERR.08 Do not use return, break, or continue, or throw an exception to abruptly terminate the finally block--Return from finally block

codemars

Java

G.ERR.09 Do not call System.exit() to terminate the JVM

codemars

Java

G.MET.07 Do not ignore values returned by methods

secbrella

Java

Table 2 C rules

Rule Name

Engine

Language

G.AST.03 Do not use assertions to verify the absence of runtime errors. Use error codes to handle possible errors [C]

codemars

C

G.PRE.04 Do not pass expressions with side effects to a function-like macro [C]

clangtidy

C

G.CMT.02 Place code comments above or to the right of the code [C]

fixbotengine-cxx

C

G.OTH.01 Delete code that has no effect or is never executed [C]

fixbotengine-cxx

C

G.CMT.01 Add a space between the comment character and comment content [C]

fixbotengine-cxx

C

G.PRE.03 Implementation statements of function-like macros that contain multiple statements must be placed in a do-while(0) [C]

fixbotengine-cxx

C

G.EXP.04 Use parentheses to specify the sequence of expressions, instead of using the default priority [C]

fixbotengine-cxx

C

G.PRE.09 Do not end macro definitions with a semicolon [C]

fixbotengine-cxx

C

G.FMT.04 One line contains only one statement [C]

fixbotengine-cxx

C

P.04 Check the validity of all values received from external sources [C]

codemars

C

G.FIL.03 Do not create temporary files in shared directories [C]

codemars

C

G.INT.03 Ensure that division and remainder operations do not cause divide-by-zero errors [C]

codemars

C

G.FUU.08 Do not use the abort() function [C]

codemars

C

G.FUU.07 Do not use the exit() or ExitProcess() function to exit (except the main() function) [C]

codemars

C

G.FUU.10 Do not use the alloca() function to request stack memory [C]

codemars

C

G.FUU.09 Do not use the realloc() function [C]

codemars

C

G.FUU.04 Do not use the atexit() function [C]

codemars

C

G.OTH.05 Prohibits the inclusion of public network addresses in the code [C]

codemars

C

G.FMT.11 Use spaces to highlight keywords and important information--ternary condition expressions [C]

clangtidy

C

G.EXP.02 When comparing expressions, follow the principle that the left side tends to change and the right side tends to remain unchanged [C]

clangtidy

C

G.CTL.07 Switch statement shall have a default label--default is not the last branch [C]

clangtidy

C

G.FUD.09 Avoid changing the value of a function parameter [C]

clangtidy

C

G.VAR.02 Do not reuse variable names in subscopes [C]

clangtidy

C

G.CNS.01 Do not suffix a lowercase letter "l" to a numeric constant [C]

clangtidy

C

G.PRE.02 When a macro is defined, macro parameters should be parenthesized [C]

clangtidy

C

G.FMT.11 Use spaces to highlight keywords and important information--function name [C]

clangtidy

C

G.FMT.11 Use spaces to highlight keywords and important information--unary expressions [C]

clangtidy

C

G.FUU.21 Do not use unsafe functions related to memory operations [C]

codemars

C

G.FUU.11 Check and correctly handle the return values of safe functions [C]

codemars

C

G.FUU.12 Correctly set destMax in safe functions--check destMax parameter [C]

codemars

C

G.FUU.12 Correctly set destMax in safe functions--Check the destMax and count parameters [C]

codemars

C

G.FIL.02 Canonicalize and verify file paths before using them [C]

secbrella:hcs

C

G.INT.03 Ensure that division and remainder operations do not cause divide-by-zero errors [C]

secbrella:hcs

C

G.EXP.01 Two operands that perform arithmetic or comparison operations must be of the same essential type [C]

secbrella:hcs

C

G.OTH.04 Do not output the address of an object or function in a released version [C]

secbrella:hcs

C

G.FUU.11 Check and correctly handle the return values of safe functions [C]

secbrella:hcs

C

G.VAR.03 Avoid large stack allocations [C]

secbrella:hcs

C

G.FUU.22 Do not use the atoi(), atol(), atoll(), or atof() function [C]

secbrella:hcs

C

G.FUU.17 Do not use external controllable data as parameters for module loading functions such as dlopen() and LoadLibrary() [C]

secbrella:hcs

C

G.VAR.05 Assign a new value to the variable pointing to a resource handle or descriptor immediately after the resource is freed [C]

codemars

C

G.MEM.01 Verify the requested memory size before requesting memory [C]

codemars

C

G.OTH.03 Do not use rand() to generate pseudorandom numbers for security purposes [C]

codemars

C

G.AST.01 Define assertions using a macro and use them only in debugging versions [C]

codemars

C

G.AST.02 Avoid direct use of assert() [C]

codemars

C

G.TYP.04 Avoid implicit lossy arithmetic conversion [C]

secbrella:hcs

C

G.ARR.06 Do not use variable-length arrays [C]

secbrella:hcs

C

Table 3 C++ rules

Rule Name

Engine

Language

G.AST.03 Do not use assertions to verify the absence of runtime errors. Use error codes to handle possible errors

codemars

C++

G.PRE.04 Do not pass expressions with side effects to a function-like macro

clangtidy

C++

G.EXP.43-CPP Delete unused code snippets instead of commenting them out

fixbotengine-cxx

C++

G.OTH.01 Delete code that has no effect or is never executed

fixbotengine-cxx

C++

G.CMT.01-CPP Add a space between the comment character and comment content

fixbotengine-cxx

C++

G.CMT.02-CPP Place code comments above or to the right of the code

fixbotengine-cxx

C++

G.PRE.03 Implementation statements of function-like macros that contain multiple statements must be placed in a do-while(0)

fixbotengine-cxx

C++

G.EXP.30-CPP Use parentheses to specify the sequence of expressions, instead of using the default priority

fixbotengine-cxx

C++

G.PRE.09 Do not end macro definitions with a semicolon

fixbotengine-cxx

C++

G.FMT.04-CPP Each variable is declared or assigned on a separate line

fixbotengine-cxx

C++

G.STD.15-CPP Do not use external controllable data as parameters for process startup functions or module loading functions such as dlopen() and LoadLibrary()

codemars

C++

G.FMT.14-CPP The pointer type "*" and reference type "&" can only be placed close to a variable name or a type--Reference type

fixbotengine-cxx

C++

G.FMT.09-CPP A constructor initialization list is placed on the same line or on different lines indented by four spaces

fixbotengine-cxx

C++

G.RES.10-CPP Use std::make_shared instead of new to create std::shared_ptr

fixbotengine-cxx

C++

G.RES.09-CPP Use std::make_unique instead of new to create std::unique_ptr

fixbotengine-cxx

C++

G.FIL.03 Do not create temporary files in shared directories

codemars

C++

G.EXP.22-CPP Ensure that division and remainder operations do not cause divide-by-zero errors

codemars

C++

G.FUU.10 Do not use the `alloca()` function to request stack memory

codemars

C++

G.FUU.09 Do not use the `realloc()` function

codemars

C++

G.STD.16-CPP Do not use the exit and atexit functions of programs and threads

codemars

C++

G.OTH.05 Do not include public network addresses in code

codemars

C++

G.FMT.16-CPP Use spaces to highlight keywords and important information--ternary condition expressions

clangtidy

C++

G.EXP.28-CPP Avoid extra == or != in bool type comparison

clangtidy

C++

G.EXP.29-CPP When comparing expressions, follow the principle that the left side tends to change and the right side tends to remain unchanged

clangtidy

C++

G.EXP.37-CPP Switch statement shall have a default label--default is not the last branch

clangtidy

C++

G.CLS.03-CPP Single-parameter constructors should be declared as explicit

clangtidy

C++

G.EXP.10-CPP Do not reuse names in nested scopes

clangtidy

C++

G.CNS.01-CPP Do not suffix a lowercase letter "l" to a numeric literal

clangtidy

C++

G.PRE.01-CPP Do not use macros for constants

clangtidy

C++

G.PRE.02 When a macro is defined, macro parameters should be parenthesized

clangtidy

C++

G.FMT.16-CPP Use spaces to highlight keywords and important information--function name

clangtidy

C++

G.FMT.16-CPP Use spaces to highlight keywords and important information--unary expressions

clangtidy

C++

G.INC.09-CPP Do not import symbols into the global namespace in header files or define alias

clangtidy

C++

G.ENU.02-CPP Avoid defining unnamed enumerations

clangtidy

C++

G.EXP.14-CPP Use type conversion operations provided by C++

clangtidy

C++

G.FUN.03-CPP Do not contain any unused parameter in functions

clangtidy

C++

G.FUN.06-CPP Use references instead of pointers when function parameters need to be passed as single objects

clangtidy

C++

G.EXP.34-CPP Use static_assert as an assertion that can be determined at compile time

clangtidy

C++

G.STD.01-CPP Use new standard header files

clangtidy

C++

G.CLS.12-CPP Explicitly specify override or final when overriding virtual functions

clangtidy

C++

G.FUU.21 Do not use unsafe functions related to memory operations

codemars

C++

G.FUU.11 Check and correctly handle the return values of safe functions

codemars

C++

G.FUU.12 Correctly set destMax in safe functions--Check the destMax parameter

codemars

C++

G.FUU.12 Correctly set destMax in safe functions--Check the destMax and count parameters

codemars

C++

G.FIL.02 Canonicalize and verify file paths before using them

secbrella:hcs

C++

G.RES.13-CPP Properly handle memory allocation errors where the new operator is used

secbrella:hcs

C++

G.RES.14-CPP Avoid the "delete this" operation

secbrella:hcs

C++

G.EXP.22-CPP Ensure that division and remainder operations do not cause divide-by-zero errors

secbrella:hcs

C++

G.EXP.25-CPP Do not mix signed and unsigned numbers in an expression

secbrella:hcs

C++

G.CLS.09-CPP The resources of the source object must be correctly reset in move constructors and move assignment operators

secbrella:hcs

C++

G.OTH.04 Do not output the address of an object or function in a released version

secbrella:hcs

C++

G.FUU.11 Check and correctly handle the return values of safe functions

secbrella:hcs

C++

G.VAR.03 Avoid large stack allocations

secbrella:hcs

C++

G.STD.06-CPP Do not use the atoi() , atol() , atoll() , or atof() function

secbrella:hcs

C++

G.RES.07-CPP Assign a new value to the variable pointing to a resource handle or descriptor immediately after the resource is freed

codemars

C++

G.RES.02-CPP Verify the requested memory size before requesting memory

codemars

C++

G.OTH.03 Do not use `rand()` to generate pseudorandom numbers for security purposes

codemars

C++

G.FMT.12-CPP Avoid placing if/else/else if on the same line

fixbotengine-cxx

C++

G.EXP.17-CPP Avoid implicit lossy arithmetic conversion

secbrella:hcs

C++