SONARJAVA-6205 Add an agentic focused quality profile for Java#5531
SONARJAVA-6205 Add an agentic focused quality profile for Java#5531dorian-burihabwa-sonarsource wants to merge 3 commits intomasterfrom
Conversation
37eb8d7 to
0dab089
Compare
SummaryThis PR introduces a new "AI Quality Profile" for Java code analysis that activates 467 specific rules, complementing the existing Sonar Way profile. The profile is designed for agentic/AI-focused quality checks and explicitly excludes 36 other rules. The changes also refactor shared quality profile logic into a reusable utility class ( What reviewers should knowWhere to start: Look at the new Key points for review:
No architectural surprises: Registration in
|
0dab089 to
31312fc
Compare
rombirli
left a comment
There was a problem hiding this comment.
LGTM! I just have two questions about external rules inclusion mechanism and the purpose of profileRegistrars
| for (ProfileRegistrar profileRegistrar : profileRegistrars) { | ||
| profileRegistrar.register(ruleKeys::addAll); | ||
| } |
There was a problem hiding this comment.
In test JavaAgenticWayProfileTest, profileRegistrars is always null and this part is never covered, is there a reason ?
| public void define(Context context) { | ||
| NewBuiltInQualityProfile agenticWay = context.createBuiltInQualityProfile("AI Quality Profile", Java.KEY); | ||
| Set<RuleKey> ruleKeys = QualityProfileUtils.registerRulesFromJson( | ||
| "/org/sonar/l10n/java/rules/java/Agentic_way_profile.json", |
There was a problem hiding this comment.
This string constant could be extracted in a constant SONAR_AGENTIC_WAY_PATH like SONAR_WAY_PATH in JavaSonarWayProfile
| ruleKeys.forEach(ruleKey -> agenticWay.activateRule(ruleKey.repository(), ruleKey.rule())); | ||
| agenticWay.done(); | ||
| } |
There was a problem hiding this comment.
These lines and the creation of agenticWay (or sonarWay) are repeated in JavaSonarWayProfile, maybe it could be refactored in QualityProfileUtils
static void createQualityProfile(String title, Set<RuleKey> ruleKeys) {
NewBuiltInQualityProfile way = context.createBuiltInQualityProfile(title, Java.KEY);
ruleKeys.forEach(ruleKey -> way.activateRule(ruleKey.repository(), ruleKey.rule()));
way.done();
}
}| if (ruleKeys.stream().noneMatch(rule -> SECURITY_REPOSITORY_KEY.equals(rule.repository()))) { | ||
| ruleKeys.addAll(getSecurityRuleKeys()); | ||
| } |
There was a problem hiding this comment.
Is there a reason this mechanism to include external rules is not present in JavaAgenticWayProfile? (Why the implementations diverge? Is there a justification?)
rombirli
left a comment
There was a problem hiding this comment.
Agentic_way_profile.json seems to be wrong
e818473 to
35e7ca4
Compare
|





No description provided.