Quick revision
The short answer
A single shared profile gives every team a common baseline and makes audits simple, but teams work in different contexts (libraries, batch jobs, legacy code), and one profile tuned for one of them produces noise in the others. My decision rule is to make a core set of security and correctness rules mandatory for everyone and let teams own extensions for style and maintainability, and to judge the setup by outcomes such as defects and incidents, not by issue counts.
What to remember
In this answer, we saw that a single SonarQube profile gives a common baseline and simple audits, but produces noise for teams whose code does not fit it, and that noise erodes trust in every finding. The decision rule is to make security and correctness rules a mandatory core, inherited by every team profile, and to let teams own style and maintainability extensions with recorded reasons, while keeping one gate. We judge the result by defects and incidents rather than by issue counts.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A single shared profile gives every team a common baseline and makes audits simple, but teams work in different contexts (libraries, batch jobs, legacy code), and one profile tuned for one of them produces noise in the others. My decision rule is to make a core set of security and correctness rules mandatory for everyone and let teams own extensions for style and maintainability, and to judge the setup by outcomes such as defects and incidents, not by issue counts.
Why this question is asked
Standardisation questions are common at senior level because there is no universally right answer; what interviewers want to hear is the reasoning. One quality profile for an entire organisation is attractive to whoever has to report on quality and frustrating to the teams whose code does not fit it. In this answer, we will recap what a quality profile is, make the case for one shared profile and the case against it, state a decision rule that keeps the benefits of both, and show how to implement and measure it.
1A Quick Recap: What a Quality Profile Controls
In SonarQube, a quality profile is the set of rules that are active for a language, along with their parameters, such as the maximum cognitive complexity of a method. Every project is analysed with one profile per language, and every issue it raises comes from a rule in that profile. The quality gate then decides which of those issues, and which measures, block a merge.
So the profile is the definition of what counts as a problem. Choosing one profile for everyone means choosing one definition of a problem for every team and every kind of code.
2The Case for One Shared Profile
A shared profile sets a common baseline. Every service is checked for the same security and correctness issues, so a gap in one team's setup cannot leave, say, SQL injection or unsafe deserialization unchecked. Developers who move between teams meet the same rules. Results are comparable across the organisation, which matters for leadership and for audits: when an auditor or a customer asks how code is checked, there is one answer, one document and one configuration to show.
It also reduces work. One group maintains one profile, upgrades it when SonarQube adds rules, and handles disputes once instead of in every team.
3The Case Against One Profile
Teams write different kinds of code. A public library needs strict API documentation and careful exception handling. A batch job may legitimately have long methods that read like a script. A ten-year-old monolith already has thousands of issues on rules a new service would follow easily. Test code, generated code and performance-critical code each have their own conventions.
A single profile strict enough for the library produces noise everywhere else, and one relaxed enough for the batch job is too weak for the library. Noise has a cost we saw in many organisations: developers dismiss findings in bulk, and the real findings get dismissed with them. A profile that is formally shared but widely ignored is worse than profiles that are respected.
| One shared profile | Team-owned profiles only | |
|---|---|---|
| Security baseline | Guaranteed everywhere | Depends on each team |
| Fit for context | Poor for unusual code | Good |
| Audits and comparison | Simple | Hard: many definitions |
| Noise and trust | High noise for some teams | Low noise, but drift |
| Maintenance | One group, one profile | Every team maintains its own |
4The Decision Rule: Mandatory Core, Team Extensions
The rule that keeps the strengths of both is a split by purpose. Rules that protect security and correctness, such as injection flaws, unsafe cryptography, null dereferences, resource leaks and broken equals and hashCode, are mandatory for everyone. A team cannot deactivate them, and a change to them goes through a central review. Rules about style and maintainability, such as method length, naming, comment density and complexity thresholds, are owned by teams, who can add, relax or tighten them for their context and must record why.
The reason for drawing the line there is that the cost of a missed security or correctness issue does not depend on the team's context, while the value of a style rule does. A SQL injection in a batch job is as dangerous as one in a web service; a 70-line method is a problem in one codebase and normal in another.
- Team profile, for example payments-javateam-owned style and maintainability choices, with reasons
- Organisation core profilemandatory security and correctness rules, centrally reviewed
- Built-in Sonar way profilethe vendor baseline the core extends
3 layers, from the top down. Step through them one at a time.
SonarQube supports profile inheritance: a child profile inherits its parent's rules and can add or change others.
5Implementing It
SonarQube's profile inheritance fits this directly. We create an organisation core profile that inherits from the built-in profile and activates the mandatory rules, then a child profile per team or per kind of code that inherits from the core. Permissions restrict who can edit the core profile. To make the mandatory part truly mandatory, a scheduled check compares each team profile with the core, using the SonarQube web API, and reports any project whose profile does not inherit from it or has deactivated an inherited rule (check your version for which changes inheritance allows).
The quality gate stays the same for everyone and focuses on the core concerns: no new bugs or vulnerabilities, hotspots reviewed and coverage on new code. That way a green gate means the same thing in every team, even though style feedback differs.
6Measure Outcomes, Not Issue Counts
It is tempting to compare teams by the number of open issues, but issue counts reward the wrong things: a team can lower its count by relaxing rules, and a team with a strict profile looks worse than a team with a lax one. What we actually care about is fewer defects and incidents. So we measure escaped defects, production incidents traced to code faults, security findings from penetration tests and bug bounties, and the time reviewers spend on issues a tool could have caught.
If teams with relaxed style rules show no more defects than teams with strict ones, the relaxed rules were not buying anything. If a class of incident keeps recurring, it is a strong argument for adding a rule to the mandatory core. That is the feedback loop that keeps the decision honest.
7Follow-up questions
What do you do when a team wants to disable a core security rule?
We look at the specific case. Often the rule fires on code where the risk is genuinely absent, such as a test helper, and the right fix is an exclusion for that path or a resolution with a reviewed comment, not deactivating the rule for the whole team. If the rule is generally wrong or too noisy for everyone, the central owners can change it in the core profile, which benefits all teams.
How do you keep team profiles from drifting into irrelevance?
Each team profile change needs a recorded reason, and we review team profiles once or twice a year against outcome data. Because the core is inherited, new security rules added centrally reach every team automatically, so drift can only happen in the style layer, where it is far less risky.
Does this approach work with tools other than SonarQube?
Yes. The same split applies to Checkstyle, PMD or Error Prone: a shared configuration with mandatory correctness checks, published as a dependency or a convention plugin, and team-level additions in their own build. The principle is about which decisions are central and which are local, not about one tool.
8Conclusion
In this answer, we saw that a single SonarQube profile gives a common baseline and simple audits, but produces noise for teams whose code does not fit it, and that noise erodes trust in every finding. The decision rule is to make security and correctness rules a mandatory core, inherited by every team profile, and to let teams own style and maintainability extensions with recorded reasons, while keeping one gate. We judge the result by defects and incidents rather than by issue counts.
Open with
I would argue both sides and then split the decision by purpose. For one shared profile: everyone gets the same security and correctness checks, developers who move teams see the same rules, and audits and reporting have one answer.
Then, if they want more
Against it: teams write different code, a public library, a batch job, a ten-year-old monolith, and a profile tuned for one is noise for the others, and noise leads to bulk dismissals that hide real issues.
So my rule is a mandatory core for security and correctness, things like injection, weak crypto, null dereferences and resource leaks, which nobody can deactivate because the risk does not depend on context, and team-owned extensions for style and maintainability, like method length or naming, with a recorded reason for each change.
In SonarQube I would implement this with profile inheritance: an organisation core profile extending Sonar way, team profiles inheriting from it, edit rights on the core restricted, and a scheduled check that every project uses a profile that inherits from the core. The gate stays the same everywhere.
Then I would measure outcomes, escaped defects, incidents and security findings, rather than issue counts, and use that data to add rules to the core or remove style rules that buy nothing.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Maven guides, Gradle user manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Should your organisation enforce a single SonarQube quality profile across all teams?...": https://scrivio-interview-library.netlify.app/java/code-quality-tools/d8a1d9c12b/