diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 61a9d9f..2418569 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ on: jobs: tests: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -35,4 +35,4 @@ jobs: - run: composer install --no-interaction - name: PHPUnit - run: phpunit --coverage-text \ No newline at end of file + run: phpunit --coverage-text diff --git a/src/CognitiveComplexity/Analyzer.php b/src/CognitiveComplexity/Analyzer.php index 41ded1a..681f21f 100644 --- a/src/CognitiveComplexity/Analyzer.php +++ b/src/CognitiveComplexity/Analyzer.php @@ -71,6 +71,7 @@ final class Analyzer T_WHILE => T_WHILE, T_DO => T_DO, T_CATCH => T_CATCH, + T_MATCH => T_MATCH, ]; /** diff --git a/tests/AnalyzerTest.php b/tests/AnalyzerTest.php index d635386..6781452 100644 --- a/tests/AnalyzerTest.php +++ b/tests/AnalyzerTest.php @@ -58,6 +58,7 @@ public function provideTokensAndExpectedCognitiveComplexity(): Iterator yield [__DIR__ . '/Data/function9.php.inc', 5]; yield [__DIR__ . '/Data/function10.php.inc', 19]; yield [__DIR__ . '/Data/function11.php.inc', 1]; + yield [__DIR__ . '/Data/function12.php.inc', 6]; } /** diff --git a/tests/Data/function12.php.inc b/tests/Data/function12.php.inc new file mode 100644 index 0000000..3509ba4 --- /dev/null +++ b/tests/Data/function12.php.inc @@ -0,0 +1,17 @@ + $b ? "one" : "uno", // +1 ternary +2 nesting + 2 => "a couple", + 3 => "a few", + default => "lots", + }; + } +} + +// Cognitive Complexity 6