Skip to content

Commit 801bf3c

Browse files
SONARPHP-1626 S1541 should detect elseif clauses (#1374)
1 parent b68cc24 commit 801bf3c

File tree

19 files changed

+118
-18
lines changed

19 files changed

+118
-18
lines changed

its/plugin/src/integrationTest/java/com/sonar/it/php/PHPIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void projectMetric() {
6969
softly.assertThat(getProjectMeasureAsDouble("public_api")).isNull();
7070

7171
// Complexity
72-
softly.assertThat(getProjectMeasureAsDouble("complexity")).isEqualTo(4341d);
72+
softly.assertThat(getProjectMeasureAsDouble("complexity")).isEqualTo(4440d);
7373
softly.assertThat(getProjectMeasureAsDouble("cognitive_complexity")).isEqualTo(3203d);
7474
});
7575
}
@@ -96,7 +96,7 @@ void fileMetrics() {
9696
softly.assertThat(getFileMeasureAsDouble("public_api")).isNull();
9797

9898
// Complexity
99-
softly.assertThat(getFileMeasureAsDouble("complexity")).isEqualTo(14d);
99+
softly.assertThat(getFileMeasureAsDouble("complexity")).isEqualTo(15d);
100100
softly.assertThat(getFileMeasureAsDouble("cognitive_complexity")).isEqualTo(14d);
101101
});
102102
}

its/ruling/src/integrationTest/java/org/sonar/php/it/PhpGeneralRulingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void testFlysystem() throws Exception {
6666
void testMonica() throws Exception {
6767
// To avoid error: File tests/Unit/Traits/SearchableTest.php can't be indexed twice...
6868
// the tests directory needs to be excluded
69-
testProject("monica", "sonar.exclusions", "**/tests/**");
69+
testProject("monica", "sonar.exclusions", "tests/**");
7070
}
7171

7272
@Test

its/ruling/src/integrationTest/resources/expected/PHPMailer/php-S1541.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
173
44
],
55
"PHPMailer:src/PHPMailer.php": [
6+
1082,
67
1222,
78
1540,
89
1724,
@@ -24,5 +25,8 @@
2425
512,
2526
730,
2627
1253
28+
],
29+
"PHPMailer:test/TestCase.php": [
30+
141
2731
]
2832
}

its/ruling/src/integrationTest/resources/expected/PHPWord/php-S1541.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"PHPWord:src/PhpWord/Element/Image.php": [
33
530
44
],
5+
"PHPWord:src/PhpWord/Escaper/Rtf.php": [
6+
52
7+
],
58
"PHPWord:src/PhpWord/Reader/MsDoc.php": [
69
1536,
710
1608,
@@ -13,7 +16,8 @@
1316
"PHPWord:src/PhpWord/Reader/Word2007/AbstractPart.php": [
1417
191,
1518
331,
16-
493
19+
493,
20+
596
1721
],
1822
"PHPWord:src/PhpWord/Reader/Word2007/Numbering.php": [
1923
34
@@ -49,7 +53,9 @@
4953
4309,
5054
4458,
5155
4784,
52-
5191
56+
5114,
57+
5191,
58+
5269
5359
],
5460
"PHPWord:src/PhpWord/TemplateProcessor.php": [
5561
530,

its/ruling/src/integrationTest/resources/expected/PhpSpreadsheet/php-S1311.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"PhpSpreadsheet:src/PhpSpreadsheet/Writer/Html.php": [
2424
33
2525
],
26+
"PhpSpreadsheet:src/PhpSpreadsheet/Writer/Xls/Parser.php": [
27+
34
28+
],
2629
"PhpSpreadsheet:src/PhpSpreadsheet/Writer/Xls/Worksheet.php": [
2730
56
2831
],

its/ruling/src/integrationTest/resources/expected/PhpSpreadsheet/php-S1541.json

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88
3634,
99
3785,
1010
3828,
11+
3870,
1112
4039,
1213
4551,
14+
5175,
1315
5269,
1416
5422,
1517
5486
1618
],
1719
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php": [
1820
43
1921
],
22+
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php": [
23+
39
24+
],
2025
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php": [
2126
33
2227
],
@@ -29,6 +34,12 @@
2934
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/Functions.php": [
3035
146
3136
],
37+
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/Information/Value.php": [
38+
281
39+
],
40+
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/Logical/Operations.php": [
41+
133
42+
],
3243
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/LookupRef/Address.php": [
3344
50
3445
],
@@ -49,6 +60,9 @@
4960
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php": [
5061
39
5162
],
63+
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/Statistical/Deviations.php": [
64+
105
65+
],
5266
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php": [
5367
39,
5468
92
@@ -62,6 +76,10 @@
6276
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php": [
6377
32
6478
],
79+
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/Statistical/Variances.php": [
80+
64,
81+
153
82+
],
6583
"PhpSpreadsheet:src/PhpSpreadsheet/Calculation/TextData/Format.php": [
6684
281
6785
],
@@ -77,7 +95,8 @@
7795
616
7896
],
7997
"PhpSpreadsheet:src/PhpSpreadsheet/Cell/DataValidator.php": [
80-
19
98+
19,
99+
55
81100
],
82101
"PhpSpreadsheet:src/PhpSpreadsheet/Cell/DefaultValueBinder.php": [
83102
46
@@ -88,6 +107,9 @@
88107
"PhpSpreadsheet:src/PhpSpreadsheet/CellReferenceHelper.php": [
89108
44
90109
],
110+
"PhpSpreadsheet:src/PhpSpreadsheet/Chart/ChartColor.php": [
111+
84
112+
],
91113
"PhpSpreadsheet:src/PhpSpreadsheet/Chart/DataSeriesValues.php": [
92114
429
93115
],
@@ -117,6 +139,7 @@
117139
849
118140
],
119141
"PhpSpreadsheet:src/PhpSpreadsheet/Reader/Ods.php": [
142+
46,
120143
140,
121144
246
122145
],
@@ -161,6 +184,9 @@
161184
157,
162185
192
163186
],
187+
"PhpSpreadsheet:src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php": [
188+
198
189+
],
164190
"PhpSpreadsheet:src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php": [
165191
49
166192
],
@@ -202,6 +228,9 @@
202228
150,
203229
326
204230
],
231+
"PhpSpreadsheet:src/PhpSpreadsheet/Shared/StringHelper.php": [
232+
226
233+
],
205234
"PhpSpreadsheet:src/PhpSpreadsheet/Shared/Trend/BestFit.php": [
206235
299
207236
],
@@ -217,6 +246,9 @@
217246
"PhpSpreadsheet:src/PhpSpreadsheet/Style/Font.php": [
218247
167
219248
],
249+
"PhpSpreadsheet:src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php": [
250+
119
251+
],
220252
"PhpSpreadsheet:src/PhpSpreadsheet/Style/NumberFormat/Formatter.php": [
221253
46,
222254
118
@@ -241,8 +273,11 @@
241273
"PhpSpreadsheet:src/PhpSpreadsheet/Worksheet/Worksheet.php": [
242274
684,
243275
857,
276+
1191,
244277
2106,
245-
2884
278+
2884,
279+
3446,
280+
3501
246281
],
247282
"PhpSpreadsheet:src/PhpSpreadsheet/Writer/Html.php": [
248283
461,
@@ -266,6 +301,7 @@
266301
"PhpSpreadsheet:src/PhpSpreadsheet/Writer/Xls/Parser.php": [
267302
479,
268303
1011,
304+
1172,
269305
1282,
270306
1460
271307
],
@@ -275,6 +311,7 @@
275311
],
276312
"PhpSpreadsheet:src/PhpSpreadsheet/Writer/Xls/Worksheet.php": [
277313
223,
314+
776,
278315
2373,
279316
2574,
280317
2735,
@@ -320,6 +357,8 @@
320357
"PhpSpreadsheet:src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php": [
321358
192,
322359
256,
360+
589,
361+
621,
323362
762,
324363
861,
325364
939,

its/ruling/src/integrationTest/resources/expected/monica/php-S1106.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4142,6 +4142,9 @@
41424142
294,
41434143
306
41444144
],
4145+
"monica:scripts/tests/server-cc.php": [
4146+
19
4147+
],
41454148
"monica:server.php": [
41464149
15
41474150
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"monica:app/Models/Contact/Contact.php": [
3+
47
4+
]
5+
}

its/ruling/src/integrationTest/resources/expected/monica/php-S1578.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,6 +2411,9 @@
24112411
"monica:routes/web.php": [
24122412
0
24132413
],
2414+
"monica:scripts/tests/server-cc.php": [
2415+
0
2416+
],
24142417
"monica:server.php": [
24152418
0
24162419
]

its/ruling/src/integrationTest/resources/expected/monica/php-S2003.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
],
55
"monica:public/index.php": [
66
24
7+
],
8+
"monica:scripts/tests/server-cc.php": [
9+
26
710
]
811
}

0 commit comments

Comments
 (0)