Skip to content

Commit da0f04b

Browse files
committed
Generic/CyclomaticComplexity: improve code coverage
1 parent dbc1663 commit da0f04b

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function process(File $phpcsFile, $stackPtr)
6060
{
6161
$tokens = $phpcsFile->getTokens();
6262

63-
// Ignore abstract methods.
63+
// Ignore abstract and interface methods. Bail early when live coding.
6464
if (isset($tokens[$stackPtr]['scope_opener']) === false) {
6565
return;
6666
}

src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.1.inc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,10 @@ function complexityElevenWithNullSafeOperator()
451451
$bits = $object5->getX()?->getY()?->getZ();
452452
}
453453

454-
?>
454+
abstract class AbstractClass {
455+
abstract public function sniffShouldIgnoreAbstractMethods();
456+
}
457+
458+
interface MyInterface {
459+
public function sniffShouldIgnoreInterfaceMethods();
460+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// Intentional parse error (missing opening curly bracket).
4+
// This should be the only test in this file.
5+
// Testing that the sniff is *not* triggered.
6+
7+
function sniffShouldBailMissingScopeOpener()

0 commit comments

Comments
 (0)