Getting Started with Sourcery for VSCode¶
Installing Sourcery¶
- Open the Sourcery extension in VS Code and click the install button
OR
- Go to the VS Code Preferences menu and select Extensions
- Search for Sourcery and click Install
Logging In¶
Login by opening the command palette
(Ctrl+Shift+P or
Cmd+Shift+P) and running Sourcery: Login
.
To log in with your token, copy the token from your
Sourcery dashboard and paste it in the
input box in the Sourcery
section of the VS Code settings.
If you do not have a Sourcery account you can sign up for one here.
VS Code Specific Features¶
Suggest AI Fixes¶
By default, Sourcery will suggest AI fixes for all problems in the Problems pane, including those created by other tools.
Bring up the code actions menu on a problem either inline in the code or in the Problems pane, then take the 'Sourcery - Fix in Chat' option. This will open up the Sourcery AI assistant to explain and fix the problem. You can apply the fix by clicking the 'Apply Changes' button on the code block.
You can switch this feature on or off by setting the suggestFixes
setting to
true
or false
in the VS Code settings. This can also be accessed from the
settings menu in the Sourcery sidebar.
Suggest improvements to complex functions¶
The Sourcery code metrics hover suggests improvements to complex functions, such as extracting out complex logic. You can click on these suggestions to cause Sourcery to suggest code to implement them in the chat.