VS Code | Using SonarLint | File exclusions

Was this page helpful?

On this page

Install Free

File exclusions

All versions of SonarLint will fetch file exclusions from the SonarQube or SonarCloud server when you bind a project or update a binding while running in Connected Mode. Check the SonarQube and SonarCloud documentation for information about setting your Analysis scope.

File exclusions in the IDE

Defining file exclusions locally in SonarLint for VS Code is possible in versions 3.22 and newer. 

When running in Connected Mode with SonarQube or SonarCloud, SonarLint will ignore local exclusions and fetch file exclusions from the SonarQube or SonarCloud server.

Defining file exclusions

To use VS Code’s file exclusions, go to VS Code Settings > Workspace, search File: Exclude and select Add Pattern. The Workspace setting has information about how VS Code uses wildcard patterns to manage exclusions in the editor.

Wildcard patterns

The recognized path-matching patterns are defined using the following wildcards:

  • *  Match zero or more characters (not including the directory delimiter,  / ).
  • **  Match zero or more directory segments within the path.
  • ?  Match a single character (not including the directory delimiter,  / ).

Wildcard examples

  • The pattern  **/*.css
    • matches  anyDirectory/anyFile.css
    • doesn't match  org/sonar.api/MyBean.java
  • The pattern  **/*Bean.java
    • matches  org/sonar.api/MyBean.java
    • doesn't match  org/sonar/util/MyDTO.java
  • The pattern  **/*Bean?.java
    • matches  org/sonar/util/MyOtherBean1.java
    • doesn't match  org/sonar/util/MyOtherBean.java
  • The pattern  org/sonar/*
    • matches  org/sonar/MyClass.java
    • doesn't match  org/sonar/util/MyClassUtil.java
  • The pattern  org/sonar/**/*
    • matches  org/sonar/MyClass.java
    • doesn't match  org/radar/MyClass.java

The use of ? to match a single character is available in SonarLint for VS Code v4.0+.

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARLINT, SONARQUBE, SONARCLOUD, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License