Skip to main content
TopMiniSite

Back to all posts

How to Exclude Files Or Directories From SonarQube Analysis?

Published on
6 min read
How to Exclude Files Or Directories From SonarQube Analysis? image

Best SonarQube Tools to Buy in November 2025

1 SonarQube in Action

SonarQube in Action

  • AFFORDABLE PRICES FOR QUALITY, PRE-LOVED LITERARY TREASURES!
  • ENVIRONMENTALLY FRIENDLY: SUPPORT RECYCLING THROUGH USED BOOKS.
  • UNIQUE FINDS: DIVERSE SELECTION OF TITLES FOR EVERY READER!
BUY & SAVE
$49.99
SonarQube in Action
2 Re-Engineering Legacy Software

Re-Engineering Legacy Software

BUY & SAVE
$49.93 $64.99
Save 23%
Re-Engineering Legacy Software
3 Replacement Sonar Sensor for Venterior VT-FF005 Portable Fish Finder (Yellow)

Replacement Sonar Sensor for Venterior VT-FF005 Portable Fish Finder (Yellow)

  • CONFIRM COMPATIBILITY WITH YOUR FISH FINDER BEFORE BUYING!
  • ENHANCE YOUR FISHING EXPERIENCE WITH THIS REPLACEMENT SONAR SENSOR.
  • EASY INSTALLATION FOR IMPROVED SONAR PERFORMANCE ON THE WATER.
BUY & SAVE
$47.99
Replacement Sonar Sensor for Venterior VT-FF005 Portable Fish Finder (Yellow)
4 Sonar RTU (Ready-to-Use) Aquatic Herbicide 1 Quart, Systemic Weed Control for Duckweed and More - No Mixing or Equipment Needed - EPA Approved, Season-Long Treatment, Safe for Fish & Wildlife

Sonar RTU (Ready-to-Use) Aquatic Herbicide 1 Quart, Systemic Weed Control for Duckweed and More - No Mixing or Equipment Needed - EPA Approved, Season-Long Treatment, Safe for Fish & Wildlife

  • NO MIXING REQUIRED: EASILY POUR INTO YOUR POND FOR QUICK RESULTS!
  • EPA APPROVED: SAFE FOR FISH, PETS, AND WILDLIFE IN ALL PONDS!
  • SIMPLE DOSING: JUST 4 QUARTS TREATS 1/2 ACRE EFFORTLESSLY!
BUY & SAVE
$107.15 $141.44
Save 24%
Sonar RTU (Ready-to-Use) Aquatic Herbicide 1 Quart, Systemic Weed Control for Duckweed and More - No Mixing or Equipment Needed - EPA Approved, Season-Long Treatment, Safe for Fish & Wildlife
5 LUCKY Portable Fish Finder Handheld Kayak Fish Finders Wired Fish Depth Finder Sonar Sensor Transducer for Boat Fishing Sea Fishing

LUCKY Portable Fish Finder Handheld Kayak Fish Finders Wired Fish Depth Finder Sonar Sensor Transducer for Boat Fishing Sea Fishing

  • DETECT FISH & DEPTH: CLEAR LCD SHOWS FISH SIZE AND WATER DEPTH!

  • VERSATILE USE: PERFECT FOR ICE, RIVER, SEA, AND KAYAK FISHING!

  • LONG BATTERY LIFE: RECHARGEABLE, UP TO 5 HOURS OF CONTINUOUS USE!

BUY & SAVE
$82.89
LUCKY Portable Fish Finder Handheld Kayak Fish Finders Wired Fish Depth Finder Sonar Sensor Transducer for Boat Fishing Sea Fishing
6 LUCKY Portable Fish Finder Transducer Sonar Sensor 147 Feet Water Depth Finder LCD Screen Echo Sounder Fishfinder with Fish Attractive Lamp for Ice Fishing Sea Fishing

LUCKY Portable Fish Finder Transducer Sonar Sensor 147 Feet Water Depth Finder LCD Screen Echo Sounder Fishfinder with Fish Attractive Lamp for Ice Fishing Sea Fishing

  • VERSATILE MODES: CHOOSE BETWEEN WIRELESS AND SIMULATION FOR FLEXIBILITY.
  • POWERFUL RANGE: DETECT FISH UP TO 147FT DEEP, 492FT AWAY, FOR VERSATILITY.
  • USER-FRIENDLY FEATURES: CUSTOMIZE SETTINGS LIKE BRIGHTNESS AND ALARMS EASILY.
BUY & SAVE
$82.89
LUCKY Portable Fish Finder Transducer Sonar Sensor 147 Feet Water Depth Finder LCD Screen Echo Sounder Fishfinder with Fish Attractive Lamp for Ice Fishing Sea Fishing
7 LUCKY Portable Sonar Fish Finder Boat Depth Fishing Fish Finders Waterproof Handheld Wireless Fishing Finder Kayak Transducer Depth Finders for Ice Fishing Sea

LUCKY Portable Sonar Fish Finder Boat Depth Fishing Fish Finders Waterproof Handheld Wireless Fishing Finder Kayak Transducer Depth Finders for Ice Fishing Sea

  • WATERPROOF & FLOATING DESIGN: NO DAMAGE FROM RAIN OR WATER SPLASHES!

  • WIRELESS & EASY CASTING: MAX 656FT WIRELESS RANGE FOR HASSLE-FREE FISHING.

  • DETAILED DATA DISPLAY: GET FISH SIZE, DEPTH, TEMP & BOTTOM CONTOUR INFO!

BUY & SAVE
$124.99
LUCKY Portable Sonar Fish Finder Boat Depth Fishing Fish Finders Waterproof Handheld Wireless Fishing Finder Kayak Transducer Depth Finders for Ice Fishing Sea
8 LUCKY Kayak Handheld Fish Finder Sonar LCD Wired Fish Finder Transducer Boat Water Depth Finders Display FF1108-1

LUCKY Kayak Handheld Fish Finder Sonar LCD Wired Fish Finder Transducer Boat Water Depth Finders Display FF1108-1

  • FIND FISH FASTER: DETECT DEPTH AND FISH LOCATION UP TO 328FT EASILY.
  • PORTABLE AND USER-FRIENDLY: HANDHELD DESIGN FOR EFFORTLESS CARRYING ANYWHERE.
  • VERSATILE USAGE: IDEAL FOR VARIOUS FISHING ENVIRONMENTS, FROM LAKES TO ICE.
BUY & SAVE
$42.99
LUCKY Kayak Handheld Fish Finder Sonar LCD Wired Fish Finder Transducer Boat Water Depth Finders Display FF1108-1
9 Sonar A.S. Liquid Aquatic Herbicide 8 oz Systemic Treatment for Duckweed, Watermeal, Hydrilla, and Invasive Pond Weeds, EPA Approved, Safe for Fish & Wildlife, Easy DIY Use for Small Ponds

Sonar A.S. Liquid Aquatic Herbicide 8 oz Systemic Treatment for Duckweed, Watermeal, Hydrilla, and Invasive Pond Weeds, EPA Approved, Safe for Fish & Wildlife, Easy DIY Use for Small Ponds

  • SYSTEMATICALLY ELIMINATES INVASIVE WEEDS, PROTECTS POND OXYGEN LEVELS.
  • EASY TO USE: JUST MIX AND POUR-NO SPRAYING EQUIPMENT NEEDED!
  • EPA APPROVED; SAFE FOR FISH, PETS, AND WILDLIFE IN ANY POND.
BUY & SAVE
$292.99
Sonar A.S. Liquid Aquatic Herbicide 8 oz Systemic Treatment for Duckweed, Watermeal, Hydrilla, and Invasive Pond Weeds, EPA Approved, Safe for Fish & Wildlife, Easy DIY Use for Small Ponds
+
ONE MORE?

To exclude files or directories from SonarQube analysis, you can use the SonarQube exclusions mechanism. Here's how:

  1. Open the SonarQube web interface and navigate to your project's dashboard.
  2. Go to "Administration" on the top menu, then select "Analysis Scope" from the left-hand side menu.
  3. In the "Source File Exclusions" section, you can provide patterns to exclude specific files or directories from the analysis. SonarQube uses Ant-style patterns to match file paths. For example, to exclude a specific file: "src/main/java/com/example/MyClass.java". To exclude all files in a directory: "src/main/java/com/example/*". To exclude a specific subdirectory: "src/main/java/com/example/subdir/**/*".
  4. Click the "Bulk Change" button to apply the exclusions.
  5. After saving the exclusions, the next analysis run will exclude the specified files or directories accordingly.

It's important to note that excluding files or directories should be used with caution, as it might introduce blind spots in the analysis. Ensure that you have valid reasons for excluding certain files or directories, such as generated code or third-party libraries.

Additionally, excluding files or directories can also be achieved through specific configuration files, depending on the build tool being used. For example:

  • For Maven projects, you can configure exclusions in the "pom.xml" file using the property.
  • For Gradle projects, you can configure exclusions in the "build.gradle" file using the sonarqube extension's exclusions property.
  • For other build tools, refer to the SonarQube documentation for information on how to configure exclusions using the respective tool.

Remember to regularly review your exclusions to ensure that they remain relevant and necessary for accurate code analysis.

How to exclude files from SonarQube analysis?

To exclude files from SonarQube analysis, you can use the following options:

  1. Using the SonarQube UI: Login to your SonarQube server as an administrator. Go to "Project Settings" or "Administration" and select the specific project you want to exclude files from. Navigate to "Analysis Scope" or "Source Code" settings. Look for options like "Inclusions" or "Exclusions" and add the file patterns you want to exclude. For example, **/test/**/* would exclude any files under the "test" directory. Save the changes and trigger a new analysis for the project.
  2. Using the SonarQube analysis parameters: In your SonarQube Scanner configuration file (sonar-project.properties or pom.xml), add the sonar.exclusions property. Assign the file patterns you want to exclude using this property. For example, sonar.exclusions=**/test/**/* would exclude any files under the "test" directory. Save the file and run the SonarQube analysis again.
  3. Using file-based exclusions: Create a file named .sonarignore in the root directory of your project. Add the file patterns you want to exclude in this file, with each pattern on a separate line. For example: **/test/** **/*.html Save the file and run the SonarQube analysis.

Note that these exclusions are project-specific and will only affect the analysis for the specified project. If you want to exclude files globally across all projects, you can set the exclusions in the SonarQube server-level settings.

How to exclude third-party libraries from SonarQube analysis?

To exclude third-party libraries from SonarQube analysis, you can use the "sonar.exclusions" property in your SonarQube project configuration.

  1. Determine the path or pattern of the files you want to exclude. For example, if you have third-party libraries located in a folder named "lib" within your project directory, the pattern may be "/lib/".
  2. Open your SonarQube project configuration file, which is typically named "sonar-project.properties".
  3. Add the "sonar.exclusions" property to the file, specifying the path or pattern to exclude. For example: sonar.exclusions=**/lib/** This will exclude all files and subdirectories within the "lib" folder from the SonarQube analysis.
  4. Save the configuration file and re-run the SonarQube analysis. The excluded files should now be skipped during the analysis process.

Note: It's recommended to exclude third-party libraries from the analysis to avoid skewing the analysis results and focusing on your own code. However, you may still want to analyze the interfaces used by these libraries. In such cases, you can exclude specific files or directories within the third-party library folder by adjusting the exclusion pattern accordingly.

What is the impact of excluding files on maintainability analysis in SonarQube?

Excluding files from analysis in SonarQube can have both positive and negative impacts on maintainability analysis.

Positive Impact:

  1. Improved Performance: By excluding files that are not relevant to the analysis, you can significantly reduce the analysis time and improve the overall performance of SonarQube.
  2. Focus on Critical Areas: Excluding certain files allows developers to focus their attention on the critical and high-risk areas of the codebase. This can be helpful when dealing with large projects with a limited amount of resources.
  3. Reduced Noise: Excluding files that are auto-generated or third-party libraries can help reduce false positives and noise in the analysis reports. This allows developers to concentrate on actionable findings rather than wasting time on irrelevant issues.

Negative Impact:

  1. Hidden Issues: Excluding files might hide potential issues that could cause maintainability problems in the future. It may lead to oversight of potential vulnerabilities or code smells.
  2. Incomplete Analysis: By excluding files, you might miss out on certain code areas that are relevant to the overall maintainability of the project. This can result in incomplete analysis and incomplete insights into the code quality.
  3. Relying on Subjectivity: Deciding which files to exclude requires subjective judgment, and different individuals may have different opinions on what should be included or excluded. This subjectivity might introduce consistency and accuracy issues in the analysis.

It's important to strike a balance between excluding files to improve performance and manageability while ensuring that critical areas and potential issues are not missed out on. Regular review and updates to the excluded file list are recommended to maintain a comprehensive analysis without sacrificing performance.

How to exclude comments from SonarQube analysis?

To exclude comments from SonarQube analysis, you can follow these steps:

  1. Open the SonarQube web interface.
  2. Navigate to your project's dashboard.
  3. Click on "Administration" in the top menu.
  4. Under the "General Settings" section, click on "Analysis Scope".
  5. Scroll down to the "Source File Exclusions" section.
  6. Edit the regular expression under "Exclusions" to exclude comments. You can use a regular expression like (?i)\\.java$ to exclude all Java files, for example.
  7. Click on "Save" to apply the changes.

By excluding comments from the analysis scope, SonarQube will ignore any issues or code smells present in the comments, improving the accuracy of the analysis results. However, keep in mind that excluding comments might not be advisable if your comments also contain important information regarding the code quality or documentation. In such cases, it's better to address any issues found in the comments to maintain a comprehensive analysis.