Skip to content
Latchkey

How to Exclude Generated Code From Quality Analysis

sonar.exclusions removes files from analysis entirely; coverage and duplication exclusions narrow specific metrics.

Set sonar.exclusions for files that should not be analyzed at all, sonar.coverage.exclusions for files that skew coverage, and sonar.cpd.exclusions for duplication. Globs are relative to the project base.

sonar-project.properties

sonar-project.properties
sonar.projectKey=my-org_my-repo
sonar.sources=src
sonar.exclusions=**/*.pb.go,**/generated/**,**/vendor/**
sonar.coverage.exclusions=**/*.config.js,**/migrations/**
sonar.cpd.exclusions=**/*.generated.ts

Exclusion property reference

PropertyRemoves from
sonar.exclusionsAll analysis (issues + metrics)
sonar.coverage.exclusionsCoverage measurement only
sonar.cpd.exclusionsDuplication detection only
sonar.test.exclusionsTest file analysis

Gotchas

  • Full sonar.exclusions also hides real bugs in those files; exclude only truly generated code.
  • Globs are POSIX-style with **; a leading / anchors to the base directory.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →