Install Free
VS Code | Using SonarQube for IDE | New code

New code

On this page

New code and your quality standards

Focusing on new code is an important step in getting the most out of SonarQube for IDE. When you run an analysis on your main branch (or other long-lived branches) in SonarQube (Server, Cloud) and have set up connected mode, SonarQube for IDE uses the server’s New Code Definition (NCD) to determine which issues you should focus on fixing, and calls out the issues found in new code. Focusing on new code is at the core of implementing the SonarQube strategy, knowing that the other code will be incrementally fixed over time.

To achieve this, SonarQube for IDE offers the Focus on new code feature to highlight new code in the IDE. 

Your new code definition

When SonarQube for IDE is running in connected mode, the SonarQube for IDE uses the NCD defined in SonarQube Server or on SonarQube Cloud. When SonarQube for IDE is running in standalone mode, a locally defined new code period highlights your new code.

Running SonarQube for IDE in connected mode with SonarQube (Server, Cloud) offers more opportunities to choose how you define new code.

New code definition options

When you use the NCD found in the SonarQube Server or SonarQube Cloud quality profile, you have more opportunities to choose how to define new code. Check out their respective pages for details.

Without Connected mode, new code is defined by a new code period: any code added or changed in the last 30 days is considered new code. The 30-day timeframe is defined using Git. 

When not using Git, the new code period begins with the first SonarQube for IDE analysis.

There is no option to manually define a new code period in SonarQube for IDE. 

Setting your focus on new code

The Focus on new code feature works when SonarQube for IDE is running in either connected mode or standalone mode. New code is defined differently in each mode as mentioned above.

Focus on new code in connected mode

Setting your focus on new code has these prerequisites running in Connected mode:

  • Your local project must be bound to a SonarQube (Server, Cloud) or SonarQube Community Build project.
  • The new code definition must be defined in SonarQube (Server, Cloud) or SonarQube Community Build using a Previous version, Number of days, or Specific analysis
  • The Reference branch new code definition is not supported. Please check the documentation in SonarQube Server,  SonarQube Cloud, or SonarQube Community Build to properly set your new code definition.

By default, the SonarQube focus is set to overall code when you set up a new connection and establish the project binding; the last saved setting persists through restarts.

Focus on new code in standalone mode

When not running in connected mode, the SonarQube focus feature can still be used to highlight only issues found in new code. By default, the SonarQube focus is set to overall code when you open SonarQube for VS Code for the first time; the last saved setting persists through restarts.

Change your SonarQube focus

Setting the SonarQube focus on new code is easy. To activate or deactivate this mode, select SonarQube focus: in the VS Code Status Bar, then press Enter or choose Focus on new code or Focus on overall code from the Command Palette. Additionally, you can select or deselect the SonarQube focus mode from the VS Code > Settings… > Settings > Extensions > SonarLint > User settings menu.

Running SonarQube for IDE in connected mode with SonarQube Server or SonarQube Cloud offers more opportunities to choose how you define new code. Check out their respective pages for details.

How the new code definition affects the analysis results

Depending on your server settings, your NCD affects how many issues you see. SonarQube Server and SonarQube Cloud uses your NCD as a baseline for code comparison to filter issues found only in new code

  • When running SonarQube for IDE in connected mode and enabling the Focus on New Code feature, the NCD from SonarQube (Server, Cloud) is used to show you only issues found in new code.
  • When running SonarQube for IDE while not in connected mode and enabling the Focus on New Code feature, every SonarQube for IDE analysis will show you only issues found in new code

The Focus on New Code feature gives you immediate feedback in the IDE, before you submit new code with new issues. Read the Focusing on new code article for more information.


Was this page helpful?

© 2008-2025 SonarSource SA. All rights reserved.

Creative Commons License