Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

Commit e1334ea

Browse files
Statements must not be empty, except catch blocks (#34)
* Statements must not be empty, except catch blocks * Update test
1 parent 0e604fe commit e1334ea

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

src/Libero/ruleset.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
</rule>
1414

1515
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
16+
<rule ref="Generic.CodeAnalysis.EmptyStatement">
17+
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
18+
</rule>
1619
<rule ref="Generic.Commenting.Fixme"/>
1720
<rule ref="Generic.Commenting.Todo"/>
1821
<rule ref="Generic.Files.InlineHTML"/>

tests/cases/php/empty-statement

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---DESCRIPTION---
2+
Statements must not be empty, except catch blocks
3+
---CONTENTS---
4+
<?php
5+
6+
declare(strict_types=1);
7+
8+
if ($foo) {
9+
// Bar
10+
} elseif ($baz) {
11+
// Qux
12+
} else {
13+
}
14+
15+
try {
16+
} catch (Exception $e) {
17+
} catch (Throwable $e) {
18+
// Corge
19+
} finally {
20+
}
21+
22+
---MESSAGES---
23+
5:1 Generic.CodeAnalysis.EmptyStatement.DetectedIf
24+
7:3 Generic.CodeAnalysis.EmptyStatement.DetectedElseif
25+
9:3 Generic.CodeAnalysis.EmptyStatement.DetectedElse
26+
12:1 Generic.CodeAnalysis.EmptyStatement.DetectedTry
27+
16:3 Generic.CodeAnalysis.EmptyStatement.DetectedFinally
28+
---

tests/cases/php/short-list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare(strict_types=1);
88
list($foo, $bar) = [$baz, $qux];
99

1010
foreach ($quux as list('quuz' => $corge, 'grault' => $plugh)) {
11+
break;
1112
}
1213

1314
---FIXED---
@@ -18,6 +19,7 @@ declare(strict_types=1);
1819
[$foo, $bar] = [$baz, $qux];
1920

2021
foreach ($quux as ['quuz' => $corge, 'grault' => $plugh]) {
22+
break;
2123
}
2224

2325
---

tests/cases/php/todo

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ TODO comments must not be used
66
declare(strict_types=1);
77

88
if ($foo) {
9-
// TODO add code
9+
$bar = 'baz';
10+
// TODO add more code
1011
}
1112

13+
// FIXME please
1214
if ((1 + 1) === 3) {
13-
// FIXME please
15+
$qux = 'quuz';
1416
}
1517

1618
---MESSAGES---
17-
6:5 Generic.Commenting.Todo.TaskFound
18-
10:5 Generic.Commenting.Fixme.TaskFound
19+
7:5 Generic.Commenting.Todo.TaskFound
20+
10:1 Generic.Commenting.Fixme.TaskFound
1921
---

0 commit comments

Comments
 (0)