File exclusions

How to exclude files from analysis when using SonarQube for IntelliJ IDE.

All versions of SonarQube for IDE will fetch file exclusions from SonarQube (Server, Cloud) or SonarQube Community Build when you bind a project while running in connected mode. Locally defined file exclusions will be ignored when running in connected mode. For more information about how SonarQube for Visual Studio settings are handled by the server, look at the server documentation on setting your analysis scope:

File exclusions in the IDE

When running in Connected mode with SonarQube (Server, Cloud) or SonarQube Community Build, SonarQube for IDE will ignore local exclusions and fetch file exclusions from the SonarQube (Server, Cloud) server.

Defining file exclusions

When not using connected mode, it's possible to define file exclusions locally. Go to IntelliJ Settings > Tools > SonarQube for IDE > File Exclusions to define an exclusion pattern. Wildcards are allow, using the Wildcard patterns listed below.

File exclusions defined in IntelliJ only apply when not running in Connected Mode. When a project is bound to a SonarQube (Server, Cloud) project, exclusions defined in the server’s General Settings override locally defined exclusions.

Wildcard patterns

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

  • * Match zero or more characters (not including the directory delimiter, / ).

  • ** Match zero or more directory segments or files 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.api/mybean.java or 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/**/* is equivalent to org/sonar/** and

    • matches org/sonar/anyDirectory/anyFile

    • matches org/sonar/MyClass.java

    • doesn’t match org/radar/MyClass.java

Last updated

Was this helpful?