Hello community,
SonarQube architecture now supports interface design: you can define which children of a component are accessible from outside, and Sonar enforces it during analysis.
Programming languages give you visibility controls at specific levels. Java has class-member visibility and package-scoped privacy, TypeScript has module exports, C# has internal. None of these generalize across all containment levels of an architecture or across languages.
Interface design in SonarQube does. It works at every level, in every supported language, with the same mechanism.
How it works
You opt in at the parent component. Once enabled, you mark which children are accessible from outside and which are not. The setting is recursive: marking a component as non-accessible makes its entire subtree non-accessible to anything outside the parent scope.
When code outside the parent depends on a non-accessible child, Sonar raises a deviation. Each deviation can produce multiple code issues pointing to the specific lines that deviate from the intended interface.
This composes in large projects. You define interfaces locally, one component at a time, and enforcement propagates through the hierarchy.
So what?
Combined with the existing support for structure and relationships, interface design gives you a complete architectural specification that Sonar enforces continuously. Define it once, and enforcement follows automatically.
This is particularly useful for AI-generated code. Agents that add needless dependencies or reach into internals they should not will produce deviations in SonarQube, keeping complexity under control.
Availability
Interface design is available now in SonarQube Cloud on all plans. A dedicated rule is included in the Sonar Way profile, so enforcement is active by default once you define your interfaces.
The architecture resource center has videos, presentations, and blog posts that go deeper.
Try it out and share your feedback.
