Skip to content

Commit a090b60

Browse files
committed
SONARPY-2430: Enable all rules in the extend ruling (#2230)
1 parent f56fce6 commit a090b60

File tree

1,171 files changed

+477746
-701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,171 files changed

+477746
-701
lines changed

its/ruling/src/test/java/org/sonar/python/it/PythonExtendedRulingTest.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,33 @@
2222
import java.io.File;
2323
import java.io.IOException;
2424
import java.nio.file.Files;
25-
import java.util.List;
25+
import java.util.Collections;
2626
import org.junit.jupiter.api.BeforeAll;
2727
import org.junit.jupiter.api.Test;
2828
import org.junit.jupiter.api.extension.RegisterExtension;
29+
import org.sonarsource.analyzer.commons.ProfileGenerator;
2930

3031
import static java.nio.charset.StandardCharsets.UTF_8;
3132
import static org.assertj.core.api.Assertions.assertThat;
32-
import static org.sonar.python.it.RulingHelper.bugRuleKeys;
3333
import static org.sonar.python.it.RulingHelper.getOrchestrator;
3434

35-
// Ruling test for bug rules, to ensure they are properly tested without slowing down the CI
3635
class PythonExtendedRulingTest {
3736

3837
@RegisterExtension
3938
public static final OrchestratorExtension ORCHESTRATOR = getOrchestrator();
4039

41-
private static final String PROFILE_NAME = "customProfile";
40+
private static final String PROFILE_NAME = "rules";
4241

4342
@BeforeAll
4443
static void prepare_quality_profile() throws IOException {
45-
List<String> ruleKeys = bugRuleKeys();
46-
String pythonProfile = RulingHelper.profile(PROFILE_NAME, "py", "python", ruleKeys);
47-
RulingHelper.loadProfile(ORCHESTRATOR, pythonProfile);
48-
String iPythonProfile = RulingHelper.profile(PROFILE_NAME, "ipynb", "python", ruleKeys);
49-
RulingHelper.loadProfile(ORCHESTRATOR, iPythonProfile);
44+
ProfileGenerator.RulesConfiguration parameters = new ProfileGenerator.RulesConfiguration()
45+
.add("CommentRegularExpression", "message", "The regular expression matches this comment")
46+
.add("S1451", "headerFormat", "# Copyright 2004 by Harry Zuzan. All rights reserved.");
47+
String serverUrl = ORCHESTRATOR.getServer().getUrl();
48+
File profileFile = ProfileGenerator.generateProfile(serverUrl, "py", "python", parameters, Collections.emptySet());
49+
ORCHESTRATOR.getServer().restoreProfile(FileLocation.of(profileFile));
50+
File iPythonProfileFile = ProfileGenerator.generateProfile(serverUrl, "ipynb", "ipython", parameters, Collections.emptySet());
51+
ORCHESTRATOR.getServer().restoreProfile(FileLocation.of(iPythonProfileFile));
5052
}
5153

5254
@Test

its/ruling/src/test/java/org/sonar/python/it/RulingHelper.java

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.io.File;
2525
import java.io.IOException;
2626
import java.nio.file.Files;
27-
import java.util.Arrays;
2827
import java.util.List;
2928
import org.sonarqube.ws.Measures;
3029
import org.sonarqube.ws.client.HttpConnector;
@@ -86,68 +85,6 @@ static void loadProfile(Orchestrator orchestrator, String profile) throws IOExce
8685
file.delete();
8786
}
8887

89-
// TODO: SONARPY-984, read rules metadata instead of hardcoding this list
90-
static List<String> bugRuleKeys() {
91-
return Arrays.asList(
92-
"PreIncrementDecrement",
93-
"S935",
94-
"S1045",
95-
"S1143",
96-
"S1226",
97-
"S1656",
98-
"S1716",
99-
"S1751",
100-
"S1763",
101-
"S1764",
102-
"S1862",
103-
"S2159",
104-
"S2190",
105-
"S2201",
106-
"S2275",
107-
"S2711",
108-
"S2712",
109-
"S2734",
110-
"S2757",
111-
"S2823",
112-
"S2876",
113-
"S3403",
114-
"S3699",
115-
"S3827",
116-
"S3862",
117-
"S3923",
118-
"S3981",
119-
"S3984",
120-
"S4143",
121-
"S5549",
122-
"S5607",
123-
"S5632",
124-
"S5642",
125-
"S5644",
126-
"S5707",
127-
"S5708",
128-
"S5714",
129-
"S5719",
130-
"S5722",
131-
"S5724",
132-
"S5756",
133-
"S5796",
134-
"S5807",
135-
"S5828",
136-
"S5842",
137-
"S5850",
138-
"S5855",
139-
"S5856",
140-
"S5868",
141-
"S5996",
142-
"S6002",
143-
"S6323",
144-
"S6328",
145-
"S6468",
146-
"S6662",
147-
"S905",
148-
"S930");
149-
}
150-
15188
static Measures.Measure getMeasure(Orchestrator orchestrator, String branch, String componentKey, String metricKey) {
15289
List<Measures.Measure> measures = getMeasures(orchestrator, branch, componentKey, singletonList(metricKey));
15390
return measures != null && measures.size() == 1 ? measures.get(0) : null;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"Archery:sql/engines/mongo.py": [
3+
0
4+
]
5+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"Archery:sql/archiver.py": [
3+
254
4+
],
5+
"Archery:sql/binlog.py": [
6+
85,
7+
221
8+
],
9+
"Archery:sql/engines/models.py": [
10+
28
11+
],
12+
"Archery:sql/engines/mongo.py": [
13+
384,
14+
729
15+
],
16+
"Archery:sql/engines/oracle.py": [
17+
375,
18+
604
19+
],
20+
"Archery:sql/instance_account.py": [
21+
157
22+
],
23+
"Archery:sql/notify.py": [
24+
37
25+
],
26+
"Archery:sql/query.py": [
27+
26
28+
],
29+
"Archery:sql/query_privileges.py": [
30+
38,
31+
161
32+
],
33+
"Archery:sql/utils/data_masking.py": [
34+
18,
35+
71
36+
],
37+
"Archery:sql/utils/extract_tables.py": [
38+
112
39+
],
40+
"Archery:sql/utils/sql_utils.py": [
41+
148
42+
]
43+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"Archery:archery/settings.py": [
3+
207
4+
],
5+
"Archery:common/utils/aliyun_sdk.py": [
6+
63
7+
],
8+
"Archery:common/utils/convert.py": [
9+
8
10+
],
11+
"Archery:common/utils/sendmsg.py": [
12+
240
13+
],
14+
"Archery:sql/admin.py": [
15+
92
16+
],
17+
"Archery:sql/audit_log.py": [
18+
61,
19+
64,
20+
88,
21+
95,
22+
109
23+
],
24+
"Archery:sql/data_dictionary.py": [
25+
167
26+
],
27+
"Archery:sql/db_diagnostic.py": [
28+
29
29+
],
30+
"Archery:sql/engines/goinception.py": [
31+
100
32+
],
33+
"Archery:sql/engines/mongo.py": [
34+
263,
35+
264,
36+
266,
37+
267,
38+
345,
39+
415,
40+
454,
41+
456,
42+
708
43+
],
44+
"Archery:sql/engines/oracle.py": [
45+
115,
46+
161,
47+
163,
48+
240,
49+
637,
50+
650,
51+
651,
52+
660,
53+
662,
54+
755,
55+
773,
56+
815
57+
],
58+
"Archery:sql/engines/tests.py": [
59+
995
60+
],
61+
"Archery:sql/instance.py": [
62+
213,
63+
217,
64+
218,
65+
219,
66+
220
67+
],
68+
"Archery:sql/models.py": [
69+
141
70+
],
71+
"Archery:sql/notify.py": [
72+
152
73+
],
74+
"Archery:sql/slowlog.py": [
75+
192
76+
],
77+
"Archery:sql/sql_tuning.py": [
78+
146,
79+
149,
80+
150
81+
],
82+
"Archery:sql/tests.py": [
83+
529
84+
],
85+
"Archery:sql/utils/go_data_masking.py": [
86+
91,
87+
146
88+
],
89+
"Archery:sql/utils/sql_utils.py": [
90+
159
91+
],
92+
"Archery:sql/utils/tests.py": [
93+
119,
94+
237,
95+
1246,
96+
1260
97+
],
98+
"Archery:src/docker-compose/archery/settings.py": [
99+
200
100+
]
101+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"Archery:sql/engines/mongo.py": [
3+
159
4+
]
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"Archery:common/utils/aliyun_sdk.py": [
3+
42,
4+
51,
5+
60
6+
]
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Archery:sql/engines/tests.py": [
3+
0
4+
],
5+
"Archery:sql/tests.py": [
6+
0
7+
],
8+
"Archery:sql/utils/tests.py": [
9+
0
10+
]
11+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"Archery:sql/utils/extract_tables.py": [
3+
129
4+
]
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Archery:sql/archiver.py": [
3+
65
4+
],
5+
"Archery:sql/sql_workflow.py": [
6+
76
7+
],
8+
"Archery:sql/views.py": [
9+
61,
10+
462
11+
]
12+
}

0 commit comments

Comments
 (0)