Skip to content

Commit cdc2bd8

Browse files
benzonicoclaude
andcommitted
Add Agent Quality Profile for AI agents (high-severity rules)
Create a quality profile for AI agents focused on reliability, security, and complexity with high-severity rules only (Major, Critical, Blocker). This profile activates 215 high-severity rules: - Security vulnerabilities and hotspots: 72 rules - Reliability issues (bugs): 132 rules - Code complexity metrics: 27 rules The Agent Quality Profile helps AI agents maintain code quality by enforcing critical security, reliability, and complexity standards. Changes: - Add Agent_quality_profile.json with curated high-severity rules - Add PythonAgentQualityProfile.java profile loader - Register profile in PythonExtensions.java 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bde7966 commit cdc2bd8

File tree

3 files changed

+281
-0
lines changed

3 files changed

+281
-0
lines changed
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
{
2+
"name": "Agent Quality Profile",
3+
"ruleKeys": [
4+
"S104",
5+
"S1045",
6+
"S107",
7+
"S108",
8+
"S1142",
9+
"S1143",
10+
"S1172",
11+
"S1244",
12+
"S134",
13+
"S138",
14+
"S1523",
15+
"S1656",
16+
"S1700",
17+
"S1716",
18+
"S1717",
19+
"S1751",
20+
"S1763",
21+
"S1764",
22+
"S1862",
23+
"S2053",
24+
"S2068",
25+
"S2077",
26+
"S2115",
27+
"S2159",
28+
"S2190",
29+
"S2201",
30+
"S2245",
31+
"S2257",
32+
"S2275",
33+
"S2612",
34+
"S2711",
35+
"S2712",
36+
"S2733",
37+
"S2734",
38+
"S2755",
39+
"S2757",
40+
"S2823",
41+
"S2876",
42+
"S3329",
43+
"S3358",
44+
"S3403",
45+
"S3699",
46+
"S3776",
47+
"S3827",
48+
"S3862",
49+
"S3923",
50+
"S3981",
51+
"S3984",
52+
"S3985",
53+
"S4143",
54+
"S4423",
55+
"S4426",
56+
"S4433",
57+
"S4502",
58+
"S4721",
59+
"S4784",
60+
"S4787",
61+
"S4790",
62+
"S4792",
63+
"S4823",
64+
"S4828",
65+
"S4829",
66+
"S4830",
67+
"S5042",
68+
"S5247",
69+
"S5300",
70+
"S5332",
71+
"S5344",
72+
"S5439",
73+
"S5443",
74+
"S5445",
75+
"S5527",
76+
"S5542",
77+
"S5547",
78+
"S5549",
79+
"S5607",
80+
"S5632",
81+
"S5642",
82+
"S5644",
83+
"S5659",
84+
"S5707",
85+
"S5708",
86+
"S5714",
87+
"S5717",
88+
"S5719",
89+
"S5722",
90+
"S5724",
91+
"S5756",
92+
"S5796",
93+
"S5807",
94+
"S5828",
95+
"S5845",
96+
"S5850",
97+
"S5852",
98+
"S5855",
99+
"S5856",
100+
"S5868",
101+
"S5905",
102+
"S5915",
103+
"S5953",
104+
"S5994",
105+
"S5996",
106+
"S6001",
107+
"S6002",
108+
"S6249",
109+
"S6265",
110+
"S6270",
111+
"S6275",
112+
"S6281",
113+
"S6302",
114+
"S6303",
115+
"S6304",
116+
"S6308",
117+
"S6317",
118+
"S6319",
119+
"S6323",
120+
"S6327",
121+
"S6328",
122+
"S6329",
123+
"S6330",
124+
"S6332",
125+
"S6333",
126+
"S6377",
127+
"S6418",
128+
"S6437",
129+
"S6463",
130+
"S6468",
131+
"S6540",
132+
"S6543",
133+
"S6552",
134+
"S6560",
135+
"S6662",
136+
"S6663",
137+
"S6709",
138+
"S6714",
139+
"S6725",
140+
"S6727",
141+
"S6729",
142+
"S6734",
143+
"S6735",
144+
"S6740",
145+
"S6741",
146+
"S6779",
147+
"S6781",
148+
"S6785",
149+
"S6786",
150+
"S6799",
151+
"S6863",
152+
"S6882",
153+
"S6883",
154+
"S6887",
155+
"S6890",
156+
"S6894",
157+
"S6900",
158+
"S6903",
159+
"S6908",
160+
"S6911",
161+
"S6918",
162+
"S6919",
163+
"S6925",
164+
"S6928",
165+
"S6929",
166+
"S6971",
167+
"S6972",
168+
"S6973",
169+
"S6974",
170+
"S6978",
171+
"S6982",
172+
"S6984",
173+
"S6985",
174+
"S7483",
175+
"S7484",
176+
"S7487",
177+
"S7488",
178+
"S7489",
179+
"S7490",
180+
"S7493",
181+
"S7497",
182+
"S7499",
183+
"S7501",
184+
"S7502",
185+
"S7506",
186+
"S7507",
187+
"S7514",
188+
"S7515",
189+
"S7608",
190+
"S7609",
191+
"S7613",
192+
"S7617",
193+
"S7618",
194+
"S7619",
195+
"S7620",
196+
"S7621",
197+
"S7625",
198+
"S7931",
199+
"S7932",
200+
"S7942",
201+
"S7943",
202+
"S8370",
203+
"S8371",
204+
"S8374",
205+
"S8375",
206+
"S8385",
207+
"S8389",
208+
"S8392",
209+
"S8396",
210+
"S8400",
211+
"S8401",
212+
"S8405",
213+
"S8409",
214+
"S8411",
215+
"S8414",
216+
"S905",
217+
"S930",
218+
"S935"
219+
]
220+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* SonarQube Python Plugin
3+
* Copyright (C) 2011-2025 SonarSource Sàrl
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
* See the Sonar Source-Available License for more details.
13+
*
14+
* You should have received a copy of the Sonar Source-Available License
15+
* along with this program; if not, see https://sonarsource.com/license/ssal/
16+
*/
17+
package org.sonar.plugins.python;
18+
19+
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
20+
import org.sonar.plugins.python.editions.RepositoryInfoProvider;
21+
import org.sonar.plugins.python.editions.RepositoryInfoProvider.RepositoryInfo;
22+
import org.sonarsource.analyzer.commons.BuiltInQualityProfileJsonLoader;
23+
24+
/**
25+
* Agent Quality Profile - Built-in profile focused on security, reliability, and code complexity
26+
*
27+
* This profile activates rules that help maintain code quality for AI agents by focusing on:
28+
* - Security vulnerabilities and security hotspots
29+
* - Reliability issues (bugs)
30+
* - Code complexity metrics (cognitive complexity, cyclomatic complexity, etc.)
31+
*/
32+
public class PythonAgentQualityProfile implements BuiltInQualityProfilesDefinition {
33+
34+
static final String PROFILE_NAME = "Agent Quality Profile";
35+
static final String AGENT_PROFILE_LOCATION = "org/sonar/l10n/py/rules/python/Agent_quality_profile.json";
36+
37+
private final RepositoryInfoProvider[] editionMetadataProviders;
38+
39+
public PythonAgentQualityProfile(RepositoryInfoProvider[] editionMetadataProviders) {
40+
this.editionMetadataProviders = editionMetadataProviders;
41+
}
42+
43+
@Override
44+
public void define(Context context) {
45+
NewBuiltInQualityProfile profile = context.createBuiltInQualityProfile(PROFILE_NAME, Python.KEY);
46+
47+
for (RepositoryInfoProvider repositoryInfoProvider : editionMetadataProviders) {
48+
registerRulesForEdition(repositoryInfoProvider, profile);
49+
}
50+
51+
profile.done();
52+
}
53+
54+
private static void registerRulesForEdition(RepositoryInfoProvider repositoryInfoProvider, NewBuiltInQualityProfile profile) {
55+
RepositoryInfo repositoryInfo = repositoryInfoProvider.getInfo();
56+
// Load the Agent Quality Profile instead of Sonar way profile
57+
BuiltInQualityProfileJsonLoader.load(profile, repositoryInfo.repositoryKey(), AGENT_PROFILE_LOCATION);
58+
profile.activeRules().removeIf(rule -> repositoryInfo.disabledRules().contains(rule.ruleKey()));
59+
}
60+
}

python-commons/src/main/java/org/sonar/plugins/python/PythonExtensions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public static void addCommonExtensions(Plugin.Context context) {
7676

7777
Python.class,
7878
PythonProfile.class,
79+
PythonAgentQualityProfile.class,
7980

8081
PythonSensor.class,
8182
PythonRuleRepository.class,

0 commit comments

Comments
 (0)