webiik / cli-analyse
The simple CLI tool that helps you to analyze code quality.
1.1
2021-07-02 12:45 UTC
Requires
- php: >=7.2
- phpmd/phpmd: @stable
- phpmetrics/phpmetrics: ^2
- phpstan/phpstan: ^0.1
- squizlabs/php_codesniffer: ^3
This package is auto-updated.
Last update: 2024-10-29 05:34:34 UTC
README
Analyse
This CLI tool analyses code using preconfigured PHPCS, PHPMD, PHPSTAN, PHPmetrics and SonarCloud. It can help you to write better code and find possible errors.
It's very likely that this tool will find "bugs" in your code. Always investigate these "bugs" and consider a fix. Avoid over-optimization of code, always keep in mind readability and testability.
Installation
composer require --dev webiik/cli-analyse
Usage
analyse
analyse source-dir output-dir
analyse runs code analyses over the source directory and outputs analyses results to the output directory.
bash analyse /private/app/ /private/tmp/analysis/app/
Settings
In brief, command analyse tests code for the PSR-2 standards and PHP strict types. It uses the following settings:
phpmd [source_dir] html cleancode,codesize,design,naming,unusedcode --reportfile [output_dir]/phpmd/index.html
phpcs --standard=PSR2 --report-full=[output_dir]/phpcs/report-full.txt --report-code=[output_dir]/phpcs/report-code.txt [source_dir]
phpstan analyse [source_dir] -l 7 --no-ansi --no-progress | awk '{$1=$1;print}' > [output_dir]/phpstan/result.txt
phpmetrics --report-html=[output_dir]/phpmetrics [source_dir]
sonar-scanner \ -Dsonar.projectKey=[sonar project key] \ -Dsonar.organization=[sonar organization] \ -Dsonar.projectBaseDir=[source_dir] \ -Dsonar.sources=. \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=[sonar login]