Skip to main contentSkip to navigation

Why SonarQube Misses Mock Data in Production (and what to add)

SonarQube is excellent at detecting code smells, bugs, and vulnerabilities. But it cannot detect mock data in production because mocks are valid code.

What SonarQube catches

What SonarQube misses

The blind spot

SonarQube analyzes static code structure. Mock data in production is a runtime behavior issue. A function that returns fake data is syntactically correct, type-safe, and passes all SonarQube rules.

The solution: Add a reality gate

Complement SonarQube with a deploy gate that checks:

Practical example

# SonarQube scan (existing) sonar-scanner # Add reality gate (new) npx guardrail mockproof npx guardrail gate

Result

SonarQube ensures code quality. The reality gate ensures production reality. Together they prevent both bad code and fake data.

Some teams use guardrail to detect this automatically in CI.