https://github.com/rarst/phpcs-cognitive-complexity
Cognitive Complexity implementation for PHP_CodeSniffer
https://github.com/rarst/phpcs-cognitive-complexity
php phpcs phpcs-standard
Last synced: 4 months ago
JSON representation
Cognitive Complexity implementation for PHP_CodeSniffer
- Host: GitHub
- URL: https://github.com/rarst/phpcs-cognitive-complexity
- Owner: Rarst
- License: other
- Created: 2019-12-23T13:14:26.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-24T23:42:49.000Z (over 1 year ago)
- Last Synced: 2024-10-17T08:50:36.827Z (9 months ago)
- Topics: php, phpcs, phpcs-standard
- Language: PHP
- Size: 28.3 KB
- Stars: 26
- Watchers: 4
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PHPCS Cognitive Complexity
_Make it maintainable or else._
[](https://github.com/Rarst/phpcs-cognitive-complexity/actions/workflows/tests.yml)
[](https://packagist.org/packages/rarst/phpcs-cognitive-complexity)
[](https://packagist.org/packages/rarst/phpcs-cognitive-complexity)
[](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
### Composer
```bash
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
```bash
git clone https://github.com/Rarst/phpcs-cognitive-complexity
phpcs --standard=phpcs-cognitive-complexity/src/CognitiveComplexity /path/to/scan
```## Limitations
- detection of boolean operator chains is not perfect, due to complexity of many possible cases.
## Credits
Initial code forked from [Symplify Coding Standard](https://github.com/Symplify/Symplify).
## License
MIT