PHPackages                             rarst/phpcs-cognitive-complexity - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. rarst/phpcs-cognitive-complexity

ActivePhpcodesniffer-standard[Testing &amp; Quality](/categories/testing)

rarst/phpcs-cognitive-complexity
================================

Cognitive complexity implementation for PHP\_CodeSniffer

0.2(6y ago)28108.3k↓21.4%4[4 issues](https://github.com/Rarst/phpcs-cognitive-complexity/issues)[3 PRs](https://github.com/Rarst/phpcs-cognitive-complexity/pulls)1MITPHPPHP &gt;=7.2

Since Dec 23Pushed 2y ago3 watchersCompare

[ Source](https://github.com/Rarst/phpcs-cognitive-complexity)[ Packagist](https://packagist.org/packages/rarst/phpcs-cognitive-complexity)[ RSS](/packages/rarst-phpcs-cognitive-complexity/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

PHPCS Cognitive Complexity
==========================

[](#phpcs-cognitive-complexity)

*Make it maintainable or else.*

[![Tests Status](https://github.com/rarst/phpcs-cognitive-complexity/actions/workflows/tests.yml/badge.svg)](https://github.com/Rarst/phpcs-cognitive-complexity/actions/workflows/tests.yml)[![Latest Stable Version](https://camo.githubusercontent.com/fa3b9ac217c70f250cef0ade2204d8cb7576760259dcb6251e78d2f6dfae9e98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72617273742f70687063732d636f676e69746976652d636f6d706c65786974792e7376673f6c6162656c3d76657273696f6e)](https://packagist.org/packages/rarst/phpcs-cognitive-complexity)[![PHP from Packagist](https://camo.githubusercontent.com/fdf864df1fbb207ec369eed0a2a260c45f5067774b697c07228fb66967030d67/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f72617273742f70687063732d636f676e69746976652d636f6d706c65786974792e737667)](https://packagist.org/packages/rarst/phpcs-cognitive-complexity)[![PDS Skeleton](https://camo.githubusercontent.com/a8ce1f2a7b71f101b18fc0393ba5bf89b7a5b1f9d08a31b658ca0eab0064c0f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7064732d736b656c65746f6e2d626c75652e737667)](https://github.com/php-pds/skeleton)

The project implements [Cognitive Complexity metric by SonarSource](https://www.sonarsource.com/resources/white-papers/cognitive-complexity.html) as [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) standard.

Install
-------

[](#install)

### Composer

[](#composer)

```
composer init --no-interaction
composer require rarst/phpcs-cognitive-complexity squizlabs/php_codesniffer dealerdirect/phpcodesniffer-composer-installer
vendor/bin/phpcs --standard=CognitiveComplexity /path/to/scan
```

### Standalone

[](#standalone)

```
git clone https://github.com/Rarst/phpcs-cognitive-complexity
phpcs --standard=phpcs-cognitive-complexity/src/CognitiveComplexity /path/to/scan
```

Limitations
-----------

[](#limitations)

- detection of boolean operator chains is not perfect, due to complexity of many possible cases.

Credits
-------

[](#credits)

Initial code forked from [Symplify Coding Standard](https://github.com/Symplify/Symplify).

License
-------

[](#license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2337d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/689ddc4f33541ac4a001d247e560f8805d219a95e7e42a16e0d22b9409f385cb?d=identicon)[Rarst](/maintainers/Rarst)

---

Top Contributors

[![Rarst](https://avatars.githubusercontent.com/u/737584?v=4)](https://github.com/Rarst "Rarst (17 commits)")[![epic-64](https://avatars.githubusercontent.com/u/105014007?v=4)](https://github.com/epic-64 "epic-64 (1 commits)")[![GaryJones](https://avatars.githubusercontent.com/u/88371?v=4)](https://github.com/GaryJones "GaryJones (1 commits)")

---

Tags

phpphpcsphpcs-standardstandardsphpcs

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/rarst-phpcs-cognitive-complexity/health.svg)

```
[![Health](https://phpackages.com/badges/rarst-phpcs-cognitive-complexity/health.svg)](https://phpackages.com/packages/rarst-phpcs-cognitive-complexity)
```

###  Alternatives

[wp-coding-standards/wpcs

PHP\_CodeSniffer rules (sniffs) to enforce WordPress coding conventions

2.8k42.5M1.6k](/packages/wp-coding-standards-wpcs)[dealerdirect/phpcodesniffer-composer-installer

PHP\_CodeSniffer Standards Composer Installer Plugin

598161.9M1.9k](/packages/dealerdirect-phpcodesniffer-composer-installer)[phpcompatibility/phpcompatibility-wp

A ruleset for PHP\_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.

22130.6M587](/packages/phpcompatibility-phpcompatibility-wp)[phpcsstandards/phpcsextra

A collection of sniffs and standards for use with PHP\_CodeSniffer.

10324.3M44](/packages/phpcsstandards-phpcsextra)[acquia/coding-standards

PHP\_CodeSniffer rules (sniffs) for Acquia coding standards

214.8M28](/packages/acquia-coding-standards)[moxio/php-codesniffer-sniffs

Custom sniffs for PHP\_CodeSniffer

18283.0k3](/packages/moxio-php-codesniffer-sniffs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
