The CodeScan VS Code plugin provides on-the-fly feedback to developers on bugs and quality issues, it is a fully-integrated user experience in VS Code.
You will need:
- Java 8+
- A working SonarQube (7.3+) installation
- A recent version of VS Code installed (v1.12 or above)
- A licensed version of CodeScan (4.3+) plugin to get started (see here)
- If you are working with Salesforce code, you will need the Salesforce Extensions for VS Code or at least the Apex and Visualforce plugins.
PLEASE NOTE: Currently in VS Code, extensions cannot access the internet from behind a proxy. This does not allow CodeScan to access the license server and therefor does not work. You can keep up to date on this issue here: Extension proxy support #12588
In VS Code, go to the Marketplace and download CodeScan.
Restart VS Code.
In the VS Code User Settings, in the CodeScan section, copy over the
codescan.projectsettings to the right hand pane.
Edit the following in
For CodeScan Cloud
For Self-Hosted CodeScan
tokenwith a token generated in SonarQube.
- Add server
Urlas your SonarQube server URL (Default is http://localhost:9000).
- Add server
Idwith a value you will remember.
- Edit the following in
projectKeywith the key of the project you would like to use the settings from (Where do I find this?).
serverIdyou used when editing your
- Now hit Ctrl+Shift+P (Windows/Linux) or Shift+Command+P(Mac) to open the Command Palette.
- Type in CodeScan to bring up the CodeScan commands and run “Update CodeScan binding to SonarQube/CodeScan Cloud”. If any changes are made on the SonarQube server you should repeat this step.
- Open a file, you should see the issues in your code underlined.
VS Code behind a proxy
VS Code extensions can be difficult to use behind a proxy.
To point CodeScan at the correct proxy, all it takes is a single line in the settings.json file.
"codescan.ls.vmargs": "-Dhttp.proxyHost=your.proxy.host -Dhttp.proxyPort=3333 -Dhttps.proxyHost=your.proxy.host -Dhttps.proxyPort=3333"
Some useful debugging information is available under the Output window under the ‘CodeScan’ tab.
CodeScan should automatically find the JRE installed on your computer. If you are having trouble you can specify the path using
sonarlint.ls.javaHome variable in your VS Code Settings.
You can check for any serious errors by going to Help > Toggle Developer Tools to bring up the console.
You can also contact us at the CodeScan Support Page. Feel free to ask questions, report issues, and give suggestions.