Canary provides linting and static analysis for stickee Laravel projects.
It includes:
- the stickee PHP CS Fixer config to adhere to our code styles
- the stickee Larastan config to analyse your code
- the stickee Rector config to refactor your code
- shortcuts to run the included tools
- an installation command
Lint Staged can be used to lint staged files and Husky can be used to manage the pre-commit hook that would call it.
The install
command will copy example configs over for these tools but you must install them before running it.
mkdir -p tools/canary
composer require --working-dir=tools/canary stickee/canary
tools/canary/vendor/bin/canary install
Why do we install tools into their own directory?
You should commit this new directory and the config files that are installed.
Canary provides a unified and decoupled platform for making use of powerful linting and static analysis tools that we make heavy use of at stickee.
To pass options through you must write them after a --
.
tools/canary/vendor/bin/canary analyse -- -c phpstan.ci.neon --error-format=github
tools/canary/vendor/bin/canary analyse -- -c phpstan.dist.neon
This command will perform static-analysis of your whole project.
It should be ran as part of the pre-commit
hook.
See stickee/larastan-config for more details.
tools/canary/vendor/bin/canary fix -- --config .php-cs-fixer.dist.php
This command will attempt to fix minor code style issues.
It can be ran against a single file.
It should be ran against staged files as part of the pre-commit
hook.
See stickee/php-cs-fixer-config for more details.
Rector in --dry-run
mode
tools/canary/vendor/bin/canary suggest
This command will suggest improvements as diffs in the terminal.
Any suggest
ed improvements must be performed manually or you can run the improve
command to do it for you.
See stickee/rector-config for more details.
tools/canary/vendor/bin/canary improve
This command will refactor your code in an attempt to improve it.
Any improve
d code must be checked before committing.
It can be ran against a single file.
It should not be ran as part of the pre-commit
hook.
See stickee/rector-config for more details.
You may find it useful to add these improve
ments as patches with Git.
You could use a Git integration in your editor or stage the improve
ments as patches with:
git add <file> -p
Contributions are welcome! Canary is written using Laravel Zero. Improvements to any of the amalgamated open source tools should be directed towards their respective repositories.
You are encouraged to provide tests, which are written using the Pest testing framework.
Canary is open source software licensed under the MIT license.