Skip to content

Commit 5144ae0

Browse files
SONARJAVA-6205 Trim down of rules to match initial selection
1 parent ad7867d commit 5144ae0

2 files changed

Lines changed: 68 additions & 60 deletions

File tree

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/Agentic_way_profile.json

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
"name": "Agentic AI",
33
"ruleKeys": [
44
"S100",
5-
"S101",
65
"S106",
76
"S107",
87
"S108",
9-
"S110",
108
"S112",
11-
"S114",
12-
"S115",
13-
"S116",
14-
"S117",
159
"S119",
1610
"S120",
1711
"S125",
@@ -21,11 +15,7 @@
2115
"S135",
2216
"S899",
2317
"S1065",
24-
"S1066",
2518
"S1068",
26-
"S1075",
27-
"S1104",
28-
"S1110",
2919
"S1111",
3020
"S1113",
3121
"S1116",
@@ -34,7 +24,6 @@
3424
"S1119",
3525
"S1121",
3626
"S1123",
37-
"S1124",
3827
"S1125",
3928
"S1126",
4029
"S1128",
@@ -68,8 +57,6 @@
6857
"S1191",
6958
"S1192",
7059
"S1193",
71-
"S1195",
72-
"S1197",
7360
"S1199",
7461
"S1201",
7562
"S1206",
@@ -98,14 +85,11 @@
9885
"S1602",
9986
"S1604",
10087
"S1607",
101-
"S1611",
10288
"S1612",
10389
"S1640",
10490
"S1643",
10591
"S1656",
106-
"S1659",
10792
"S1700",
108-
"S1710",
10993
"S1751",
11094
"S1764",
11195
"S1844",
@@ -325,42 +309,28 @@
325309
"S4635",
326310
"S4682",
327311
"S4684",
328-
"S4719",
329312
"S4738",
330313
"S4790",
331314
"S4830",
332-
"S4838",
333-
"S4925",
334-
"S4929",
335-
"S4968",
336315
"S4970",
337316
"S4973",
338-
"S4977",
339317
"S5042",
340318
"S5122",
341319
"S5164",
342320
"S5247",
343-
"S5261",
344321
"S5301",
345322
"S5320",
346323
"S5322",
347324
"S5324",
348-
"S5329",
349325
"S5332",
350326
"S5344",
351327
"S5361",
352-
"S5411",
353-
"S5413",
354328
"S5443",
355329
"S5445",
356330
"S5527",
357331
"S5542",
358332
"S5547",
359333
"S5659",
360-
"S5663",
361-
"S5664",
362-
"S5665",
363-
"S5669",
364334
"S5679",
365335
"S5689",
366336
"S5693",
@@ -371,7 +341,6 @@
371341
"S5779",
372342
"S5783",
373343
"S5785",
374-
"S5786",
375344
"S5790",
376345
"S5803",
377346
"S5804",
@@ -381,40 +350,27 @@
381350
"S5831",
382351
"S5833",
383352
"S5838",
384-
"S5841",
385353
"S5842",
386354
"S5843",
387355
"S5845",
388356
"S5846",
389357
"S5850",
390358
"S5852",
391-
"S5853",
392-
"S5854",
393359
"S5855",
394360
"S5856",
395-
"S5857",
396-
"S5860",
397361
"S5863",
398362
"S5866",
399363
"S5868",
400-
"S5869",
401364
"S5876",
402365
"S5917",
403-
"S5958",
404366
"S5960",
405-
"S5961",
406367
"S5967",
407368
"S5969",
408-
"S5973",
409-
"S5976",
410-
"S5993",
411369
"S5994",
412370
"S5996",
413371
"S5998",
414372
"S6001",
415373
"S6002",
416-
"S6019",
417-
"S6035",
418374
"S6068",
419375
"S6070",
420376
"S6103",
@@ -429,16 +385,9 @@
429385
"S6207",
430386
"S6208",
431387
"S6209",
432-
"S6213",
433388
"S6216",
434-
"S6217",
435389
"S6218",
436-
"S6219",
437-
"S6241",
438-
"S6242",
439390
"S6243",
440-
"S6244",
441-
"S6246",
442391
"S6262",
443392
"S6263",
444393
"S6288",
@@ -460,21 +409,14 @@
460409
"S6539",
461410
"S6541",
462411
"S6548",
463-
"S6804",
464412
"S6806",
465413
"S6809",
466414
"S6810",
467-
"S6813",
468415
"S6814",
469416
"S6816",
470417
"S6817",
471418
"S6818",
472-
"S6829",
473-
"S6830",
474419
"S6831",
475-
"S6832",
476-
"S6833",
477-
"S6837",
478420
"S6838",
479421
"S6856",
480422
"S6857",
@@ -491,7 +433,6 @@
491433
"S6905",
492434
"S6906",
493435
"S6909",
494-
"S6912",
495436
"S6913",
496437
"S6915",
497438
"S6916",
@@ -528,6 +469,6 @@
528469
"S8450",
529470
"S8465",
530471
"S8469",
531-
"S8491"
472+
"S8471"
532473
]
533474
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* SonarQube Java
3+
* Copyright (C) 2012-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.java;
18+
19+
20+
import java.util.ArrayList;
21+
import java.util.List;
22+
import java.util.Map;
23+
import org.junit.jupiter.api.Test;
24+
import org.sonar.api.rule.RuleKey;
25+
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
26+
import org.sonar.plugins.java.api.ProfileRegistrar;
27+
28+
import static org.assertj.core.api.Assertions.assertThat;
29+
30+
class JavaAgenticWayProfileTest {
31+
@Test
32+
void rule_count_as_expected() {
33+
JavaAgenticWayProfile profile = new JavaAgenticWayProfile();
34+
assertThat(profile.sonarJavaAgenticWayRuleKeys()).hasSize(469);
35+
}
36+
37+
@Test
38+
void profile_is_not_registered_as_default() {
39+
JavaAgenticWayProfile profile = new JavaAgenticWayProfile();
40+
BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context();
41+
profile.define(context);
42+
43+
Map<String, Map<String, BuiltInQualityProfilesDefinition.BuiltInQualityProfile>> profilesPerLanguages = context.profilesByLanguageAndName();
44+
assertThat(profilesPerLanguages).containsOnlyKeys("java");
45+
assertThat(profilesPerLanguages.get("java")).containsOnlyKeys("Agentic way");
46+
BuiltInQualityProfilesDefinition.BuiltInQualityProfile actualProfile = profilesPerLanguages.get("java").get("Agentic way");
47+
assertThat(actualProfile.isDefault()).isFalse();
48+
assertThat(actualProfile.rules()).hasSize(469);
49+
}
50+
51+
@Test
52+
void profile_is_not_registered_as_default_across_profile_registrars() {
53+
final List<RuleKey> ruleKeys = new ArrayList<>();
54+
ProfileRegistrar emptyProfileRegistrar =
55+
registrarContext -> registrarContext.registerDefaultQualityProfileRules(ruleKeys);
56+
57+
JavaAgenticWayProfile profile = new JavaAgenticWayProfile(new ProfileRegistrar[]{emptyProfileRegistrar});
58+
BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context();
59+
profile.define(context);
60+
61+
Map<String, Map<String, BuiltInQualityProfilesDefinition.BuiltInQualityProfile>> profilesPerLanguages = context.profilesByLanguageAndName();
62+
assertThat(profilesPerLanguages).containsOnlyKeys("java");
63+
assertThat(profilesPerLanguages.get("java")).containsOnlyKeys("Agentic way");
64+
BuiltInQualityProfilesDefinition.BuiltInQualityProfile actualProfile = profilesPerLanguages.get("java").get("Agentic way");
65+
assertThat(actualProfile.isDefault()).isFalse();
66+
}
67+
}

0 commit comments

Comments
 (0)