Address code issues in JetBrains and Visual Studio Code
To address a code issue in JetBrains and Visual Studio Code, you will either have the option to generate an in-place
fix or generate an explanation that you can use to manually update your code.
You can take the following actions:
-
Generate an in-place code fix
-
Explain the issue and get new code
-
Ignore the issue, or ignore all similar issues
Generate in place fixes for your file
Amazon Q can update your files in-place to automatically remediate a code issue
it detected.
To automatically fix a code issue:
- JetBrains IDEs
-
-
In the Code Issues tab, choose the code issue you want to address.
-
Choose the wrench glass icon to open the Code Issue
Details panel, where Amazon Q will start generating a fix.
The following image shows the wrench icon for a code issue.
-
Updated code appears in the Code Issue Details
panel. You can perform the following actions:
-
Below the suggested code, choose Open diff to see a diff of
the suggested code changes in the file where the code
originated.
-
Below the suggested code, choose Copy to copy the code to your
clipboard.
-
To apply the generated fix to your file, choose Accept fix at the
bottom of the panel to replace the problematic code with the suggested
code.
-
If the suggested code doesn’t satisfy your requirements, you
can choose Regenerate fix to see an alternate solution.
-
When you apply the fix, the Code Issue
Details panel closes, and the issue is
automatically resolved and removed from the list of issues in
the Code Issues tab.
- Visual Studio Code
-
-
In the Code Issues panel, choose the
code issue you want to address.
-
Choose the wrench glass icon.
The following image shows the wrench icon for a code issue in Visual Studio Code.
-
In the chat panel, Amazon Q provides a brief explanation
of the fix and then applies an in-place fix in your code
file.
-
To apply the generated fix to your file, choose Accept fix at the
bottom of the panel to replace the problematic code with the suggested
code.
-
You will see the code change in your file, and have the
option to undo the change from the chat panel.
Explain the code issue and get new code
Amazon Q can provide an in-depth explanation of a code issue and provide
remediation options with accompanying code for you to add to your files.
To explain a code issue:
- JetBrains IDEs
-
-
In the Code Issues tab, choose the code issue you want to address.
-
Choose the magnifying glass icon to open the Code Issue
Details panel.
The following image shows the magnifying glass icon for a code issue in Visual Studio Code.
-
At the bottom of the Code Issue Details panel,
choose Explain.
-
The type of code issue and associated code are sent to Amazon Q in the
chat panel. Amazon Q provides an explanation of the issue and suggests
new code you can use to replace the problematic code.
-
To add the code to your file, you can choose Insert at cursor to add
the new code where your cursor is in the file. You can also choose Copy
and paste the code to your file yourself.
Make sure to remove the underlined code to replace it with the new code.
- Visual Studio Code
-
-
In the Code Issues panel, choose the
code issue you want to address.
-
Choose the magnifying glass icon.
The following image shows the magnifying glass icon for a code issue in Visual Studio Code.
-
In the chat panel, Amazon Q provides details about the
issue and suggest a remediation with code that you can
insert into your file.
-
To update your file, follow Amazon Q’s instructions for
where to add or replace code, and copy the provided code in
the correct location in your file.
Ignore a code issue
If a detected code issue isn’t applicable, you can choose to ignore it, or
ignore it and all similar issues (issues with the same CWE). The issues will be removed from the Code
Issues tab.
To ignore a code issue:
-
In the Code Issues panel, choose the code issue you want to
ignore.
-
To ignore just that code issue, choose the ignore icon.
The following image shows the ignore icon for a code issue in Visual Studio Code.
-
To ignore a code issue and similar ones, choose the ellipses icon, then choose Ignore Similar Issues.
In JetBrains IDEs, you can also choose Ignore from the Code Issue
Details panel. The issue will be ignored and removed from the
list of issues in the Code Issues tab. If you choose
Ignore all from the Code Issue Details panel, this and
other code issues with the same CWE will be ignored.